@esri/solutions-components 1.1.0-next.20251008.1 → 1.1.0-next.20251009

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (467) hide show
  1. package/dist/cdn/{RPO6K4PZ.js → 226EKHZI.js} +2 -2
  2. package/dist/cdn/{SP6SUXKY.js → 243VF4YK.js} +2 -2
  3. package/dist/cdn/{RFUS6QQB.js → 26IT2E3J.js} +2 -2
  4. package/dist/cdn/{VAMPOWND.js → 2AH2WSNR.js} +2 -2
  5. package/dist/cdn/{O6RMBLXU.js → 2BTD7WOH.js} +2 -2
  6. package/dist/cdn/{AG2MFEZ6.js → 2EPBHDKS.js} +2 -2
  7. package/dist/cdn/{FZGFJV7S.js → 2JRSQSXY.js} +2 -2
  8. package/dist/cdn/{YKETMFXF.js → 2JYNQUQN.js} +2 -2
  9. package/dist/cdn/{HNM4DY7D.js → 2N7CXCK5.js} +2 -2
  10. package/dist/cdn/{FYW6TDRR.js → 2NXNFYET.js} +1 -1
  11. package/dist/cdn/{FMEUQ2UK.js → 2QFCQREF.js} +2 -2
  12. package/dist/cdn/{5VBO2I6I.js → 34VVVXQX.js} +2 -2
  13. package/dist/cdn/{KPUDB73R.js → 36FSS2E6.js} +2 -2
  14. package/dist/cdn/{EM5GGJNR.js → 3ILNZEC4.js} +2 -2
  15. package/dist/cdn/{E7A4ZQFN.js → 3JAJM6DX.js} +2 -2
  16. package/dist/cdn/{ZRK3KCXC.js → 3KLZ7B3U.js} +2 -2
  17. package/dist/cdn/{JSHVJKBM.js → 3MXA5J55.js} +2 -2
  18. package/dist/cdn/{NEEHDW7C.js → 3NENGL6B.js} +2 -2
  19. package/dist/cdn/3QYAGUQH.js +18 -0
  20. package/dist/cdn/{XG5IJRYX.js → 3SELIRDQ.js} +2 -2
  21. package/dist/cdn/{CR3NNKCK.js → 3T7RYRJA.js} +2 -2
  22. package/dist/cdn/3TMXINCP.js +89 -0
  23. package/dist/cdn/{IFDKIMEI.js → 42FNOYAU.js} +2 -2
  24. package/dist/cdn/{756WFIVI.js → 4ABNCQDB.js} +2 -2
  25. package/dist/cdn/{WHNBYCHC.js → 4ER4R32B.js} +2 -2
  26. package/dist/cdn/{P5XLXAQA.js → 4EV62ZAH.js} +2 -2
  27. package/dist/cdn/{VBNWJQZF.js → 4HNOA75C.js} +2 -2
  28. package/dist/cdn/{5HDPFIVC.js → 4JW4CQNN.js} +2 -2
  29. package/dist/cdn/{SAVFDVBT.js → 4L5CJ23W.js} +2 -2
  30. package/dist/cdn/{KVATQSHE.js → 4NIOJ5Q7.js} +2 -2
  31. package/dist/cdn/{VYYHWT27.js → 4SKPOAEA.js} +1 -1
  32. package/dist/cdn/{UWOUOAFJ.js → 4SMKQVHS.js} +2 -2
  33. package/dist/cdn/{JVY74GGT.js → 4TOCWPT7.js} +2 -2
  34. package/dist/cdn/{VYE7W4ST.js → 4XQBM6NS.js} +2 -2
  35. package/dist/cdn/{TQJZMY6X.js → 53SIKPP4.js} +2 -2
  36. package/dist/cdn/{FEMAZO23.js → 5AFOHCKK.js} +2 -2
  37. package/dist/cdn/{TESCLWOD.js → 5D37OJV6.js} +2 -2
  38. package/dist/cdn/5KRZOHOG.js +4 -0
  39. package/dist/cdn/{EQWAE3LS.js → 5QLH2JLO.js} +2 -2
  40. package/dist/cdn/{4XJEGG4Z.js → 5VQBNU6N.js} +2 -2
  41. package/dist/cdn/{GDH2I4CJ.js → 5W3FJJMX.js} +2 -2
  42. package/dist/cdn/{AXZU7T6V.js → 5XBU6WNO.js} +2 -2
  43. package/dist/cdn/{AJAJCTHK.js → 5ZJHNTJJ.js} +2 -2
  44. package/dist/cdn/{3FTPCQ44.js → 67D7ZMIO.js} +2 -2
  45. package/dist/cdn/{EPB5OL3N.js → 6ETHNHOQ.js} +1 -1
  46. package/dist/cdn/{3UQB4RD5.js → 6GV5SWOL.js} +2 -2
  47. package/dist/cdn/{UWJ7VSUW.js → 6IZ72CYT.js} +2 -2
  48. package/dist/cdn/{WQPH2FQF.js → 6K7IMQAZ.js} +1 -1
  49. package/dist/cdn/{HMQXESJA.js → 6KRIA3WU.js} +1 -1
  50. package/dist/cdn/{NYLEG34F.js → 6PTHBN37.js} +2 -2
  51. package/dist/cdn/{QRCNCBZJ.js → 6Q3W2MTP.js} +2 -2
  52. package/dist/cdn/{CHI5MGFW.js → 6VW53YUA.js} +2 -2
  53. package/dist/cdn/{XON2SCN5.js → 6ZCPANPE.js} +1 -1
  54. package/dist/cdn/{V6FDFSOP.js → 74EZV4UX.js} +2 -2
  55. package/dist/cdn/{DKIV4FLU.js → 76QJRQBJ.js} +2 -2
  56. package/dist/cdn/{XG3Y6KTQ.js → 76SE6KPJ.js} +2 -2
  57. package/dist/cdn/{743OCRIE.js → 77F7MDBV.js} +2 -2
  58. package/dist/cdn/{J4FGHXBK.js → 7CCJSXT2.js} +1 -1
  59. package/dist/cdn/{SSZSKJJ6.js → 7FCXE7NI.js} +2 -2
  60. package/dist/cdn/{D2ZJY2KS.js → 7GJPU4K4.js} +2 -2
  61. package/dist/cdn/{XSQKKMXB.js → 7I2TS3GR.js} +1 -1
  62. package/dist/cdn/{4PZRZB5Z.js → 7I5NXQ33.js} +2 -2
  63. package/dist/cdn/{7FCMQAOP.js → 7SDNNJMZ.js} +2 -2
  64. package/dist/cdn/7WNAFFUW.js +18 -0
  65. package/dist/cdn/{MLPRYWRQ.js → 7YH3U343.js} +2 -2
  66. package/dist/cdn/{BEH7FNEI.js → 7ZJDDQT3.js} +2 -2
  67. package/dist/cdn/{CUJTS7QI.js → A34HAXS3.js} +2 -2
  68. package/dist/cdn/{EREF2H4R.js → A3G7VILZ.js} +2 -2
  69. package/dist/cdn/{CXNKOKEM.js → A6VJRS3P.js} +2 -2
  70. package/dist/cdn/A7ZCUUWM.js +18 -0
  71. package/dist/cdn/{GAEESAH6.js → AA5KKISV.js} +2 -2
  72. package/dist/cdn/{BPVK7HOQ.js → AQAFMTV6.js} +2 -2
  73. package/dist/cdn/{776MXZQE.js → AUO3LWK7.js} +2 -2
  74. package/dist/cdn/{OORBMELH.js → B267WMF6.js} +2 -2
  75. package/dist/cdn/{IQVETGXP.js → B2OVGNEE.js} +2 -2
  76. package/dist/cdn/{YZDGBQMM.js → B3AUIQZF.js} +2 -2
  77. package/dist/cdn/{ZPTC5XZ7.js → B5NR3C3E.js} +2 -2
  78. package/dist/cdn/{YLBXMSCK.js → B7DYL7LN.js} +1 -1
  79. package/dist/cdn/{OFO3X4RI.js → B7GUMABT.js} +2 -2
  80. package/dist/cdn/{NXPVCNN2.js → BBW7AC2K.js} +2 -2
  81. package/dist/cdn/{YD7YA2VM.js → BFBCENRQ.js} +2 -2
  82. package/dist/cdn/{2VRBTKNK.js → BHHGVC25.js} +2 -2
  83. package/dist/cdn/{3OV4CTEC.js → BKQTXCOD.js} +2 -2
  84. package/dist/cdn/{S7RDKFUW.js → BMM3OTCM.js} +2 -2
  85. package/dist/cdn/{CEQ7VZ4K.js → BMPGHWZT.js} +2 -2
  86. package/dist/cdn/{JW3TOTMR.js → BYBVVZYA.js} +2 -2
  87. package/dist/cdn/{YVC764Y3.js → CBOGHC63.js} +1 -1
  88. package/dist/cdn/{R2OUBP75.js → CJ5XERUL.js} +2 -2
  89. package/dist/cdn/{6MRKYGL5.js → CN7MWGHW.js} +2 -2
  90. package/dist/cdn/{CXNLIR2Z.js → COT5JG6F.js} +2 -2
  91. package/dist/cdn/{HKVEGDNW.js → CRJOXM3C.js} +1 -1
  92. package/dist/cdn/{6OANKKZD.js → CWCZOOFR.js} +2 -2
  93. package/dist/cdn/{MWTSTC2U.js → CX5OMPL5.js} +2 -2
  94. package/dist/cdn/{PFXT675J.js → CXKKDPGI.js} +2 -2
  95. package/dist/cdn/CY5EU6CB.js +4 -0
  96. package/dist/cdn/{DJY7KWMN.js → CYISDZ7S.js} +2 -2
  97. package/dist/cdn/{CUG6ZCT7.js → D7KDA4VG.js} +2 -2
  98. package/dist/cdn/{A5KZBDUA.js → D7XDPUSJ.js} +2 -2
  99. package/dist/cdn/{XDM5TPF2.js → DHEIRCI3.js} +1 -1
  100. package/dist/cdn/{UIWMOIM6.js → DHWQHSSL.js} +2 -2
  101. package/dist/cdn/{7GMTCCQG.js → DI6CERQV.js} +2 -2
  102. package/dist/cdn/{L5XMRFBN.js → DJUCWGCW.js} +2 -2
  103. package/dist/cdn/{NE2VS6NF.js → DME4JNOT.js} +2 -2
  104. package/dist/cdn/{EO4S63HB.js → DMFPVVK5.js} +2 -2
  105. package/dist/cdn/{WKXAKHUN.js → DPSXO6CT.js} +2 -2
  106. package/dist/cdn/{WV4DG7QK.js → DSLPBIW7.js} +2 -2
  107. package/dist/cdn/{EGTDJUUX.js → DU4GKE5S.js} +2 -2
  108. package/dist/cdn/{56MVUILU.js → DZGW46QG.js} +2 -2
  109. package/dist/cdn/{55TVP7JA.js → DZOR3MZ2.js} +3 -3
  110. package/dist/cdn/{IYZ36D6C.js → EA5C7NIW.js} +2 -2
  111. package/dist/cdn/{ZBGUCLYL.js → EEYBFROQ.js} +2 -2
  112. package/dist/cdn/{5H4AMHXY.js → EGUK5B4A.js} +2 -2
  113. package/dist/cdn/{HPRGI5L7.js → EIXNBA6I.js} +2 -2
  114. package/dist/cdn/{JVL3OO6Z.js → EKFHNN73.js} +2 -2
  115. package/dist/cdn/{VDW6NDPI.js → ELKIH3DJ.js} +3 -3
  116. package/dist/cdn/{O6DNOSLP.js → EOVPDUOM.js} +2 -2
  117. package/dist/cdn/{ZBNWUIOH.js → EXPGGFET.js} +2 -2
  118. package/dist/cdn/{TR6XLP2K.js → EXY6X22Q.js} +2 -2
  119. package/dist/cdn/{E4GPFMZZ.js → EZ2UWRYF.js} +2 -2
  120. package/dist/cdn/{BZQ336PO.js → F7GGXQ54.js} +2 -2
  121. package/dist/cdn/{A4MRQM3U.js → FC7AN576.js} +2 -2
  122. package/dist/cdn/{QD6LXGY5.js → FCIOM4CD.js} +1 -1
  123. package/dist/cdn/{KHGBSFAO.js → FEZV7OSP.js} +1 -1
  124. package/dist/cdn/{MDJNGXKN.js → FNT5NEFS.js} +2 -2
  125. package/dist/cdn/{6SBUNPG6.js → FU6T75NF.js} +2 -2
  126. package/dist/cdn/{NARHDIR6.js → FWUQZ3X3.js} +2 -2
  127. package/dist/cdn/{BJKYVFXO.js → FXLZ2G3B.js} +2 -2
  128. package/dist/cdn/{JVNOFKDY.js → G3ATMUBJ.js} +1 -1
  129. package/dist/cdn/{AKOIGMGW.js → G42B6MR7.js} +1 -1
  130. package/dist/cdn/{SIGCWFSG.js → GDLEPFHR.js} +2 -2
  131. package/dist/cdn/{ZHEMMAMB.js → GNMN5Y5L.js} +2 -2
  132. package/dist/cdn/{SXILLYU2.js → GRXPNSVT.js} +1 -1
  133. package/dist/cdn/{WVMSFAZ2.js → GVJS66GD.js} +2 -2
  134. package/dist/cdn/{WINI76U6.js → GWW2W723.js} +2 -2
  135. package/dist/cdn/{FNUNDERC.js → GXGE4F75.js} +4 -4
  136. package/dist/cdn/{TPCS32WS.js → GZG7NEOR.js} +2 -2
  137. package/dist/cdn/{WZTWBWLY.js → H7RUG54M.js} +2 -2
  138. package/dist/cdn/{PQVNM2JP.js → HGQ3H5NR.js} +1 -1
  139. package/dist/cdn/{CSAONTTQ.js → HIEQOA47.js} +2 -2
  140. package/dist/cdn/{EJDVI7YM.js → HONGNHE7.js} +2 -2
  141. package/dist/cdn/{H7FZQF6E.js → HPJZQVYK.js} +2 -2
  142. package/dist/cdn/{VU4KDMOC.js → HQ3X7DTJ.js} +2 -2
  143. package/dist/cdn/{N5GGMSDO.js → HUDLB6WS.js} +2 -2
  144. package/dist/cdn/{WF2BNI4T.js → HUQF7L2V.js} +2 -2
  145. package/dist/cdn/{6GFREZVC.js → I35LP6AP.js} +2 -2
  146. package/dist/cdn/{B3Q54R55.js → I3IEAVA4.js} +2 -2
  147. package/dist/cdn/IA7LMYXQ.js +4 -0
  148. package/dist/cdn/{LF2V666Y.js → IANPXHOC.js} +2 -2
  149. package/dist/cdn/{DDBLGIPI.js → ICSXIORY.js} +2 -2
  150. package/dist/cdn/{IMSAFY4W.js → IH3JSV4L.js} +2 -2
  151. package/dist/cdn/{L7HL2JNS.js → IJIOMW76.js} +2 -2
  152. package/dist/cdn/{BGQ2ZB43.js → IKEPEJSC.js} +2 -2
  153. package/dist/cdn/{NUSVAYCZ.js → IVNPCIFN.js} +1 -1
  154. package/dist/cdn/{H6UGWCMX.js → J3KJVEQM.js} +1 -1
  155. package/dist/cdn/{QTT755QR.js → JA6XJHST.js} +2 -2
  156. package/dist/cdn/{HDOENBZW.js → JAEFUU7E.js} +2 -2
  157. package/dist/cdn/{6GDKLYDH.js → JBTU5LYM.js} +2 -2
  158. package/dist/cdn/{CWTU3CNC.js → JF3DBMQC.js} +2 -2
  159. package/dist/cdn/{2W24N4O3.js → JHAMVTNV.js} +2 -2
  160. package/dist/cdn/{PF6CK2R7.js → JHVPCIGT.js} +2 -2
  161. package/dist/cdn/{QE5FDYR6.js → JL2P3OXW.js} +1 -1
  162. package/dist/cdn/{H4P3FZCK.js → JLL4BYYV.js} +2 -2
  163. package/dist/cdn/{CWPY45T3.js → JWNZVRXT.js} +1 -1
  164. package/dist/cdn/{KGYW3EWF.js → JY72U7AC.js} +2 -2
  165. package/dist/cdn/{RSTPCXZ7.js → K3CZ4NX3.js} +2 -2
  166. package/dist/cdn/{P4CI3RSD.js → KDANYDON.js} +2 -2
  167. package/dist/cdn/{63OPKMPJ.js → KLGEKJVD.js} +2 -2
  168. package/dist/cdn/{XDZHITLM.js → KV2AI44O.js} +2 -2
  169. package/dist/cdn/{ZUUC4HH4.js → L4MZ3SRK.js} +2 -2
  170. package/dist/cdn/{GR2TX3EZ.js → L5FFR5IW.js} +2 -2
  171. package/dist/cdn/{XQ4TPQRL.js → LB4XXKXQ.js} +2 -2
  172. package/dist/cdn/{PG36F4KN.js → LGH2MNKB.js} +2 -2
  173. package/dist/cdn/{TOZPFY6T.js → LHCHUU52.js} +2 -2
  174. package/dist/cdn/{OYAA6DUV.js → LL3OVKGG.js} +2 -2
  175. package/dist/cdn/{DPZDK7BZ.js → LLM6XJLM.js} +2 -2
  176. package/dist/cdn/{DMV3DJAP.js → LOG7XAZY.js} +2 -2
  177. package/dist/cdn/{RSKF3E66.js → LVAQ5TL6.js} +2 -2
  178. package/dist/cdn/{O62DQJR5.js → M2YYZVD5.js} +2 -2
  179. package/dist/cdn/{ZDVR52XS.js → M4QRYUPC.js} +1 -1
  180. package/dist/cdn/{LK4ZES4F.js → MCSVMBT3.js} +2 -2
  181. package/dist/cdn/{QJF5CTAW.js → MCZ5FXVG.js} +1 -1
  182. package/dist/cdn/{M5PWB7WI.js → MDNZHHNA.js} +2 -2
  183. package/dist/cdn/{5VCSKMJM.js → MEWN2ZS2.js} +2 -2
  184. package/dist/cdn/{A2VNVKLM.js → ML67KHTJ.js} +2 -2
  185. package/dist/cdn/{V3G4P54D.js → MLXWP6T3.js} +2 -2
  186. package/dist/cdn/{7EKLS25S.js → MO3ZDQHS.js} +1 -1
  187. package/dist/cdn/{YAMBUVFM.js → MOG3DNAW.js} +2 -2
  188. package/dist/cdn/{RSXEVZ6T.js → MRTP6T5M.js} +2 -2
  189. package/dist/cdn/{OJLTKJF5.js → MSE37YY2.js} +2 -2
  190. package/dist/cdn/{BKTK4DTH.js → MVMQLI5V.js} +3 -3
  191. package/dist/cdn/{4K6HZ75C.js → MWIPC3Q3.js} +2 -2
  192. package/dist/cdn/{Y4IKVVIS.js → MWJ5QDLR.js} +2 -2
  193. package/dist/cdn/{CDZTTQBO.js → MXUCVOBL.js} +2 -2
  194. package/dist/cdn/N7W7MP75.js +4 -0
  195. package/dist/cdn/{COLRFXEM.js → NCSFOFEP.js} +2 -2
  196. package/dist/cdn/{F6PESHM3.js → NK2BUMZ3.js} +2 -2
  197. package/dist/cdn/{UKQKNMGD.js → NMZRKCZJ.js} +2 -2
  198. package/dist/cdn/{VVJBM5I2.js → NRELBK3K.js} +2 -2
  199. package/dist/cdn/{KDL2UNFT.js → NSAYCRHW.js} +2 -2
  200. package/dist/cdn/{SJKN3XBP.js → NVO76HPK.js} +2 -2
  201. package/dist/cdn/{IJKFQKPV.js → OAATM3IS.js} +2 -2
  202. package/dist/cdn/{RUGVEC76.js → OBCI3UP5.js} +2 -2
  203. package/dist/cdn/{G3ZGSWSN.js → OBG3ZDPQ.js} +2 -2
  204. package/dist/cdn/{K4WOVDKF.js → OC6XUPAK.js} +2 -2
  205. package/dist/cdn/OD6TX7KT.js +4 -0
  206. package/dist/cdn/{SFYPFXOW.js → ODZHRVH3.js} +2 -2
  207. package/dist/cdn/{ENPAUPOO.js → OGG2DXTJ.js} +2 -2
  208. package/dist/cdn/{QVRVVWMD.js → ONTFRZRW.js} +2 -2
  209. package/dist/cdn/{GMV2G5MI.js → OO7FHEFG.js} +2 -2
  210. package/dist/cdn/{JCD6XUXZ.js → OU5ZW2BU.js} +2 -2
  211. package/dist/cdn/OXMRNPBS.js +4 -0
  212. package/dist/cdn/{PFQYJBOH.js → OZSS4H2S.js} +2 -2
  213. package/dist/cdn/{BYPLBSOB.js → P3JB7IDU.js} +2 -2
  214. package/dist/cdn/PB6VIV4Q.js +4 -0
  215. package/dist/cdn/{VLGVQAPL.js → PCWJM2FN.js} +1 -1
  216. package/dist/cdn/PF5GLPZ3.js +4 -0
  217. package/dist/cdn/{AW4OKAIA.js → PGWD7NIZ.js} +2 -2
  218. package/dist/cdn/{WSUPRKRV.js → PHXE7HAG.js} +2 -2
  219. package/dist/cdn/{7GB7DC3T.js → PN22QPMG.js} +2 -2
  220. package/dist/cdn/{GJU42TAV.js → PNDOKPLD.js} +2 -2
  221. package/dist/cdn/{7VOB6CTQ.js → PRRHXLB5.js} +2 -2
  222. package/dist/cdn/{JRFZS76Z.js → PTXZWZ4F.js} +2 -2
  223. package/dist/cdn/{P5NTKGVD.js → PTZV3F2R.js} +2 -2
  224. package/dist/cdn/{H3LZRTAE.js → PVPRNP5I.js} +2 -2
  225. package/dist/cdn/{W4XNCXXM.js → PXLN6W6W.js} +2 -2
  226. package/dist/cdn/{GP4L6OF4.js → QDMZUHS7.js} +2 -2
  227. package/dist/cdn/{4HGQRLEE.js → QJ2F77F7.js} +2 -2
  228. package/dist/cdn/{RZHUXMRX.js → QJFZFB2W.js} +2 -2
  229. package/dist/cdn/{QLTIVCCL.js → QK3HU5M7.js} +2 -2
  230. package/dist/cdn/{5RMEYG3D.js → QNI7TBQ2.js} +1 -1
  231. package/dist/cdn/{55VJKIT4.js → QQNA62QN.js} +2 -2
  232. package/dist/cdn/{CXHSOU2D.js → QSBB7GQ6.js} +1 -1
  233. package/dist/cdn/{6NADAFNM.js → QT2LAQHT.js} +2 -2
  234. package/dist/cdn/{5HRKE7ZZ.js → QWD7JVUY.js} +2 -2
  235. package/dist/cdn/{D37EHLIU.js → QWQKPP6Y.js} +2 -2
  236. package/dist/cdn/{NR2CWC4R.js → R3SVTMKR.js} +2 -2
  237. package/dist/cdn/{V264VMRH.js → R4LARKP2.js} +2 -2
  238. package/dist/cdn/{FHUI2QNQ.js → R7CT3Y4T.js} +2 -2
  239. package/dist/cdn/{JEWUWYLX.js → RG3BO7AY.js} +2 -2
  240. package/dist/cdn/{VGTFE7FF.js → RH5NTXLA.js} +2 -2
  241. package/dist/cdn/{3ZMDA7RH.js → RPB2L5YR.js} +1 -1
  242. package/dist/cdn/{2JWUP3G5.js → RROREMR6.js} +2 -2
  243. package/dist/cdn/{BSVUMICC.js → RS5O7RQU.js} +2 -2
  244. package/dist/cdn/{HY46BCFR.js → RU633SA5.js} +2 -2
  245. package/dist/cdn/{XVCV7IJR.js → RVQISVJ7.js} +2 -2
  246. package/dist/cdn/{A27O3RQI.js → RWENZJIC.js} +2 -2
  247. package/dist/cdn/{GICBZ47Y.js → S4ZX4LBZ.js} +2 -2
  248. package/dist/cdn/{SSZH5PHK.js → S64LM6IC.js} +2 -2
  249. package/dist/cdn/{O7FCB5DM.js → S6UDV3GG.js} +2 -2
  250. package/dist/cdn/S6WM4NDY.js +4 -0
  251. package/dist/cdn/{7ETFO7MW.js → SBYAEUJS.js} +2 -2
  252. package/dist/cdn/{BPE3B3PQ.js → SCOK55L3.js} +2 -2
  253. package/dist/cdn/{KCKWWFJT.js → SDIA27L5.js} +2 -2
  254. package/dist/cdn/{GSNXO6QJ.js → SF3EG5NR.js} +2 -2
  255. package/dist/cdn/{ZBJGVZER.js → SGLGLKA4.js} +2 -2
  256. package/dist/cdn/{E3RMDO5S.js → SGSNI66C.js} +2 -2
  257. package/dist/cdn/{U5IFXOY7.js → SHGVPHG7.js} +2 -2
  258. package/dist/cdn/{WOU4W4YD.js → SKM7TPWS.js} +2 -2
  259. package/dist/cdn/{CSK3C4OD.js → SLFULM7O.js} +2 -2
  260. package/dist/cdn/{GYN6BUOW.js → SOVCZGKV.js} +2 -2
  261. package/dist/cdn/{62XONJJJ.js → SP2I6DAS.js} +2 -2
  262. package/dist/cdn/{JOCTUVR5.js → SWIEPYK4.js} +2 -2
  263. package/dist/cdn/{DNLIXRFX.js → SWMW7QZQ.js} +2 -2
  264. package/dist/cdn/{Q6YM2NMB.js → SZTTA2YZ.js} +2 -2
  265. package/dist/cdn/{LYMQGSBH.js → T2POAIC3.js} +2 -2
  266. package/dist/cdn/{DI5Z2EGV.js → T3EU27V5.js} +2 -2
  267. package/dist/cdn/{WBPISCZO.js → TE3SERQU.js} +2 -2
  268. package/dist/cdn/{FH3TT5EI.js → TFWL2Z5V.js} +2 -2
  269. package/dist/cdn/{A5MUT7MZ.js → TIXAREAF.js} +2 -2
  270. package/dist/cdn/{54IQCDXA.js → TMDJXYFF.js} +2 -2
  271. package/dist/cdn/{RWKUOQK4.js → TNHEIYAF.js} +2 -2
  272. package/dist/cdn/{SWXQKMYN.js → TQHAP3WF.js} +1 -1
  273. package/dist/cdn/{CZCWXKCD.js → TR4KTHZE.js} +2 -2
  274. package/dist/cdn/{2QUMF6BC.js → TRKOGPMK.js} +2 -2
  275. package/dist/cdn/{6GJT2N3Q.js → TSXFDKFL.js} +2 -2
  276. package/dist/cdn/{QJOKJMCH.js → TWZXSC3I.js} +2 -2
  277. package/dist/cdn/{KUAZALFT.js → TYANLUYZ.js} +2 -2
  278. package/dist/cdn/{GBVMAPOJ.js → U5AKGSFP.js} +2 -2
  279. package/dist/cdn/{BXW45NKL.js → U5ZMQXWT.js} +2 -2
  280. package/dist/cdn/{4GRSWWG6.js → UA56H5VP.js} +2 -2
  281. package/dist/cdn/{IROFTJMS.js → UBSQGMJ3.js} +2 -2
  282. package/dist/cdn/{TWAOBOD6.js → UFEUVJXZ.js} +1 -1
  283. package/dist/cdn/{ET5FJSK3.js → UOHC5GPC.js} +2 -2
  284. package/dist/cdn/{CO55C2XS.js → URE6WWZA.js} +2 -2
  285. package/dist/cdn/{NYBDENWM.js → UZRCLMIV.js} +2 -2
  286. package/dist/cdn/{DDW3RLEE.js → V4SQ7F5T.js} +1 -1
  287. package/dist/cdn/{7PMTYFF7.js → VAU6S7LJ.js} +2 -2
  288. package/dist/cdn/{OXRKB5XI.js → VHOUIJX3.js} +2 -2
  289. package/dist/cdn/{QHIMAEBD.js → VJ7XH7BQ.js} +2 -2
  290. package/dist/cdn/{CTJZ6TOJ.js → VLYVJPDZ.js} +2 -2
  291. package/dist/cdn/{SUNHHKCC.js → VM4BFHIZ.js} +2 -2
  292. package/dist/cdn/{G4MED4FO.js → VRCZX2NN.js} +2 -2
  293. package/dist/cdn/{KZHAHJH2.js → VSV4N3FF.js} +2 -2
  294. package/dist/cdn/{TJMFXXPG.js → VWIENO5R.js} +2 -2
  295. package/dist/cdn/{VH3ATFO3.js → VXGW42EG.js} +2 -2
  296. package/dist/cdn/{BABMMEKK.js → VXK44RQM.js} +1 -1
  297. package/dist/cdn/{VHM2OX4R.js → VZWBZ7ZJ.js} +2 -2
  298. package/dist/cdn/{LTLMMK2M.js → W5743N5H.js} +3 -3
  299. package/dist/cdn/{J45N5IQC.js → WMHW2WFZ.js} +1 -1
  300. package/dist/cdn/{O67AZXCG.js → WP3IVJJL.js} +2 -2
  301. package/dist/cdn/{GIAPUD45.js → WSMZXTEM.js} +2 -2
  302. package/dist/cdn/{CHPMYDMZ.js → WT5HVSBV.js} +2 -2
  303. package/dist/cdn/{IQJWMX3G.js → WTU4WODR.js} +2 -2
  304. package/dist/cdn/{PS7SLYOT.js → WWUJHR4Q.js} +2 -2
  305. package/dist/cdn/{TCK45PQB.js → WXL2LEWB.js} +2 -2
  306. package/dist/cdn/{FXVCYLIP.js → X5NMZI3S.js} +2 -2
  307. package/dist/cdn/{TGV35MZM.js → X6QTF4AP.js} +2 -2
  308. package/dist/cdn/{ZPTE6MXZ.js → X7WZ66XE.js} +2 -2
  309. package/dist/cdn/{3VHBN5ZL.js → XARCEH7R.js} +2 -2
  310. package/dist/cdn/{OJ654LI2.js → XBQ44PA7.js} +2 -2
  311. package/dist/cdn/{QWN7KWEY.js → XQ765V7U.js} +2 -2
  312. package/dist/cdn/{Y4PNQMH4.js → XQEOXZKV.js} +2 -2
  313. package/dist/cdn/{UG73IGUR.js → XQZKO5TB.js} +2 -2
  314. package/dist/cdn/{BHF3J3OL.js → XTXJ33WB.js} +2 -2
  315. package/dist/cdn/{Y4HFEOXU.js → Y3DYWWOY.js} +2 -2
  316. package/dist/cdn/{NCB7BUFY.js → Y44JLKQH.js} +2 -2
  317. package/dist/cdn/{OCPIF5BH.js → Y5ACJQDB.js} +1 -1
  318. package/dist/cdn/YBGBKHQR.js +4 -0
  319. package/dist/cdn/{PULR3YSX.js → YDDBA5BZ.js} +1 -1
  320. package/dist/cdn/{LAUE442A.js → YEC444BK.js} +2 -2
  321. package/dist/cdn/{5XIMDQZK.js → YGJWDZYW.js} +2 -2
  322. package/dist/cdn/{KQBMQCV5.js → YHSZAJGH.js} +2 -2
  323. package/dist/cdn/{PKZR4IAA.js → YJDL2AIK.js} +1 -1
  324. package/dist/cdn/{SNXTG7RZ.js → YMT2T2MU.js} +2 -2
  325. package/dist/cdn/{TA4MF2WH.js → YNHNDQS3.js} +2 -2
  326. package/dist/cdn/{GYKUFCDS.js → YQN2X3PI.js} +2 -2
  327. package/dist/cdn/{ZA25NSZJ.js → YUDLASXK.js} +2 -2
  328. package/dist/cdn/{JFKL5MZH.js → Z3A7EHJL.js} +2 -2
  329. package/dist/cdn/{6OPGZGV3.js → Z5FTYJRT.js} +2 -2
  330. package/dist/cdn/{UDKE7EDS.js → Z65OPCIO.js} +1 -1
  331. package/dist/cdn/ZAG6K5LN.js +4 -0
  332. package/dist/cdn/{RIWIV546.js → ZKS6HDEM.js} +2 -2
  333. package/dist/cdn/{H6KX7P7Y.js → ZMSP4XC3.js} +2 -2
  334. package/dist/cdn/{W26PVN5N.js → ZMTV2F6H.js} +2 -2
  335. package/dist/cdn/{ATACWWKU.js → ZQMHVZRK.js} +2 -2
  336. package/dist/cdn/{UZ7JPZ7Q.js → ZSPKTF7O.js} +2 -2
  337. package/dist/cdn/{KCTTON3E.js → ZW6SVOQA.js} +1 -1
  338. package/dist/cdn/{YBWHEWDW.js → ZWEENOOZ.js} +2 -2
  339. package/dist/cdn/{RT7OCX6V.js → ZWMASVPS.js} +2 -2
  340. package/dist/cdn/{BHMXTBXC.js → ZY27ARHF.js} +2 -2
  341. package/dist/cdn/{PK5ASELS.js → ZYDWLGOT.js} +2 -2
  342. package/dist/cdn/index.js +2 -2
  343. package/dist/chunks/Auth.js +1 -1
  344. package/dist/chunks/CardsFetcher.js +1 -1
  345. package/dist/chunks/appConfig.js +1 -1
  346. package/dist/chunks/cardFetchingUtils.js +1 -1
  347. package/dist/chunks/cardsHelpers.js +1 -1
  348. package/dist/chunks/common.js +1 -1
  349. package/dist/chunks/deployAppContexts.js +1 -1
  350. package/dist/chunks/downloadUtils.js +1 -1
  351. package/dist/chunks/getItemIcon.js +1 -1
  352. package/dist/chunks/helpers.js +1 -1
  353. package/dist/chunks/interfaces.js +1 -1
  354. package/dist/chunks/loadModules.js +1 -1
  355. package/dist/chunks/mapViewUtils.js +1 -1
  356. package/dist/chunks/pciUtils.js +1 -1
  357. package/dist/chunks/popupUtils.js +1 -1
  358. package/dist/chunks/prepareDataForSolutionDisplay.js +1 -1
  359. package/dist/chunks/privilegeUtils.js +1 -1
  360. package/dist/chunks/publicNotificationContext.js +1 -1
  361. package/dist/chunks/queryUtils.js +1 -1
  362. package/dist/chunks/runtime.js +1 -1
  363. package/dist/chunks/solution-store.js +1 -1
  364. package/dist/chunks/templates.js +1 -1
  365. package/dist/chunks/useT9n.js +1 -1
  366. package/dist/components/arcgis-solutions-assistant/customElement.js +1 -1
  367. package/dist/components/basemap-gallery/customElement.js +1 -1
  368. package/dist/components/buffer-tools/customElement.js +1 -1
  369. package/dist/components/card-manager/customElement.js +1 -1
  370. package/dist/components/consent-manager/customElement.js +1 -1
  371. package/dist/components/create-feature/customElement.js +1 -1
  372. package/dist/components/create-related-feature/customElement.js +1 -1
  373. package/dist/components/crowdsource-manager/customElement.js +1 -1
  374. package/dist/components/crowdsource-reporter/customElement.js +1 -1
  375. package/dist/components/deduct-calculator/customElement.js +1 -1
  376. package/dist/components/delete-button/customElement.js +1 -1
  377. package/dist/components/delete-dialog/customElement.js +1 -1
  378. package/dist/components/edit-card/customElement.js +1 -1
  379. package/dist/components/feature-details/customElement.js +1 -1
  380. package/dist/components/feature-list/customElement.js +1 -1
  381. package/dist/components/field-selection/customElement.js +1 -1
  382. package/dist/components/floor-filter/customElement.js +1 -1
  383. package/dist/components/info-card/customElement.js +1 -1
  384. package/dist/components/json-editor/customElement.js +1 -1
  385. package/dist/components/layer-list/customElement.js +1 -1
  386. package/dist/components/layer-table/customElement.js +1 -1
  387. package/dist/components/map-card/customElement.js +2 -2
  388. package/dist/components/map-draw-tools/customElement.js +1 -1
  389. package/dist/components/map-fullscreen/customElement.js +1 -1
  390. package/dist/components/map-layer-picker/customElement.js +1 -1
  391. package/dist/components/map-legend/customElement.js +1 -1
  392. package/dist/components/map-picker/customElement.js +1 -1
  393. package/dist/components/map-search/customElement.js +1 -1
  394. package/dist/components/map-select-tools/customElement.js +1 -1
  395. package/dist/components/map-tools/customElement.js +1 -1
  396. package/dist/components/pci-calculator/customElement.js +1 -1
  397. package/dist/components/pdf-download/customElement.js +1 -1
  398. package/dist/components/public-notification/customElement.js +1 -1
  399. package/dist/components/refine-selection/customElement.js +1 -1
  400. package/dist/components/selection-tool/customElement.js +1 -1
  401. package/dist/components/solution-article-card/customElement.js +1 -1
  402. package/dist/components/solution-configuration/customElement.js +1 -1
  403. package/dist/components/solution-configure-dialog/customElement.js +1 -1
  404. package/dist/components/solution-configure-titles/customElement.js +1 -1
  405. package/dist/components/solution-contents/customElement.js +1 -1
  406. package/dist/components/solution-delete-dialog/customElement.js +1 -1
  407. package/dist/components/solution-deploy-dialog/customElement.js +1 -1
  408. package/dist/components/solution-deployed-card/customElement.js +1 -1
  409. package/dist/components/solution-deploying-dialog/customElement.js +1 -1
  410. package/dist/components/solution-details-card/customElement.js +1 -1
  411. package/dist/components/solution-details-panel/customElement.d.ts +2 -0
  412. package/dist/components/solution-details-panel/customElement.js +55 -52
  413. package/dist/components/solution-item/customElement.js +1 -1
  414. package/dist/components/solution-item-accordion/customElement.js +1 -1
  415. package/dist/components/solution-item-details/customElement.js +1 -1
  416. package/dist/components/solution-item-diagram/customElement.js +1 -1
  417. package/dist/components/solution-item-icon/customElement.js +1 -1
  418. package/dist/components/solution-item-sharing/customElement.js +1 -1
  419. package/dist/components/solution-organization-variables/customElement.js +1 -1
  420. package/dist/components/solution-resource-item/customElement.js +1 -1
  421. package/dist/components/solution-snapshot-gallery/customElement.js +1 -1
  422. package/dist/components/solution-social-share/customElement.js +1 -1
  423. package/dist/components/solution-spatial-ref/customElement.js +1 -1
  424. package/dist/components/solution-template-data/customElement.js +1 -1
  425. package/dist/components/solution-variables/customElement.js +1 -1
  426. package/dist/components/solutions-all-panel/customElement.js +1 -1
  427. package/dist/components/solutions-all-shell/customElement.js +13 -10
  428. package/dist/components/solutions-article-panel/customElement.js +1 -1
  429. package/dist/components/solutions-articles/customElement.js +1 -1
  430. package/dist/components/solutions-articles-shell/customElement.d.ts +2 -0
  431. package/dist/components/solutions-articles-shell/customElement.js +15 -12
  432. package/dist/components/solutions-deploy-app/customElement.js +1 -1
  433. package/dist/components/solutions-deploy-app-nav/customElement.js +1 -1
  434. package/dist/components/solutions-deployed-filter-panel/customElement.js +1 -1
  435. package/dist/components/solutions-deployed-panel/customElement.js +1 -1
  436. package/dist/components/solutions-deployed-shell/customElement.js +10 -7
  437. package/dist/components/solutions-filter-panel/customElement.js +1 -1
  438. package/dist/components/spatial-ref/customElement.js +1 -1
  439. package/dist/components/store-manager/customElement.js +1 -1
  440. package/dist/docs/api.json +28 -2
  441. package/dist/docs/docs.json +32 -3
  442. package/dist/docs/vscode.html-custom-data.json +2 -2
  443. package/dist/docs/web-types.json +27 -5
  444. package/dist/index.d.ts +16 -1
  445. package/dist/index.js +1 -1
  446. package/dist/loader.js +1 -1
  447. package/dist/types/lumina.d.ts +2 -0
  448. package/dist/types/preact.d.ts +2 -0
  449. package/dist/types/preact10.d.ts +2 -0
  450. package/dist/types/react.d.ts +2 -0
  451. package/dist/types/stencil.d.ts +2 -0
  452. package/package.json +3 -3
  453. package/dist/cdn/2QA7JT7T.js +0 -4
  454. package/dist/cdn/6MMPHOBK.js +0 -4
  455. package/dist/cdn/77AW2L67.js +0 -4
  456. package/dist/cdn/7CAATV33.js +0 -18
  457. package/dist/cdn/7UXNV7RB.js +0 -4
  458. package/dist/cdn/D2N2I4QJ.js +0 -4
  459. package/dist/cdn/E4R6SRQL.js +0 -4
  460. package/dist/cdn/KAQ2HO6H.js +0 -4
  461. package/dist/cdn/LP5QSNPJ.js +0 -89
  462. package/dist/cdn/MZ23NF3L.js +0 -4
  463. package/dist/cdn/RPF7YPFG.js +0 -18
  464. package/dist/cdn/T7NEKD33.js +0 -4
  465. package/dist/cdn/UJP5AKJT.js +0 -4
  466. package/dist/cdn/UZFCVK2C.js +0 -18
  467. package/dist/cdn/XIHBBKIM.js +0 -4
@@ -0,0 +1,89 @@
1
+ /*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
2
+ See https://js.arcgis.com/1.1/esri/copyright.txt for details.
3
+ v1.1.0-next.20251009 */
4
+ import{a as Zn}from"./6GV5SWOL.js";import{a as Jn}from"./67D7ZMIO.js";import"./FWUQZ3X3.js";import"./6PTHBN37.js";import{b as $n}from"./SHGVPHG7.js";import{C as Qs,D as _s,E as Wn,h as qn,i as Hn}from"./6K7IMQAZ.js";import"./QSBB7GQ6.js";(function(){let C=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};C.requestAnimationFrame===void 0&&(C.setImmediate===void 0?C.requestAnimationFrame=x=>C.setTimeout(x,0):C.requestAnimationFrame=C.setImmediate);class g{static ur=C.navigator!==void 0&&C.navigator.platform!==void 0&&C.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static NP(t,e,i){let s=-1;return function(){let n=this,o=arguments;s!==-1&&g.yc(s),s=g.dn(()=>{s=-1,i||t.apply(n,o)},e),i&&!s&&t.apply(n,o)}}static dn(t,e){return C.setTimeout(t,e)}static yc(t){C.clearTimeout(t)}static Ni(t){return C.document.createElement(t)}static o(t){throw new Error(t)}static L(t,e){let i="The object is frozen, so its properties cannot be set: "+t.toString();e!==void 0&&(i+=" to value: "+e),g.o(i)}static se(t,e,i,s){}static s(t,e,i,s){}static CU(t,e,i){}static wc(t,e,i){if(t===null||typeof t!="object"){let s=g.LL(e);i!==void 0&&(s+="."+i),g.si(t,"object",s)}}static S(t,e,i){g.s(t,"function",e,i)}static LU(t,e,i){}static si(t,e,i,s){}static J(t,e,i,s){let n=g.LL(i);s!==void 0&&(n+="."+s),g.o(n+" is not in the range "+e+": "+t)}static Gi(t){}static dr(t,e){}static ne(t){C.console&&C.console.log(t)}static $(t){return t!==null&&typeof t=="object"}static nt(t){return typeof t=="function"}static CP=[];static ot(){let t=g.CP.pop();return t===void 0?[]:t}static Z(t){t.length=0,g.CP.push(t)}static AU=Object.freeze([]);static LL(t){return t===null?"*":typeof t=="string"?t:g.nt(t)?t.name:""}static Hn(t){return g.nt(t)?t.className?t.className:t.name:g.$(t)&&t.constructor?g.Hn(t.constructor):typeof t}static Wa(t,e){return e==null||e===""?null:g.$(t)&&e in t||t[e]?t[e]:null}static toString(t){let e=t;return g.$(t)&&(t.text?e=t.text:t.name?e=t.name:t.key!==void 0?e=t.key:t.id!==void 0?e=t.id:t.constructor===Object&&(t.Text?e=t.Text:t.Name?e=t.Name:t.Key!==void 0?e=t.Key:t.Id!==void 0?e=t.Id:t.ID!==void 0&&(e=t.ID))),e===void 0?"undefined":e===null?"null":e.toString()}static Hw(t,e){if(t.hasOwnProperty(e))return!0;let i=Object.getPrototypeOf(t);for(;i&&i!==Function;){if(i.hasOwnProperty(e))return!0;let s=i.TU;if(s&&s[e])return!0;i=Object.getPrototypeOf(i)}return!1}static zF(t){let e=[],i=0;for(i=0;i<256;i++)e[i]=i;let s=0,n=0;for(i=0;i<256;i++)s=(s+e[i]+119)%256,n=e[i],e[i]=e[s],e[s]=n;i=0,s=0;let o="";for(let r=0;r<t.length;r++)i=(i+1)%256,s=(s+e[i])%256,n=e[i],e[i]=e[s],e[s]=n,o+=String.fromCharCode(t.charCodeAt(r)^e[(e[i]+e[s])%256]);return o}static XF(t){let e="0123456789abcdef",i=[];for(let r=0;r<256;r++)i[e.charAt(r>>4)+e.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);let s=[],n=0;for(let r=0;r<t.length;r+=2)s[n++]=i[t.substring(r,r+2)];let o=s.join("");return o===""?"0":o}static We(t){return g.zF(g.XF(t))}static color1="@COLOR1";static color2="@COLOR2";static jw="32ab5ff3b26f42dc0ed90f21412913b5"}g.vfo="29e647fdb3";class z{LP;constructor(){this.LP=[]}toString(){return this.LP.join("")}add(t){t!==""&&this.LP.push(t)}}class W{}class J{g;constructor(){this.g=[]}[Symbol.iterator](){return this.g.values()}key;value;get iterator(){return this}reset(){}next(){return!1}hasNext(){return!1}first(){return null}any(){return!1}all(){return!0}each(){return this}map(t){return this}filter(){return this}get count(){return 0}Ml(){}toString(){return"EmptyIterator"}static instance=new J}class ${constructor(t){this.key=-1,this.value=t}[Symbol.iterator](){return[this.value].values()}key;value;get iterator(){return this}reset(){this.key=-1}next(){return this.key===-1?(this.key=0,!0):!1}hasNext(){return this.next()}first(){return this.key=0,this.value}any(t){return this.key=-1,t(this.value)}all(t){return this.key=-1,t(this.value)}each(t){return this.key=-1,t(this.value),this}map(t){return new $(t(this.value))}filter(t){return t(this.value)?new $(this.value):J.instance}get count(){return 1}Ml(){this.value=null}toString(){return"SingletonIterator("+this.value+")"}}class et{jt;Xs;Gt;Tt;constructor(t){this.jt=t,this.Xs=null,t.gr=null,this.Gt=t.lt,this.Tt=-1}[Symbol.iterator](){return this.Xs===null?this.jt.r.values():this.jt.r.filter(this.Xs).values()}key;value;get iterator(){return this}get predicate(){return this.Xs}set predicate(t){this.Xs=t}reset(){let t=this.jt;t.gr=null,this.Gt=t.lt,this.Tt=-1}next(){let t=this.jt;if(t.lt!==this.Gt){if(this.key<0)return!1;g.Gi(t)}let e=t.r,i=e.length,s=++this.Tt,n=this.Xs;if(n!==null)for(;s<i;){let o=e[s];if(n(o))return this.Tt=s,this.key=s,this.value=o,!0;s++}else{if(s<i)return this.key=s,this.value=e[s],!0;this.Ml()}return!1}hasNext(){return this.next()}first(){let t=this.jt;this.Gt=t.lt,this.Tt=0;let e=t.r,i=e.length,s=this.Xs;if(s!==null){let n=0;for(;n<i;){let o=e[n];if(s(o))return this.Tt=n,this.key=n,this.value=o,o;n++}return null}else if(i>0){let n=e[0];return this.key=0,this.value=n,n}else return null}any(t){let e=this.jt;e.gr=null;let i=e.lt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(t(a))return!0;e.lt!==i&&g.Gi(e)}}return!1}all(t){let e=this.jt;e.gr=null;let i=e.lt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(!t(a))return!1;e.lt!==i&&g.Gi(e)}}return!0}each(t){let e=this.jt;e.gr=null;let i=e.lt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];o!==null&&!o(a)||(t(a),e.lt!==i&&g.Gi(e))}return this}map(t){let e=this.jt;e.gr=null;let i=e.lt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.Xs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(s.push(t(l)),e.lt!==i&&g.Gi(e))}let a=new U;return a.r=s,a.Yi(),a.iterator}filter(t){let e=this.jt;e.gr=null;let i=e.lt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.Xs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(t(l)&&s.push(l),e.lt!==i&&g.Gi(e))}let a=new U;return a.r=s,a.Yi(),a.iterator}get count(){let t=this.Xs;if(t!==null){let e=0,i=this.jt.r,s=i.length;for(let n=0;n<s;n++)t(i[n])&&e++;return e}else return this.jt.r.length}Ml(){this.key=-1,this.value=null,this.Gt=-1,this.Xs=null,this.jt.gr=this}toString(){return"ListIterator@"+this.Tt+"/"+this.jt.count}}class ct{jt;Gt;Tt;constructor(t){this.jt=t,t.pr=null,this.Gt=t.lt,this.Tt=t.r.length}[Symbol.iterator](){return this.jt.r.reverse().values()}key;value;get iterator(){return this}reset(){let t=this.jt;t.pr=null,this.Gt=t.lt,this.Tt=t.r.length}next(){let t=this.jt;if(t.lt!==this.Gt){if(this.key<0)return!1;g.Gi(t)}let e=--this.Tt;return e>=0?(this.key=e,this.value=t.r[e],!0):(this.Ml(),!1)}hasNext(){return this.next()}first(){let t=this.jt;this.Gt=t.lt;let e=t.r,i=e.length-1;if(this.Tt=i,i>=0){let s=e[i];return this.key=i,this.value=s,s}else return null}any(t){let e=this.jt;e.pr=null;let i=e.lt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(t(r))return!0;e.lt!==i&&g.Gi(e)}return!1}all(t){let e=this.jt;e.pr=null;let i=e.lt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(!t(r))return!1;e.lt!==i&&g.Gi(e)}return!0}each(t){let e=this.jt;e.pr=null;let i=e.lt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];t(r),e.lt!==i&&g.Gi(e)}return this}map(t){let e=this.jt;e.pr=null;let i=e.lt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];s.push(t(h)),e.lt!==i&&g.Gi(e)}let r=new U;return r.r=s,r.Yi(),r.iterator}filter(t){let e=this.jt;e.pr=null;let i=e.lt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];t(h)&&s.push(h),e.lt!==i&&g.Gi(e)}let r=new U;return r.r=s,r.Yi(),r.iterator}get count(){return this.jt.r.length}Ml(){this.key=-1,this.value=null,this.Gt=-1,this.jt.pr=this}toString(){return"ListIteratorBackwards("+this.Tt+"/"+this.jt.count+")"}}class U{f;r;lt;gr;pr;constructor(t){I.Je(this),this.f=!1,this.r=[],this.lt=0,this.gr=null,this.pr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Yi(){let t=this.lt;t++,t>999999999&&(t=0),this.lt=t}b(){return this.f=!0,this}ce(){return this.f=!1,this}toString(){return"List()#"+I.xs(this)}add(t){return this.f&&g.L(this,t),this.r.push(t),this.Yi(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&g.L(this);let e=this.r;if(t.first){let i=t.iterator;for(;i.next();)e.push(i.value)}else for(let i of t)e.push(i);return this.Yi(),this}clear(){this.f&&g.L(this),this.r.length=0,this.Yi()}contains(t){return this.has(t)}has(t){return t===null?!1:this.r.indexOf(t)!==-1}indexOf(t){return t===null?-1:this.r.indexOf(t)}elt(t){let e=this.r;return(t<0||t>=e.length)&&g.J(t,"0 <= i < length",U,"elt:i"),e[t]}get(t){return this.elt(t)}setElt(t,e){let i=this.r;(t<0||t>=i.length)&&g.J(t,"0 <= i < length",U,"setElt:i"),this.f&&g.L(this,t),i[t]=e}set(t,e){this.setElt(t,e)}first(){let t=this.r;return t.length===0?null:t[0]}last(){let t=this.r,e=t.length;return e>0?t[e-1]:null}pop(){this.f&&g.L(this);let t=this.r;if(t.length>0){let e=t.pop();return e===void 0?null:e}return null}any(t){let e=this.r,i=this.lt,s=e.length;for(let n=0;n<s;n++){if(t(e[n]))return!0;this.lt!==i&&g.Gi(this)}return!1}all(t){let e=this.r,i=this.lt,s=e.length;for(let n=0;n<s;n++){if(!t(e[n]))return!1;this.lt!==i&&g.Gi(this)}return!0}each(t){let e=this.r,i=this.lt,s=e.length;for(let n=0;n<s;n++)t(e[n]),this.lt!==i&&g.Gi(this);return this}map(t){let e=new U,i=[],s=this.r,n=this.lt,o=s.length;for(let r=0;r<o;r++)i.push(t(s[r])),this.lt!==n&&g.Gi(this);return e.r=i,e.Yi(),e}filter(t){let e=new U,i=[],s=this.r,n=this.lt,o=s.length;for(let r=0;r<o;r++){let a=s[r];t(a)&&i.push(a),this.lt!==n&&g.Gi(this)}return e.r=i,e.Yi(),e}insertAt(t,e){t<0&&g.J(t,">= 0",U,"insertAt:i"),this.f&&g.L(this,t);let i=this.r;t>=i.length?i.push(e):i.splice(t,0,e),this.Yi()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&g.L(this,t);let e=this.r,i=e.indexOf(t);return i===-1?!1:(i===e.length-1?e.pop():e.splice(i,1),this.Yi(),!0)}removeAt(t){let e=this.r;(t<0||t>=e.length)&&g.J(t,"0 <= i < length",U,"removeAt:i"),this.f&&g.L(this,t),t===e.length-1?e.pop():e.splice(t,1),this.Yi()}removeRange(t,e){let i=this.r,s=i.length;if(t<0)t=0;else if(t>=s)return this;if(e<0)return this;if(e>=s&&(e=s-1),t>e)return this;this.f&&g.L(this);let n=t,o=e+1;for(;o<s;)i[n++]=i[o++];return i.length=s-(e-t+1),this.Yi(),this}copy(){let t=new U,e=this.r;return e.length>0&&(t.r=Array.prototype.slice.call(e)),t}toArray(){let t=this.r,e=this.count,i=new Array(e);for(let s=0;s<e;s++)i[s]=t[s];return i}get AL(){return this.r}toSet(){let t=new I,e=this.r,i=this.count;for(let s=0;s<i;s++)t.add(e[s]);return t}sort(t){return this.f&&g.L(this),this.r.sort(t),this.Yi(),this}sortRange(t,e,i){let s=this.r,n=s.length;e===void 0&&(e=0),i===void 0&&(i=n),this.f&&g.L(this);let o=i-e;if(o<=1)return this;if((e<0||e>=n-1)&&g.J(e,"0 <= from < length",U,"sortRange:from"),o===2){let r=s[e],a=s[e+1];return t(r,a)>0&&(s[e]=a,s[e+1]=r,this.Yi()),this}if(e===0)if(i>=n)s.sort(t);else{let r=s.slice(0,i);r.sort(t);for(let a=0;a<i;a++)s[a]=r[a]}else if(i>=n){let r=s.slice(e);r.sort(t);for(let a=e;a<n;a++)s[a]=r[a-e]}else{let r=s.slice(e,i);r.sort(t);for(let a=e;a<i;a++)s[a]=r[a-e]}return this.Yi(),this}reverse(){return this.f&&g.L(this),this.r.reverse(),this.Yi(),this}get count(){return this.r.length}get size(){return this.r.length}get length(){return this.r.length}get iterator(){if(this.r.length<=0)return J.instance;let t=this.gr;return t!==null?(t.reset(),t):new et(this)}get iteratorBackwards(){if(this.r.length<=0)return J.instance;let t=this.pr;return t!==null?(t.reset(),t):new ct(this)}}class Lt{Do;oe;constructor(t){this.Do=t,this.oe=t.g.values()}[Symbol.iterator](){return this.Do.g.values()}key;value;get iterator(){return this}reset(){let t=this.Do;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Do.g.size===0?null:(this.oe=this.Do.g.values(),this.oe.next().value)}any(t){return this.Do.any(t)}all(t){return this.Do.all(t)}each(t){return this.Do.each(t),this}map(t){let e=new U;return this.Do.g.forEach(i=>e.add(t(i))),e.iterator}filter(t){let e=new U;return this.Do.g.forEach(i=>{t(i)&&e.add(i)}),e.iterator}get count(){return this.Do.count}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"SetIterator"}}class I{f;g;constructor(t){this.f=!1,this.g=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.values()}values(){return this.g.values()}b(){return this.f=!0,this}ce(){return this.f=!1,this}toString(){return"Set()#"+I.xs(this)}add(t){return t===null?this:(this.g.add(t),this)}addAll(t){if(t===null)return this;if(this.f&&g.L(this),t.first){let e=t.iterator;for(;e.next();)this.g.add(e.value)}else for(let e of t)this.g.add(e);return this}has(t){return this.g.has(t)}contains(t){return this.has(t)}containsAll(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(!this.has(e.value))return!1}else for(let e of t)if(!this.has(e))return!1;return!0}containsAny(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(this.has(e.value))return!0}else for(let e of t)if(this.has(e))return!0;return!1}first(){return this.g.size===0?null:this.g.values().next().value}any(t){for(let e of this.g)if(t(e))return!0;return!1}all(t){for(let e of this.g)if(!t(e))return!1;return!0}each(t){for(let e of this.g)t(e);return this}map(t){let e=new I;for(let i of this.g)e.add(t(i));return e}filter(t){let e=new I;for(let i of this.g)t(i)&&e.add(i);return e}delete(t){return this.f&&g.L(this),this.g.delete(t)}remove(t){return this.delete(t)}removeAll(t){if(t===null)return this;if(this.f&&g.L(this),t.first){let e=t.iterator;for(;e.next();)this.delete(e.value)}else for(let e of t)this.delete(e);return this}retainAll(t){if(t===null)return this;if(this.count===0)return this;this.f&&g.L(this);let e=new I;e.addAll(t);let i=[];if(t.first){let s=t.iterator;for(;s.next();){let n=s.value;e.has(n)||i.push(n)}}else for(let s of t)e.has(s)||i.push(s);return this.removeAll(i),this}clear(){this.f&&g.L(this),this.g.clear()}copy(){let t=new I;return this.g.forEach(e=>t.add(e)),t}toArray(){return Array.from(this.g)}toList(){let t=new U;return this.g.forEach(e=>t.add(e)),t}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?J.instance:new Lt(this)}entries(){return this.g.entries()}keys(){return this.g.keys()}forEach(t,e){return this.g.forEach(t,e)}static qw=1;static Je(t){t.__gohashid=I.qw++}static xs(t){return t.__gohashid}}class Rt{q;oe;constructor(t){this.q=t,this.oe=t.g.keys()}[Symbol.iterator](){return this.q.g.keys()}key;value;get iterator(){return this}reset(){let t=this.q;this.oe=t.g.keys()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.q.g.size===0?null:(this.oe=this.q.g.keys(),this.oe.next().value)}any(t){for(let e of this.q.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.q.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.q.g)t(e[0]);return this}map(t){let e=this.q,i=new U;for(let s of e.g)i.add(t(s[0]));return i.iterator}filter(t){let e=this.q,i=new U;for(let s of e.g){let n=s[0];t(n)&&i.add(n)}return i.iterator}get count(){return this.q.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapKeySetIterator"}}class le extends I{q;constructor(t){super(),I.Je(this),this.f=!0,this.q=t}[Symbol.iterator](){return this.g.keys()}values(){return this.g.keys()}b(){return this}ce(){return this}toString(){return"MapKeySet("+this.q.toString()+")"}add(t){g.o("This Set is read-only: "+this.toString())}has(t){return this.q.has(t)}contains(t){return this.has(t)}delete(t){g.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){g.o("This Set is read-only: "+this.toString())}first(){return this.q.g.size===0?null:this.q.g.keys().next().value}any(t){for(let e of this.q.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.q.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.q.g)t(e[0]);return this}map(t){let e=new I;for(let i of this.q.g)e.add(t(i[0]));return e}filter(t){let e=new I;for(let i of this.q.g){let s=i[0];t(s)&&e.add(s)}return e}copy(){return new le(this.q)}toSet(){let t=new I,e=this.q.g;for(let i of e)t.add(i[0]);return t}toArray(){let t=this.q.g,e=new Array(t.size),i=0;for(let s of t)e[i]=s[0],i++;return e}toList(){let t=new U,e=this.q.g;for(let i of e)t.add(i[0]);return t}get count(){return this.q.size}get size(){return this.q.size}get iterator(){return this.q.size<=0?J.instance:new Rt(this.q)}}class Ee{q;oe;constructor(t){this.q=t,this.oe=t.g.values()}[Symbol.iterator](){return this.q.g.values()}key;value;get iterator(){return this}reset(){let t=this.q;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.q.g.size===0?null:(this.oe=this.q.g.values(),this.oe.next().value)}any(t){for(let e of this.q.g)if(t(e[1]))return!0;return!1}all(t){for(let e of this.q.g)if(!t(e[1]))return!1;return!0}each(t){for(let e of this.q.g)t(e[1]);return this}map(t){let e=this.q,i=new U;for(let s of e.g)i.add(t(s[1]));return i.iterator}filter(t){let e=this.q,i=new U;for(let s of e.g){let n=s[1];t(n)&&i.add(n)}return i.iterator}get count(){return this.q.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapValueSetIterator"}}class Ht{constructor(t,e){this.key=t,this.value=e}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class $t{q;oe;constructor(t){this.q=t,this.oe=t.g.entries()}[Symbol.iterator](){return this.q.g.entries()}key;value;get iterator(){return this}reset(){let t=this.q;this.oe=t.g.entries()}next(){let t=this.oe.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.q.g.size===0)return null;this.oe=this.q.g.entries();let t=this.oe.next().value;return this.key=t[0],this.value=t[1],new Ht(t[0],t[1])}any(t){return this.q.any(t)}all(t){return this.q.all(t)}each(t){return this.q.each(t),this}map(t){let e=new U,i=null;return this.q.g.forEach((s,n)=>{i===null?i=new Ht(n,s):(i.key=n,i.value=s),e.add(t(i))}),e.iterator}filter(t){let e=new U,i=null;return this.q.g.forEach((s,n)=>{i===null?i=new Ht(n,s):(i.key=n,i.value=s),t(i)&&(e.add(i),i=null)}),e.iterator}get count(){return this.q.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapIterator"}}class wt{f;g;constructor(t){I.Je(this),this.f=!1,this.g=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.entries()}entries(){return this.g.entries()}b(){return this.f=!0,this}ce(){return this.f=!1,this}toString(){return"Map()#"+I.xs(this)}set(t,e){return this.f&&g.L(this,t),this.g.set(t,e),this}add(t,e){return this.set(t,e)}addAll(t){if(t===null)return this;if(this.f&&g.L(this),t instanceof wt){let e=t.iterator;for(;e.next();)this.g.set(e.key,e.value)}else if(t.first){let e=t.iterator;for(;e.next();){let i=e.value;this.g.set(i.key,i.value)}}else for(let e of t){let i=e;Array.isArray(i)?this.g.set(i[0],i[1]):this.g.set(i.key,i.value)}return this}first(){if(this.g.size===0)return null;let t=this.g.entries().next().value;return t?new Ht(t[0],t[1]):null}any(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new Ht(i,s):(e.key=i,e.value=s),t(e))return!0;return!1}all(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new Ht(i,s):(e.key=i,e.value=s),!t(e))return!1;return!0}each(t){let e=null;for(let[i,s]of this.g)e===null?e=new Ht(i,s):(e.key=i,e.value=s),t(e);return this}map(t){let e=new wt,i=null;for(let[s,n]of this.g)i===null?i=new Ht(s,n):(i.key=s,i.value=n),e.set(s,t(i));return e}filter(t){let e=new wt,i=null;for(let[s,n]of this.g)i===null?i=new Ht(s,n):(i.key=s,i.value=n),t(i)&&e.set(s,n);return e}has(t){return this.g.has(t)}contains(t){return this.has(t)}get(t){let e=this.g.get(t);return e===void 0?null:e}getValue(t){return this.get(t)}delete(t){return t===null?!1:(this.f&&g.L(this,t),this.g.delete(t))}remove(t){return this.delete(t)}clear(){this.f&&g.L(this),this.g.clear()}copy(){let t=new wt;return t.g=new Map(this.g),t}toArray(){let t=this.g,e=new Array(t.size),i=0;for(let s of t)e[i]=new Ht(s[0],s[1]),i++;return e}toKeySet(){return new le(this)}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?J.instance:new $t(this)}get iteratorKeys(){return this.count<=0?J.instance:new Rt(this)}keys(){return this.g.keys()}get iteratorValues(){return this.count<=0?J.instance:new Ee(this)}values(){return this.g.values()}forEach(t,e){return this.g.forEach(t,e)}}class P{px;py;f;constructor(t,e){t===void 0?(this.px=0,this.py=0):typeof t=="number"&&typeof e=="number"?(this.px=t,this.py=e):g.o("Invalid arguments to Point constructor: "+t+", "+e),this.f=!1}h(t){return this.px=t.px,this.py=t.py,this}e(t,e){return this.px=t,this.py=e,this}setTo(t,e){return this.px=t,this.py=e,this}set(t){return this.px=t.px,this.py=t.py,this}copy(){let t=new P;return t.px=this.px,t.py=this.py,t}kt(){return this.f=!0,Object.freeze(this),this}N(){return this.f||Object.isFrozen(this)?this:this.copy().b()}b(){return this.f||(this.f=!0),this}Ww(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new P(s,o)}else return new P}static stringify(t){return t.x.toString()+" "+t.y.toString()}static stringifyFixed(t){return g.s(t,"number",P,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof P?this.px===t.x&&this.py===t.y:!1}equalTo(t,e){return this.px===t&&this.py===e}equalsApprox(t){return A.u(this.px,t.x)&&A.u(this.py,t.y)}add(t){return this.px+=t.x,this.py+=t.y,this}subtract(t){return this.px-=t.x,this.py-=t.y,this}offset(t,e){return this.px+=t,this.py+=e,this}rotate(t){if(t===0)return this;let e=this.px,i=this.py;if(e===0&&i===0)return this;let s=0,n=0;if(t=A.Ee(t),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.px=s*e-n*i,this.py=n*e+s*i,this}scale(t,e){return this.px*=t,this.py*=e,this}distanceSquaredPoint(t){let e=t.x-this.px,i=t.y-this.py;return e*e+i*i}distanceSquared(t,e){let i=t-this.px,s=e-this.py;return i*i+s*s}normalize(){let t=this.px,e=this.py,i=Math.sqrt(t*t+e*e);return i>0&&(this.px=t/i,this.py=e/i),this}directionPoint(t){return this.TL(t.x-this.px,t.y-this.py)}direction(t,e){return this.TL(t-this.px,e-this.py)}TL(t,e){if(t===0)return e>0?90:e<0?270:0;if(e===0)return t>0?0:180;{if(isNaN(t)||isNaN(e))return 0;let i=Math.atan(Math.abs(e/t))*180/Math.PI;return t<0?e<0?i+=180:i=180-i:e<0&&(i=360-i),i}}static compareWithLineSegment(t,e,i,s,n,o){return A.ku(t,e,i,s,n,o)}compareWithLineSegmentPoint(t,e){return A.ku(t.x,t.y,e.x,e.y,this.x,this.y)}static intersectingLineSegments(t,e,i,s,n,o,r,a){return A.Pu(t,e,i,s,n,o,r,a)}projectOntoLineSegment(t,e,i,s){return A.Nl(t,e,i,s,this.px,this.py,this),this}projectOntoLineSegmentPoint(t,e){return A.Nl(t.x,t.y,e.x,e.y,this.px,this.py,this),this}snapToGrid(t,e,i,s){return A._g(this.px,this.py,t,e,i,s,this),this}snapToGridPoint(t,e){return A._g(this.px,this.py,t.x,t.y,e.width,e.height,this),this}setRectSpot(t,e){return this.px=t.x+e.x*t.width+e.offsetX,this.py=t.y+e.y*t.height+e.offsetY,this}setSpot(t,e,i,s,n){return this.px=t+n.x*i+n.offsetX,this.py=e+n.y*s+n.offsetY,this}v(t){return t.gt(this),this}Ki(t){return t.Ci(this),this}static distanceLineSegmentSquared(t,e,i,s,n,o){let r=n-i,a=o-s,h=r*r+a*a,l=i-t,c=s-e,u=-l*r-c*a;if(u<=0||u>=h)return r=n-t,a=o-e,Math.min(l*l+c*c,r*r+a*a);{let d=r*c-a*l;return d*d/h}}static distanceSquared(t,e,i,s){let n=i-t,o=s-e;return n*n+o*o}static direction(t,e,i,s){let n=i-t,o=s-e;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.px}set x(t){this.px=t}get y(){return this.py}set y(t){this.py=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static gn=new P(0,0).kt();static DL=new P(-1/0,-1/0).kt();static vL=new P(1/0,1/0).kt();static FL=new P(6,6).kt();static mn=new P(NaN,NaN).kt();static Jw=[];static l(){let t=P.Jw.pop();return t===void 0?new P:t}static bs(t){let e=P.Jw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e){let i=P.Jw.pop();return i===void 0?new P(t,e):(i.x=t,i.y=e,i)}static i(t){P.Jw.push(t)}}class _{sw;sh;f;constructor(t,e){t===void 0?(this.sw=0,this.sh=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof e=="number"&&(e>=0||isNaN(e))?(this.sw=t,this.sh=e):g.o("Invalid arguments to Size constructor: "+t+", "+e),this.f=!1}h(t){return this.sw=t.sw,this.sh=t.sh,this}e(t,e){return this.sw=t,this.sh=e,this}setTo(t,e){return this.sw=t,this.sh=e,this}set(t){return this.sw=t.sw,this.sh=t.sh,this}copy(){let t=new _;return t.sw=this.sw,t.sh=this.sh,t}kt(){return this.f=!0,Object.freeze(this),this}N(){return this.f||Object.isFrozen(this)?this:this.copy().b()}b(){return this.f||(this.f=!0),this}Ww(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new _(s,o)}else return new _}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return g.s(t,"number",_,"stringifyFixed:digits"),e=>e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof _?this.sw===t.width&&this.sh===t.height:!1}equalTo(t,e){return this.sw===t&&this.sh===e}equalsApprox(t){return A.u(this.sw,t.width)&&A.u(this.sh,t.height)}inflate(t,e){let i=this.width+t;this.sw=i>=0?i:0;let s=this.height+e;return this.sh=s>=0?s:0,this}get width(){return this.sw}set width(t){t<0&&g.J(t,">= 0",_,"width"),this.sw=t}get height(){return this.sh}set height(t){t<0&&g.J(t,">= 0",_,"height"),this.sh=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static xc=new _(0,0).kt();static AP=new _(1,1).kt();static RL=new _(6,6).kt();static Su=new _(8,8).kt();static OL=new _(10,10).kt();static TP=new _(1/0,1/0).kt();static $w=new _(NaN,NaN).kt();static IL=[];static l(){let t=_.IL.pop();return t===void 0?new _:t}static i(t){_.IL.push(t)}}class B{rx;ry;rw;rh;f;constructor(t,e,i,s){if(t===void 0)this.rx=0,this.ry=0,this.rw=0,this.rh=0;else if(typeof t=="number"&&typeof e=="number"&&typeof i=="number"&&(i>=0||isNaN(i))&&typeof s=="number"&&(s>=0||isNaN(s)))this.rx=t,this.ry=e,this.rw=i,this.rh=s;else if(t instanceof P){let n=t.x,o=t.y;if(e instanceof P){let r=e.x,a=e.y;this.rx=Math.min(n,r),this.ry=Math.min(o,a),this.rw=Math.abs(n-r),this.rh=Math.abs(o-a)}else e instanceof _?(this.rx=n,this.ry=o,this.rw=e.width,this.rh=e.height):g.o("Incorrect second argument supplied to Rect constructor "+e)}else g.o("Invalid arguments to Rect constructor: "+t+", "+e+", "+i+", "+s);this.f=!1}h(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}e(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}jn(t,e){return this.rw=t,this.rh=e,this}setTo(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}set(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}setPoint(t){return this.rx=t.x,this.ry=t.y,this}setSize(t){return this.rw=t.width,this.rh=t.height,this}copy(){let t=new B;return t.rx=this.rx,t.ry=this.ry,t.rw=this.rw,t.rh=this.rh,t}kt(){return this.f=!0,Object.freeze(this),this}N(){return this.f||Object.isFrozen(this)?this:this.copy().b()}b(){return this.f||(this.f=!0),this}ce(){return this.f&&(Object.isFrozen(this)&&g.o("cannot thaw constant: "+this),this.f=!1),this}Ww(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),new B(s,o,r,a)}else return new B}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return g.s(t,"number",B,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof B?this.rx===t.x&&this.ry===t.y&&this.rw===t.width&&this.rh===t.height:!1}equalTo(t,e,i,s){return this.rx===t&&this.ry===e&&this.rw===i&&this.rh===s}equalsApprox(t){return A.u(this.rx,t.x)&&A.u(this.ry,t.y)&&A.u(this.rw,t.width)&&A.u(this.rh,t.height)}equalsApproxTo(t,e,i,s){return A.u(this.rx,t)&&A.u(this.ry,e)&&A.u(this.rw,i)&&A.u(this.rh,s)}equalsApproxClose(t){return A.X(this.rx,t.x)&&A.X(this.ry,t.y)&&A.X(this.rw,t.width)&&A.X(this.rh,t.height)}containsPoint(t){return this.rx<=t.x&&this.rx+this.rw>=t.x&&this.ry<=t.y&&this.ry+this.rh>=t.y}containsRect(t){return this.rx<=t.x&&t.x+t.width<=this.rx+this.rw&&this.ry<=t.y&&t.y+t.height<=this.ry+this.rh}contains(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.rx<=t&&t+i<=this.rx+this.rw&&this.ry<=e&&e+s<=this.ry+this.rh}offset(t,e){return this.rx+=t,this.ry+=e,this}inflate(t,e){return this.Zw(e,t,e,t)}addMargin(t){return this.Zw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.Zw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,e,i,s){return this.Zw(t,e,i,s)}Zw(t,e,i,s){let n=this.rw;e+s<=-n?(this.rx+=n/2,this.rw=0):(this.rx-=s,this.rw+=e+s);let o=this.rh;return t+i<=-o?(this.ry+=o/2,this.rh=0):(this.ry-=t,this.rh+=t+i),this}intersectRect(t){return this.EL(t.x,t.y,t.width,t.height)}intersect(t,e,i,s){return this.EL(t,e,i,s)}EL(t,e,i,s){let n=Math.max(this.rx,t),o=Math.max(this.ry,e),r=Math.min(this.rx+this.rw,t+i),a=Math.min(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=Math.max(0,r-n),this.rh=Math.max(0,a-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,e,i,s){let n=this.rw,o=this.rx;if(n!==1/0&&i!==1/0&&(n+=o,i+=t,isNaN(i)||isNaN(n)||o>i||t>n))return!1;let r=this.rh,a=this.ry;return!(r!==1/0&&s!==1/0&&(r+=a,s+=e,isNaN(s)||isNaN(r)||a>s||e>r))}UL(t,e){let i=this.rw,s=t.width+e+e,n=this.rx,o=t.x-e;if(i+=n,s+=o,n>s||o>i)return!1;let r=this.rh,a=t.height+e+e,h=this.ry,l=t.y-e;return r+=h,a+=l,!(h>a||l>r)}unionPoint(t){return this.re(t.x,t.y,0,0)}unionRect(t){return this.re(t.rx,t.ry,t.rw,t.rh)}union(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.re(t,e,i,s)}re(t,e,i,s){let n=Math.min(this.rx,t),o=Math.min(this.ry,e),r=Math.max(this.rx+this.rw,t+i),a=Math.max(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=r-n,this.rh=a-o,this}setSpot(t,e,i){return this.rx=t-i.offsetX-i.x*this.rw,this.ry=e-i.offsetY-i.y*this.rh,this}nearestSideDirection(t,e){return A.Qw(this,t,e,!0)}nearestSideDirectionPoint(t){return A.Qw(this,t.x,t.y,!0)}static contains(t,e,i,s,n,o,r,a){return r===void 0&&(r=0),a===void 0&&(a=0),t<=n&&n+r<=t+i&&e<=o&&o+a<=e+s}static intersects(t,e,i,s,n,o,r,a){let h=i,l=r,c=t,u=n;if(h+=c,l+=u,c>l||u>h)return!1;let d=s,f=a,p=e,m=o;return d+=p,f+=m,!(p>f||m>d)}static intersectsLineSegment(t,e,i,s,n,o,r,a){return A.VL(t,e,i,s,n,o,r,a)}get x(){return this.rx}set x(t){this.rx=t}get y(){return this.ry}set y(t){this.ry=t}get width(){return this.rw}set width(t){t<0&&g.J(t,">= 0",B,"width"),this.rw=t}get height(){return this.rh}set height(t){t<0&&g.J(t,">= 0",B,"height"),this.rh=t}get left(){return this.rx}set left(t){this.rx=t}get top(){return this.ry}set top(t){this.ry=t}get right(){return this.rx+this.rw}set right(t){this.rx+=t-(this.rx+this.rw)}get bottom(){return this.ry+this.rh}set bottom(t){this.ry+=t-(this.ry+this.rh)}get position(){return new P(this.rx,this.ry)}set position(t){this.rx=t.x,this.ry=t.y}get size(){return new _(this.rw,this.rh)}set size(t){this.rw=t.width,this.rh=t.height}get center(){return new P(this.rx+this.rw/2,this.ry+this.rh/2)}set center(t){this.rx=t.x-this.rw/2,this.ry=t.y-this.rh/2}get centerX(){return this.rx+this.rw/2}set centerX(t){this.rx=t-this.rw/2}get centerY(){return this.ry+this.rh/2}set centerY(t){this.ry=t-this.rh/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static tm=new B(0,0,0,0).kt();static GF=new B(NaN,NaN,NaN,NaN).kt();static _w=[];static l(){let t=B._w.pop();return t===void 0?new B:t}static bs(t){let e=B._w.pop();return e===void 0?t.copy():e.h(t)}static z(t,e,i,s){let n=B._w.pop();return n===void 0?new B(t,e,i,s):n.e(t,e,i,s)}static i(t){B._w.push(t)}}class Dt{mt;mr;mb;ml;constructor(t,e,i,s){t===void 0?(this.mt=0,this.mr=0,this.mb=0,this.ml=0):e===void 0?(e=t,i=t,s=t,this.mt=t,this.mr=e,this.mb=i,this.ml=s):i===void 0?(i=t,s=e,this.mt=t,this.mr=e,this.mb=i,this.ml=s):s!==void 0?(this.mt=t,this.mr=e,this.mb=i,this.ml=s):g.o("Invalid arguments to Margin constructor: "+t+", "+e+", "+i+", "+s)}setTo(t,e,i,s){return this.mt=t,this.mr=e,this.mb=i,this.ml=s,this}set(t){return this.mt=t.mt,this.mr=t.mr,this.mb=t.mb,this.ml=t.ml,this}copy(){let t=new Dt;return t.mt=this.mt,t.mr=this.mr,t.mb=this.mb,t.ml=this.ml,t}kt(){return Object.freeze(this),this}N(){return Object.isFrozen(this)?this:this.copy().kt()}Ww(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=NaN;for(;e[i]==="";)i++;let n=e[i++];if(n&&(s=parseFloat(n)),isNaN(s))return new Dt;let o=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(o=parseFloat(n)),isNaN(o))return new Dt(s);let r=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(r=parseFloat(n)),isNaN(r))return new Dt(s,o);let a=NaN;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),isNaN(a)?new Dt(s,o):new Dt(s,o,r,a)}else return new Dt}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return g.s(t,"number",Dt,"stringifyFixed:digits"),e=>e.top.toFixed(t)+" "+e.right.toFixed(t)+" "+e.bottom.toFixed(t)+" "+e.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Dt?this.mt===t.top&&this.mr===t.right&&this.mb===t.bottom&&this.ml===t.left:!1}equalTo(t,e,i,s){return this.mt===t&&this.mr===e&&this.mb===i&&this.ml===s}equalsApprox(t){return A.u(this.mt,t.top)&&A.u(this.mr,t.right)&&A.u(this.mb,t.bottom)&&A.u(this.ml,t.left)}get top(){return this.mt}set top(t){this.mt=t}get right(){return this.mr}set right(t){this.mr=t}get bottom(){return this.mb}set bottom(t){this.mb=t}get left(){return this.ml}set left(t){this.ml=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static em=new Dt(0,0,0,0).kt();static BL=new Dt(2,2,2,2).kt()}class T{sx;sy;ox;oy;constructor(t,e,i,s){t===void 0?(this.sx=0,this.sy=0,this.ox=0,this.oy=0):(e===void 0&&(e=0),i===void 0&&(i=0),s===void 0&&(s=0),this.sx=t,this.sy=e,this.ox=i,this.oy=s)}setTo(t,e,i,s){return this.sx=t,this.sy=e,this.ox=i,this.oy=s,this}set(t){return this.sx=t.sx,this.sy=t.sy,this.ox=t.ox,this.oy=t.oy,this}copy(){let t=new T;return t.sx=this.sx,t.sy=this.sy,t.ox=this.ox,t.oy=this.oy,t}kt(){return Object.freeze(this),this}N(){return Object.isFrozen(this)?this:this.copy().kt()}Ww(t){}Hi(t){return this.sx=NaN,this.sy=NaN,this.ox=t,this.kt()}DU(t,e){(isNaN(t)||t>1||t<0)&&g.J(t,"0 <= "+e+" <= 1",T,e)}vU(t,e){(isNaN(t)||t===1/0||t===-1/0)&&g.J(t,"real number, not NaN or Infinity",T,e)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return T.None;if(t==="TopLeft")return T.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return T.TopCenter;if(t==="TopRight")return T.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return T.LeftCenter;if(t==="Center")return T.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return T.RightCenter;if(t==="BottomLeft")return T.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return T.BottomCenter;if(t==="BottomRight")return T.BottomRight;if(t==="TopSide")return T.TopSide;if(t==="LeftSide")return T.LeftSide;if(t==="RightSide")return T.RightSide;if(t==="BottomSide")return T.BottomSide;if(t==="TopBottomSides")return T.TopBottomSides;if(t==="LeftRightSides")return T.LeftRightSides;if(t==="TopLeftSides")return T.TopLeftSides;if(t==="TopRightSides")return T.TopRightSides;if(t==="BottomLeftSides")return T.BottomLeftSides;if(t==="BottomRightSides")return T.BottomRightSides;if(t==="NotTopSide")return T.NotTopSide;if(t==="NotLeftSide")return T.NotLeftSide;if(t==="NotRightSide")return T.NotRightSide;if(t==="NotBottomSide")return T.NotBottomSide;if(t==="AllSides")return T.AllSides;if(t==="Default")return T.Default;let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n!==void 0&&n.length>0&&(a=parseFloat(n)),new T(s,o,r,a)}else return new T}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return g.s(t,"number",T,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.offsetX.toFixed(t)+" "+e.offsetY.toFixed(t)}toString(){return this.isSpot()?this.ox===0&&this.oy===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(T.None)?"None":this.equals(T.TopLeft)?"TopLeft":this.equals(T.TopCenter)?"Top":this.equals(T.TopRight)?"TopRight":this.equals(T.LeftCenter)?"Left":this.equals(T.Center)?"Center":this.equals(T.RightCenter)?"Right":this.equals(T.BottomLeft)?"BottomLeft":this.equals(T.BottomCenter)?"Bottom":this.equals(T.BottomRight)?"BottomRight":this.equals(T.TopSide)?"TopSide":this.equals(T.LeftSide)?"LeftSide":this.equals(T.RightSide)?"RightSide":this.equals(T.BottomSide)?"BottomSide":this.equals(T.TopBottomSides)?"TopBottomSides":this.equals(T.LeftRightSides)?"LeftRightSides":this.equals(T.TopLeftSides)?"TopLeftSides":this.equals(T.TopRightSides)?"TopRightSides":this.equals(T.BottomLeftSides)?"BottomLeftSides":this.equals(T.BottomRightSides)?"BottomRightSides":this.equals(T.NotTopSide)?"NotTopSide":this.equals(T.NotLeftSide)?"NotLeftSide":this.equals(T.NotRightSide)?"NotRightSide":this.equals(T.NotBottomSide)?"NotBottomSide":this.equals(T.AllSides)?"AllSides":this.equals(T.Default)?"Default":"None"}equals(t){return t instanceof T?(this.sx===t.x||isNaN(this.sx)&&isNaN(t.x))&&(this.sy===t.y||isNaN(this.sy)&&isNaN(t.y))&&this.ox===t.offsetX&&this.oy===t.offsetY:!1}opposite(){return new T(.5-(this.sx-.5),.5-(this.sy-.5),-this.ox,-this.oy)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(T.Left))t=T.LeftSide;else if(t.equals(T.Right))t=T.RightSide;else if(t.equals(T.Top))t=T.TopSide;else if(t.equals(T.Bottom))t=T.BottomSide;else return!1;let e=this.oy,i=t.offsetY;return(e&i)===i}get x(){return this.sx}set x(t){this.sx=t}get y(){return this.sy}set y(t){this.sy=t}get offsetX(){return this.ox}set offsetX(t){this.ox=t}get offsetY(){return this.oy}set offsetY(t){this.oy=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new T(0,0,0,0).Hi(0);static Default=new T(0,0,-1,0).Hi(-1);static TopLeft=new T(0,0,0,0).kt();static TopCenter=new T(.5,0,0,0).kt();static TopRight=new T(1,0,0,0).kt();static LeftCenter=new T(0,.5,0,0).kt();static Center=new T(.5,.5,0,0).kt();static RightCenter=new T(1,.5,0,0).kt();static BottomLeft=new T(0,1,0,0).kt();static BottomCenter=new T(.5,1,0,0).kt();static BottomRight=new T(1,1,0,0).kt();static MiddleTop=T.TopCenter;static MiddleLeft=T.LeftCenter;static MiddleRight=T.RightCenter;static MiddleBottom=T.BottomCenter;static Top=T.TopCenter;static Left=T.LeftCenter;static Right=T.RightCenter;static Bottom=T.BottomCenter;static TopSide=new T(0,0,1,1).Hi(1);static LeftSide=new T(0,0,1,2).Hi(1);static RightSide=new T(0,0,1,4).Hi(1);static BottomSide=new T(0,0,1,8).Hi(1);static TopBottomSides=new T(0,0,1,9).Hi(1);static LeftRightSides=new T(0,0,1,6).Hi(1);static TopLeftSides=new T(0,0,1,3).Hi(1);static TopRightSides=new T(0,0,1,5).Hi(1);static BottomLeftSides=new T(0,0,1,10).Hi(1);static BottomRightSides=new T(0,0,1,12).Hi(1);static NotTopSide=new T(0,0,1,14).Hi(1);static NotLeftSide=new T(0,0,1,13).Hi(1);static NotRightSide=new T(0,0,1,11).Hi(1);static NotBottomSide=new T(0,0,1,7).Hi(1);static AllSides=new T(0,0,1,15).Hi(1);static DP=new T(.156,.156).kt();static vP=new T(.844,.844).kt()}class Pt{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,e,i,s,n,o){return this.m11=t,this.m12=e,this.m21=i,this.m22=s,this.dx=n,this.dy=o,this}copy(){let t=new Pt;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}FP(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ue(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}bc(t){let e=this.m11*t.m11+this.m21*t.m12,i=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=e,this.m12=i,this.m21=s,this.m22=n,this}zL(t){let e=1/(t.m11*t.m22-t.m12*t.m21),i=t.m22*e,s=-t.m12*e,n=-t.m21*e,o=t.m11*e,r=e*(t.m21*t.dy-t.m22*t.dx),a=e*(t.m12*t.dx-t.m11*t.dy),h=this.m11*i+this.m21*s,l=this.m12*i+this.m22*s,c=this.m11*n+this.m21*o,u=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*a+this.dx,this.dy=this.m12*r+this.m22*a+this.dy,this.m11=h,this.m12=l,this.m21=c,this.m22=u,this}tx(){let t=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*t,i=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=e,this.m12=i,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ks(t,e,i){if(t=A.Ee(t),t===0)return this;this.Gs(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,a=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=a,this.m22=h,this.Gs(-e,-i),this}Gs(t,e){return this.dx+=this.m11*t+this.m21*e,this.dy+=this.m12*t+this.m22*e,this}it(t,e){return e===void 0&&(e=t),this.m11*=t,this.m12*=t,this.m21*=e,this.m22*=e,this}YF(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}gt(t){let e=t.x,i=t.y;return t.e(e*this.m11+i*this.m21+this.dx,e*this.m12+i*this.m22+this.dy)}Ci(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=t.x-this.dx,a=t.y-this.dy;return t.e(r*i+a*n,r*s+a*o)}Mu(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=e*(this.m21*this.dy-this.m22*this.dx),a=e*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,l=t.y*1.2;return t.e(h*i+l*n+r,h*s+l*o+a)}im(t){let e=t.x,i=t.y,s=e+t.width,n=i+t.height,o=this.m11,r=this.m12,a=this.m21,h=this.m22,l=this.dx,c=this.dy,u=e*o+i*a+l,d=e*r+i*h+c,f=s*o+i*a+l,p=s*r+i*h+c,m=e*o+n*a+l,y=e*r+n*h+c,b=s*o+n*a+l,v=s*r+n*h+c,w=u,k=u,S=d,M=d;return w=Math.min(w,f),k=Math.max(k,f),S=Math.min(S,p),M=Math.max(M,p),w=Math.min(w,m),k=Math.max(k,m),S=Math.min(S,y),M=Math.max(M,y),w=Math.min(w,b),k=Math.max(k,b),S=Math.min(S,v),M=Math.max(M,v),t.e(w,S,k-w,M-S),t}static XL=[];static l(){let t=Pt.XL.pop();return t===void 0?new Pt:t}static i(t){Pt.XL.push(t)}static RP="54a702f3e53909c447824c6706603faf4c"}let A={KF:"7da71ca0ad381e90",qn:4*((Math.sqrt(2)-1)/3),GL:[],ex:x=>{if(x<=0)return 0;let t=A.GL;if(t===null){t=[];for(let e=0;e<=2e3;e++)t[e]=Math.sqrt(e);A.GL=t}if(x<1){let e=1/x;return e<=2e3?1/t[e|0]:Math.sqrt(x)}else return x<=2e3?t[x|0]:Math.sqrt(x)},u:(x,t)=>{let e=x-t;return e<.5&&e>-.5},X:(x,t)=>{let e=x-t;return e<5e-8&&e>-5e-8},Ve:(x,t,e,i,s,n,o)=>{s<=0&&(s=1e-6);let r=0,a=0,h=0,l=0;if(x<e?(a=x,r=e):(a=e,r=x),t<i?(l=t,h=i):(l=i,h=t),x===e)return l<=o&&o<=h&&x-s<=n&&n<=x+s;if(t===i)return a<=n&&n<=r&&t-s<=o&&o<=t+s;let c=r+s,u=a-s;if(u<=n&&n<=c){let d=h+s,f=l-s;if(f<=o&&o<=d)if(c-u>d-f)if(x-e>s||e-x>s){let p=(i-t)/(e-x)*(n-x)+t;if(p-s<=o&&o<=p+s)return!0}else return!0;else if(t-i>s||i-t>s){let p=(e-x)/(i-t)*(o-t)+x;if(p-s<=n&&n<=p+s)return!0}else return!0}return!1},ix:(x,t,e,i,s,n,o,r,a,h,l,c)=>{if(!A.Ve(x,t,o,r,c,e,i)||!A.Ve(x,t,o,r,c,s,n)){let u=(x+e)/2,d=(t+i)/2,f=(e+s)/2,p=(i+n)/2,m=(s+o)/2,y=(n+r)/2,b=(u+f)/2,v=(d+p)/2,w=(f+m)/2,k=(p+y)/2,S=(b+w)/2,M=(v+k)/2;return A.ix(x,t,u,d,b,v,S,M,a,h,l,c)||A.ix(S,M,w,k,m,y,o,r,a,h,l,c)}else return A.Ve(x,t,o,r,c,h,l)},YL:(x,t,e,i,s,n,o,r,a)=>{let h=(x+e)/2,l=(t+i)/2,c=(e+s)/2,u=(i+n)/2,d=(s+o)/2,f=(n+r)/2,p=(h+c)/2,m=(l+u)/2,y=(c+d)/2,b=(u+f)/2;return a.e((p+y)/2,(m+b)/2),a},HF:(x,t,e,i,s,n,o,r)=>{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,c=(i+n)/2,u=(s+o)/2,d=(n+r)/2,f=(a+l)/2,p=(h+c)/2,m=(l+u)/2,y=(c+d)/2;return P.direction(f,p,m,y)},Nu:(x,t,e,i,s,n,o,r,a,h)=>{if(!A.Ve(x,t,o,r,a,e,i)||!A.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,c=(t+i)/2,u=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,m=(l+u)/2,y=(c+d)/2,b=(u+f)/2,v=(d+p)/2,w=(m+b)/2,k=(y+v)/2;A.Nu(x,t,l,c,m,y,w,k,a,h),A.Nu(w,k,b,v,f,p,o,r,a,h)}else h.re(x,t,0,0),h.re(o,r,0,0);return h},Wn:(x,t,e,i,s,n,o,r,a,h)=>{if(!A.Ve(x,t,o,r,a,e,i)||!A.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,c=(t+i)/2,u=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,m=(l+u)/2,y=(c+d)/2,b=(u+f)/2,v=(d+p)/2,w=(m+b)/2,k=(y+v)/2;A.Wn(x,t,l,c,m,y,w,k,a,h),A.Wn(w,k,b,v,f,p,o,r,a,h)}else h.length===0&&(h.push(x),h.push(t)),h.push(o),h.push(r);return h},OP:(x,t,e,i,s,n,o,r,a,h)=>{if(A.Ve(x,t,s,n,h,e,i))return A.Ve(x,t,s,n,h,r,a);{let l=(x+e)/2,c=(t+i)/2,u=(e+s)/2,d=(i+n)/2,f=(l+u)/2,p=(c+d)/2;return A.OP(x,t,l,c,f,p,o,r,a,h)||A.OP(f,p,u,d,s,n,o,r,a,h)}},IP:(x,t,e,i,s,n,o,r)=>{if(A.Ve(x,t,s,n,o,e,i))r.re(x,t,0,0),r.re(s,n,0,0);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,c=(i+n)/2,u=(a+l)/2,d=(h+c)/2;A.IP(x,t,a,h,u,d,o,r),A.IP(u,d,l,c,s,n,o,r)}return r},sm:(x,t,e,i,s,n,o,r)=>{if(A.Ve(x,t,s,n,o,e,i))r.length===0&&(r.push(x),r.push(t)),r.push(s),r.push(n);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,c=(i+n)/2,u=(a+l)/2,d=(h+c)/2;A.sm(x,t,a,h,u,d,o,r),A.sm(u,d,l,c,s,n,o,r)}return r},nm:(x,t,e,i,s,n,o,r,a,h,l,c,u,d)=>{if(!A.Ve(x,t,o,r,u,e,i)||!A.Ve(x,t,o,r,u,s,n)){let f=(x+e)/2,p=(t+i)/2,m=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+m)/2,k=(p+y)/2,S=(m+b)/2,M=(y+v)/2,F=(w+S)/2,D=(k+M)/2,N=1/0,L=!1,R=0,O=0;if(A.nm(x,t,f,p,w,k,F,D,a,h,l,c,u,d)){let V=(d.x-a)**2+(d.y-h)**2;V<N&&(N=V,L=!0,R=d.x,O=d.y)}if(A.nm(F,D,S,M,b,v,o,r,a,h,l,c,u,d)){let V=(d.x-a)**2+(d.y-h)**2;V<N&&(N=V,L=!0,R=d.x,O=d.y)}return L&&(d.x=R,d.y=O),L}else{if(!A.Pu(x,t,o,r,a,h,l,c))return!1;let f=(x-o)*(h-c)-(t-r)*(a-l);if(f===0)return!1;let p=((x*r-t*o)*(a-l)-(x-o)*(a*c-h*l))/f,m=((x*r-t*o)*(h-c)-(t-r)*(a*c-h*l))/f;return d.e(p,m),!0}},om:(x,t,e,i,s,n,o,r,a,h,l,c,u)=>{let d=0;if(!A.Ve(x,t,o,r,u,e,i)||!A.Ve(x,t,o,r,u,s,n)){let f=(x+e)/2,p=(t+i)/2,m=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+m)/2,k=(p+y)/2,S=(m+b)/2,M=(y+v)/2,F=(w+S)/2,D=(k+M)/2;d+=A.om(x,t,f,p,w,k,F,D,a,h,l,c,u),d+=A.om(F,D,S,M,b,v,o,r,a,h,l,c,u)}else{let f=(x-o)*(h-c)-(t-r)*(a-l);if(f===0)return d;let p=((x*r-t*o)*(a-l)-(x-o)*(a*c-h*l))/f,m=((x*r-t*o)*(h-c)-(t-r)*(a*c-h*l))/f;if(p>=l)return d;let y=0,b=0;if((a>l?a-l:l-a)<(h>c?h-c:c-h)){if(t<r?(y=t,b=r):(y=r,b=t),m<y||m>b)return d}else if(x<o?(y=x,b=o):(y=o,b=x),p<y||p>b)return d;f>0?d++:f<0&&d--}return d},Nl:(x,t,e,i,s,n,o)=>{if(A.X(x,e)){let r=0,a=0;t<i?(r=t,a=i):(r=i,a=t);let h=n;return h<r?(o.e(x,r),!1):h>a?(o.e(x,a),!1):(o.e(x,h),!0)}else if(A.X(t,i)){let r=0,a=0;x<e?(r=x,a=e):(r=e,a=x);let h=s;return h<r?(o.e(r,t),!1):h>a?(o.e(a,t),!1):(o.e(h,t),!0)}else{let r=(e-x)**2+(i-t)**2,a=((x-s)*(x-e)+(t-n)*(t-i))/r;if(a<-5e-6)return o.e(x,t),!1;if(a>1.000005)return o.e(e,i),!1;{let h=x+a*(e-x),l=t+a*(i-t);return o.e(h,l),!0}}},vo:(x,t,e,i,s,n,o,r,a)=>{if(A.u(x,e)&&A.u(t,i))return a.e(x,t),!1;if(A.X(s,o)){if(A.X(x,e))return A.Nl(x,t,e,i,s,n,a),!1;{let h=(i-t)/(e-x)*(s-x)+t;return A.Nl(x,t,e,i,s,h,a)}}else{let h=(r-n)/(o-s);if(A.X(x,e)){let l=h*(x-s)+n,c=0,u=0;return t<i?(c=t,u=i):(c=i,u=t),l<c?(a.e(x,c),!1):l>u?(a.e(x,u),!1):(a.e(x,l),!0)}else{let l=(i-t)/(e-x);if(A.X(h,l))return A.Nl(x,t,e,i,s,n,a),!1;{let c=(l*x-h*s+n-t)/(l-h);if(A.X(l,0)){let u=0,d=0;return x<e?(u=x,d=e):(u=e,d=x),c<u?(a.e(u,t),!1):c>d?(a.e(d,t),!1):(a.e(c,t),!0)}else{let u=l*(c-x)+t;return A.Nl(x,t,e,i,c,u,a)}}}}},Cl:(x,t,e,i,s,n,o,r,a)=>{let h=1e21,l=x,c=t;if(A.vo(x,t,x,i,s,n,o,r,a)){let u=(a.x-s)**2+(a.y-n)**2;u<h&&(h=u,l=a.x,c=a.y)}if(A.vo(e,t,e,i,s,n,o,r,a)){let u=(a.x-s)**2+(a.y-n)**2;u<h&&(h=u,l=a.x,c=a.y)}if(A.vo(x,t,e,t,s,n,o,r,a)){let u=(a.x-s)**2+(a.y-n)**2;u<h&&(h=u,l=a.x,c=a.y)}if(A.vo(x,i,e,i,s,n,o,r,a)){let u=(a.x-s)**2+(a.y-n)**2;u<h&&(h=u,l=a.x,c=a.y)}return a.e(l,c),h<1e21},nx:(x,t,e)=>A.VL(x.x,x.y,x.width,x.height,t.x,t.y,e.x,e.y),VL:(x,t,e,i,s,n,o,r)=>{let a=x,h=x+e,l=t,c=t+i;if(s===o){let u=0,d=0;return n<r?(u=n,d=r):(u=r,d=n),a<=s&&s<=h&&u<=c&&d>=l}if(n===r){let u=0,d=0;return s<o?(u=s,d=o):(u=o,d=s),l<=n&&n<=c&&u<=h&&d>=a}return!!(B.contains(x,t,e,i,s,n)||B.contains(x,t,e,i,o,r)||A.Pu(a,l,h,l,s,n,o,r)||A.Pu(h,l,h,c,s,n,o,r)||A.Pu(h,c,a,c,s,n,o,r)||A.Pu(a,c,a,l,s,n,o,r))},Pu:(x,t,e,i,s,n,o,r)=>x===e&&t===i&&s===o&&n===r?x===s&&t===n:A.ku(x,t,e,i,s,n)*A.ku(x,t,e,i,o,r)<=0&&A.ku(s,n,o,r,x,t)*A.ku(s,n,o,r,e,i)<=0,ku:(x,t,e,i,s,n)=>{let o=e-x,r=i-t,a=s-x,h=n-t,l=a*r-h*o;return l===0&&(l=a*o+h*r,l>0&&(a-=o,h-=r,l=a*o+h*r,l<0&&(l=0))),l},Qw(x,t,e,i){i===void 0&&(i=!1);let s=0,n=x===null?t:(t-x.x)/(x.width>0?x.width:1),o=x===null?e:(e-x.y)/(x.height>0?x.height:1);return n>o?n>1-o||(i||n<1-o?s=270:s=315):i||n<o?n>1-o?s=90:i||n<1-o?s=180:s=135:n<.5?s=225:n>.5&&(s=45),s},Ee:x=>(x>=360?x-=360:x<0&&(x+=360),x),jF:(x,t)=>x>t?Math.min(x-t,Math.abs(x-360-t)):t>x?Math.min(t-x,Math.abs(x-(t-360))):0,KL:(x,t,e,i,s,n)=>{let o=Math.PI;n||(i=i*(o/180),s=s*(o/180));let r=i>s?-1:1,a=1e-5,h=o*2,l=[],c=o/2,u=i,d=Math.min(h,Math.abs(s-i));if(d<a){let f=u+r*Math.min(d,c),p=x+e*Math.cos(u),m=t+e*Math.sin(u),y=x+e*Math.cos(f),b=t+e*Math.sin(f),v=(p+y)/2,w=(m+b)/2;return l.push([p,m,v,w,v,w,y,b]),l}for(;d>a;){let f=u+r*Math.min(d,c);l.push(A.qF(e,u,f,x,t)),d-=Math.abs(f-u),u=f}return l},qF:(x,t,e,i,s)=>{let n=(e-t)/2,o=x*Math.cos(n),r=x*Math.sin(n),a=o,h=-r,l=a*a+h*h,c=l+a*o+h*r,u=4/3*(Math.sqrt(2*l*c)-c)/(a*r-h*o),d=a-u*h,f=h+u*a,p=d,m=-f,y=n+t,b=Math.cos(y),v=Math.sin(y);return[i+x*Math.cos(t),s+x*Math.sin(t),i+d*b-f*v,s+d*v+f*b,i+p*b-m*v,s+p*v+m*b,i+x*Math.cos(e),s+x*Math.sin(e)]},_g:(x,t,e,i,s,n,o)=>{let r=s,a=n,h=Math.floor((x-e)/r)*r+e,l=Math.floor((t-i)/a)*a+i,c=h;h+r-x<r/2&&(c=h+r);let u=l;return l+a-t<a/2&&(u=l+a),o.e(c,u),o},HL:(x,t)=>{let e=Math.max(x,t),i=Math.min(x,t),s=1,n=1;do s=e%i,n=i,e=i,i=s;while(s>0);return n},WF:(x,t,e,i)=>{let s=e<0,n=i<0,o=0,r=0,a=0;x<t?(r=1,a=0):(r=0,a=1);let h=0,l=0,c=0,u=0;return o=r,h=o===0?x:t,c=o===0?e:i,(o===0?s:n)&&(c=-c),o=a,l=o===0?x:t,u=o===0?e:i,(o===0?s:n)&&(u=-u),A.JF(h,l,c,u,0,0)},JF:(x,t,e,i,s,n)=>{let o=0;if(i>0)if(e>0){let r=x*x,a=t*t,h=x*e,l=t*i,c=-a+l,u=-a+Math.sqrt(h*h+l*l),d=c,f=9999999999;for(let y=0;y<f&&(d=.5*(c+u),!(d===c||d===u));++y){let b=h/(d+r),v=l/(d+a),w=b*b+v*v-1;if(w>0)c=d;else if(w<0)u=d;else break}s=r*e/(d+r),n=a*i/(d+a);let p=s-e,m=n-i;o=Math.sqrt(p*p+m*m)}else s=0,n=t,o=Math.abs(i-t);else{let r=x*x-t*t,a=x*e;if(a<r){let h=a/r,l=h*h;s=x*h,n=t*Math.sqrt(Math.abs(1-l));let c=s-e;o=Math.sqrt(c*c+n*n)}else s=x,n=0,o=Math.abs(e-x)}return o},Jn:{},rm:new W,yr:new W,wr:0,lm:100};A.za=A.KF;var ii=(x=>(x[x.Line=1]="Line",x[x.Rectangle=2]="Rectangle",x[x.Ellipse=3]="Ellipse",x[x.Path=4]="Path",x))(ii||{}),ys=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x))(ys||{});class St{n;am;hm;kc;Cu;Lu;$n;Zn;Qn;W;Li;Ai;ni;oi;Ys;Pc;Sc;constructor(t,e){I.Je(this),this.n=2,t===void 0&&(t=4),this.W=t,this.Li=0,this.Ai=0,this.ni=0,this.oi=0,t===4?this.Ys=new U:this.Ys=St.lx,this.am=this.Ys.lt,this.hm=new B,this.kc=null,this.Cu=null,this.Lu=NaN,this.$n=T.TopLeft,this.Zn=T.BottomRight,this.Pc=NaN,this.Sc=NaN,this.Qn=2,e&&Object.assign(this,e)}copy(){let t=new St;if(t.n=this.n&-2,t.W=this.W,t.Li=this.Li,t.Ai=this.Ai,t.ni=this.ni,t.oi=this.oi,this.W===4){let e=this.Ys.r,i=t.Ys;for(let s=0;s<e.length;s++){let n=e[s];i.add(n.copy())}t.Ys=i}else t.Ys=this.Ys;return t.am=this.am,t.hm.h(this.hm),t.kc=this.kc,t.Cu=this.Cu,t.Lu=this.Lu,t.$n=this.$n.N(),t.Zn=this.Zn.N(),t.Pc=this.Pc,t.Sc=this.Sc,t.Qn=this.Qn,t}static Line=1;static Rectangle=2;static Ellipse=3;static Path=4;static lx=new U().b();get f(){return(this.n&1)!==0}set f(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}b(){if(this.f=!0,this.type!==4)return this;let t=this.figures;t.b();for(let e of t)e.b();return this}equalsApprox(t){if(!(t instanceof St))return!1;if(this.type!==t.type)return this.type===1&&t.type===4?this.jL(t):t.type===1&&this.type===4?t.jL(this):!1;if(this.type===4){let e=this.figures.r,i=t.figures.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}else return A.u(this.startX,t.startX)&&A.u(this.startY,t.startY)&&A.u(this.endX,t.endX)&&A.u(this.endY,t.endY)}jL(t){if(this.type!==1||t.type!==4)return!1;if(t.figures.count===1){let e=t.figures.elt(0);if(e.segments.count===1&&A.u(this.startX,e.startX)&&A.u(this.startY,e.startY)){let i=e.segments.elt(0);if(i.type===2&&A.u(this.endX,i.endX)&&A.u(this.endY,i.endY))return!0}}return!1}static stringify(t){return t.toString()}static stringifyFixed(t){return g.s(t,"number",St,"stringifyFixed:digits"),e=>e.toString(t)}fe(t){t in ii?this.type=t:g.dr(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+e(this.startX)+" "+e(this.startY)+"L"+e(this.endX)+" "+e(this.endY);case 2:return i=new B(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0?"M"+i.x.toString()+" "+i.y.toString()+"H"+i.right.toString()+"V"+i.bottom.toString()+"H"+i.left.toString()+"z":"M"+e(i.x)+" "+e(i.y)+"H"+e(i.right)+"V"+e(i.bottom)+"H"+e(i.left)+"z";case 3:if(i=new B(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0){let r=i.left.toString()+" "+(i.y+i.height/2).toString(),a=i.right.toString()+" "+(i.y+i.height/2).toString();return"M"+r+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+a+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+r}else{let r=e(i.left)+" "+e(i.y+i.height/2),a=e(i.right)+" "+e(i.y+i.height/2);return"M"+r+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+a+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+r}case 4:let s="",n=this.figures.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];r>0&&(s+=" x "),a.isFilled&&(s+="F "),s+=a.toString(t)}return s;default:return ii[this.type]}}static fillPath(t){typeof t!="string"&&g.si(t,"string",St,"fillPath:str");let e=t.split(/[Xx]/),i=e.length,s="";for(let n=0;n<i;n++){let o=e[n];if(o.match(/[Ff]/)!==null){n===0?s+=o:s+="X"+(o[0]===" "?"":" ")+o;continue}s+=(n===0?"":"X ")+"F"+(o[0]===" "?"":" ")+o}return s}static cm="UuBbMmZzLlHhVvCcSsQqTtAaFfXx";static parse(t,e){e===void 0&&(e=!1),typeof t!="string"&&g.si(t,"string",St,"parse:str");let i=new RegExp("(["+St.cm+"])(["+St.cm+"])","gm"),s=new RegExp("(["+St.cm+"])([^s])","gm"),n=new RegExp("([^s])(["+St.cm+"])","gm");t=t.replace(/,/gm," "),t=t.replace(i,"$1 $2"),t=t.replace(i,"$1 $2"),t=t.replace(s,"$1 $2"),t=t.replace(n,"$1 $2"),t=t.replace(/([0-9])([+\-])/gm,"$1 $2"),t=t.replace(/[\s\r\t\n]+/gm," "),t=t.replace(/^\s+|\s+$/g,"");let o=t.split(" ");for(let R=0;R<o.length;R++){let O=o[R];if(O.match(/(\.[0-9]*)(\.)/gm)!==null){let V=g.ot(),K="",Y=!1;for(let X=0;X<O.length;X++){let G=O[X];G==="."&&!Y?(Y=!0,K+=G):G==="."?(V.push(K),K="."):K+=G}V.push(K),o.splice(R,1);for(let X=0;X<V.length;X++)o.splice(R+X,0,V[X]);R+=V.length-1,g.Z(V)}}let r=-1,a="",h="",l=new P(0,0),c=new P(0,0),u=new P(0,0),d=!0;function f(){return r>=w-1||o[r+1].match(N)!==null?!0:(d=!1,!1)}function p(){return r++,o[r]}function m(R){let O=parseFloat(p()),V=parseFloat(p());a===a.toLowerCase()&&(O=u.x+O,V=u.y+V),R.e(O,V)}function y(){return m(u),u}function b(){return m(c),c}function v(){let R=h.toLowerCase();return R==="c"||R==="s"||R==="q"||R==="t"?new P(2*u.x-c.x,2*u.y-c.y):new P(u.x,u.y)}let w=o.length,k=Ye.qL(null),S=!1,M=!1,F=!1,D=!0,N=new RegExp("["+St.cm+"]");for(;!(r>=w-1);){if(h=a,a=p(),a==="")continue;d=!0;let R=!1;switch(a.toUpperCase()){case"X":D=!0,S=!1,M=!1;break;case"M":let O=y();for(k.Ne===null||D===!0?(k.Au(O.x,O.y,S,!1,!M,F),D=!1):k.$F(O.x,O.y),l.h(u);!f();){let V=y();k.Ks(V.x,V.y)}break;case"L":for(;!f();){let V=y();k.Ks(V.x,V.y)}d&&(R=!0);break;case"H":for(;!f();)u.e((a===a.toLowerCase()?u.x:0)+parseFloat(p()),u.y),k.Ks(u.x,u.y);break;case"V":for(;!f();)u.e(u.x,(a===a.toLowerCase()?u.y:0)+parseFloat(p())),k.Ks(u.x,u.y);d&&(R=!0);break;case"C":for(;!f();){let V=new P;m(V);let K=b(),Y=y();k.xr(V.x,V.y,K.x,K.y,Y.x,Y.y)}d&&(R=!0);break;case"S":for(;!f();){let V=v(),K=b(),Y=y();k.xr(V.x,V.y,K.x,K.y,Y.x,Y.y)}d&&(R=!0);break;case"Q":for(;!f();){let V=b(),K=y();k.Tu(V.x,V.y,K.x,K.y)}d&&(R=!0);break;case"T":for(;!f();){let V=v();c.h(V);let K=y();k.Tu(V.x,V.y,K.x,K.y),c.h(K)}d&&(R=!0);break;case"B":for(;!f();){let V=parseFloat(p()),K=parseFloat(p()),Y=parseFloat(p()),X=parseFloat(p()),G=parseFloat(p()),rt=G,lt=!1;f()||(rt=parseFloat(p()),f()||(lt=parseFloat(p())!==0)),a===a.toLowerCase()&&(Y+=u.x,X+=u.y),k.ZF(V,K,Y,X,G,rt,lt)}d&&(R=!0);break;case"A":for(;!f();){let V=Math.abs(parseFloat(p())),K=Math.abs(parseFloat(p())),Y=parseFloat(p()),X=!1,G=!1,rt=0,lt=0,st=p();st.length===1?(X=!!parseFloat(st),G=!!parseFloat(p()),rt=parseFloat(p()),lt=parseFloat(p())):st.length===2?(X=!!parseFloat(st[0]),G=!!parseFloat(st[1]),rt=parseFloat(p()),lt=parseFloat(p())):(X=!!parseFloat(st[0]),G=!!parseFloat(st[1]),rt=parseFloat(st.slice(2)),lt=parseFloat(p())),a===a.toLowerCase()&&(rt=u.x+rt,lt=u.y+lt),u.e(rt,lt),k.QF(V,K,Y,X,G,rt,lt)}d&&(R=!0);break;case"Z":k._F(),u.h(l);break;case"F":{let V="",K=1;for(;o[r+K];){if(o[r+K]==="0"){F=!0,K++;continue}if(o[r+K].match(/[Uu]/)!==null){K++;continue}if(o[r+K].match(N)===null){K++;continue}V=o[r+K];break}V.match(/[Mm]/)?S=!0:k.tR();break}case"U":{let V="",K=1;for(;o[r+K];){if(o[r+K].match(/[Ff]/)!==null){K++;continue}if(o[r+K].match(N)===null){K++;continue}V=o[r+K];break}V.match(/[Mm]/)?M=!0:k.eR(!1);break}default:if(a==="0"||a==="1")break;g.ne("Unknown geometry command: "+a);break}if(R){g.ne(`Bad geometry command: ${a}, next token: ${p()},
5
+ string: ${t}`);break}}let L=k.fm;if(Ye.WL(k),e){let R=L.figures.iterator;for(;R.next();){let O=R.value;O.isFilled=!0}}return L}static JL(t,e){let i=t.length,s=P.l();for(let n=0;n<i;n++){let o=t[n];s.x=o[0],s.y=o[1],e.gt(s),o[0]=s.x,o[1]=s.y,s.x=o[2],s.y=o[3],e.gt(s),o[2]=s.x,o[3]=s.y,s.x=o[4],s.y=o[5],e.gt(s),o[4]=s.x,o[5]=s.y,s.x=o[6],s.y=o[7],e.gt(s),o[6]=s.x,o[7]=s.y}P.i(s)}EP(){if(this.yt)return!0;if(this.type===4){let t=this.figures;if(this.am!==t.lt)return!0;let e=this.figures.r,i=e.length;for(let s=0;s<i;s++)if(e[s].EP())return!0}return!1}hx(){if(this.yt=!1,this.kc=null,this.Cu=null,this.Lu=NaN,this.type===4){let e=this.figures;this.am=e.lt;let i=this.figures.r,s=i.length;for(let n=0;n<s;n++)i[n].iR()}let t=this.hm;isNaN(this.Pc)||isNaN(this.Sc)?t.e(0,0,0,0):t.e(0,0,this.Pc,this.Sc),this.$L(t,!1),t.re(0,0,0,0)}computeBoundsWithoutOrigin(){let t=new B;return this.$L(t,!0),t}$L(t,e){switch(this.type){case 1:case 2:case 3:e?t.e(this.Li,this.Ai,0,0):t.re(this.Li,this.Ai,0,0),t.re(this.ni,this.oi,0,0);break;case 4:let i=this.figures,s=i.r,n=i.length;for(let o=0;o<n;o++){let r=s[o];e&&o===0?t.e(r.startX,r.startY,0,0):t.re(r.startX,r.startY,0,0);let a=r.segments.r,h=a.length,l=r.startX,c=r.startY;for(let u=0;u<h;u++){let d=a[u];switch(d.type){case 2:case 1:l=d.endX,c=d.endY,t.re(l,c,0,0);break;case 3:A.Nu(l,c,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,t),l=d.endX,c=d.endY;break;case 4:A.IP(l,c,d.point1X,d.point1Y,d.endX,d.endY,.5,t),l=d.endX,c=d.endY;break;case 5:case 6:let f=d.type===5?d.Fo(r):d.Ja(r,l,c),p=f.length;if(p===0){l=d.type===5?d.centerX:d.endX,c=d.type===5?d.centerY:d.endY,t.re(l,c,0,0);break}let m=null;for(let y=0;y<p;y++)m=f[y],A.Nu(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],.5,t);m!==null&&(l=m[6],c=m[7]);break;default:g.o("Unknown Segment type: "+d.type)}}}break;default:g.o("Unknown Geometry type: "+this.type)}}sR(t,e){let i=this.bounds,s=t/i.width,n=e/i.height;return isFinite(s)||(s=1),isFinite(n)||(n=1),s===1&&n===1?this:this.copy().scale(s,n)}normalize(){this.f&&g.L(this);let t=this.computeBoundsWithoutOrigin();return this.offset(-t.x,-t.y),new P(-t.x,-t.y)}offset(t,e){return this.f&&g.L(this),this.v(1,0,0,1,t,e),this}scale(t,e){return this.f&&g.L(this),this.v(t,0,0,e,0,0),this}rotate(t,e,i){this.f&&g.L(this),e===void 0&&(e=0),i===void 0&&(i=0);let s=Pt.l();return s.Ue(),s.ks(t,e,i),this.v(s.m11,s.m12,s.m21,s.m22,s.dx,s.dy),Pt.i(s),this}v(t,e,i,s,n,o){let r=0,a=0;switch(this.type){case 1:case 2:case 3:r=this.Li,a=this.Ai,this.Li=r*t+a*i+n,this.Ai=r*e+a*s+o,r=this.ni,a=this.oi,this.ni=r*t+a*i+n,this.oi=r*e+a*s+o;break;case 4:let h=this.figures.r,l=h.length;for(let c=0;c<l;c++){let u=h[c];r=u.startX,a=u.startY,u.startX=r*t+a*i+n,u.startY=r*e+a*s+o;let d=u.segments.r,f=d.length;for(let p=0;p<f;p++){let m=d[p];switch(m.type){case 2:case 1:r=m.endX,a=m.endY,m.endX=r*t+a*i+n,m.endY=r*e+a*s+o;break;case 3:r=m.point1X,a=m.point1Y,m.point1X=r*t+a*i+n,m.point1Y=r*e+a*s+o,r=m.point2X,a=m.point2Y,m.point2X=r*t+a*i+n,m.point2Y=r*e+a*s+o,r=m.endX,a=m.endY,m.endX=r*t+a*i+n,m.endY=r*e+a*s+o;break;case 4:r=m.point1X,a=m.point1Y,m.point1X=r*t+a*i+n,m.point1Y=r*e+a*s+o,r=m.endX,a=m.endY,m.endX=r*t+a*i+n,m.endY=r*e+a*s+o;break;case 5:if(r=m.centerX,a=m.centerY,m.centerX=r*t+a*i+n,m.centerY=r*e+a*s+o,e!==0){let y=Math.atan2(e,t)*180/Math.PI;y<0&&(y+=360),m.startAngle+=y}t<0&&(m.startAngle=180-m.startAngle,m.sweepAngle=-m.sweepAngle),s<0&&(m.startAngle=-m.startAngle,m.sweepAngle=-m.sweepAngle),m.radiusX*=Math.sqrt(t*t+i*i),m.radiusY!==void 0&&(m.radiusY*=Math.sqrt(e*e+s*s));break;case 6:if(r=m.endX,a=m.endY,m.endX=r*t+a*i+n,m.endY=r*e+a*s+o,m.radiusX===0||m.radiusY===0)break;if(e!==0){let y=Math.atan2(e,t)*180/Math.PI;y<0&&(y+=360),m.xAxisRotation+=y}t<0&&(m.xAxisRotation=180-m.xAxisRotation,m.isClockwiseArc=!m.isClockwiseArc),s<0&&(m.xAxisRotation=-m.xAxisRotation,m.isClockwiseArc=!m.isClockwiseArc),m.radiusX*=Math.sqrt(t*t+i*i),m.radiusY*=Math.sqrt(e*e+s*s);break;default:g.o("Unknown Segment type: "+m.type)}}}break}return this.yt=!0,this}containsPoint(t,e){e===void 0&&(e=0);let i=this.Li,s=this.Ai,n=this.ni,o=this.oi;switch(this.type){case 1:return A.Ve(i,s,n,o,e,t.x,t.y);case 2:{let r=Math.min(i,n)-e,a=Math.min(s,o)-e,h=Math.abs(n-i)+e*2,l=Math.abs(o-s)+e*2,c=B.z(r,a,h,l),u=c.containsPoint(t);return B.i(c),u}case 3:{let r=Math.min(i,n)-e,a=Math.min(s,o)-e,h=Math.abs(n-i)+e*2,l=Math.abs(o-s)+e*2,c=h/2,u=l/2;return c<=0||u<=0?!1:(r=t.x-(r+c),a=t.y-(a+u),r*r/(c*c)+a*a/(u*u)<=1)}case 4:return this.UP(t,e,!0,!1);default:return!1}}UP(t,e,i,s){let n=t.x,o=t.y,r=this.bounds.x-20,a=o,h=0,l=0,c=0,u=0,d=0,f=0,p=this.figures.r,m=p.length;for(let y=0;y<m;y++){let b=p[y],v=!b.isEvenOdd;if(b.isFilled){if(i&&b.VP(n,o,e))return!0}else{if(b.VP(n,o,s?e:e+2))return!0;continue}let w=b.segments;l=b.startX,c=b.startY;let k=l,S=c,M=w.r,F=M[0];for(let D=0;D<=w.length;D++){let N;switch(D!==w.length?(F=M[D],N=F.type,d=F.endX,f=F.endY):(N=2,d=k,f=S),N){case 1:{let L=this.cx(n,o,r,a,l,c,k,S);if(isNaN(L))return!0;h+=L,k=d,S=f;break}case 2:{let L=this.cx(n,o,r,a,l,c,d,f);if(isNaN(L))return!0;h+=L;break}case 3:u=A.om(l,c,F.point1X,F.point1Y,F.point2X,F.point2Y,d,f,r,a,n,o,.5),h+=u;break;case 4:{let L=(l+2*F.point1X)/3,R=(c+2*F.point1Y)/3,O=(F.point1X*2+d)/3,V=(F.point1Y*2+f)/3;u=A.om(l,c,L,R,O,V,d,f,r,a,n,o,.5),h+=u;break}case 5:case 6:{let L=F.type===5?F.Fo(b):F.Ja(b,l,c),R=L.length;if(R===0){let V=this.cx(n,o,r,a,l,c,F.type===5?F.centerX:F.endX,F.type===5?F.centerY:F.endY);if(isNaN(V))return!0;h+=V;break}let O=null;for(let V=0;V<R;V++){if(O=L[V],V===0){let K=this.cx(n,o,r,a,l,c,O[0],O[1]);if(isNaN(K))return!0;h+=K}u=A.om(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],r,a,n,o,.5),h+=u}O!==null&&(d=O[6],f=O[7]);break}default:g.o("Unknown Segment type: "+F.type)}l=d,c=f}if(v){if(h!==0)return!0}else if(h%2!==0)return!0;h=0}return!1}cx(t,e,i,s,n,o,r,a){if(A.Ve(n,o,r,a,.05,t,e))return NaN;let h=(t-i)*(o-a);if(h===0)return 0;let l=((t*s-e*i)*(n-r)-(t-i)*(n*a-o*r))/h,c=(t*s-e*i)*(o-a)/h;if(l>=t)return 0;if((n>r?n-r:r-n)<(o>a?o-a:a-o)){if(o<a){if(c<o||c>a)return 0}else if(c<a||c>o)return 0}else if(n<r){if(l<n||l>r)return 0}else if(l<r||l>n)return 0;return h>0?1:-1}ZL(t,e,i){let s=this.figures.r,n=s.length;for(let o=0;o<n;o++)if(s[o].VP(t,e,i))return!0;return!1}getPointAlongPath(t,e){if(t<0?t=0:t>1&&(t=1),e===void 0&&(e=new P),this.type===1)return e.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),e;let i=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=i.length,r=n*t,a=0;for(let h=0;h<o;h++){let l=s[h],c=l.length;for(let u=0;u<c;u++){let d=l[u];if(a+d>=r){let f=r-a,p=d===0?0:f/d,m=i[h],y=m[u*2],b=m[u*2+1],v=m[u*2+2],w=m[u*2+3];return e.e(y+(v-y)*p,b+(w-b)*p),e}a+=d}}return e}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;let e=this.flattenedSegments,i=this.flattenedLengths,s=this.flattenedTotalLength,n=e.length,o=s*t,r=0;for(let a=0;a<n;a++){let h=i[a],l=h.length;for(let c=0;c<l;c++){let u=h[c];if(r+u>=o){let d=e[a],f=d[c*2],p=d[c*2+1],m=d[c*2+2],y=d[c*2+3];return Math.abs(m-f)<1&&Math.abs(y-p)<1?0:Math.abs(m-f)<1?y-p>=0?90:270:Math.abs(y-p)<1?m-f>=0?0:180:Math.atan2(y-p,m-f)*180/Math.PI}r+=u}}return NaN}getPointAndAngleAlongPath(t,e){if(t<0?t=0:t>1&&(t=1),e===void 0&&(e=[]),e.length=3,this.type===1)return e[0]=this.startX+t*(this.endX-this.startX),e[1]=this.startY+t*(this.endY-this.startY),e[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,e;let i=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=i.length,r=n*t,a=0;for(let h=0;h<o;h++){let l=s[h],c=l.length;for(let u=0;u<c;u++){let d=l[u];if(a+d>=r){let f=r-a,p=d===0?0:f/d,m=i[h],y=m[u*2],b=m[u*2+1],v=m[u*2+2],w=m[u*2+3];e[0]=y+(v-y)*p,e[1]=b+(w-b)*p;let k;return Math.abs(v-y)<1&&Math.abs(w-b)<1?k=0:Math.abs(v-y)<1?k=w-b>=0?90:270:Math.abs(w-b)<1?k=v-y>=0?0:180:k=Math.atan2(w-b,v-y)*180/Math.PI,e[2]=k,e}a+=d}}return e}getFractionForPoint(t){if(this.type===1){let e=this.startX,i=this.startY,s=this.endX,n=this.endY;if(e===s&&i===n)return 0;{let o=t.x,r=t.y,a=0,h=0;if(e===s)return i<n?(a=i,h=n):(a=n,h=i),r<=a?a===i?0:1:r>=h?h===i?0:1:Math.abs(r-i)/(h-a);if(i===n)return e<s?(a=e,h=s):(a=s,h=e),o<=a?a===e?0:1:o>=h?h===e?0:1:Math.abs(o-e)/(h-a);{let l=(s-e)**2+(n-i)**2,c=P.l();A.Nl(e,i,s,n,o,r,c);let u=c.x,d=c.y;return P.i(c),Math.sqrt(((u-e)**2+(d-i)**2)/l)}}}else if(this.type===2){let e=this.startX,i=this.startY,s=this.endX,n=this.endY;if(e===s&&i===n)return 0;{let o=s-e,r=n-i,a=o*2+r*2,h=t.x,l=t.y;h=Math.min(Math.max(h,e),s),l=Math.min(Math.max(l,i),n);let c=Math.abs(h-e),u=Math.abs(h-s),d=Math.abs(l-i),f=Math.abs(l-n),p=Math.min(c,u,d,f);if(p===d)return h/a;if(p===u)return(o+l)/a;if(p===f)return(o*2+r-h)/a;if(p===c)return(o*2+r*2-l)/a}}else{let e=this.flattenedSegments,i=this.flattenedLengths,s=this.flattenedTotalLength,n=P.l(),o=1/0,r=0,a=0,h=e.length,l=0,c=0;for(let d=0;d<h;d++){let f=e[d],p=i[d],m=f.length;for(let y=0;y<m;y+=2){let b=f[y],v=f[y+1];if(y===0){l=b,c=v;continue}A.Nl(l,c,b,v,t.x,t.y,n);let w=(n.x-t.x)**2+(n.y-t.y)**2;w<o&&(o=w,r=a,r+=Math.sqrt((n.x-l)**2+(n.y-c)**2)),a+=p[(y-2)/2],l=b,c=v}}P.i(n);let u=r/s;return u<0?0:u>1?1:u}return 0}get flattenedSegments(){return this.QL(),this.kc}QL(){if(this.kc===null){let t=this.kc=[],e=this.Cu=[];this.nR(t,e)}}get flattenedLengths(){return this.QL(),this.Cu}get flattenedTotalLength(){let t=this.Lu;if(isNaN(t)){if(this.type===1){let e=Math.abs(this.endX-this.startX),i=Math.abs(this.endY-this.startY);t=Math.sqrt(e*e+i*i)}else if(this.type===2){let e=Math.abs(this.endX-this.startX),i=Math.abs(this.endY-this.startY);t=e*2+i*2}else{let e=this.flattenedLengths,i=e.length;t=0;for(let s=0;s<i;s++){let n=e[s],o=n.length;for(let r=0;r<o;r++)t+=n[r]}}this.Lu=t}return t}BP(t){let e=[],i=0,s=0,n=t.length;for(let o=0;o<n;o+=2){let r=t[o],a=t[o+1];if(o===0){i=r,s=a;continue}let h=Math.sqrt(P.distanceSquared(i,s,r,a));e.push(h),i=r,s=a}return e}nR(t,e){let i=[],s=[];if(this.type===1)i.push(this.startX),i.push(this.startY),i.push(this.endX),i.push(this.endY),t.push(i),s.push(Math.sqrt((this.startX-this.endX)**2+(this.startY-this.endY)**2)),e.push(s);else if(this.type===2)i.push(this.startX),i.push(this.startY),i.push(this.endX),i.push(this.startY),i.push(this.endX),i.push(this.endY),i.push(this.startX),i.push(this.endY),i.push(this.startX),i.push(this.startY),t.push(i),s.push(Math.abs(this.startX-this.endX)),s.push(Math.abs(this.startY-this.endY)),s.push(Math.abs(this.startX-this.endX)),s.push(Math.abs(this.startY-this.endY)),e.push(s);else if(this.type===3){let n=new jt;n.startX=this.endX,n.startY=(this.startY+this.endY)/2;let o=new xt(5);o.startAngle=0,o.sweepAngle=360,o.centerX=(this.startX+this.endX)/2,o.centerY=(this.startY+this.endY)/2,o.radiusX=Math.abs(this.startX-this.endX)/2,o.radiusY=Math.abs(this.startY-this.endY)/2,n.add(o);let r=o.Fo(n),a=r.length;if(a===0)i.push(o.centerX),i.push(o.centerY);else{let h=n.startX,l=n.startY;for(let c=0;c<a;c++){let u=r[c];A.Wn(h,l,u[2],u[3],u[4],u[5],u[6],u[7],.5,i),h=u[6],l=u[7]}}t.push(i),e.push(this.BP(i))}else{let n=this.figures.iterator;for(;n.next();){let o=n.value;i=[],i.push(o.startX),i.push(o.startY);let r=o.startX,a=o.startY,h=r,l=a,c=o.segments.r,u=c.length;for(let d=0;d<u;d++){let f=c[d];switch(f.type){case 1:i.length>=4&&(t.push(i),e.push(this.BP(i))),i=[],i.push(f.endX),i.push(f.endY),r=f.endX,a=f.endY,h=r,l=a;break;case 2:i.push(f.endX),i.push(f.endY),r=f.endX,a=f.endY;break;case 3:A.Wn(r,a,f.point1X,f.point1Y,f.point2X,f.point2Y,f.endX,f.endY,.5,i),r=f.endX,a=f.endY;break;case 4:A.sm(r,a,f.point1X,f.point1Y,f.endX,f.endY,.5,i),r=f.endX,a=f.endY;break;case 5:{let p=f.Fo(o),m=p.length;if(m===0){i.push(f.centerX),i.push(f.centerY),r=f.centerX,a=f.centerY;break}for(let y=0;y<m;y++){let b=p[y];A.Wn(r,a,b[2],b[3],b[4],b[5],b[6],b[7],.5,i),r=b[6],a=b[7]}break}case 6:{let p=f.Ja(o,r,a),m=p.length,y=f.endX,b=f.endY;if(m===0){i.push(y),i.push(b),r=y,a=b;break}for(let v=0;v<m;v++){let w=p[v];A.Wn(r,a,w[2],w[3],w[4],w[5],w[6],w[7],.5,i),r=w[6],a=w[7]}break}default:g.o("Segment not of valid type: "+f.type)}f.isClosed&&(i.push(h),i.push(l))}i.length>=4&&(t.push(i),e.push(this.BP(i)))}}}get type(){return this.W}set type(t){this.W!==t&&(this.f&&g.L(this,t),this.W=t,t===4?this.Ys=new U:(St.lx===null&&(St.lx=new U().b()),this.Ys=St.lx),this.yt=!0)}get startX(){return this.Li}set startX(t){this.Li!==t&&(this.f&&g.L(this,t),this.Li=t,this.yt=!0)}get startY(){return this.Ai}set startY(t){this.Ai!==t&&(this.f&&g.L(this,t),this.Ai=t,this.yt=!0)}get endX(){return this.ni}set endX(t){this.ni!==t&&(this.f&&g.L(this,t),this.ni=t,this.yt=!0)}get endY(){return this.oi}set endY(t){this.oi!==t&&(this.f&&g.L(this,t),this.oi=t,this.yt=!0)}get figures(){return this.Ys}set figures(t){this.Ys!==t&&(this.f&&g.L(this,t),this.Ys=t,this.yt=!0)}add(t){return this.Ys.add(t),this}setSpots(t,e,i,s,n,o,r,a){return this.f&&g.L(this),this.$n=new T(t,e,n,o),this.Zn=new T(i,s,r,a),this}get spot1(){return this.$n}set spot1(t){this.f&&g.L(this,t),this.$n=t.N()}get spot2(){return this.Zn}set spot2(t){this.f&&g.L(this,t),this.Zn=t.N()}get defaultStretch(){return this.Qn}set defaultStretch(t){this.Qn=t}get bounds(){return this.EP()&&this.hx(),this.hm}polygonClosestSegment(t,e){if(e===void 0&&(e=10),this.type!==4)return null;let i=t.x,s=t.y,n=1/0,o=0,r=0,a=0,h=0,l=0,c=0,u=0,d=0;return this.figures.each(f=>{let p=f.startX,m=f.startY;f.segments.each(y=>{let b=y.endX,v=y.endY,w=0;if(y.type===2)w=P.distanceLineSegmentSquared(i,s,p,m,b,v);else{p=y.endX,m=y.endY;return}w<n&&(n=w,o=a,r=h,l=p,c=m,u=b,d=v),p=b,m=v,h++,y.isClosed&&(b=f.startX,v=f.startY,w=P.distanceLineSegmentSquared(i,s,p,m,b,v),w<n&&(n=w,o=a,r=h,l=p,c=m,u=b,d=v),h++)}),a++,h=0}),n<e*e?{figi:o,segi:r,ax:l,ay:c,bx:u,by:d}:null}get polygonArea(){if(this.type===4){let t=this.figures.iterator,e=0,i=0,s=0,n=0,o=0;for(;t.next();){let r=t.value;if(!r.isFilled)continue;e=r.startX,i=r.startY;let a=r.segments.iterator;for(;a.next();){let h=a.value;s=h.endX,n=h.endY,h.type===1||h.type!==5&&(o+=e*n-i*s),e=s,i=n}o+=e*r.startY-i*r.startX}return Math.abs(o)/2}else if(this.type===2){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return t*e}else if(this.type===3){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return Math.PI*t/2*e/2}else return 0}get polygonLength(){if(this.type===4){let t=this.figures.iterator,e=0,i=0,s=0,n=0,o=0;for(;t.next();){let r=t.value;e=r.startX,i=r.startY;let a=r.segments.iterator;for(;a.next();){let l=a.value;s=l.endX,n=l.endY,l.type===1||l.type!==5&&(o+=Math.sqrt((s-e)*(s-e)+(n-i)*(n-i))),e=s,i=n}let h=r.segments.last();h&&h.isClosed&&(s=r.startX,n=r.startY,o+=Math.sqrt((s-e)*(s-e)+(n-i)*(n-i)))}return o}else if(this.type===2){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return t*2+e*2}else if(this.type===3){let t=Math.abs(this.startX-this.endX)/2,e=Math.abs(this.startY-this.endY)/2;if(t+e===0)return 0;let i=(t-e)*(t-e)/((t+e)*(t+e)),s=i,n=1+s/4;return s*=i,n+=s/64,s*=i,n+=s/256,s*=i,n+=s*25/16384,s*=i,n+=s*49/65536,s*=i,n+=s*441/1048576,Math.PI*(t+e)*n}else{let t=this.startX,e=this.startY,i=this.endX,s=this.endY;return Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}}static computeConvexHull(t){t.sort((s,n)=>s.x===n.x?n.y-s.y:n.x-s.x);let e=[];for(let s=0;s<t.length;s++){for(;e.length>=2&&t[s].compareWithLineSegmentPoint(e[e.length-2],e[e.length-1])>=0;)e.pop();e.push(t[s])}e.pop();let i=[];for(let s=t.length-1;s>=0;s--){for(;i.length>=2&&t[s].compareWithLineSegmentPoint(i[i.length-2],i[i.length-1])>=0;)i.pop();i.push(t[s])}return i.pop(),e.concat(i)}static generatePolygon(t,e,i){e===void 0&&(e=0),i===void 0&&(i=!0);let s=new St;if(t.length>1)if(e>0)if(i){t.push(t[0]),t.push(t[1]);let n=!0,o=new jt(0,0,i,!1);for(let a=1;a<t.length;a++){let h=(t[a-1].x+t[a].x)/2,l=(t[a-1].y+t[a].y)/2,c=t[a-1].distanceSquaredPoint(t[a]),u=.5*e/Math.sqrt(c);if(u<.5){let d=t[a-1].x+(t[a].x-t[a-1].x)*u,f=t[a-1].y+(t[a].y-t[a-1].y)*u;if(n?(n=!1,o.startX=d,o.startY=f):o.add(new xt(3,d,f,t[a-1].x,t[a-1].y,t[a-1].x,t[a-1].y)),a<t.length-1){let p=t[a].x+(t[a-1].x-t[a].x)*u,m=t[a].y+(t[a-1].y-t[a].y)*u;o.add(new xt(2,p,m))}}else n?(n=!1,o.startX=h,o.startY=l):o.add(new xt(3,h,l,t[a-1].x,t[a-1].y,t[a-1].x,t[a-1].y))}let r=o.segments.last();r&&r.close(),s.add(o)}else{let n=new jt(t[0].x,t[0].y,!1,!1);for(let o=1;o<t.length;o++){let r=(t[o-1].x+t[o].x)/2,a=(t[o-1].y+t[o].y)/2,h=t[o-1].distanceSquaredPoint(t[o]),l=.5*e/Math.sqrt(h);if(l<.5){if(o>1){let d=t[o-1].x+(t[o].x-t[o-1].x)*l,f=t[o-1].y+(t[o].y-t[o-1].y)*l;n.add(new xt(3,d,f,t[o-1].x,t[o-1].y,t[o-1].x,t[o-1].y))}let c=t[o].x+(t[o-1].x-t[o].x)*l,u=t[o].y+(t[o-1].y-t[o].y)*l;n.add(new xt(2,c,u))}else o>1&&n.add(new xt(3,r,a,t[o-1].x,t[o-1].y,t[o-1].x,t[o-1].y));o===t.length-1&&n.add(new xt(2,t[o].x,t[o].y))}s.add(n)}else{let n=new jt(t[0].x,t[0].y,i,!1);for(let o=1;o<t.length;o++)n.add(new xt(2,t[o].x,t[o].y));if(i){let o=n.segments.last();o&&o.close()}s.add(n)}return s}}St.stringify=St.stringify,St.stringifyFixed=St.stringifyFixed,St.fillPath=St.fillPath,St.parse=St.parse;class jt{n;Li;Ai;Mc;um;ji;constructor(t,e,i,s,n){i===void 0&&(i=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(i?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.Li=t:this.Li=0,e!==void 0?this.Ai=e:this.Ai=0,this.Mc=new U,this.um=this.Mc.lt,this.ji=null}copy(){let t=new jt;t.n=this.n&-2,t.Li=this.Li,t.Ai=this.Ai;let e=this.Mc.r,i=e.length,s=t.Mc;for(let n=0;n<i;n++){let o=e[n].copy();s.add(o)}return t.um=this.um,t.ji=this.ji,t}equalsApprox(t){if(!(t instanceof jt)||!A.u(this.startX,t.startX)||!A.u(this.startY,t.startY))return!1;let e=this.segments.r,i=t.segments.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}toString(t){t===void 0&&(t=-1);let e="";if(t<0)e="M"+this.startX.toString()+" "+this.startY.toString();else{let n=o=>o===0?"0":o.toFixed(t);e="M"+n(this.startX)+" "+n(this.startY)}let i=this.segments.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+o.toString(t)}return e}get f(){return(this.n&1)!==0}set f(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}b(){this.f=!0;let t=this.segments;t.b();let e=t.r,i=t.length;for(let s=0;s<i;s++)e[s].b();return this}EP(){if(this.yt)return!0;let t=this.segments;if(this.um!==t.lt)return!0;for(let e of t)if(e.yt)return!0;return!1}iR(){this.yt=!1,this.ji=null;let t=this.segments;this.um=t.lt;for(let e of t)e.yt=!1,e.Hs=null}get isFilled(){return(this.n&4)!==0}set isFilled(t){this.f&&g.L(this,t),t?this.n|=4:this.n&=-5}get isShadowed(){return(this.n&8)!==0}set isShadowed(t){this.f&&g.L(this,t),t?this.n|=8:this.n&=-9}get isEvenOdd(){return(this.n&16)!==0}set isEvenOdd(t){this.f&&g.L(this,t),t?this.n|=16:this.n&=-17}get startX(){return this.Li}set startX(t){this.f&&g.L(this,t),this.Li=t,this.ji=null,this.yt=!0}get startY(){return this.Ai}set startY(t){this.f&&g.L(this,t),this.Ai=t,this.ji=null,this.yt=!0}get segments(){return this.Mc}set segments(t){this.f&&g.L(this,t),this.Mc=t,this.ji=null,this.yt=!0}add(t){return this.Mc.add(t),this.ji=null,this}VP(t,e,i){let s=this,n=s.startX,o=s.startY,r=n,a=o,h=s.segments.r,l=h.length;for(let c=0;c<l;c++){let u=h[c];switch(u.type){case 1:r=u.endX,a=u.endY,n=u.endX,o=u.endY;break;case 2:if(A.Ve(n,o,u.endX,u.endY,i,t,e))return!0;n=u.endX,o=u.endY;break;case 3:if(A.ix(n,o,u.point1X,u.point1Y,u.point2X,u.point2Y,u.endX,u.endY,.5,t,e,i))return!0;n=u.endX,o=u.endY;break;case 4:if(A.OP(n,o,u.point1X,u.point1Y,u.endX,u.endY,.5,t,e,i))return!0;n=u.endX,o=u.endY;break;case 5:case 6:let d=u.type===5?u.Fo(s):u.Ja(s,n,o),f=d.length,p=u.type===5?u.centerX:u.endX,m=u.type===5?u.centerY:u.endY;if(f===0){if(A.Ve(n,o,p,m,i,t,e))return!0;n=p,o=m;break}let y=null;for(let b=0;b<f;b++)if(y=d[b],b===0&&A.Ve(n,o,y[0],y[1],i,t,e)||A.ix(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],.5,t,e,i))return!0;y!==null&&(n=y[6],o=y[7]);break;default:g.o("Unknown Segment type: "+u.type)}if(u.isClosed&&(n!==r||o!==a)&&A.Ve(n,o,r,a,i,t,e))return!0}return!1}}var Di=(x=>(x[x.Move=1]="Move",x[x.Line=2]="Line",x[x.Bezier=3]="Bezier",x[x.QuadraticBezier=4]="QuadraticBezier",x[x.Arc=5]="Arc",x[x.SvgArc=6]="SvgArc",x))(Di||{});class xt{W;n;ni;oi;pn;Ll;Al;br;Hs;constructor(t,e,i,s,n,o,r,a){if(I.Je(this),t===void 0&&(t=2),this.W=t,this.n=2,e!==void 0?this.ni=e:this.ni=0,i!==void 0?this.oi=i:this.oi=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.pn=h,this.Ll=0,this.Al=Math.max(s,0),this.br=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),a&&(this.isClockwiseArc=!0)}else this.pn=s,this.Ll=n,t===5&&(o=Math.max(o,0)),this.Al=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.br=r):this.br=0;this.Hs=null}copy(){let t=new xt;return t.W=this.W,t.n=this.n&-2,t.ni=this.ni,t.oi=this.oi,t.pn=this.pn,t.Ll=this.Ll,t.Al=this.Al,t.br=this.br,t}equalsApprox(t){if(!(t instanceof xt)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return A.u(this.endX,t.endX)&&A.u(this.endY,t.endY);case 3:return A.u(this.endX,t.endX)&&A.u(this.endY,t.endY)&&A.u(this.point1X,t.point1X)&&A.u(this.point1Y,t.point1Y)&&A.u(this.point2X,t.point2X)&&A.u(this.point2Y,t.point2Y);case 4:return A.u(this.endX,t.endX)&&A.u(this.endY,t.endY)&&A.u(this.point1X,t.point1X)&&A.u(this.point1Y,t.point1Y);case 5:return A.u(this.startAngle,t.startAngle)&&A.u(this.sweepAngle,t.sweepAngle)&&A.u(this.centerX,t.centerX)&&A.u(this.centerY,t.centerY)&&A.u(this.radiusX,t.radiusX)&&A.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&A.u(this.xAxisRotation,t.xAxisRotation)&&A.u(this.endX,t.endX)&&A.u(this.endY,t.endY)&&A.u(this.radiusX,t.radiusX)&&A.u(this.radiusY,t.radiusY);default:return!1}}fe(t){t in Di?this.type=t:g.dr(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i="";switch(this.type){case 1:t<0?i="M"+this.endX.toString()+" "+this.endY.toString():i="M"+e(this.endX)+" "+e(this.endY);break;case 2:t<0?i="L"+this.endX.toString()+" "+this.endY.toString():i="L"+e(this.endX)+" "+e(this.endY);break;case 3:t<0?i="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():i="C"+e(this.point1X)+" "+e(this.point1Y)+" "+e(this.point2X)+" "+e(this.point2Y)+" "+e(this.endX)+" "+e(this.endY);break;case 4:t<0?i="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():i="Q"+e(this.point1X)+" "+e(this.point1Y)+" "+e(this.endX)+" "+e(this.endY);break;case 5:t<0?i="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():i="B"+e(this.startAngle)+" "+e(this.sweepAngle)+" "+e(this.centerX)+" "+e(this.centerY)+" "+e(this.radiusX)+" "+e(this.radiusY);break;case 6:t<0?i="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():i="A"+e(this.radiusX)+" "+e(this.radiusY)+" "+e(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+e(this.endX)+" "+e(this.endY);break;default:i=Di[this.type]}return i+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.n&1)!==0}set f(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}b(){return this.f=!0,this}close(){return this.isClosed=!0,this}Fo(t){if(this.Hs!==null&&t.yt===!1)return this.Hs;let e=this.radiusX,i=this.radiusY;if(i===void 0&&(i=e),e===0||i===0)return this.Hs=[],this.Hs;let s=this.pn,n=this.Ll,o=A.KL(0,0,e<i?e:i,this.startAngle,this.startAngle+this.sweepAngle,!1);if(e!==i){let a=Pt.l();a.Ue(),e<i?a.it(1,i/e):a.it(e/i,1),St.JL(o,a),Pt.i(a)}let r=o.length;for(let a=0;a<r;a++){let h=o[a];h[0]+=s,h[1]+=n,h[2]+=s,h[3]+=n,h[4]+=s,h[5]+=n,h[6]+=s,h[7]+=n}return this.Hs=o,this.Hs}Ja(t,e,i){if(this.Hs!==null&&t.yt===!1)return this.Hs;if(this.radiusX===0||this.radiusY===0)return this.Hs=[],this.Hs;let s=e,n=i,o=this.Al,r=this.br;o===0&&(o=1e-4),r===0&&(r=1e-4);let a=this.pn*(Math.PI/180),h=this.isLargeArc,l=this.isClockwiseArc,c=this.ni,u=this.oi,d=Math.cos(a),f=Math.sin(a),p=d*(s-c)/2+f*(n-u)/2,m=-f*(s-c)/2+d*(n-u)/2,y=p*p/(o*o)+m*m/(r*r);y>1&&(o*=Math.sqrt(y),r*=Math.sqrt(y));let b=(h===l?-1:1)*Math.sqrt((o*o*r*r-o*o*m*m-r*r*p*p)/(o*o*m*m+r*r*p*p));isNaN(b)&&(b=0);let v=b*o*m/r,w=b*-r*p/o;isNaN(v)&&(v=0),isNaN(w)&&(w=0);let k=(s+c)/2+d*v-f*w,S=(n+u)/2+f*v+d*w,M=(ht,ot)=>Math.sqrt(ht*ht+ot*ot),F=(ht,ot,dt,pt)=>(ht*dt+ot*pt)/(M(ht,ot)*M(dt,pt)),D=(ht,ot,dt,pt)=>(ht*pt<ot*dt?-1:1)*Math.acos(F(ht,ot,dt,pt)),N=D(1,0,(p-v)/o,(m-w)/r),L=(p-v)/o,R=(m-w)/r,O=(-p-v)/o,V=(-m-w)/r,K=D(L,R,O,V),Y=F(L,R,O,V);Y<=-1?K=Math.PI:Y>=1&&(K=0),!l&&K>0&&(K=K-2*Math.PI),l&&K<0&&(K=K+2*Math.PI);let X=o>r?o:r,G=o>r?1:o/r,rt=o>r?r/o:1,lt=A.KL(0,0,X,N,N+K,!0),st=Pt.l();return st.Ue(),st.Gs(k,S),st.ks(this.pn,0,0),st.it(G,rt),St.JL(lt,st),Pt.i(st),this.Hs=lt,this.Hs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.yt=!0)}get type(){return this.W}set type(t){this.f&&g.L(this,t),this.W=t,this.yt=!0}get endX(){return this.ni}set endX(t){this.f&&g.L(this,t),this.ni=t,this.yt=!0}get endY(){return this.oi}set endY(t){this.f&&g.L(this,t),this.oi=t,this.yt=!0}get point1X(){return this.pn}set point1X(t){this.f&&g.L(this,t),this.pn=t,this.yt=!0}get point1Y(){return this.Ll}set point1Y(t){this.f&&g.L(this,t),this.Ll=t,this.yt=!0}get point2X(){return this.Al}set point2X(t){this.f&&g.L(this,t),this.Al=t,this.yt=!0}get point2Y(){return this.br}set point2Y(t){this.f&&g.L(this,t),this.br=t,this.yt=!0}get centerX(){return this.pn}set centerX(t){this.f&&g.L(this,t),this.pn=t,this.yt=!0}get centerY(){return this.Ll}set centerY(t){this.f&&g.L(this,t),this.Ll=t,this.yt=!0}get radiusX(){return this.Al}set radiusX(t){t<0&&g.J(t,">= zero",xt,"radiusX"),this.f&&g.L(this,t),this.Al=t,this.yt=!0}get radiusY(){return this.br}set radiusY(t){t<0&&g.J(t,">= zero",xt,"radiusY"),this.f&&g.L(this,t),this.br=t,this.yt=!0}get startAngle(){return this.ni}set startAngle(t){this.f&&g.L(this,t),t=t%360,t<0&&(t+=360),this.ni=t,this.yt=!0}get sweepAngle(){return this.oi}set sweepAngle(t){this.f&&g.L(this,t),t>360&&(t=360),t<-360&&(t=-360),this.oi=t,this.yt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.f&&g.L(this,t),t?this.n|=4:this.n&=-5,this.yt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.f&&g.L(this,t),t?this.n|=16:this.n&=-17,this.yt=!0}get xAxisRotation(){return this.pn}set xAxisRotation(t){this.f&&g.L(this,t),t=t%360,t<0&&(t+=360),this.pn=t,this.yt=!0}}class Se{a;fx;ux;dm;gm;mm;pm;ym;wm;xm;bm;km;Pm;Sm;Ro;Mm;Nm;Ps;Ti;constructor(){this.a=null,this.fx=new P(0,0).b(),this.ux=new P(0,0).b(),this.dm=0,this.gm=0,this.mm=1,this.pm="",this.ym="",this.wm=!1,this.xm=!1,this.bm=0,this.km=0,this.Pm=!1,this.Sm=!1,this.Ro=!1,this.Mm=null,this.Nm=0,this.Ps=null,this.Ti=null}copy(){let t=new Se;return this.clone(t)}clone(t){return t.a=this.a,t.fx.h(this.viewPoint),t.ux.h(this.documentPoint),t.dm=this.dm,t.gm=this.gm,t.mm=this.mm,t.pm=this.pm,t.ym=this.ym,t.wm=this.wm,t.xm=this.xm,t.bm=this.bm,t.km=this.km,t.Pm=this.Pm,t.Sm=this.Sm,t.Ro=this.Ro,t.Mm=this.Mm,t.Nm=this.Nm,t.Ps=this.Ps,t.Ti=this.Ti,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.a}set diagram(t){this.a=t}get viewPoint(){return this.fx}set viewPoint(t){this.fx.h(t)}get documentPoint(){return this.ux}set documentPoint(t){this.ux.h(t)}getMultiTouchViewPoint(t,e){let i=this.diagram;return i===null||i._L(this.event,t,e),e}getMultiTouchDocumentPoint(t,e){let i=this.diagram;return i===null||(i._L(this.event,t,e),e.h(i.transformViewToDoc(e))),e}get modifiers(){return this.dm}set modifiers(t){this.dm=t}get button(){return this.gm}set button(t){if(this.gm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.mm}set buttons(t){this.mm=t}get key(){return this.pm}set key(t){this.pm=t}get code(){return this.ym}set code(t){this.ym=t}get down(){return this.wm}set down(t){this.wm=t}get up(){return this.xm}set up(t){this.xm=t}get clickCount(){return this.bm}set clickCount(t){this.bm=t}get delta(){return this.km}set delta(t){this.km=t}get isMultiTouch(){return this.Pm}set isMultiTouch(t){this.Pm=t}get handled(){return this.Sm}set handled(t){this.Sm=t}get bubbles(){return this.Ro}set bubbles(t){this.Ro=t}get event(){return this.Mm}set event(t){this.Mm=t}get isTouchEvent(){let t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.Nm}set timestamp(t){this.Nm=t}get targetDiagram(){return this.Ps}set targetDiagram(t){this.Ps=t}get targetObject(){return this.Ti}set targetObject(t){this.Ti=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){let t=this.code,e=this.key;return"cxvyzagCXVYZAG".includes(e)?e.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:e}}class Qi{a;Pt;Cm;Lm;constructor(){this.a=null,this.Pt="",this.Cm=null,this.Lm=null}copy(){let t=new Qi;return t.a=this.a,t.Pt=this.Pt,t.Cm=this.Cm,t.Lm=this.Lm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.a}set diagram(t){this.a=t}get name(){return this.Pt}set name(t){this.Pt=t}get subject(){return this.Cm}set subject(t){this.Cm=t}get parameter(){return this.Lm}set parameter(t){this.Lm=t}}var xs=(x=>(x[x.Transaction=1]="Transaction",x[x.Property=2]="Property",x[x.Insert=3]="Insert",x[x.Remove=4]="Remove",x))(xs||{});class si{Du;Am;yn;Ce;a;vu;Nc;Cc;Lc;Ac;constructor(){this.Du=2,this.Am="",this.yn="",this.Ce=null,this.a=null,this.vu=null,this.Nc=null,this.Cc=null,this.Lc=null,this.Ac=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ce=null,this.a=null,this.vu=null,this.Nc=null,this.Cc=null,this.Lc=null,this.Ac=null}copy(){let t=new si;t.Du=this.Du,t.Am=this.Am,t.yn=this.yn,t.Ce=this.Ce,t.a=this.a,t.vu=this.vu;let e=this.Nc;return g.$(e)&&g.nt(e.copyFrozen)?t.Nc=e.copyFrozen():t.Nc=e,e=this.Cc,g.$(e)&&g.nt(e.copyFrozen)?t.Cc=e.copyFrozen():t.Cc=e,e=this.Lc,g.$(e)&&g.nt(e.copyFrozen)?t.Lc=e.copyFrozen():t.Lc=e,e=this.Ac,g.$(e)&&g.nt(e.copyFrozen)?t.Ac=e.copyFrozen():t.Ac=e,t}fe(t){t in xs?this.change=t:g.dr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=g.toString(this.object)),this.oldValue!==null&&(t+=" old: "+g.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+g.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.tA(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.tA(this,!1))}get model(){return this.Ce}set model(t){this.Ce=t}get diagram(){return this.a}set diagram(t){this.a=t}get change(){return this.Du}set change(t){this.Du=t}get modelChange(){return this.Am}set modelChange(t){this.Am=t}get propertyName(){return this.yn}set propertyName(t){this.yn=t}get isTransactionFinished(){return this.Du===1&&(this.yn==="CommittedTransaction"||this.yn==="FinishedUndo"||this.yn==="FinishedRedo")}get object(){return this.vu}set object(t){this.vu=t}get oldValue(){return this.Nc}set oldValue(t){this.Nc=t}get oldParam(){return this.Cc}set oldParam(t){this.Cc=t}get newValue(){return this.Lc}set newValue(t){this.Lc=t}get newParam(){return this.Ac}set newParam(t){this.Ac=t}}class Fi{eA;Pt;zP;constructor(){this.eA=new U().b(),this.Pt="",this.zP=!1}toString(t){let e="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){let i=this.changes.count;for(let s=0;s<i;s++){let n=this.changes.elt(s);n!==null&&(e+=`
6
+ `+n.toString())}}return e}clear(){let t=this.changes;t.ce();for(let e=t.count-1;e>=0;e--){let i=t.elt(e);i!==null&&i.clear()}t.clear(),t.b()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){let e=this.changes.elt(t);e!==null&&e.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;let t=this.changes.count;for(let e=0;e<t;e++){let i=this.changes.elt(e);i!==null&&i.redo()}}oR(t){let e=this.changes;for(let i=e.count-1;i>=t;i--){let s=e.elt(i);s!==null&&s.undo(),e.ce(),e.removeAt(i)}e.b()}thaw(){this.changes.ce()}optimize(){if(!this.isComplete)return;let t=this.changes;t.ce();let e=new Map;for(let s=0;s<t.count;s++){let n=t.elt(s);if(n===null||n.change!==2||!n.object)continue;let o=e.get(n.object);o||(o=new Map,e.set(n.object,o));let r=o.get(n.propertyName);r===void 0?o.set(n.propertyName,-1):(r>0&&t.setElt(r,null),o.set(n.propertyName,s))}let i=0;for(let s=0;s<t.count;s++){let n=t.elt(s);n!==null&&(s>i&&t.setElt(i,n),i++)}for(;t.length>i;)t.pop();t.b()}get changes(){return this.eA}get name(){return this.Pt}set name(t){this.Pt=t}get isComplete(){return this.zP}set isComplete(t){this.zP=t}}class _i{gx;Be;iA;js;XP;Tm;Tl;GP;YP;wn;Tc;mx;qs;yx;wx;Dm;xx;constructor(t){this.gx=new I,this.Be=!1,this.iA=new U().b(),this.js=-1,this.XP=999,this.qs=!1,this.Tm=null,this.Tl=0,this.GP=!1,this.YP=23,this.wn=new U().b(),this.Tc=new U,this.mx=!0,this.yx=!1,this.wx=!1,this.Dm=!1,this.xx=!1,t&&Object.assign(this,t)}toString(t){let e="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;e+="[";let i=this.nestedTransactionNames.count;for(let s=0;s<i;s++)s>0&&(e+=" "),e+=this.nestedTransactionNames.elt(s);if(e+="]",t!==void 0&&t>0){i=this.history.count;for(let s=0;s<i;s++)e+=`
7
+ `+this.history.elt(s).toString(t-1)}return e}clear(){let t=this.history;t.ce();for(let e=t.count-1;e>=0;e--){let i=t.elt(e);i!==null&&i.clear()}t.clear(),this.js=-1,t.b(),this.qs=!1,this.Tm=null,this.Tl=0,this.wn.ce(),this.wn.clear(),this.wn.b(),this.Tc.clear(),this.yx=!1,this.wx=!1,this.Dm=!1,this.xx=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.vm=t.vm}addModel(t){this.gx.add(t)}removeModel(t){this.gx.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.mx===!0&&(this.mx=!1,this.Tl++,this.Dl||this.vl("StartingFirstTransaction",t,this.currentTransaction),this.Tl>0&&this.Tl--),this.isEnabled&&(this.wn.ce(),this.wn.add(t),this.wn.b(),this.currentTransaction===null?this.Tc.add(0):this.Tc.add(this.currentTransaction.changes.count)),this.Tl++;let e=this.transactionLevel===1;return e&&(this.Dl||this.vl("StartedTransaction",t,this.currentTransaction)),e}commitTransaction(t){return t===void 0&&(t=""),this.sA(!0,t)}rollbackTransaction(){return this.sA(!1,"")}sA(t,e){if(this.isUndoingRedoing)return!1;this.vm&&this.transactionLevel<1&&g.ne("Ending transaction without having started a transaction: "+e);let i=this.transactionLevel===1,s=this.currentTransaction;i&&t&&(this.Dl||this.vl("CommittingTransaction",e,s));let n=0;if(this.transactionLevel>0&&(this.Tl--,this.isEnabled)){let o=this.wn.count;o>0&&(e===""&&(e=this.wn.elt(0)),this.wn.ce(),this.wn.removeAt(o-1),this.wn.b());let r=this.Tc.count;r>0&&(n=this.Tc.elt(r-1),this.Tc.removeAt(r-1))}if(i){if(t){if(this.Dm=!1,s===null&&e!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){let o=s;o.isComplete||(o.isComplete=!0,o.name=e),this.discardHistoryAfterIndex();let r=this.history;r.ce();let a=this.maxHistoryLength;if(a>=0){if(a===0)r.clear();else if(r.count>=a){let h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.js--}}a!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.js++),r.b(),s=o}this.Dl||this.vl("CommittedTransaction",e,s)}else{this.qs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Dl||this.vl("RolledBackTransaction",e,s),this.qs=!1}s!==null&&s.clear()}return this.Tm=null,this.kx&&this.clear(),this.kx=!1,this.Px=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.oR(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;let t=this.history;t.ce();for(let e=t.count-1;e>this.historyIndex;e--){let i=t.elt(e);i!==null&&i.clear(),t.removeAt(e),this.Dm=!0}t.b()}thaw(){this.history.ce()}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;let t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;let t=this.transactionToUndo;if(t!==null)try{this.qs=!0,this.vl("StartingUndo","Undo",t),this.js--,t.undo()}catch(e){g.ne("undo error: "+e.toString())}finally{this.vl("FinishedUndo","Undo",t),this.qs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;let t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;let t=this.transactionToRedo;if(t!==null)try{this.qs=!0,this.vl("StartingRedo","Redo",t),this.js++,t.redo()}catch(e){g.ne("redo error: "+e.toString())}finally{this.vl("FinishedRedo","Redo",t),this.qs=!1}}vl(t,e,i){let s=new si;s.change=1,s.propertyName=t,s.object=i,s.oldValue=e;let n=this.models;for(;n.next();){let o=n.value;s.model=o,o.rR(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let e=this.currentTransaction;e===null&&(e=new Fi,this.Tm=e);let i=t.copy(),s=e.changes;if(s.ce(),s.add(i),s.b(),this.vm&&this.YP>0&&this.transactionLevel<=0&&!this.mx){let n=t.diagram;if(n!==null&&n.$a===!1)return;g.ne("Change not within a transaction: "+i.toString()),this.YP--}}}skipsEvent(t){if(t===null||t.change===1)return!0;let e=t.object;if(e===null)return!1;if(e.layer!==void 0){let i=e.layer;if(i!==null&&i.isTemporary)return!0}else if(e.isTemporary)return!0;return!1}get models(){return this.gx.iterator}get isEnabled(){return this.Be}set isEnabled(t){this.Be=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex<this.history.count-1?this.history.elt(this.historyIndex+1):null}get isUndoingRedoing(){return this.qs}get history(){return this.iA}get maxHistoryLength(){return this.XP}set maxHistoryLength(t){this.XP=t}get historyIndex(){return this.js}get currentTransaction(){return this.Tm}get transactionLevel(){return this.Tl}get isInTransaction(){return this.Tl>0}get vm(){return this.GP}set vm(t){this.GP=t}get nestedTransactionNames(){return this.wn}get kx(){return this.yx}set kx(t){this.yx=t}get Px(){return this.wx}set Px(t){this.wx=t}get Dl(){return this.xx}set Dl(t){this.xx=t}get isJustDiscarded(){return this.Dm}}class ie{a;Pt;Be;KP;HP;Fm;nA;constructor(){I.Je(this),this.a=j.Rm(),this.Pt="",this.Be=!0,this.KP=!1,this.HP=null,this.nA=new Se,this.Fm=-1}get diagram(){return this.a}set diagram(t){t instanceof j&&(this.a=t)}toString(){return this.name!==""?this.name+" Tool":g.Hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){let t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){let t=this.diagram,e=t.lastInput,i=e.getMultiTouchViewPoint(0,P.z(NaN,NaN)),s=e.getMultiTouchViewPoint(1,P.z(NaN,NaN));if(!i.isReal()||!s.isReal()){P.i(i),P.i(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.jP=t.scale;let n=s.x-i.x,o=s.y-i.y,r=Math.sqrt(n*n+o*o);t.qP=r,e.bubbles=!1}P.i(i),P.i(s)}standardPinchZoomMove(){let t=this.diagram,e=t.lastInput,i=e.getMultiTouchViewPoint(0,P.z(NaN,NaN)),s=e.getMultiTouchViewPoint(1,P.z(NaN,NaN));if(!i.isReal()||!s.isReal()){P.i(i),P.i(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){let n=s.x-i.x,o=s.y-i.y,r=Math.sqrt(n*n+o*o)/t.qP,a=new P((Math.min(s.x,i.x)+Math.max(s.x,i.x))/2,(Math.min(s.y,i.y)+Math.max(s.y,i.y))/2),h=t.jP*r,l=t.commandHandler;if(h!==t.scale&&l.canResetZoom(h)){let c=t.zoomPoint;t.zoomPoint=a,l.resetZoom(h),t.zoomPoint=c}e.bubbles=!1}P.i(i),P.i(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){let t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){let t=this.diagram;if(!t.allowSelect)return;let e=t.lastInput,i=t.findPartAt(e.documentPoint,!1);if(i!==null){if(g.ur?e.meta:e.control){t.T("ChangingSelection",t.selection);let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.T("ChangedSelection",t.selection)}else if(e.shift){if(!i.isSelected){t.T("ChangingSelection",t.selection);let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.T("ChangedSelection",t.selection)}}else if(!i.isSelected){let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else e.left&&!(g.ur?e.meta:e.control)&&!e.shift&&t.clearSelection()}standardMouseClick(t,e){t===void 0&&(t=null),e===void 0&&(e=o=>!o.layer?.isTemporary);let i=this.diagram,s=i.lastInput,n=i.findObjectAt(s.documentPoint,t,e);return s.targetObject=n,this.oA(n,s,i)}oA(t,e,i){if(e.handled=!1,t!==null&&!t.isEnabledObject())return!1;let s=0;e.left?e.clickCount===1?s=1:e.clickCount===2?s=2:s=1:e.right&&e.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&i.T(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&i.T(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(e,t),e.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=i.click;break;case 2:o=i.doubleClick?i.doubleClick:i.click;break;case 3:o=i.contextClick;break}o!==null&&o(e)}return e.handled}standardMouseOver(){let t=this.diagram,e=t.lastInput;if(t.animationManager.ke===!0)return;let i=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(e.documentPoint)?t.findObjectAt(e.documentPoint,null,null):null;e.event&&(e.event.type==="pointercancel"||e.event.type==="pointerout")&&(s=null),e.targetObject=s;let n=!1;if(s!==t.Dc){let o=t.Dc,r=o;for(t.Dc=s,this.rA(o,s),e.handled=!1;o!==null;){let a=o.mouseLeave;if(a!==null&&(s===o||s!==null&&s.isContainedBy(o)||(a(e,o,s),n=!0,e.handled)))break;o=o.panel}for(o=r,e.handled=!1;s!==null;){let a=s.mouseEnter;if(a!==null&&(o===s||o!==null&&o.isContainedBy(s)||(a(e,s,o),n=!0,e.handled)))break;s=s.panel}s=t.Dc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,e.handled=!1,o=s;o!==null;){let a=o.mouseOver;if(a!==null&&(a(e,o),n=!0,e.handled))break;o=o.panel}}else{this.doUpdateCursor(null);let o=t.mouseOver;o!==null&&(o(e),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=i}doUpdateCursor(t){let e=this.diagram;e&&(e.currentCursor="")}rA(t,e){}standardMouseWheel(){let t=this.diagram,e=t.lastInput,i=e.delta;if(i===0||!t.documentBounds.isReal())return;let s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!e.shift||n===1&&e.control)){if(i>0?s.canIncreaseZoom():s.canDecreaseZoom()){let o=t.zoomPoint;t.zoomPoint=e.viewPoint,i>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}e.bubbles=!1}else if(n===2&&e.shift||n===1&&!e.control){let o=t.position.copy(),r=e.event,a=r.deltaMode,h=r.deltaX,l=r.deltaY,c="pixel";if((h!==0||l!==0)&&!e.shift){switch(a){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){let u=t.scrollHorizontalLineChange;h=h*(u/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(l!==0&&t.allowVerticalScroll){let u=t.scrollVerticalLineChange;l=l*(u/16),t.scroll(c,l>0?"down":"up",Math.abs(l))}}else!e.shift&&t.allowVerticalScroll?(i=i*3*t.scrollVerticalLineChange,t.scroll(c,i>0?"up":"down",Math.abs(i))):e.shift&&t.allowHorizontalScroll&&(i=i*3*t.scrollHorizontalLineChange,t.scroll(c,i>0?"left":"right",Math.abs(i)));this.doWheelChange(t,o,e)}}doWheelChange(t,e,i){(!t.position.equals(e)||i.event.wheelDeltaX!==0)&&(i.bubbles=!1)}standardWaitAfter(t,e){e===void 0&&(e=this.diagram.lastInput),this.cancelWaitAfter();let i=this,s=e.clone(this.nA);this.Fm=g.dn(()=>i.doWaitAfter(s),t)}cancelWaitAfter(){this.Fm!==-1&&g.yc(this.Fm),this.Fm=-1}doWaitAfter(t){}findToolHandleAt(t,e){let i=this.diagram.findObjectAt(t,s=>{for(;s!==null&&!(s.panel instanceof Mt);)s=s.panel;return s});return i===null?null:i.part.category===e?i:null}isBeyondDragSize(t,e){let i=this.diagram;t===void 0&&(t=i.firstInput.viewPoint),e===void 0&&(e=i.lastInput.viewPoint);let s=i.toolManager.dragSize,n=s.width,o=s.height;return i.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(e.x-t.x)>n||Math.abs(e.y-t.y)>o}get name(){return this.Pt}set name(t){g.s(t,"string",ie,"name"),this.Pt=t}get isEnabled(){return this.Be}set isEnabled(t){g.s(t,"boolean",ie,"isEnabled"),this.Be=t}get isActive(){return this.KP}set isActive(t){g.s(t,"boolean",ie,"isActive"),this.KP=t}get transactionResult(){return this.HP}set transactionResult(t){t!==null&&g.s(t,"string",ie,"transactionResult"),this.HP=t}}var mn=(x=>(x[x.Scroll=1]="Scroll",x[x.Zoom=2]="Zoom",x[x.None=3]="None",x))(mn||{}),pn=(x=>(x[x.Zoom=1]="Zoom",x[x.Cancel=2]="Cancel",x[x.None=3]="None",x))(pn||{});class de extends ie{lA;aA;hA;WP;JP;$P;ZP;QP;_P;tS;Om;Za;constructor(t){super(),this.name="ToolManager",this.lA=new U,this.aA=new U,this.hA=new U,this.WP=850,this.JP=850,this.$P=new _(2,2).kt(),this.ZP=5e3,this.QP=1,this._P=1,this.tS=null,this.Om=null,this.Za=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.QP}set mouseWheelBehavior(t){this.QP=t}get gestureBehavior(){return this._P}set gestureBehavior(t){this._P=t}initializeStandardTools(){}updateAdornments(t){let e=this.currentToolTip;if(e instanceof Mt&&this.Om===t){let i=e.adornedObject;(t!==null?i!==null&&i.part===t:i===null)?this.showToolTip(e,i):this.hideToolTip()}}doMouseDown(){let t=this.diagram,e=t.lastInput;if(e.isTouchEvent&&this.gestureBehavior===2&&(e.bubbles=!1),e.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){e.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}let i=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n<s;n++){let o=this.mouseDownTools.elt(n);if(o.diagram=this.diagram,o.canStart()){t.doFocus(),t.currentTool=o,t.currentTool===o&&(o.isActive||o.doActivate(),o.doMouseDown());return}}t.lastInput.button===1&&(this.mouseWheelBehavior===1?this.mouseWheelBehavior=2:this.mouseWheelBehavior===2&&(this.mouseWheelBehavior=1)),this.doActivate(),this.standardWaitAfter(this.holdDelay,e)}doMouseMove(){let t=this.diagram,e=t.lastInput;if(e.isMultiTouch){if(this.gestureBehavior===3){e.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomMove();return}}if(this.isActive){let s=this.mouseMoveTools.length;for(let n=0;n<s;n++){let o=this.mouseMoveTools.elt(n);if(o.diagram=this.diagram,o.canStart()){t.doFocus(),t.currentTool=o,t.currentTool===o&&(o.isActive||o.doActivate(),o.doMouseMove());return}}}this.cA(t);let i=e.event;i!==null&&(i.type==="pointermove"||!i.cancelable)&&(e.bubbles=!0)}cA(t){this.standardMouseOver(),this.isBeyondDragSize()&&this.standardWaitAfter(this.isActive?this.holdDelay:this.hoverDelay,t.lastInput)}rA(t,e){let i=this.currentToolTip;i!==null&&(e!==null&&i instanceof Mt&&(e===i||e.isContainedBy(i))||this.hideToolTip())}doWaitAfter(t){let e=this.diagram;if(!e.lR())return;let i=e.lastInput;if(e.lastInput=t,this.doMouseHover(),this.isActive||this.doToolTip(),t.isTouchEvent&&!e.lastInput.handled){let s=t.copy();s.button=2,e.lastInput=s,e.Sx=!0,e.doMouseUp()}e.lastInput=i}doMouseHover(){let t=this.diagram,e=t.lastInput;e.targetObject===null&&(e.targetObject=t.findObjectAt(e.documentPoint,null,null));let i=e.targetObject;if(i!==null)for(e.handled=!1;i!==null;){let s=this.isActive?i.mouseHold:i.mouseHover;if(s!==null&&(s(e,i),e.handled))break;i=i.panel}else{let s=this.isActive?t.mouseHold:t.mouseHover;s!==null&&s(e)}}doToolTip(){let t=this.diagram,e=t.lastInput;e.targetObject===null&&(e.targetObject=t.findObjectAt(e.documentPoint,null,null));let i=e.targetObject;if(i!==null){let s=this.currentToolTip;if(s instanceof Mt&&(i===s||i.isContainedBy(s)))return;for(;i!==null;){let n=i.toolTip;if(n!==null){this.showToolTip(n,i);return}i=i.panel}this.hideToolTip()}else{let s=t.toolTip;s!==null?this.showToolTip(s,null):this.hideToolTip()}}showToolTip(t,e){e!==null&&g.se(e,tt,de,"showToolTip:obj");let i=this.diagram;if(t!==this.currentToolTip&&this.hideToolTip(),t instanceof Mt){t.layerName="Tool",t.selectable=!1,t.scale=1/i.scale,t.category="ToolTip",t.hasPlaceholder()&&(t.placeholder.scale=i.scale);let s=t.diagram;s!==null&&s!==i&&s.remove(t),i.add(t),e!==null?t.adornedObject=e:t.data=i.model,t.ensureBounds(),this.positionToolTip(t,e)}else t instanceof Me&&t!==this.currentToolTip&&t.show!==null&&t.show(e,i,this);this.currentToolTip=t,this.extendToolTip(this.toolTipDuration)}positionToolTip(t,e){if(t.hasPlaceholder())return;let i=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=i.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.x<r.x&&(n.x=r.x),n.y+20/s.scale+o.height>r.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y<r.y&&(n.y=r.y),i.position=n}extendToolTip(t){t===void 0&&(t=3e3),this.currentToolTip!==null&&(this.Za!==-1&&(g.yc(this.Za),this.Za=-1),t>0&&t!==1/0&&(this.Za=g.dn(()=>this.hideToolTip(),t)))}hideToolTip(){this.Za!==-1&&(g.yc(this.Za),this.Za=-1);let t=this.diagram,e=this.currentToolTip;e!==null&&(e instanceof Mt?(t.remove(e),this.Om!==null&&this.Om.removeAdornment(e.category),e.data=null,e.adornedObject=null):e instanceof Me&&e.hide!==null&&e.hide(t,this),this.currentToolTip=null)}get currentToolTip(){return this.tS}set currentToolTip(t){this.tS=t,this.Om=t!==null&&t instanceof Mt?t.adornedPart:null}doMouseUp(){this.cancelWaitAfter();let t=this.diagram;if(this.isActive){let e=this.mouseUpTools.length;for(let i=0;i<e;i++){let s=this.mouseUpTools.elt(i);if(s.diagram=this.diagram,s.canStart()){t.doFocus(),t.currentTool=s,t.currentTool===s&&(s.isActive||s.doActivate(),s.doMouseUp());return}}}t.doFocus(),this.doDeactivate()}doMouseWheel(){this.standardMouseWheel()}doKeyDown(){let t=this.diagram;t.commandHandler!==null&&t.commandHandler.doKeyDown()}doKeyUp(){let t=this.diagram;t.commandHandler!==null&&t.commandHandler.doKeyUp()}findTool(t){g.s(t,"string",de,"findTool:name");let e=this.mouseDownTools.length;for(let i=0;i<e;i++){let s=this.mouseDownTools.elt(i);if(s.name===t)return s}e=this.mouseMoveTools.length;for(let i=0;i<e;i++){let s=this.mouseMoveTools.elt(i);if(s.name===t)return s}e=this.mouseUpTools.length;for(let i=0;i<e;i++){let s=this.mouseUpTools.elt(i);if(s.name===t)return s}return null}replaceTool(t,e){g.s(t,"string",de,"replaceTool:name"),e!==null&&(e.diagram=this.diagram);let i=this.mouseDownTools.length;for(let s=0;s<i;s++){let n=this.mouseDownTools.elt(s);if(n.name===t)return e!==null?this.mouseDownTools.setElt(s,e):this.mouseDownTools.removeAt(s),n}i=this.mouseMoveTools.length;for(let s=0;s<i;s++){let n=this.mouseMoveTools.elt(s);if(n.name===t)return e!==null?this.mouseMoveTools.setElt(s,e):this.mouseMoveTools.removeAt(s),n}i=this.mouseUpTools.length;for(let s=0;s<i;s++){let n=this.mouseUpTools.elt(s);if(n.name===t)return e!==null?this.mouseUpTools.setElt(s,e):this.mouseUpTools.removeAt(s),n}return null}replaceStandardTool(t,e,i){this.Jt(t,e,i)}Jt(t,e,i){g.s(t,"string",de,"replaceStandardTool:name"),e!==null&&(e.name=t,e.diagram=this.diagram),this.findTool(t)?this.replaceTool(t,e):e!==null&&i.add(e)}get mouseDownTools(){return this.lA}get mouseMoveTools(){return this.aA}get mouseUpTools(){return this.hA}get hoverDelay(){return this.WP}set hoverDelay(t){g.s(t,"number",de,"hoverDelay"),this.WP=t}get holdDelay(){return this.JP}set holdDelay(t){g.s(t,"number",de,"holdDelay"),this.JP=t}get dragSize(){return this.$P}set dragSize(t){this.$P=t.N()}get toolTipDuration(){return this.ZP}set toolTipDuration(t){g.s(t,"number",de,"toolTipDuration"),this.ZP=t}get actionTool(){return this.findTool("Action")}set actionTool(t){this.Jt("Action",t,this.mouseDownTools)}get relinkingTool(){return this.findTool("Relinking")}set relinkingTool(t){this.Jt("Relinking",t,this.mouseDownTools)}get linkReshapingTool(){return this.findTool("LinkReshaping")}set linkReshapingTool(t){this.Jt("LinkReshaping",t,this.mouseDownTools)}get resizingTool(){return this.findTool("Resizing")}set resizingTool(t){this.Jt("Resizing",t,this.mouseDownTools)}get rotatingTool(){return this.findTool("Rotating")}set rotatingTool(t){this.Jt("Rotating",t,this.mouseDownTools)}get linkingTool(){return this.findTool("Linking")}set linkingTool(t){this.Jt("Linking",t,this.mouseMoveTools)}get draggingTool(){return this.findTool("Dragging")}set draggingTool(t){this.Jt("Dragging",t,this.mouseMoveTools)}get dragSelectingTool(){return this.findTool("DragSelecting")}set dragSelectingTool(t){this.Jt("DragSelecting",t,this.mouseMoveTools)}get panningTool(){return this.findTool("Panning")}set panningTool(t){this.Jt("Panning",t,this.mouseMoveTools)}get contextMenuTool(){return this.findTool("ContextMenu")}set contextMenuTool(t){this.Jt("ContextMenu",t,this.mouseUpTools)}get textEditingTool(){return this.findTool("TextEditing")}set textEditingTool(t){this.Jt("TextEditing",t,this.mouseUpTools)}get clickCreatingTool(){return this.findTool("ClickCreating")}set clickCreatingTool(t){this.Jt("ClickCreating",t,this.mouseUpTools)}get clickSelectingTool(){return this.findTool("ClickSelecting")}set clickSelectingTool(t){this.Jt("ClickSelecting",t,this.mouseUpTools)}}class Tt extends ie{eS;iS;xn;sS;nS;oS;rS;vc;Im;lS;Qa;kr;fA;aS;Fu;Ru;hS;cS;fS;uS;static Mx=new U;static le=null;static _a=null;constructor(t){super(),this.name="Dragging",this.eS=!0,this.uS=!0,this.iS=!0,this.xn=null,this.sS=null,this.nS=null,this.oS=null,this.rS=!1,this.Fu=!1,this.vc=new P(NaN,NaN),this.Im=new P,this.lS=!0,this.Qa=100,this.kr=[],this.fA=new I().b(),this.aS=new es,this.Ru=null,this.hS="copy",this.cS="",this.fS="no-drop",t&&Object.assign(this,t)}get isCopyEnabled(){return this.eS}set isCopyEnabled(t){g.s(t,"boolean",Tt,"isCopyEnabled"),this.eS=t}get copiesEffectiveCollection(){return this.iS}set copiesEffectiveCollection(t){g.s(t,"boolean",Tt,"copiesEffectiveCollection"),this.iS=t}get dragOptions(){return this.aS}set dragOptions(t){this.aS=t}get isGridSnapEnabled(){return this.dragOptions.isGridSnapEnabled}set isGridSnapEnabled(t){g.s(t,"boolean",Tt,"isGridSnapEnabled"),this.dragOptions.isGridSnapEnabled=t}get isComplexRoutingRealtime(){return this.lS}set isComplexRoutingRealtime(t){this.lS=t;let e=this.diagram.findRouter("AvoidsLinks");e!==null&&(e.isRealtime=t)}get isGridSnapRealtime(){return this.dragOptions.isGridSnapRealtime}set isGridSnapRealtime(t){g.s(t,"boolean",Tt,"isGridSnapRealtime"),this.dragOptions.isGridSnapRealtime=t}get gridSnapCellSize(){return this.dragOptions.gridSnapCellSize}set gridSnapCellSize(t){this.dragOptions.gridSnapCellSize.equals(t)||(t=t.N(),this.dragOptions.gridSnapCellSize=t)}get gridSnapCellSpot(){return this.dragOptions.gridSnapCellSpot}set gridSnapCellSpot(t){this.dragOptions.gridSnapCellSpot.equals(t)||(t=t.N(),this.dragOptions.gridSnapCellSpot=t)}get gridSnapOrigin(){return this.dragOptions.gridSnapOrigin}set gridSnapOrigin(t){this.dragOptions.gridSnapOrigin.equals(t)||(t=t.N(),this.dragOptions.gridSnapOrigin=t)}get dragsLink(){return this.dragOptions.dragsLink}set dragsLink(t){g.s(t,"boolean",Tt,"dragsLink"),this.dragOptions.dragsLink=t}get dragsTree(){return this.dragOptions.dragsTree}set dragsTree(t){g.s(t,"boolean",Tt,"dragsTree"),this.dragOptions.dragsTree=t}get copyCursor(){return this.hS}set copyCursor(t){this.hS=t}get moveCursor(){return this.cS}set moveCursor(t){this.cS=t}get nodropCursor(){return this.fS}set nodropCursor(t){this.fS=t}get currentPart(){return this.sS}set currentPart(t){t!==null&&g.se(t,bt,Tt,"currentPart"),this.sS=t}get copiedParts(){return this.oS}set copiedParts(t){this.oS=t}get draggedParts(){return this.nS}set draggedParts(t){this.nS=t}get draggingParts(){return this.copiedParts!==null?this.copiedParts.toKeySet():this.draggedParts!==null?this.draggedParts.toKeySet():this.fA}get draggedLink(){return this.diagram.draggedLink}set draggedLink(t){t!==null&&g.se(t,q,Tt,"draggedLink"),this.diagram.draggedLink=t}get isDragOutStarted(){return this.rS}set isDragOutStarted(t){this.rS=t}get startPoint(){return this.Im}set startPoint(t){this.Im.equals(t)||this.Im.h(t)}get delay(){return this.Qa}set delay(t){g.s(t,"number",Tt,"delay"),this.Qa=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||t.isReadOnly&&!t.allowDragOut||!t.allowMove&&!t.allowCopy&&!t.allowDragOut||!t.allowSelect)return!1;let e=t.lastInput;return!e.left||t.currentTool!==this&&(!this.isBeyondDragSize()||e.isTouchEvent&&e.timestamp-t.firstInput.timestamp<this.Qa)?!1:this.findDraggablePart()!==null}findDraggablePart(){let t=this.diagram,e=t.findPartAt(t.firstInput.documentPoint,!1);if(e===null)return null;for(;e!==null&&!e.canSelect();)e=e.containingGroup;return e!==null&&(e.canMove()||e.canCopy())?e:null}standardMouseSelect(){let t=this.diagram;if(!t.allowSelect)return;let e=t.findPartAt(t.firstInput.documentPoint,!1);if(e!==null){for(;e!==null&&!e.canSelect();)e=e.containingGroup;if(this.currentPart=e,this.currentPart!==null&&!this.currentPart.isSelected){t.T("ChangingSelection",t.selection);let i=t.lastInput;!(g.ur?i.meta:i.control)&&!i.shift&&t.clearSelection(!0),this.currentPart.isSelected=!0,t.T("ChangedSelection",t.selection)}}}doActivate(){let t=this.diagram;this.Ru=null,this.currentPart===null&&this.standardMouseSelect();let e=this.currentPart;if(e===null||!e.canMove()&&!e.canCopy())return;t.cacheGroupExternalLinks(!0),Tt.le=null,this.isActive=!0,this.vc.set(t.position),this.dS(t.selection),this.kr.length=0,t.animationManager.stopAnimation();let i=this.computeEffectiveCollection(t.selection,this.dragOptions);this.draggedParts=i,this.uS=!!this.diagram.layout.isRealtime,this.diagram.layout.isRealtime=!1,t.Ou=!0,t.getRenderingHint("temporaryPixelRatio")===!0&&t.avgSpf>30&&t.Nx(),t.uA(this.draggedParts),t.Iu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.aR()}dS(t){if(!this.dragsLink)return;let e=this.diagram,i=e.model.Em(),s=t.first();i&&t.count===1&&s instanceof q&&this.mayDragLink(s)?(this.draggedLink=s,this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.xn=e.toolManager.findTool("Relinking"),this.xn===null&&(this.xn=new di,this.xn.diagram=e),this.xn.originalLink=this.draggedLink):(this.draggedLink=null,this.xn=null)}mayDragLink(t){let e=this.diagram;return e!==null&&e.allowRelink}computeEffectiveCollection(t,e){return this.diagram.commandHandler.computeEffectiveCollection(t,e)}Ws(t){return t===void 0?new ni(P.gn):this.isGridSnapEnabled?new ni(new P(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new ni(t.copy())}doDeactivate(){this.isActive=!1;let t=this.diagram;this.diagram.layout.isRealtime=this.uS,t.Iu=!1,t.Fl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.gS(),t.mS(this.draggedParts),this.Ru=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.Fu=!1,Tt.hR(),this.dA(),this.vc.e(NaN,NaN),Tt._a!==null&&(Tt._a.currentCursor=""),Tt._a=null,Tt.le=null,this.Rl(),t.isMouseCaptured=!1,t.currentCursor="",t.Ou=!1,this.stopTransaction(),t.pS(!0)}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}gS(){let t=this.diagram,e=t.skipsUndoManager;t.skipsUndoManager=!0;let i=t.lastInput;this.gA(i,null),t.skipsUndoManager=e,this.kr.length=0}mA(){this.Rl(),this.yS();let t=this.diagram;this.vc.isReal()&&(t.position=this.vc),t.stopAutoScroll()}doCancel(){this.Rl(),this.yS();let t=this.diagram;this.vc.isReal()&&(t.position=this.vc),this.stopTool()}doKeyDown(){let t=this.diagram;if(!this.isActive)return;let e=t.lastInput,i=t.previousInput;e.code==="Escape"?this.doCancel():(e.code!==i.code||e.modifiers!==i.modifiers)&&this.doMouseMove()}doKeyUp(){this.isActive&&this.doMouseMove()}cR(t,e){let i=1/0,s=1/0,n=-1/0,o=-1/0,r=t.iterator;for(;r.next();){let a=r.value;if(!a.isVisible())continue;let h=a.location,l=h.x,c=h.y;isNaN(l)||isNaN(c)||(l<i&&(i=l),c<s&&(s=c),l>n&&(n=l),c>o&&(o=c))}return i===1/0?e.e(0,0,0,0):e.e(i,s,n-i,o-s),e}wS(t){if(this.copiedParts!==null)return;let e=this.diagram;if(t&&(e.isReadOnly||e.isModelReadOnly)||this.draggedParts===null)return;let i=e.undoManager;i.isEnabled&&i.isInTransaction?i.currentTransaction!==null&&i.currentTransaction.changes.count>0&&(e.undoManager.rollbackTransaction(),e.startTransaction("Drag")):this.yS(),e.skipsUndoManager=!t,e.partManager.addsToTemporaryLayer=!t,this.startPoint=e.firstInput.documentPoint;let s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():e.selection,n=e.copyParts(s,e,!0),o=new wt,r=this.draggedParts.iterator;for(;r.next();){let h=r.key;if(h.Di()&&h.canCopy()){let l=n.get(h);if(l===null)continue;l.location=h.location,l.ensureBounds(),o.set(l,this.Ws(l.location))}}let a=n.iterator;for(;a.next();){let h=a.value;h instanceof q&&h.canCopy()&&o.set(h,this.Ws())}if(this.copiedParts=o,this.dS(o.toKeySet()),this.draggedLink!==null){let h=this.draggedLink,l=h.routeBounds;h.Pr(this.startPoint.x-(l.x+l.width/2),this.startPoint.y-(l.y+l.height/2))}this.doUpdateCursor(null)}Rl(){let t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){let e=this.draggedParts.iterator;for(;e.next();)if(e.key instanceof q){let i=e.value;i.point=new P(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}dA(){this.draggedLink!==null&&(this.dragsLink&&this.xn!==null&&(this.xn.stopDraggingMouseMove(),this.xn.originalLink=null),this.draggedLink=null,this.xn=null)}Fc(t,e){if(t===null)return;let i=this.diagram,s=this.startPoint,n=P.l();n.h(i.lastInput.documentPoint),this.moveParts(t,n.subtract(s),e),P.i(n),i.getRenderingHint("temporaryPixelRatio")===!0&&i.Ol===null&&i.avgSpf>30&&(i.Nx(),i.Eu())}moveParts(t,e,i){i===void 0&&(i=!1);let s=this.diagram;s!==null&&s.Cx(t,e,this.dragOptions,i)}yS(){if(this.draggedParts===null)return;let t=this.diagram,e=this.draggedParts.iterator;for(;e.next();){let i=e.key;i.Di()&&(i.location=e.value.point)}for(e=this.draggedParts.iterator;e.next();){let i=e.key;if(i instanceof q&&i.suspendsRouting){let s=e.value.point;this.draggedParts.set(i,this.Ws()),i.Pr(-s.x,-s.y)}}t.maybeUpdate()}fR(t){if(t===null)return!0;let e=t.part;return!!(e===null||e instanceof Mt||e.layer?.isTemporary||this.draggedParts&&this.draggedParts.has(e)||this.copiedParts&&this.copiedParts.has(e))}xS(t){let e=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.pA(!1));let i=this.findDragOverObject(t),s=e.lastInput;s.targetObject=i,this.doUpdateCursor(i);let n=e.skipsUndoManager,o=!1;try{if(e.skipsUndoManager=!0,o=this.gA(s,i),!this.isActive&&Tt.le===null)return;let r=i!==null?i.part:null;if(r===null||e.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof ft)){let a=e.mouseDragOver;a!==null&&(a(s),o=!0)}if(!this.isActive&&Tt.le===null||(this.doDragOver(t,i),!this.isActive&&Tt.le===null))return}finally{e.skipsUndoManager=n,o&&e.maybeUpdate()}this.Ru=i,!e.isReadOnly&&(e.allowMove||e.allowCopy)&&(e.allowHorizontalScroll||e.allowVerticalScroll)&&e.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.bS(t,null,e=>!this.fR(e))}doUpdateCursor(t){let e=this.diagram;(t===null||this.Ru!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?e.currentCursor=this.copyCursor:this.mayMove()?e.currentCursor=this.moveCursor:this.mayDragOut()&&(e.currentCursor=this.nodropCursor))}gA(t,e){let i=!1,s=this.kr.length,n=s>0?this.kr[0]:null;if(e===n)return!1;t.handled=!1;for(let r=0;r<s;r++){let a=this.kr[r],h=a.mouseDragLeave;if(h!==null&&(h(t,a,e),i=!0,t.handled))break}if(this.kr.length=0,!this.isActive&&Tt.le===null||e===null)return i;t.handled=!1;let o=e;for(;o!==null;)this.kr.push(o),o=this.yA(o);s=this.kr.length;for(let r=0;r<s;r++){let a=this.kr[r],h=a.mouseDragEnter;if(h!==null&&(h(t,a,n),i=!0,t.handled))break}return i}FU(t,e){return t===null?!1:!!(t===e||t.isContainedBy(e)||e instanceof ft&&!(t instanceof ft)&&e.handlesDragDropForMembers&&t.part?.isMemberOf(e))}yA(t){let e=t.panel;if(e!==null)return e;if(t instanceof bt&&!(t instanceof ft)){let i=t.containingGroup;if(i!==null&&i.handlesDragDropForMembers)return i}return null}wA(t,e){let i=this.diagram,s=this.xn;if(s===null)return null;let n=s.portGravity,o=i.findObjectsNear(t,n,l=>s.findValidLinkablePort(l,e)),r=P.l(),a=1/0,h=null;for(let l=o.iterator;l.next();){let c=l.value;if(c.part===null)continue;let u=c.getDocumentPoint(T.Center,r),d=t.distanceSquaredPoint(u);d<a&&(h=c,a=d)}return P.i(r),h}pA(t){let e=this.draggedLink;if(e!==null){if(e.pointsCount<2)return;let i=this.diagram;if(i.isReadOnly)return;let s=this.xn;if(s===null)return;let n=null,o=null;e.fromNode===null&&(n=this.wA(e.getPoint(0),!1),n!==null&&(o=n.part));let r=null,a=null;e.toNode===null&&(r=this.wA(e.getPoint(e.pointsCount-1),!0),r!==null&&(a=r.part)),s.isValidLink(o,n,a,r)?t?(e.defaultFromPoint=e.getPoint(0),e.defaultToPoint=e.getPoint(e.pointsCount-1),e.suspendsRouting=!1,e.fromNode=o,n!==null&&(e.fromPortId=n.portId),e.toNode=a,r!==null&&(e.toPortId=r.portId),e.fromPort!==i.kS&&i.T("LinkRelinked",e,i.kS),e.toPort!==i.PS&&i.T("LinkRelinked",e,i.PS)):s.doDraggingMouseMove(o,n,a,r):s.doDraggingMouseMove(null,null,null,null)}}doDragOver(t,e){}xA(t){let e=this.diagram;this.dragsLink&&this.pA(!0),this.gS();let i=this.findDragOverObject(t),s=e.lastInput;if(s.targetObject=i,i!==null){s.handled=!1;let a=i;for(;a!==null;){let h=a.mouseDrop;if(h!==null&&(h(s,a),s.handled))break;this.uR(s,a),a=this.yA(a)}}else{let a=e.mouseDrop;a!==null&&a(s)}if(!this.isActive&&Tt.le===null)return;let n=this.copiedParts||this.draggedParts;if(n!==null){let a=n.iterator;for(;a.next();){let h=a.key;h instanceof it&&h.linksConnected.each(l=>l.suspendsRouting=!1)}}if(this.doDropOnto(t,i),!this.isActive&&Tt.le===null)return;let o=B.l(),r=e.selection.iterator;for(;r.next();){let a=r.value;a instanceof it&&this.dR(e,a,o)}B.i(o)}uR(t,e){let i=this.diagram,s=e.part;if(i.handlesDragDropForTopLevelParts&&s!==null&&s.isTopLevel&&!(s instanceof ft)){let n=i.mouseDrop;n!==null&&n(t)}}dR(t,e,i){if(!e.canAvoid())return;let s=!1;i=e.getAvoidableRect(i),t.viewportBounds.containsRect(i)&&(s=!0);let n=this.copiedParts||this.draggedParts;if(n===null)return;let o=t.SS(i,a=>a.part,a=>a instanceof q,!0,a=>a instanceof q,s);if(o.count===0)return;let r=o.iterator;for(;r.next();){let a=r.value;n.has(a)&&n.has(e)||!a.isMemberOf(e)&&a.isAvoiding&&a.$t()}}doDropOnto(t,e){}doMouseMove(){if(!this.isActive)return;let t=this.diagram,e=t.lastInput;this.simulatedMouseMove(e.event,e.documentPoint,e.targetDiagram)||this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.wS(!1),this.Fc(this.copiedParts,!1)):this.mayMove()?(this.Rl(),this.Fc(this.draggedParts,!0)):this.mayDragOut()?(this.wS(!1),this.Fc(this.copiedParts,!1)):this.Rl(),this.xS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;let t=this.diagram,e=t.lastInput;if(this.simulatedMouseUp(e.event,e.documentPoint,e.targetDiagram))return;let i=!1,s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Rl(),this.wS(!0),this.Fc(this.copiedParts,!1),this.copiedParts!==null&&(t.T("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(i=!0,this.Rl(),this.mayMove()&&(this.Fc(this.draggedParts,!0),this.xS(t.lastInput.documentPoint))),this.Fu=!0,this.xA(t.lastInput.documentPoint),this.isActive){let n=s&&this.copiedParts,o=n?this.copiedParts?.toKeySet():this.draggedParts?this.draggedParts.toKeySet():null;this.copiedParts=null,i&&this.gR(),t.invalidateDocumentBounds(),t.mS(this.draggedParts),this.transactionResult=n?"Copy":"Move",t.T(n?"SelectionCopied":"SelectionMoved",o)}this.stopTool(),s&&t.T("ChangedSelection",t.selection)}simulatedMouseMove(t,e,i){if(Tt.le===null)return!1;let s=Tt.le.diagram;i instanceof j||(i=null);let n=Tt._a;if(i!==n){if(n!==null&&n!==s){n.stopAutoScroll(),Tt.le.isDragOutStarted=!1;let r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(Tt._a=i,i!==null&&i!==s){Tt.le.mA();let r=i.toolManager.findTool("Dragging");r!==null&&(r.bA(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(i===null||i===s||!i.allowDrop||i.isReadOnly||!i.allowInsert)return!1;let o=i.toolManager.findTool("Dragging");if(o!==null){let r=e;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=i.getMouse(t)),i.lastInput.documentPoint=r,i.lastInput.viewPoint=i.transformDocToView(r),i.lastInput.down=!1,i.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,e,i){if(Tt.le===null)return!1;let s=Tt._a,n=Tt.le.diagram;if(i===null)return Tt.le.doCancel(),!0;if(i!==s){if(s!==null){let r=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&r!==null)return s.stopAutoScroll(),Tt.le.isDragOutStarted=!1,r.doSimulatedDragLeave(),!1}Tt._a=i;let o=i.toolManager.findTool("Dragging");o!==null&&(Tt.le.mA(),o.bA(),o.doSimulatedDragEnter())}if(i!==this.diagram){let o=e;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=i.getMouse(t)):o===null&&(o=new P),i.lastInput.documentPoint=o,i.lastInput.viewPoint=i.transformDocToView(o),i.lastInput.down=!1,i.lastInput.up=!0;let r=i.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();let a=Tt.le;if(a!==null){let h=a.mayCopy();a.transactionResult=h?"Copy":"Move",a.stopTool()}return!0}return!1}gR(){if(this.draggedParts===null)return;let t=this.draggedParts.iterator;for(;t.next();){let e=t.key;if(e instanceof it){let i=e.containingGroup;i!==null&&i.hasPlaceholder()&&!this.draggedParts.has(i)&&i.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(g.ur?t.lastInput.alt:t.lastInput.control))return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;let t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){let t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}bA(){Tt.Mx.has(this)||Tt.Mx.add(this)}static hR(){if(Tt.Mx.count>0){let t=Tt.Mx,e=t.length;for(let i=0;i<e;i++){let s=t.elt(i);s.dA(),s.Rl(),s.gS(),s.diagram.stopAutoScroll()}t.clear()}}mR(t,e,i){return!this.Fu&&this.draggedParts!==null&&!this.draggedParts.has(t)?(i.h(e),!0):!1}get draggingSource(){return Tt.le}mayDragIn(){let t=this.diagram;if(!t.allowDrop||t.isReadOnly||t.isModelReadOnly||!t.allowInsert)return!1;let e=Tt.le;return!(e===null||e.diagram.model.dataFormat!==t.model.dataFormat)}doSimulatedDragEnter(){if(!this.mayDragIn())return;let t=this.diagram;t.animationManager.stopAnimation(),t.Sr(),t.animationManager.stopAnimation();let e=Tt.le;e!==null&&(this.diagram.Ou=!0,t.lastInput.event===null&&(t.lastInput.event=e.diagram.lastInput.event)),this.doUpdateCursor(null)}doSimulatedDragLeave(){let t=Tt.le;t!==null&&t.doSimulatedDragOut(),this.diagram.Ou=!1,this.doCancel()}doSimulatedDragOver(){let t=this.diagram;t.animationManager.Uu=!0;let e=Tt.le;if(e!==null&&e.draggedParts!==null){if(!this.mayDragIn())return;this.kA(e.draggedParts.toKeySet(),!1,t.firstInput),this.Fc(this.copiedParts,!1),this.xS(t.lastInput.documentPoint)}t.animationManager.Uu=!1}doSimulatedDrop(){let t=this.diagram,e=Tt.le;if(e!==null){let i=e.diagram;if(e.Fu=!0,this.Rl(),e.draggedParts===null||!this.mayDragIn())return;t.animationManager.Uu=!0,t.T("ChangingSelection",t.selection),this.startTransaction("Drop"),this.kA(e.draggedParts.toKeySet(),!0,t.lastInput),this.Fc(this.copiedParts,!1);let s=new I;this.copiedParts!==null&&(t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0,s.add(n)})),this.xA(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.Ou=!1,t.T("ExternalObjectsDropped",s,i),this.stopTransaction(),t.T("ChangedSelection",t.selection)}t.animationManager.Uu=!1}kA(t,e,i){if(this.copiedParts!==null)return;let s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!e,s.partManager.addsToTemporaryLayer=!e,this.startPoint=i.documentPoint;let n=s.copyParts(t,s,!0),o=B.l();this.cR(t,o);let r=o.x+o.width/2,a=o.y+o.height/2;B.i(o);let h=this.Im,l=new wt,c=P.l(),u=t.iterator;for(;u.next();){let f=u.value;if(f instanceof q&&f.canCopy()){let p=n.get(f);if(p===null)continue;p.points=f.points,p.Pr(h.x-r,h.y-a),p.suspendsRouting=!0,l.set(p,this.Ws())}}let d=t.iterator;for(;d.next();){let f=d.value;if(f.Di()&&f.canCopy()){let p=n.get(f);if(p===null)continue;let m=f.location;c.e(h.x-(r-m.x),h.y-(a-m.y)),p.location=c,p.ensureBounds(),l.set(p,this.Ws(c))}}if(P.i(c),this.copiedParts=l,this.dS(l.toKeySet()),this.draggedLink!==null){let f=this.draggedLink,p=f.routeBounds;f.Pr(this.startPoint.x-(p.x+p.width/2),this.startPoint.y-(p.y+p.height/2))}this.doUpdateCursor(null)}aR(){this.isDragOutStarted=!0,this.Fu=!1,Tt.le=this,Tt._a=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){let t=this.diagram;!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Ru=null}computeMove(t,e,i,s){let n=this.diagram;return n!==null?n.computeMove(t,e,this.dragOptions,s):new P}}de.prototype.doCancel=function(){Tt.le!==null&&Tt.le.doCancel(),ie.prototype.doCancel.call(this)};class xe extends ie{MS;NS;Il;CS;LS;th;AS;eh;TS;DS;vS;FS;RS;OS;PA;IS;El;ES;constructor(){super(),this.MS=100,this.NS=!1,this.Il="pointer",this.CS=new q({layerName:"Tool"}).add(new at({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new at({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).It(),this.th=new at("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:_.AP}).theme("stroke","tempPort"),this.LS=new it({selectable:!1,layerName:"Tool"}).add(this.th).It(),this.eh=new at("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:_.AP}).theme("stroke","tempPort"),this.AS=new it({selectable:!1,layerName:"Tool"}).add(this.eh).It(),this.TS=null,this.DS=null,this.vS=null,this.FS=null,this.RS=null,this.OS=!0,this.PA=new wt,this.IS=null,this.El=null,this.ES=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.MS}set portGravity(t){g.s(t,"number",xe,"portGravity"),t>=0&&(this.MS=t)}get isUnconnectedLinkValid(){return this.NS}set isUnconnectedLinkValid(t){g.s(t,"boolean",xe,"isUnconnectedLinkValid"),this.NS=t}get linkingCursor(){return this.Il}set linkingCursor(t){this.Il=t}get temporaryLink(){return this.CS}set temporaryLink(t){t.It(),this.CS=t}get temporaryFromNode(){return this.LS}set temporaryFromNode(t){t.It(),this.LS=t,t&&(this.th=t.port)}get temporaryFromPort(){return this.th}set temporaryFromPort(t){if(this.th!==null){let e=this.th.panel;if(e!==null){let i=e.D.indexOf(this.th);e.removeAt(i),e.insertAt(i,t)}}this.th=t}get temporaryToNode(){return this.AS}set temporaryToNode(t){t.It(),this.AS=t,t&&(this.eh=t.port)}get temporaryToPort(){return this.eh}set temporaryToPort(t){if(this.eh!==null){let e=this.eh.panel;if(e!==null){let i=e.D.indexOf(this.eh);e.removeAt(i),e.insertAt(i,t)}}this.eh=t}get originalLink(){return this.TS}set originalLink(t){t!==null&&g.se(t,q,xe,"originalLink"),this.TS=t}get originalFromNode(){return this.DS}set originalFromNode(t){t!==null&&g.se(t,it,xe,"originalFromNode"),this.DS=t}get originalFromPort(){return this.vS}set originalFromPort(t){t!==null&&g.se(t,tt,xe,"originalFromPort"),this.vS=t}get originalToNode(){return this.FS}set originalToNode(t){t!==null&&g.se(t,it,xe,"originalToNode"),this.FS=t}get originalToPort(){return this.RS}set originalToPort(t){t!==null&&g.se(t,tt,xe,"originalToPort"),this.RS=t}get isForwards(){return this.OS}set isForwards(t){this.OS=t}get validPortsCache(){return this.PA}get targetPort(){return this.IS}set targetPort(t){t!==null&&g.se(t,tt,xe,"targetPort"),this.IS=t}copyPortProperties(t,e,i,s,n){if(t===null||e===null||i===null||s===null)return;let o=e.getDocumentScale(),r=_.l();r.width=e.naturalBounds.width*o,r.height=e.naturalBounds.height*o,s.desiredSize=r,_.i(r),n?(s.toSpot=e.toSpot,s.toEndSegmentLength=e.toEndSegmentLength):(s.fromSpot=e.fromSpot,s.fromEndSegmentLength=e.fromEndSegmentLength),i.locationSpot=T.Center;let a=P.l();i.location=e.getDocumentPoint(T.Center,a),P.i(a),s.angle=e.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,e,i,s,n)}setNoTargetPortProperties(t,e,i){e!==null&&(e.desiredSize=_.AP,e.fromSpot=T.None,e.toSpot=T.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,e,i)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){let t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof it){let e=this.targetPort.part;this.isForwards?this.copyPortProperties(e,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(e,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,e){if(t===null)return null;let i=t.part;if(!(i instanceof it))return null;for(;t!==null;){let s=e?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof it)&&(e?this.isValidTo(i,t):this.isValidFrom(i,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){let e=this.diagram,i=e.lastInput.documentPoint,s=this.portGravity,n=e.findObjectsNear(i,s,h=>this.findValidLinkablePort(h,t),null,!0),o=1/0,r=null,a=n.iterator;for(;a.next();){let h=a.value,l=h.part;if(!(l instanceof it))continue;let c=h.getDocumentPoint(T.Center,P.l()),u=i.x-c.x,d=i.y-c.y;P.i(c);let f=u*u+d*d;if(f<o){let p=this.validPortsCache.get(h);p!==null?p&&(r=h,o=f):t&&this.isValidLink(this.originalFromNode,this.originalFromPort,l,h)||!t&&this.isValidLink(l,h,this.originalToNode,this.originalToPort)?(this.validPortsCache.set(h,!0),r=h,o=f):this.validPortsCache.set(h,!1)}}if(r!==null){let h=r.part;if(h instanceof it&&(h.layer===null||h.layer.allowLink))return r}return null}isValidFrom(t,e){if(t===null||e===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||e.fromLinkable!==!0))return!1;let i=e.fromMaxLinks;if(i<1/0){if(this.originalLink!==null&&t===this.originalFromNode&&e===this.originalFromPort)return!0;let s=e.portId;if(s===null&&(s=""),t.findLinksOutOf(s).count>=i)return!1}return!0}isValidTo(t,e){if(t===null||e===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||e.toLinkable!==!0))return!1;let i=e.toMaxLinks;if(i<1/0){if(this.originalLink!==null&&t===this.originalToNode&&e===this.originalToPort)return!0;let s=e.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=i)return!1}return!0}isInSameNode(t,e){if(t===null||e===null)return!1;if(t===e)return!0;let i=t.part,s=e.part;return i!==null&&i===s}isLinked(t,e){if(t===null||e===null)return!1;let i=t.part;if(!(i instanceof it))return!1;let s=t.portId;s===null&&(s="");let n=e.part;if(!(n instanceof it))return!1;let o=e.portId;o===null&&(o="");let r=n.findLinksInto(o);for(;r.next();){let a=r.value;if(a.fromNode===i&&a.fromPortId===s)return!0}return!1}isValidLink(t,e,i,s){if(!this.isValidFrom(t,e)||!this.isValidTo(i,s)||e!==null&&s!==null&&(!(e.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(e,s)||!(e.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(e,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||i!==null&&this.isLabelDependentOnLink(i,this.originalLink))||t!==null&&i!==null&&(t.data===null&&i.data!==null||t.data!==null&&i.data===null)||!this.isValidCycle(t,i,this.originalLink))return!1;let n;return t!==null&&e!==null&&(n=t.linkValidation,n!==null&&!n(t,e,i,s,this.originalLink))||i!==null&&s!==null&&(n=i.linkValidation,n!==null&&!n(t,e,i,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,e,i,s,this.originalLink):!0)}isLabelDependentOnLink(t,e){if(t===null)return!1;let i=t.labeledLink;if(i===null)return!1;if(i===e)return!0;let s=new I;return s.add(t),this.US(i,e,s)}US(t,e,i){if(t===e)return!0;let s=t.fromNode;if(s!==null&&s.labeledLink&&(i.add(s),this.US(s.labeledLink,e,i)))return!0;let n=t.toNode;return!!(n!==null&&n.labeledLink&&(i.add(n),this.US(n.labeledLink,e,i)))}isValidCycle(t,e,i){if(i===void 0&&(i=null),t===null||e===null)return this.isUnconnectedLinkValid;let s=this.diagram,n=1;if(s&&(s.model.Um()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){let o=i||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;let r=e.linksConnected;for(;r.next();){let a=r.value;if(a!==i&&a.isTreeLink&&a.toNode===e)return!1}return!this.Vu(t,e,i,!0)}else if(n===6){let o=i||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;let r=t.linksConnected;for(;r.next();){let a=r.value;if(a!==i&&a.isTreeLink&&a.fromNode===t)return!1}return!this.Vu(t,e,i,!0)}else{if(n===2)return!this.pR(t,e,i);if(n===3)return!this.Vu(t,e,i,!1);if(n===4)return!this.yR(t,e,i)}return!0}Vu(t,e,i,s){if(t===e)return!0;if(t===null||e===null)return!1;let n=t.linksConnected;for(;n.next();){let o=n.value;if(o===i||s&&!o.isTreeLink||o.toNode!==t)continue;let r=o.fromNode;if(!(r===t||r===null)&&this.Vu(r,e,i,s))return!0}return!1}pR(t,e,i){if(t===e)return!0;let s=new Set;return s.add(e),this.SA(s,t,e,i)}SA(t,e,i,s){if(e===i)return!0;if(e===null||i===null||t.has(e))return!1;t.add(e);let n=e.linksConnected;for(;n.next();){let o=n.value;if(o===s||o.toNode!==e)continue;let r=o.fromNode;if(!(r===e||r===null)&&this.SA(t,r,i,s))return!0}return!1}yR(t,e,i){if(t===e)return!0;let s=new Set;return s.add(e),this.MA(s,t,e,i)}MA(t,e,i,s){if(e===i)return!0;if(e===null||i===null||t.has(e))return!1;t.add(e);let n=e.linksConnected;for(;n.next();){let o=n.value;if(o===s)continue;let r=o.fromNode,a=o.toNode,h=r===e?a:r;if(!(h===e||h===null)&&this.MA(t,h,i,s))return!0}return!1}get linkValidation(){return this.El}set linkValidation(t){t!==null&&g.S(t,xe,"linkValidation"),this.El=t}get portTargeted(){return this.ES}set portTargeted(t){t!==null&&g.S(t,xe,"portTargeted"),this.ES=t}}var yn=(x=>(x[x.Either=1]="Either",x[x.ForwardsOnly=2]="ForwardsOnly",x[x.BackwardsOnly=3]="BackwardsOnly",x))(yn||{});class Ge extends xe{VS;BS;P;zS;constructor(t){super(),this.name="Linking",this.VS={},this.BS=null,this.P=1,this.zS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.VS}set archetypeLinkData(t){t!==null&&g.wc(t,Ge,"archetypeLinkData"),t instanceof tt&&g.se(t,q,Ge,"archetypeLinkData"),this.VS=t}get archetypeLabelNodeData(){return this.BS}set archetypeLabelNodeData(t){t!==null&&g.wc(t,Ge,"archetypeLabelNodeData"),t instanceof tt&&g.se(t,it,Ge,"archetypeLabelNodeData"),this.BS=t}get direction(){return this.P}set direction(t){this.P=t}get startObject(){return this.zS}set startObject(t){t!==null&&g.se(t,tt,Ge,"startObject"),this.zS=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Lx()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){let t=this.diagram,e=this.startObject;if(e===null&&(e=t.findObjectAt(t.firstInput.documentPoint,null,null)),e===null)return null;let i=e.part;if(!(i instanceof it))return null;let s=this.direction;if(s===1||s===2){let n=this.findValidLinkablePort(e,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===i){let o=i.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){let n=this.findValidLinkablePort(e,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===i){let o=i.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){let t=this.diagram,e=this.findLinkablePort();if(e===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=e;let i=this.originalFromPort.part;i instanceof it&&(this.originalFromNode=i),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=e;let i=this.originalToPort.part;i instanceof it&&(this.originalToNode=i),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.$t(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;let t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){let t=this.diagram;this.transactionResult=null;let e=null,i=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);let r=this.targetPort;if(r!==null){let a=r.part;a instanceof it&&(this.isForwards?(this.originalFromNode!==null&&(e=this.originalFromNode,i=this.originalFromPort),s=a,n=r):(e=a,i=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(e=this.originalFromNode,i=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);e!==null||s!==null?(o=this.insertLink(e,i,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.T("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.T("LinkDrawn",o)):this.doNoLink(e,i,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.T("ChangedSelection",t.selection)}}}isNewTreeLink(){let t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof q)return t.isTreeLink;let e=this.diagram;if(e===null)return!0;let i=e.partManager.getLinkCategoryForData(t),s=e.partManager.findLinkTemplateForCategory(i);return s!==null?s.isTreeLink:!0}insertLink(t,e,i,s){return this.diagram.partManager.insertLink(t,e,i,s)}doNoLink(t,e,i,s){}}class di extends xe{NA=null;CA=null;XS=null;GS=null;Ss;YS;constructor(t){super(),this.name="Relinking",this.fromHandleArchetype=new at("Diamond",{desiredSize:_.Su,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.toHandleArchetype=new at("Diamond",{desiredSize:_.Su,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.YS=new B,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof q))return;let e="RelinkFrom",i=null;if(t.isSelected&&!this.diagram.isReadOnly){let s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(i=t.findAdornment(e),i===null&&(i=this.makeAdornment(s,!1),t.addAdornment(e,i)))}if(i===null&&t.removeAdornment(e),e="RelinkTo",i=null,t.isSelected&&!this.diagram.isReadOnly){let s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(i=t.findAdornment(e),i===null?(i=this.makeAdornment(s,!0),t.addAdornment(e,i)):i.c())}i===null&&t.removeAdornment(e)}makeAdornment(t,e){let i=e?this.GS:this.XS;return i&&(i=i.copy(),i.adornedObject=t),i}get fromHandleArchetype(){return this.NA}set fromHandleArchetype(t){t!==null&&g.se(t,tt,di,"fromHandleArchetype"),this.NA=t,t!==null?this.XS=new Mt(H.Link).add(t).It():this.XS=null}get toHandleArchetype(){return this.CA}set toHandleArchetype(t){t!==null&&g.se(t,tt,di,"toHandleArchetype"),this.CA=t,t!==null?this.GS=new Mt(H.Link).add(t).It():this.GS=null}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof Mt||g.o("new handle is not in an Adornment: "+t)),this.Ss=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Lx()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){let t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;let s=i.part;if(!(s instanceof Mt)||!(s.adornedPart instanceof q))return;this.handle=i,this.isForwards=s===null||s.category==="RelinkTo",this.originalLink=s.adornedPart}let e=this.originalLink;e!==null&&(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=e.fromPort,this.originalFromNode=e.fromNode,this.originalToPort=e.toPort,this.originalToNode=e.toNode,this.YS.set(e.actualBounds),e.pointsCount>0&&(e.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=_.xc),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=e.getPoint(0))),e.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=_.xc),this.temporaryToNode!==null&&(this.temporaryToNode.location=e.getPoint(e.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(e,this.temporaryLink),this.temporaryLink.$t(),t.add(this.temporaryLink)),this.isActive=!0)}copyLinkProperties(t,e){if(t===null||e===null)return;e.adjusting=t.adjusting,e.corner=t.corner;let i=t.curve;(i===11||i===10)&&(i=0),e.curve=i,e.curviness=t.curviness,e.isTreeLink=t.isTreeLink,e.points=t.points,e.routing=t.routing,e.smoothness=t.smoothness,e.fromSpot=t.fromSpot,e.fromEndSegmentLength=t.fromEndSegmentLength,e.fromShortLength=t.fromShortLength,e.toSpot=t.toSpot,e.toEndSegmentLength=t.toEndSegmentLength,e.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;let t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){let t=this.diagram;this.transactionResult=null;let e=this.originalFromNode,i=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){let r=this.targetPort.part;r instanceof it&&(this.isForwards?(s=r,n=this.targetPort):(e=r,i=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(e=null,i=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:e,this.isForwards?n:i,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.$t()),this.transactionResult=this.name,t.T("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.originalLink!==null&&this.doNoRelink(this.originalLink,this.isForwards),this.originalLink!==null&&this.originalLink.invalidateOtherJumpOvers(this.YS)}finally{this.stopTool()}}}reconnectLink(t,e,i,s){let n=i!==null&&i.portId!==null?i.portId:"";return s?(t.toNode=e,t.toPortId=n):(t.fromNode=e,t.fromPortId=n),!0}doNoRelink(t,e){}doDraggingMouseMove(t,e,i,s){t!==null?(this.copyPortProperties(t,e,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),i!==null?(this.copyPortProperties(i,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var xn=(x=>(x[x.None=0]="None",x[x.Horizontal=1]="Horizontal",x[x.Vertical=2]="Vertical",x[x.All=3]="All",x))(xn||{});class fi extends ie{Mr;KS;HS;Ss;Ax;jS;Vm;constructor(t){super(),this.name="LinkReshaping",this.Mr=new at("Rectangle",{desiredSize:_.RL,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.KS=new at("Diamond",{desiredSize:_.Su,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HS=3,this.Ss=null,this.Ax=null,this.jS=new P,this.Vm=new U,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Nr:0}setReshapingBehavior(t,e){t.Nr=e}updateAdornments(t){if(t===null||!(t instanceof q))return;let e=null;if(t.isSelected&&!this.diagram.isReadOnly){let i=t.path;i!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()&&(e=t.findAdornment(this.name),(e===null||e.qS!==t.pointsCount||e.WS!==t.resegmentable)&&(e=this.makeAdornment(i),e!==null&&(e.qS=t.pointsCount,e.WS=t.resegmentable,t.addAdornment(this.name,e))))}e===null&&t.removeAdornment(this.name)}makeAdornment(t){let e=t.part,i=e.points,s=e.pointsCount,n=e.isOrthogonal,o=null;if(i!==null&&s>1){o=new Mt,o.type=H.Link;let r=e.firstPickIndex,a=e.lastPickIndex,h=n?1:0;if(e.resegmentable&&e.computeCurve()!==9)for(let l=r+h;l<a-h;l++){let c=this.makeResegmentHandle(t,l);c!==null&&(c.segmentIndex=l,c.segmentFraction=.5,c.fromMaxLinks=999,o.add(c))}for(let l=r+1;l<a;l++){let c=this.makeHandle(t,l);if(c!==null){if(c.segmentIndex=l,l!==r)if(l===r+1&&n){let u=e.getPoint(r),d=e.getPoint(r+1);A.u(u.x,d.x)&&A.u(u.y,d.y)?(d=e.getPoint(r-1),A.u(u.x,d.x)?(this.setReshapingBehavior(c,2),c.cursor="n-resize"):A.u(u.y,d.y)&&(this.setReshapingBehavior(c,1),c.cursor="w-resize")):A.u(u.x,d.x)?(this.setReshapingBehavior(c,2),c.cursor="n-resize"):A.u(u.y,d.y)&&(this.setReshapingBehavior(c,1),c.cursor="w-resize")}else if(l===a-1&&n){let u=e.getPoint(a-1),d=e.getPoint(a);A.u(u.x,d.x)&&A.u(u.y,d.y)?(u=e.getPoint(a+1),A.u(u.x,d.x)?(this.setReshapingBehavior(c,2),c.cursor="n-resize"):A.u(u.y,d.y)&&(this.setReshapingBehavior(c,1),c.cursor="w-resize")):A.u(u.x,d.x)?(this.setReshapingBehavior(c,2),c.cursor="n-resize"):A.u(u.y,d.y)&&(this.setReshapingBehavior(c,1),c.cursor="w-resize")}else l===a||(this.setReshapingBehavior(c,3),c.cursor="move");o.add(c)}}o.adornedObject=t}return o}makeHandle(t,e){let i=this.handleArchetype;return i===null?null:i.copy().JS()}get handleArchetype(){return this.Mr}set handleArchetype(t){t!==null&&g.se(t,tt,fi,"handleArchetype"),this.Mr=t}makeResegmentHandle(t,e){let i=this.midHandleArchetype;return i===null?null:i.copy().JS()}get midHandleArchetype(){return this.KS}set midHandleArchetype(t){t!==null&&g.se(t,tt,fi,"midHandleArchetype"),this.KS=t}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof Mt||g.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedLink(){return this.Ax}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowReshape||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;let e=this.handle.part.adornedPart;if(e instanceof q){if(this.Ax=e,t.isMouseCaptured=!0,this.startTransaction(this.name),e.resegmentable&&this.handle.fromMaxLinks===999){let i=e.points.copy(),s=this.getResegmentingPoint();if(i.insertAt(this.handle.segmentIndex+1,s),e.isOrthogonal&&i.insertAt(this.handle.segmentIndex+1,s),e.points=i,e.invalidateAdornments(),e.updateAdornments(),this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name),this.handle===null){this.doDeactivate();return}}this.jS=e.getPoint(this.handle.segmentIndex),this.Vm=e.points.copy(),this.isActive=!0}}doDeactivate(){this.stopTransaction(),this.handle=null,this.Ax=null;let t=this.diagram;t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){let t=this.adornedLink;t!==null&&(t.points=this.Vm),this.stopTool()}getResegmentingPoint(){return this.handle===null?this.diagram.lastInput.documentPoint:this.handle.getDocumentPoint(T.Center)}doMouseMove(){let t=this.diagram;if(this.isActive){let e=this.computeReshape(t.lastInput.documentPoint);this.reshape(e)}}doMouseUp(){let t=this.diagram;if(this.isActive){let e=this.computeReshape(t.lastInput.documentPoint);this.reshape(e);let i=this.adornedLink;if(i!==null&&i.resegmentable&&this.handle!==null){let s=this.handle.segmentIndex,n=i.getPoint(s-1),o=i.getPoint(s),r=i.getPoint(s+1);if(i.isOrthogonal){if(s>i.firstPickIndex+1&&s<i.lastPickIndex-1){let a=i.getPoint(s-2);if(this.isWithinResegmentingDistance(n,o)&&(this.isInLineOrtho(a,n,o,r,!0)||this.isInLineOrtho(a,n,o,r,!1))){let h=i.points.copy();this.isInLineOrtho(a,n,o,r,!0)?(h.setElt(s-2,new P(a.x,(r.y+a.y)/2)),h.setElt(s+1,new P(r.x,(r.y+a.y)/2))):(h.setElt(s-2,new P((r.x+a.x)/2,a.y)),h.setElt(s+1,new P((r.x+a.x)/2,r.y))),h.removeAt(s),h.removeAt(s-1),i.points=h,i.invalidateAdornments()}else if(a=i.getPoint(s+2),this.isWithinResegmentingDistance(o,r)&&(this.isInLineOrtho(n,o,r,a,!0)||this.isInLineOrtho(n,o,r,a,!1))){let h=i.points.copy();this.isInLineOrtho(n,o,r,a,!0)?(h.setElt(s-1,new P(n.x,(n.y+a.y)/2)),h.setElt(s+2,new P(a.x,(n.y+a.y)/2))):(h.setElt(s-1,new P((n.x+a.x)/2,n.y)),h.setElt(s+2,new P((n.x+a.x)/2,a.y))),h.removeAt(s+1),h.removeAt(s),i.points=h,i.invalidateAdornments()}}}else{let a=P.l();if(A.Nl(n.x,n.y,r.x,r.y,o.x,o.y,a)&&a.distanceSquaredPoint(o)<this.resegmentingDistance*this.resegmentingDistance){let h=i.points.copy();h.removeAt(s),i.points=h,i.invalidateAdornments()}P.i(a)}}t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("LinkReshaped",this.adornedLink,this.Vm)}this.stopTool()}isWithinResegmentingDistance(t,e){return Math.abs(t.x-e.x)<this.resegmentingDistance&&Math.abs(t.y-e.y)<this.resegmentingDistance}isInLineOrtho(t,e,i,s,n){return n?Math.abs(t.y-e.y)<this.resegmentingDistance&&Math.abs(e.y-i.y)<this.resegmentingDistance&&Math.abs(i.y-s.y)<this.resegmentingDistance:Math.abs(t.x-e.x)<this.resegmentingDistance&&Math.abs(e.x-i.x)<this.resegmentingDistance&&Math.abs(i.x-s.x)<this.resegmentingDistance}get resegmentingDistance(){return this.HS}set resegmentingDistance(t){g.s(t,"number",fi,"resegmentingDistance"),this.HS=t}reshape(t){let e=this.adornedLink;if(e===null)return;let i=this.handle;if(i===null)return;e.startRoute();let s=i.segmentIndex,n=this.getReshapingBehavior(i);if(e.isOrthogonal)if(s===e.firstPickIndex+1){let o=e.firstPickIndex+1;n===2?(e.setPointAt(o,e.getPoint(o-1).x,t.y),e.setPointAt(o+1,e.getPoint(o+2).x,t.y)):n===1&&(e.setPointAt(o,t.x,e.getPoint(o-1).y),e.setPointAt(o+1,t.x,e.getPoint(o+2).y))}else if(s===e.lastPickIndex-1){let o=e.lastPickIndex-1;n===2?(e.setPointAt(o-1,e.getPoint(o-2).x,t.y),e.setPointAt(o,e.getPoint(o+1).x,t.y)):n===1&&(e.setPointAt(o-1,t.x,e.getPoint(o-2).y),e.setPointAt(o,t.x,e.getPoint(o+1).y))}else{let o=s,r=e.getPoint(o),a=e.getPoint(o-1),h=e.getPoint(o+1);A.u(a.x,r.x)&&A.u(r.y,h.y)?(A.u(a.x,e.getPoint(o-2).x)&&!A.u(a.y,e.getPoint(o-2).y)?(e.insertPointAt(o,t.x,a.y),s++,o++):e.setPointAt(o-1,t.x,a.y),A.u(h.y,e.getPoint(o+2).y)&&!A.u(h.x,e.getPoint(o+2).x)?e.insertPointAt(o+1,h.x,t.y):e.setPointAt(o+1,h.x,t.y)):A.u(a.y,r.y)&&A.u(r.x,h.x)?(A.u(a.y,e.getPoint(o-2).y)&&!A.u(a.x,e.getPoint(o-2).x)?(e.insertPointAt(o,a.x,t.y),s++,o++):e.setPointAt(o-1,a.x,t.y),A.u(h.x,e.getPoint(o+2).x)&&!A.u(h.y,e.getPoint(o+2).y)?e.insertPointAt(o+1,t.x,h.y):e.setPointAt(o+1,t.x,h.y)):A.u(a.x,r.x)&&A.u(r.x,h.x)?(A.u(a.x,e.getPoint(o-2).x)&&!A.u(a.y,e.getPoint(o-2).y)?(e.insertPointAt(o,t.x,a.y),s++,o++):e.setPointAt(o-1,t.x,a.y),A.u(h.x,e.getPoint(o+2).x)&&!A.u(h.y,e.getPoint(o+2).y)?e.insertPointAt(o+1,t.x,h.y):e.setPointAt(o+1,t.x,h.y)):A.u(a.y,r.y)&&A.u(r.y,h.y)&&(A.u(a.y,e.getPoint(o-2).y)&&!A.u(a.x,e.getPoint(o-2).x)?(e.insertPointAt(o,a.x,t.y),s++,o++):e.setPointAt(o-1,a.x,t.y),A.u(h.y,e.getPoint(o+2).y)&&!A.u(h.x,e.getPoint(o+2).x)?e.insertPointAt(o+1,h.x,t.y):e.setPointAt(o+1,h.x,t.y)),e.setPointAt(s,t.x,t.y)}else{e.setPointAt(s,t.x,t.y);let o=e.fromNode,r=e.fromPort;if(o!==null){let l=o.findVisibleNode();l!==null&&l!==o&&(o=l,r=o.port)}if(s===1&&r!==null&&e.computeSpot(!0,r).isNoSpot()){let l=r.getDocumentPoint(T.Center,P.l()),c=e.getLinkPointFromPoint(o,r,l,t,!0,P.l());e.setPointAt(0,c.x,c.y),P.i(l),P.i(c)}let a=e.toNode,h=e.toPort;if(a!==null){let l=a.findVisibleNode();l!==null&&l!==a&&(a=l,h=a.port)}if(s===e.pointsCount-2&&h!==null&&e.computeSpot(!1,h).isNoSpot()){let l=h.getDocumentPoint(T.Center,P.l()),c=e.getLinkPointFromPoint(a,h,l,t,!1,P.l());e.setPointAt(e.pointsCount-1,c.x,c.y),P.i(l),P.i(c)}}e.commitRoute()}computeReshape(t){let e=this.adornedLink;if(e===null)return t;let i=this.handle;if(i===null)return t;let s=i.segmentIndex;switch(this.getReshapingBehavior(i)){case 3:return t;case 2:{let n=e.getPoint(s);return new P(n.x,t.y)}case 1:{let n=e.getPoint(s);return new P(t.x,n.y)}default:case 0:return e.getPoint(s)}}get originalPoint(){return this.jS}get originalPoints(){return this.Vm}}class gi extends ie{Cr;Lr;Oo;Rc;$S;Ms;Mr;Ss;Bm;ZS;Oc;Tx;Dx;vx;constructor(t){super(),this.name="Resizing",this.Cr=new _(1,1).b(),this.Lr=new _(9999,9999).b(),this.Oo=new _(NaN,NaN).b(),this.Rc=!1,this.$S=!0,this.Ms=null,this.Mr=new at("Rectangle",{alignmentFocus:T.Center,desiredSize:_.RL,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.Bm=new P,this.ZS=new _,this.Oc=new P,this.Tx=new _(0,0),this.Dx=new _(1/0,1/0),this.vx=new _(1,1),t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Ar()){let e=t.rotateObject;if(e===t||e===t.path||e.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){let e=t.resizeObject,i=t.findAdornment(this.name);if(e!==null&&t.canResize()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&((i===null||i.adornedObject!==e)&&(i=this.makeAdornment(e)),i!==null)){let s=e.getDocumentAngle();t.Ul()&&this.updateResizeHandles(i,s),t.addAdornment(this.name,i);return}}t.removeAdornment(this.name)}}makeAdornment(t){let e=null,i=t.part?.resizeAdornmentTemplate;if(i){if(e=i.copy(),e===null)return null}else{e=new Mt,e.type=H.Spot,e.locationSpot=T.Center;let s=new we;s.isPanelMain=!0,e.add(s);let n=this.makeHandle(t,T.TopLeft);n!==null&&e.add(n),n=this.makeHandle(t,T.TopRight),n!==null&&e.add(n),n=this.makeHandle(t,T.BottomRight),n!==null&&e.add(n),n=this.makeHandle(t,T.BottomLeft),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleTop),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleRight),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleBottom),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleLeft),n!==null&&e.add(n)}return e.adornedObject=t,e}makeHandle(t,e){let i=this.handleArchetype;if(i===null)return null;let s=i.copy().JS();return s.alignment=e,s}updateResizeHandles(t,e){if(t!==null){if(!t.alignment.isDefault()&&(t.cursor==="pointer"||t.cursor.indexOf("resize")>0))this.wR(t,e);else if(t instanceof H){let i=t.elements;for(;i.next();){let s=i.value;this.updateResizeHandles(s,e)}}}}wR(t,e){let i=t.alignment;i.isNoSpot()&&(i=T.Center);let s=e;if(i.x<=0)i.y<=0?s+=225:i.y>=1?s+=135:s+=180;else if(i.x>=1)i.y<=0?s+=315:i.y>=1&&(s+=45);else if(i.y<=0)s+=270;else if(i.y>=1)s+=90;else return;s=A.Ee(s),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Mr}set handleArchetype(t){t!==null&&g.se(t,tt,gi,"handleArchetype"),this.Mr=t}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof Mt||g.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedObject(){return this.Ms}set adornedObject(t){t!==null&&t.part instanceof Mt&&g.o("new handle must not be in an Adornment: "+t),this.Ms=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&this.adornedObject.part!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Iu=!0,this.startTransaction(this.name),this.Bm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Oc.set(this.adornedObject.part.location),this.ZS.set(this.adornedObject.desiredSize),this.vx=this.computeCellSize(),this.Tx=this.computeMinSize(),this.Dx=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){let t=this.diagram;t.Iu=!1,t.Fl=!0,this.stopTransaction(),this.handle=null,this.Ms=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){this.adornedObject!==null&&this.adornedObject.part!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){let t=this.diagram;if(!this.isActive||this.adornedObject===null||this.handle===null)return;let e=this.Tx,i=this.Dx,s=this.vx,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,P.l()),r=this.computeReshape(),a=this.computeResize(o,this.handle.alignment,e,i,s,r);this.resize(a),t.maybeUpdate(),P.i(o)}doMouseUp(){let t=this.diagram;if(this.isActive&&this.adornedObject!==null&&this.handle!==null){let e=this.Tx,i=this.Dx,s=this.vx,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,P.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,e,i,s,o);this.resize(r),P.i(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){let e=this.diagram,i=this.adornedObject;if(i===null)return;i.desiredSize=t.size;let s=i.part;if(s===null||this.handle===null)return;s.ensureBounds();let n=i.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof ft){let o=new U;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new es,r.dragsMembers=!1),e.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);e.maybeUpdate()}computeResize(t,e,i,s,n,o){if(this.adornedObject===null)return B.tm;e.isNoSpot()&&(e=T.Center);let r=this.adornedObject.naturalBounds,a=r.x,h=r.y,l=r.x+r.width,c=r.y+r.height,u=1;if(!o){let p=r.width,m=r.height;p<=0&&(p=1),m<=0&&(m=1),u=m/p}let d=P.l();A._g(t.x,t.y,a,h,n.width,n.height,d);let f=r.copy();return e.x<=0?e.y<=0?(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=Math.max(l-f.x,i.width),f.y=Math.max(d.y,c-s.height),f.y=Math.min(f.y,c-i.height),f.height=Math.max(c-f.y,i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(u*f.width,s.height),i.height),f.width=f.height/u):(f.width=Math.max(Math.min(f.height/u,s.width),i.width),f.height=u*f.width),f.x=l-f.width,f.y=c-f.height)):e.y>=1?(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=Math.max(l-f.x,i.width),f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(u*f.width,s.height),i.height),f.width=f.height/u):(f.width=Math.max(Math.min(f.height/u,s.width),i.width),f.height=u*f.width),f.x=l-f.width)):(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=l-f.x,o||(f.height=Math.max(Math.min(u*f.width,s.height),i.height),f.width=f.height/u,f.y=h+.5*(c-h-f.height))):e.x>=1?e.y<=0?(f.width=Math.max(Math.min(d.x-a,s.width),i.width),f.y=Math.max(d.y,c-s.height),f.y=Math.min(f.y,c-i.height),f.height=Math.max(c-f.y,i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(u*f.width,s.height),i.height),f.width=f.height/u):(f.width=Math.max(Math.min(f.height/u,s.width),i.width),f.height=u*f.width),f.y=c-f.height)):e.y>=1?(f.width=Math.max(Math.min(d.x-a,s.width),i.width),f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(u*f.width,s.height),i.height),f.width=f.height/u):(f.width=Math.max(Math.min(f.height/u,s.width),i.width),f.height=u*f.width))):(f.width=Math.max(Math.min(d.x-a,s.width),i.width),o||(f.height=Math.max(Math.min(u*f.width,s.height),i.height),f.width=f.height/u,f.y=h+.5*(c-h-f.height))):e.y<=0?(f.y=Math.max(d.y,c-s.height),f.y=Math.min(f.y,c-i.height),f.height=c-f.y,o||(f.width=Math.max(Math.min(f.height/u,s.width),i.width),f.height=u*f.width,f.x=a+.5*(l-a-f.width))):e.y>=1&&(f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.width=Math.max(Math.min(f.height/u,s.width),i.width),f.height=u*f.width,f.x=a+.5*(l-a-f.width))),P.i(d),f}computeReshape(){let t=0;return this.adornedObject instanceof at&&(t=this.adornedObject.QS()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){if(this.adornedObject===null)return _.xc;let t=this.adornedObject.minSize.copy(),e=this.minSize;return!isNaN(e.width)&&e.width>t.width&&(t.width=e.width),!isNaN(e.height)&&e.height>t.height&&(t.height=e.height),t}computeMaxSize(){if(this.adornedObject===null)return _.TP;let t=this.adornedObject.maxSize.copy(),e=this.maxSize;return!isNaN(e.width)&&e.width<t.width&&(t.width=e.width),!isNaN(e.height)&&e.height<t.height&&(t.height=e.height),t}computeCellSize(){let t=new _(NaN,NaN),e=this.adornedObject?.part;if(e){let n=e.resizeCellSize;!isNaN(n.width)&&n.width>0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let i=this.cellSize;isNaN(t.width)&&!isNaN(i.width)&&i.width>0&&(t.width=i.width),isNaN(t.height)&&!isNaN(i.height)&&i.height>0&&(t.height=i.height);let s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){let n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(i=n.gridCellSize,isNaN(t.width)&&!isNaN(i.width)&&i.width>0&&(t.width=i.width),isNaN(t.height)&&!isNaN(i.height)&&i.height>0&&(t.height=i.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Cr}set minSize(t){if(!this.Cr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let i=t.height;isNaN(i)&&(i=0),this.Cr.e(e,i)}}get maxSize(){return this.Lr}set maxSize(t){if(!this.Lr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let i=t.height;isNaN(i)&&(i=1/0),this.Lr.e(e,i)}}get cellSize(){return this.Oo}set cellSize(t){this.Oo.equals(t)||this.Oo.h(t)}get isGridSnapEnabled(){return this.Rc}set isGridSnapEnabled(t){g.s(t,"boolean",gi,"isGridSnapEnabled"),this.Rc=t}get dragsMembers(){return this.$S}set dragsMembers(t){g.s(t,"boolean",gi,"dragsMembers"),this.$S=t}get oppositePoint(){return this.Bm}set oppositePoint(t){this.Bm.equals(t)||this.Bm.h(t)}get originalDesiredSize(){return this.ZS}get originalLocation(){return this.Oc}}class qe extends ie{_S;tM;Ms=null;Mr=null;Fx=null;Ss=null;eM;zm;Oc;iM;sM;constructor(t){super(),this.name="Rotating",this._S=45,this.tM=2,this.Oc=new P,this.Ms=null,this.handleArchetype=new at("Ellipse",{desiredSize:_.Su,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.eM=0,this.zm=new P(NaN,NaN),this.iM=0,this.sM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Ar()){let e=t.rotateObject;if(e===t||e===t.path||e.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){let e=t.rotateObject;if(e!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()){let i=t.findAdornment(this.name);if((i===null||i.adornedObject!==e)&&(i=this.makeAdornment(e)),i!==null){i.angle=e.getDocumentAngle(),i.hasPlaceholder()||(i.location=this.computeAdornmentLocation(e)),t.addAdornment(this.name,i);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let e=null,i=t.part?.rotateAdornmentTemplate;return i?e=i.copy():this.Fx!==null&&(e=this.Fx.copy()),e===null?null:(e.adornedObject=t,e)}get handleArchetype(){return this.Mr}set handleArchetype(t){t!==null&&g.se(t,tt,qe,"handleArchetype"),this.Mr=t,t!==null?this.Fx=new Mt(H.Position,{locationSpot:T.Center}).add(t).It():this.Fx=null}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof Mt||g.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedObject(){return this.Ms}set adornedObject(t){t!==null&&t.part instanceof Mt&&g.o("new handle must not be in an Adornment: "+t),this.Ms=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject===null||this.adornedObject.part===null||(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eM=this.adornedObject.angle,this.zm=this.computeRotationPoint(this.adornedObject),this.Oc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){let e=t.part;if(e!==null){let i=e.locationObject;if(e.rotationSpot.isSpot())return t.getDocumentPoint(e.rotationSpot);if(t===e||t===i)return i.getDocumentPoint(e.locationSpot)}return t.getDocumentPoint(T.Center)}computeAdornmentLocation(t){let e=this.rotationPoint;e.isReal()||(e=this.computeRotationPoint(t));let i=t.getLocalPoint(e),s=this.handleAngle;s=A.Ee(s),s=Math.round(Math.round(s/45)*45);let n=this.handleDistance;return s===0?i.x=t.naturalBounds.width+n:s===45?(i.x=t.naturalBounds.width+n,i.y=t.naturalBounds.height+n):s===90?i.y=t.naturalBounds.height+n:s===135?(i.x=-n,i.y=t.naturalBounds.height+n):s===180?i.x=-n:s===225?(i.x=-n,i.y=-n):s===270?i.y=-n:s===315&&(i.x=t.naturalBounds.width+n,i.y=-n),t.getDocumentPoint(i)}doDeactivate(){let t=this.diagram;this.stopTransaction(),this.handle=null,this.Ms=null,this.zm=new P(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){let t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){let t=this.diagram;if(this.isActive){let e=this.computeRotate(t.lastInput.documentPoint);this.rotate(e)}}doMouseUp(){let t=this.diagram;if(this.isActive){t.delaysLayout=!1;let e=this.computeRotate(t.lastInput.documentPoint);this.rotate(e),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){let e=this.adornedObject;if(e===null||e.part===null)return;e.angle=t;let i=e.part;i.ensureBounds();let s=i.locationObject,n=i.rotateObject;if(s===n||s.isContainedBy(n)){let o=this.Oc.copy();i.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let e=this.rotationPoint.directionPoint(t)-this.handleAngle,i=this.adornedObject?.panel;i&&(e-=i.getDocumentAngle()),e=A.Ee(e);let s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(e%s<n?e=Math.floor(e/s)*s:e%s>s-n&&(e=(Math.floor(e/s)+1)*s)),A.Ee(e)}get snapAngleMultiple(){return this._S}set snapAngleMultiple(t){g.s(t,"number",qe,"snapAngleMultiple"),this._S=t}get snapAngleEpsilon(){return this.tM}set snapAngleEpsilon(t){g.s(t,"number",qe,"snapAngleEpsilon"),this.tM=t}get originalAngle(){return this.eM}get rotationPoint(){return this.zm}set rotationPoint(t){this.zm=t.copy()}get handleAngle(){return this.iM}set handleAngle(t){g.s(t,"number",qe,"handleAngle"),this.iM=t}get handleDistance(){return this.sM}set handleDistance(t){g.s(t,"number",qe,"handleDistance"),this.sM=t}}class bn extends ie{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class wn extends ie{Ic;constructor(t){super(),this.name="Action",this.Ic=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram,e=t.lastInput,i=t.findObjectAt(e.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return i!==null&&i.isActionable?(this.Ic=i,t.Dc=t.findObjectAt(e.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{let t=this.diagram.lastInput,e=this.Ic;if(e===null)return;t.targetObject=e,e.actionDown!==null&&e.actionDown(t,e)}}doMouseMove(){if(this.isActive){let t=this.diagram.lastInput,e=this.Ic;if(e===null)return;t.targetObject=e,e.actionMove!==null&&e.actionMove(t,e)}}doMouseUp(){if(this.isActive){let t=this.diagram.lastInput,e=this.Ic;if(e===null)return;t.targetObject=e,e.actionUp!==null&&e.actionUp(t,e),this.standardMouseClick(i=>{for(;i.panel!==null;){if(i.isActionable&&i===e)return i;i=i.panel}return i},i=>i===e)}this.stopTool()}doCancel(){let t=this.diagram.lastInput,e=this.Ic;e!==null&&(t.targetObject=e,e.actionCancel!==null&&e.actionCancel(t,e),this.stopTool())}doStop(){this.Ic=null}}class mi extends ie{Vl;nM;Rc;oM;constructor(t){super(),this.name="ClickCreating",this.Vl=null,this.nM=!0,this.Rc=!1,this.oM=new P(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.oM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.oM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){let t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){let e=this.diagram,i=this.archetypeNodeData;if(i===null)return null;let s=null;try{if(e.T("ChangingSelection",e.selection),this.startTransaction(this.name),i instanceof bt)i.Di()&&(i.It(),s=i.copy(),s!==null&&e.add(s));else if(i!==null){let n=e.model.copyNodeData(i);e.model.addNodeData(n),s=e.findPartForData(n)}if(s!==null){let n=P.z(t.x,t.y);this.isGridSnapEnabled&&this.diagram.rM(s,t,n),s.location=n,e.allowSelect&&(e.clearSelection(!0),s.isSelected=!0),P.i(n)}e.invalidateDocumentBounds(),this.transactionResult=this.name,e.T("PartCreated",s)}finally{this.stopTransaction(),e.T("ChangedSelection",e.selection)}return s}get archetypeNodeData(){return this.Vl}set archetypeNodeData(t){t!==null&&g.wc(t,mi,"archetypeNodeData"),this.Vl=t}get isDoubleClick(){return this.nM}set isDoubleClick(t){g.s(t,"boolean",mi,"isDoubleClick"),this.nM=t}get isGridSnapEnabled(){return this.Rc}set isGridSnapEnabled(t){g.s(t,"boolean",mi,"isGridSnapEnabled"),this.Rc=t}}class Oi extends ie{Qa;lM;Bl;constructor(t){super(),this.name="DragSelecting",this.Qa=175,this.lM=!1,this.Bl=new bt({layerName:"Tool",selectable:!1}).add(new at("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).It(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(!t.allowSelect)return!1;let e=t.lastInput;return!(!e.left||t.currentTool!==this&&(!this.isBeyondDragSize()||e.timestamp-t.firstInput.timestamp<this.delay||t.findPartAt(e.documentPoint,!0)!==null))}doActivate(){let t=this.diagram;this.isActive=!0,t.isMouseCaptured=!0,t.skipsUndoManager=!0,this.box&&t.add(this.box),this.doMouseMove()}doDeactivate(){let t=this.diagram;t.stopAutoScroll(),this.box&&t.remove(this.box),t.skipsUndoManager=!1,t.isMouseCaptured=!1,this.isActive=!1}doMouseMove(){let t=this.diagram;if(this.isActive&&this.box!==null){let e=this.computeBoxBounds(),i=this.box.findObject("SHAPE");i===null&&(i=this.box.findMainElement());let s=_.l().e(e.width,e.height);i!==null&&(i.desiredSize=s),this.box.Ec(e.x,e.y,!1),_.i(s),(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}doMouseUp(){if(this.isActive){let t=this.diagram;this.box&&t.remove(this.box);try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),this.selectInRect(this.computeBoxBounds()),t.T("ChangedSelection",t.selection)}finally{t.currentCursor=""}}this.stopTool()}computeBoxBounds(){let t=this.diagram;return new B(t.firstInput.documentPoint,t.lastInput.documentPoint)}selectInRect(t){let e=this.diagram,i=e.lastInput,s=e.findPartsIn(t,this.isPartialInclusion);if(g.ur?i.meta:i.control)if(i.shift){let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected&&(o.isSelected=!1)}}else{let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected=!o.isSelected}}else if(i.shift){let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected||(o.isSelected=!0)}}else{let n=new U,o=e.selection.iterator;for(;o.next();){let h=o.value;s.has(h)||n.add(h)}let r=n.iterator;for(;r.next();){let h=r.value;h.isSelected=!1}let a=s.iterator;for(;a.next();){let h=a.value;h.isSelected||(h.isSelected=!0)}}}get delay(){return this.Qa}set delay(t){g.s(t,"number",Oi,"delay"),this.Qa=t}get isPartialInclusion(){return this.lM}set isPartialInclusion(t){g.s(t,"boolean",Oi,"isPartialInclusion"),this.lM=t}get box(){return this.Bl}set box(t){t!==null&&t.It(),this.Bl=t}}class ts extends ie{Rx;LA;Ro;aM;constructor(t){super(),this.name="Panning",this.Rx=new P,this.LA=new P,this.Ro=!1;let e=this;this.aM=()=>{let i=e.diagram;i!==null&&i.Le(C.document,"scroll",e.aM,!1),e.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){let t=this.diagram;this.Ro?(t.lastInput.bubbles=!0,t.Et(C.document,"scroll",this.aM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Rx.h(t.position)),this.isActive=!0}doDeactivate(){let t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){let t=this.diagram;t.position=this.Rx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.AA()}doMouseUp(){this.AA(),this.stopTool()}AA(){let t=this.diagram;if(this.isActive&&t){if(this.Ro){t.lastInput.bubbles=!0;return}let e=t.position,i=t.firstInput.documentPoint,s=t.lastInput.documentPoint,n=e.x+i.x-s.x,o=e.y+i.y-s.y;t.allowHorizontalScroll||(n=e.x),t.allowVerticalScroll||(o=e.y),t.position=this.LA.e(n,o)}}get bubbles(){return this.Ro}set bubbles(t){g.s(t,"boolean",ts,"bubbles"),this.Ro=t}get originalPosition(){return this.Rx}}class Me{Ox;Ix;hM;cM;constructor(t){this.Ox=null,this.Ix=null,this.hM=null,this.cM=null,t&&Object.assign(this,t)}get mainElement(){return this.hM}set mainElement(t){t!==null&&g.se(t,HTMLElement,Me,"mainElement"),this.hM=t}get show(){return this.Ox}set show(t){this.Ox!==t&&(t!==null&&g.S(t,Me,"show"),this.Ox=t)}get hide(){return this.Ix}set hide(t){this.Ix!==t&&(t!==null&&g.S(t,Me,"hide"),this.Ix=t)}get valueFunction(){return this.cM}set valueFunction(t){this.cM=t}}class ke{ue;Ex;Uc;constructor(t,e,i){this.ue=t,this.Ex=e,this.Uc=i}}class Xt extends ie{fM;Ux;uM;dM;Vx;Bx;Xm;constructor(t){super(),this.name="ContextMenu",this.fM=null,this.Ux=null,this.uM=null,this.dM=new P,this.Vx=null,this.Xm=!1;let e=this;this.Bx=()=>e.stopTool(),t&&Object.assign(this,t)}xR(){let t=new Me;t.show=(r,a,h)=>h.showDefaultContextMenu(),t.hide=(r,a)=>a.hideDefaultContextMenu(),Xt.Bu=t;let e=this;this.Bx=()=>e.stopTool();let i=g.Ni("div"),s=g.Ni("div");i.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";let n=g.Ni("style");C.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);let o=this.diagram;o!==null&&(o.Et(i,"contextmenu",Xt.ih,!1),o.Et(i,"selectstart",Xt.ih,!1),o.Et(s,"contextmenu",Xt.ih,!1)),i.className="goCXforeground",s.className="goCXbackground",C.document.body&&(C.document.body.appendChild(i),C.document.body.appendChild(s)),Xt.Gm=i,Xt.Ym=s,Xt.gM=!0}static Bu=null;static gM=!1;static Ym;static Gm;static ih(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){let t=this.diagram;this.dM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Xm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);let e=this.diagram,i=e.lastInput,s=null;if(t instanceof j||(t instanceof tt?s=t:s=e.findObjectAt(i.documentPoint,null,n=>!n.layer?.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(e.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(e.contextMenu!==null)return e;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Mt){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Mt){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){let t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{let e=this.currentContextMenu;if(e===null)return;let i=null;e instanceof Me||(i=t.findObjectAt(t.lastInput.documentPoint,null,null),i!==null&&i.isContainedBy(e)&&this.standardMouseClick(null,null)),this.maybeStopTool(i)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,e){if(e===void 0&&(e=null),this.Xm)return;this.Xm=!0;let i=!1;if(e instanceof j){let s=this.diagram.lastInput;s.targetObject=null,i=this.oA(null,s,this.diagram)}else t&&this.standardMouseSelect(),i=this.standardMouseClick();if(this.Xm=!1,!i){this.isActive=!0;let s=Xt.Bu;if(e===null&&(e=this.findObjectWithContextMenu()),e!==null){let n=e.contextMenu;n!==null?(this.currentObject=e instanceof tt?e:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Mt&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,e){e!==null&&g.se(e,tt,Xt,"showContextMenu:obj");let i=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Mt){let s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/i.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=i.scale);let n=s.diagram;n!==null&&n!==i&&n.remove(s),i.add(s),e!==null?s.adornedObject=e:s.data=i.model,s.ensureBounds(),this.positionContextMenu(s,e)}else t instanceof Me&&t.show!==null&&t.show(e,i,this);this.currentContextMenu=t}positionContextMenu(t,e){if(t.hasPlaceholder())return;let i=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=i.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.x<r.x&&(n.x=r.x),n.y+o.height>r.bottom&&(n.y-=o.height+5/s.scale),n.y<r.y&&(n.y=r.y),i.position=n}hideContextMenu(){let t=this.diagram,e=this.currentContextMenu;e!==null&&(e instanceof Mt?(t.remove(e),this.Ux!==null&&this.Ux.removeAdornment(e.category),e.data=null,e.adornedObject=null):e instanceof Me&&(e.hide!==null?e.hide(t,this):e.mainElement!==null&&(e.mainElement.style.display="none")),this.currentContextMenu=null,this.standardMouseOver())}bR(){let t=this,e=new U;return e.add(new ke("Copy",i=>i.commandHandler.copySelection(),i=>i.commandHandler.canCopySelection())),e.add(new ke("Cut",i=>i.commandHandler.cutSelection(),i=>i.commandHandler.canCutSelection())),e.add(new ke("Delete",i=>i.commandHandler.deleteSelection(),i=>i.commandHandler.canDeleteSelection())),e.add(new ke("Paste",i=>i.commandHandler.pasteSelection(t.mouseDownPoint),i=>i.commandHandler.canPasteSelection(t.mouseDownPoint))),e.add(new ke("Select All",i=>i.commandHandler.selectAll(),i=>i.commandHandler.canSelectAll())),e.add(new ke("Undo",i=>i.commandHandler.undo(),i=>i.commandHandler.canUndo())),e.add(new ke("Redo",i=>i.commandHandler.redo(),i=>i.commandHandler.canRedo())),e.add(new ke("Scroll To Part",i=>i.commandHandler.scrollToPart(),i=>i.commandHandler.canScrollToPart())),e.add(new ke("Zoom To Fit",i=>i.commandHandler.zoomToFit(),i=>i.commandHandler.canZoomToFit())),e.add(new ke("Reset Zoom",i=>i.commandHandler.resetZoom(),i=>i.commandHandler.canResetZoom())),e.add(new ke("Group Selection",i=>i.commandHandler.groupSelection(),i=>i.commandHandler.canGroupSelection())),e.add(new ke("Ungroup Selection",i=>i.commandHandler.ungroupSelection(),i=>i.commandHandler.canUngroupSelection())),e.add(new ke("Edit Text",i=>i.commandHandler.editTextBlock(),i=>i.commandHandler.canEditTextBlock())),e}showDefaultContextMenu(){let t=this.diagram;this.Vx===null&&(this.Vx=this.bR()),Xt.Gm.innerHTML="",Xt.Ym.addEventListener("pointerdown",this.Bx,!1);let e=this,i=g.Ni("ul");i.className="goCXul",Xt.Gm.appendChild(i),i.innerHTML="";let s=this.Vx.iterator;for(;s.next();){let n=s.value,o=n.Ex,r=n.Uc;if(!g.nt(o)||g.nt(r)&&!r(t))continue;let a=g.Ni("li");a.className="goCXli";let h=g.Ni("a");h.className="goCXa",h.href="#",h.Ex=o,h.addEventListener("pointerdown",function(l){return this.Ex(t),e.stopTool(),l.preventDefault(),!1},!1),h.textContent=n.ue,a.appendChild(h),i.appendChild(a)}Xt.Gm.style.display="block",Xt.Ym.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==Xt.Bu)return;Xt.Gm.style.display="none",Xt.Ym.style.display="none";let t=this.diagram;t!==null&&t.Le(Xt.Ym,"pointerdown",this.Bx,!1),this.currentContextMenu=null}doMouseWheel(){this.standardMouseWheel()}get currentContextMenu(){return this.fM}set currentContextMenu(t){this.fM=t,this.Ux=t instanceof Mt?t.adornedPart:null}get defaultTouchContextMenu(){return Xt.gM===!1&&Xt.Bu===null&&j.isUsingDOM()&&this.xR(),Xt.Bu}set defaultTouchContextMenu(t){t===null&&(Xt.gM=!0),Xt.Bu=t}get currentObject(){return this.uM}set currentObject(t){t!==null&&g.se(t,tt,Xt,"currentObject"),this.uM=t}get mouseDownPoint(){return this.dM}}var vn=(x=>(x[x.LostFocus=1]="LostFocus",x[x.MouseDown=2]="MouseDown",x[x.Tab=3]="Tab",x[x.Enter=4]="Enter",x))(vn||{}),kn=(x=>(x[x.SingleClick=1]="SingleClick",x[x.SingleClickSelected=2]="SingleClickSelected",x[x.DoubleClick=3]="DoubleClick",x))(kn||{}),Pn=(x=>(x[x.None=1]="None",x[x.Active=2]="Active",x[x.Editing=3]="Editing",x[x.Validating=4]="Validating",x[x.Invalid=5]="Invalid",x[x.Validated=6]="Validated",x))(Pn||{});class fe extends ie{vi;mM;pM;zl;Gt;yM;wM;xM;zx;Xx;constructor(t){super(),this.name="TextEditing",this.vi=new gt,this.mM=null,this.pM=2,this.zl=null,this.Gt=1,this.yM=1,this.wM=!0,this.xM=null,this.zx=new Me,this.Xx=null,this.kR(this.zx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;kR(t){if(!j.isUsingDOM())return;let e=g.Ni("textarea");this.Xx=e;let i=this;e.addEventListener("input",function(s){if(i.textBlock===null)return;let n=i.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(i.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(i.textBlock.lineCount,n.lineCount)},!1),e.addEventListener("keydown",function(s){if(s.isComposing||i.textBlock===null)return;let n=s.key;if(n==="Enter"){i.textBlock.isMultiline===!1&&s.preventDefault(),i.acceptText(4);return}else if(n==="Tab"){i.acceptText(3),s.preventDefault();return}else n==="Escape"&&(i.doCancel(),i.diagram!==null&&i.diagram.doFocus())},!1),e.addEventListener("focus",function(s){i.PR(s)},!1),e.addEventListener("blur",function(s){i.SR(s)},!1),t.valueFunction=()=>e.value,t.mainElement=e,t.show=(s,n,o)=>{if(!(s instanceof gt)||!n||!n.div||!(o instanceof fe))return;if(o.state===5){e.style.border="3px solid red",e.focus();return}let r=s.getDocumentPoint(T.Center),a=n.position,h=n.scale,l=s.getDocumentScale()*h;l<o.minimumEditorScale&&(l=o.minimumEditorScale);let c=s.naturalBounds.width*l+6,u=s.naturalBounds.height*l+2,d=(r.x-a.x)*h,f=(r.y-a.y)*h,p=s.verticalAlignment,m=(s.lineHeight+s.spacingAbove+s.spacingBelow)*s.lineCount*l,y=.5*u-.5*m,b=p.y*u-p.y*m+p.offsetY-y-m/2;e.value=s.text,n.div.style.font=s.font;let v=1;e.style.position="absolute",e.style.zIndex="100",e.style.font="inherit",e.style.fontSize=l*100+"%",e.style.lineHeight="normal",e.style.width=c+"px",e.style.left=(d-c/2|0)-v+"px",e.style.top=(f+b|0)-v+"px",e.style.textAlign=s.textAlign,e.style.margin="0",e.style.padding=v+"px",e.style.border="0",e.style.outline="none",e.style.whiteSpace="pre-wrap",e.style.overflow="hidden",e.rows=s.lineCount,e.textScale=l,e.className="goTXarea",n.div.appendChild(e),e.focus(),o.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))},t.hide=(s,n)=>{s.div&&s.div.removeChild(e)}}get textBlock(){return this.mM}set textBlock(t){t!==null&&g.se(t,gt,fe,"textBlock"),this.mM=t}get currentTextEditor(){return this.xM}set currentTextEditor(t){this.xM=t}get defaultTextEditor(){return this.zx}set defaultTextEditor(t){this.zx=t}get starting(){return this.pM}set starting(t){this.pM=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||t.isReadOnly||fe.Vc&&fe.Vc!==this&&(fe.Vc.acceptText(2),fe.Vc&&fe.Vc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;let e=t.lastInput.documentPoint,i=t.findObjectAt(e);if(i===null||!(i instanceof gt)||!i.editable||i.part===null||!i.part.canEdit())return!1;let s=i.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){fe.Vc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;let t=this.diagram;if(t===null)return;let e=this.textBlock;if(e===null&&(e=t.findObjectAt(t.lastInput.documentPoint)),e===null||!(e instanceof gt)||(this.textBlock=e,e.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Gt=2;let i=this.defaultTextEditor;e.textEditor!==null&&(i=e.textEditor),this.vi=this.textBlock.copy();let s=new B(this.textBlock.getDocumentPoint(T.TopLeft),this.textBlock.getDocumentPoint(T.BottomRight));t.scrollToRect(s),i!==null&&i.show!==null&&i.show(e,t,this),this.currentTextEditor=i}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Gt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Gt===2||this.Gt===5||this.Gt===3)&&(this.Gt=4,this.TA());break;case 1:case 4:case 3:if(t===4&&this.textBlock!==null&&this.textBlock.isMultiline===!0)return;(this.Gt===2||this.Gt===5||this.Gt===3)&&(this.Gt=4,this.TA());break}}TA(){let t=this.textBlock,e=this.diagram,i=this.currentTextEditor;if(t!==null&&i!==null){let s=t.text,n="";if(i.valueFunction!==null&&(n=i.valueFunction()),!this.isValidText(t,s,n)){this.Gt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Gt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),e!==null&&e.T("TextEdited",t,s),this.stopTransaction(),this.stopTool(),e!==null&&e.doFocus()}}doError(t,e){let i=this.textBlock;if(i===null)return;i.errorFunction!==null&&i.errorFunction(this,t,e);let s=this.currentTextEditor;s!==null&&s.show!==null&&s.show(i,this.diagram,this)}doSuccess(t,e){let i=this.textBlock;i!==null&&i.textEdited!==null&&i.textEdited(i,t,e)}doDeactivate(){let t=this.diagram;if(t!==null){if(this.Gt=1,this.currentTextEditor!==null){let e=this.currentTextEditor;e!==null&&e.hide!==null&&e.hide(t,this)}this.textBlock=null,this.isActive=!1}}doStop(){fe.Vc=null}PR(t){if(this.currentTextEditor===null||this.state===1)return;let e=this.Xx;this.Gt===2&&(this.Gt=3),g.nt(e.select)&&this.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))}SR(t){if(this.currentTextEditor===null||this.state===1)return;let e=this.Xx;g.nt(e.focus)&&e.focus(),g.nt(e.select)&&this.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))}isValidText(t,e,i){let s=this.textValidation;if(s!==null&&!s(t,e,i))return!1;let n=t.textValidation;return!(n!==null&&!n(t,e,i))}get textValidation(){return this.zl}set textValidation(t){t!==null&&g.S(t,fe,"textValidation"),this.zl=t}get minimumEditorScale(){return this.yM}set minimumEditorScale(t){t!==null&&g.s(t,"number",fe,"minimumEditorScale"),this.yM=t}get selectsTextOnActivate(){return this.wM}set selectsTextOnActivate(t){t!==null&&g.s(t,"boolean",fe,"selectsTextOnActivate"),this.wM=t}get state(){return this.Gt}set state(t){this.Gt!==t&&(this.Gt=t)}measureTemporaryTextBlock(t){let e=this.vi;return e.text=t,this.textBlock!==null&&e.ht(this.textBlock.Xl,1/0),e}static Vc=null}var Sn=(x=>(x[x.Default=1]="Default",x[x.AnimateLocations=2]="AnimateLocations",x[x.None=3]="None",x))(Sn||{});class be{a;Ae;Be;Tr;_n;Io;bM;kM;Km;Gx;ke;Bc;bn;Hm;nh;Yx;jm;Kx;zc;Uu;qm;constructor(t){this.a=j.Rm(),this.Ae=!1,this.Km=!1,this.Gx=!1,this.ke=!1,this.Bc=!1,this.Kx=!0,this.zc=1,this.Uu=!1,this.Be=!0,this.Tr=!0,this.Io=600,this.bM=!1,this.kM=!1,this._n=new I,this.bn=new Te,this.Hm=new Te,this.bn.Ns=this,this.nh=new I,this.Yx=new I,this.jm=new I,this.qm=new I,t&&Object.assign(this,t)}Eo(t){this.a=t}RU(){return this.a}canStart(t){return!0}Gl(t){return!this.Be||!this.canStart(t)?!1:(this._n.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.a.Te(),this.ke=!0,!0)}getBundleAnimation(){return this.Hm}PM(){if(!this.Be||(this.Hm.pi.count>0&&this.Hm.start(),!this.ke))return;let t=this.bn,e=this.a,i=this._n.has("Model");if(i&&(this.Bc=!0,this.zc===1?(t.isViewportUnconstrained=!0,t.pi.clear(),t.add(e,"position",e.position.copy().offset(0,-200),e.position),t.add(e,"opacity",0,1)):this.zc===3&&t.pi.clear(),this.zc===2&&e.Hx.equals(e.ct)?this.Kx=!0:this.Kx=!1,e.T("InitialAnimationStarting",this)),i&&!this.Tr||t.pi.count===0){this._n.clear(),this.ke=!1,t.pi.clear(),t.jx(e),this.Bc=!1,e.C();return}this._n.clear(),e.Dr=!1;let s=t.pi.get(e);e.autoScale!==1&&s!==null&&(delete s.ae.scale,delete s.Cs.scale);let n=this;C.requestAnimationFrame(()=>{n.ke===!1||t.Ae||(e.getRenderingHint("temporaryPixelRatio")&&e.Nx(),e.SM(),n.ke=!1,t.start(),t.Ae&&(n.zu(),e.invalidateDocumentBounds(),t.DA(0),e.Sr(!0),n.Xu(),e.T("AnimationStarting",n)))})}MM(){return this._n.has("Trigger")&&this._n.count===1}vA(t,e,i,s){this.isTicking||this.MM()||t instanceof q&&(t.fromNode!==null||t.toNode!==null)||this.bn.add(t,"position",e,i,s)}qx(t){return this.bn.qx(t)}NM(t){return this.bn.NM(t)}MR(t){let e=this.nh,i=this;function s(){if(i.jm.count>0&&(e.addAll(i.jm),i.jm.clear(),i.Ae=!0),i.Ae===!1||e.count===0){i.Gx=!1;return}i.Yx.addAll(e);let n=i.Yx.iterator;for(;n.next();){let o=n.value;o.Ae!==!1&&(o.NR()?o.FA(!1):o.Xc=!0)}if(i.Yx.clear(),i.Ae===!1){C.requestAnimationFrame(s);return}i.zu(),i.a.Sr(),i.Xu(),C.requestAnimationFrame(s)}this.Ae?this.RA(t):(this.Ae=!0,this.Gx?this.RA(t):(this.Gx=!0,e.add(t),C.requestAnimationFrame(()=>s())))}RA(t){this.jm.add(t)}CR(){let t=this.nh.iterator;for(;t.next();)t.value.Xc=!1}zu(){if(this.Km)return;let t=this.a;this.bM=t.skipsUndoManager,this.kM=t.yi,t.skipsUndoManager=!0,t.yi=!0,this.Km=!0}Xu(){let t=this.a;t.skipsUndoManager=this.bM,t.yi=this.kM,this.Km=!1}stopAnimation(t){let e=this.bn;if(this.ke===!0&&(this.ke=!1,this.Bc=!1,this._n.clear(),e.LR()&&this.a.requestUpdate()),!this.Ae){e.pi.clear(),e.jx(this.a);return}if(e.Gu(!0),e.jx(null),t===!0){let i=this.nh.toArray();for(let s=0;s<i.length;s++)i[s].Gu(!0)}}Gu(t){this.nh.delete(t),this.nh.count===0&&(this.Ae=!1,this.a.requestUpdate()),t===this.defaultAnimation&&this.a.T("AnimationFinished",this)}Gc(t,e){this.ke&&(!this._n.has("Expand Tree")&&!this._n.has("Expand SubGraph")||(this.bn.Gc(t,e),this.OA(t)))}Yc(t,e){this.ke&&(!this._n.has("Collapse Tree")&&!this._n.has("Collapse SubGraph")||(this.bn.Yc(t,e),this.bn.CM(e,"position",e.position,e.position),this.OA(t)))}IA(t,e){!this.ke||t.equals(e)||this.MM()||(this.a.$a||(t=e.copy()),this.bn.CM(this.a,"position",t,e))}EA(t,e){this.ke&&(this.MM()||this.bn.add(this.a,"scale",t,e))}LM(t,e){t.Fi&&(t.vr=e,this.qm.add(t))}OA(t){let e=t.findLinksConnected();for(;e.next();){let i=e.value;i.Fi&&(i.vr=i.points.copy(),this.qm.add(i))}}get isEnabled(){return this.Be}set isEnabled(t){g.s(t,"boolean",be,"isEnabled"),this.Be=t,t&&this.nh.each(e=>{!e.isAnimating&&e.runCount===1/0&&e.start()})}get duration(){return this.Io}set duration(t){g.s(t,"number",be,"duration"),t<1&&g.J(t,">= 1",be,"duration"),this.Io=t}get isAnimating(){return this.Ae}get isTicking(){return this.Km}get isInitial(){return this.Tr}set isInitial(t){g.s(t,"boolean",be,"isInitial"),this.Tr=t}get defaultAnimation(){return this.bn}get activeAnimations(){return this.nh}get initialAnimationStyle(){return this.zc}set initialAnimationStyle(t){this.zc=t}static Wx=new wt;static defineAnimationEffect(t,e){be.Wx.set(t,e)}static AM(t,e,i,s,n){t===null&&(t=[0,0,0,0]),e===null&&(e=[0,0,0,0]);let o=t[0],r=t[1],a=t[2],h=t[3],l=e[0],c=e[1],u=e[2],d=e[3];a===0||a===100?(o=l,r=c):(u===0||u===100)&&(l=o,c=r),Math.abs(l-o)>180&&(l>o?o+=360:l+=360);let f=n(i,o,l-o,s)%360,p=n(i,r,c-r,s),m=n(i,a,u-a,s),y=n(i,h,d-h,s);return"hsla("+f+", "+p+"%, "+m+"%, "+y+")"}static Default=1;static AnimateLocations=2;static None=3}{let x=be.Wx,t=(e,i,s,n,o,r)=>{e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))};x.set("position:diagram",t),x.set("position",t),x.set("position:part",(e,i,s,n,o,r)=>{o<r?e.Ec(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!1):e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("location",(e,i,s,n,o,r)=>{o<r?e.Ec(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!0):e.location=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("position:placeholder",(e,i,s,n,o,r)=>{o<r?e.Ec(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!1):e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("position:nodeCollapse",(e,i,s,n,o,r)=>{let a=e.actualBounds,h=s.actualBounds,l=h.x+h.width/2-a.width/2,c=h.y+h.height/2-a.height/2;o<r?e.Ec(n(o,i.x,l-i.x,r),n(o,i.y,c-i.y,r),!1):e.position=new P(n(o,i.x,l-i.x,r),n(o,i.y,c-i.y,r))}),x.set("desiredSize",(e,i,s,n,o,r)=>{e.desiredSize=new _(n(o,i.width,s.width-i.width,r),n(o,i.height,s.height-i.height,r))}),x.set("width",(e,i,s,n,o,r)=>{e.width=n(o,i,s-i,r)}),x.set("height",(e,i,s,n,o,r)=>{e.height=n(o,i,s-i,r)}),x.set("fill",(e,i,s,n,o,r)=>{e.fill=be.AM(i,s,o,r,n)}),x.set("stroke",(e,i,s,n,o,r)=>{e.stroke=be.AM(i,s,o,r,n)}),x.set("strokeWidth",(e,i,s,n,o,r)=>{e.strokeWidth=n(o,i,s-i,r)}),x.set("strokeDashOffset",(e,i,s,n,o,r)=>{e.strokeDashOffset=n(o,i,s-i,r)}),x.set("background",(e,i,s,n,o,r)=>{e.background=be.AM(i,s,o,r,n)}),x.set("opacity",(e,i,s,n,o,r)=>{e.opacity=n(o,i,s-i,r)}),x.set("scale",(e,i,s,n,o,r)=>{e.scale=n(o,i,s-i,r)}),x.set("angle",(e,i,s,n,o,r)=>{e.angle=n(o,i,s-i,r)})}class Te{Jx;Wm;Ae;Yu;Io;Ls;UA;Kc;pi;$x;ae;to;Ku;Hc;Zx;Qx;Xc;TM;_x;Ns;a;DM;vM;FM;constructor(t){this.a=null,this.Ns=null,this.TM=null,this._x=null,this.DM=!1,this.Ae=!1,this.Xc=!1,this.ae=0,this.to=0,this.Jx=Te.EaseInOutQuad,this.Wm=Te.EaseInOutQuad,this.Ku=!1,this.Hc=!1,this.Zx=1,this.Qx=0,this.Io=NaN,this.Ls=NaN,this.vM=0,this.Yu=null,this.UA=P.gn,this.pi=new wt,this.$x=new wt,this.Kc=new I,this.FM=1,t&&Object.assign(this,t)}suspend(){this.Xc=!0}advanceTo(t,e){e&&(this.Xc=!1),this.Ku&&t>=this.Ls&&(this.Hc=!0,t=t-this.Ls),this.vM=t,this.FA(!0),this.Ns.zu(),this.a.Sr(),this.Ns.Xu(),this.a.redraw()}jx(t){if(this.$x.clear(),this.Hc=!1,this.Qx=0,this.Ls=NaN,this.Kc.count>0&&this.Kc.clear(),t!==null){let e=t.links;for(;e.next();)e.value.vr=null}}LR(){return this.pi.count>0}start(){if(this.pi.count===0)return this;if(this.Ae)return this;let t=this.a,e=this.pi.iterator;for(;e.next();){let s=e.key;t===null&&(s instanceof j?t=s:s instanceof tt&&(t=s.diagram))}if(t!==null)this.a=t,this.Ns=t.animationManager;else return this;let i=this.Ns;return i.isEnabled===!1?this:(this.Ls=isNaN(this.Io)?i.duration:this.Io,this.Wm=this.Jx,i.Bc&&i.zc===1&&this===i.defaultAnimation&&(this.Wm=Te.EaseOutExpo,this.Ls=isNaN(this.Io)?i.duration===600?900:i.duration:this.Io),this.FM=t.scrollMode,this.isViewportUnconstrained&&(t.oh=2),i.zu(),this.Kc.each(s=>{s.data=null,t.add(s)}),i.Xu(),this.Ae=!0,this.ae=+new Date,this.to=this.ae+this.Ls,i.MR(this),this)}addTemporaryPart(t,e){return t.Di()?(this.Kc.add(t),this.a=e,this):this}add(t,e,i,s,n){if(this.a===null&&(t instanceof j?this.a=t:t instanceof tt&&t.diagram!==null&&(this.a=t.diagram)),t instanceof bt){if(!t.isAnimated)return this;e==="position"&&(e="position:part")}return this.CM(t,e,i,s,n),this}CM(t,e,i,s,n){let o=this.pi,r,a,h;if(t instanceof j&&e==="position"&&(e="position:diagram"),(e==="fill"||e==="stroke"||e==="background")&&(E.Uo(i),E.RM(),i=[E.ze.n0,E.ze.n1,E.ze.n2,E.ze.n3],E.Uo(s),E.RM(),s=[E.ze.n0,E.ze.n1,E.ze.n2,E.ze.n3]),o.has(t))r=o.get(t),a=r.ae,h=r.Cs,a[e]===void 0&&(a[e]=this.Hu(i)),h[e]=this.Hu(s);else{if(e==="position"&&i.equalsApprox(s))return;a={},h={},a[e]=this.Hu(i),h[e]=this.Hu(s),r=new Qo(a,h,n),o.set(t,r)}let l=a[e];l instanceof P&&!l.isReal()&&l.h(this.UA),n&&e.indexOf("position:")===0&&t instanceof bt?r.tb.location=this.Hu(t.location):n&&(r.tb[e]=this.Hu(i))}Hu(t){return t instanceof P||t instanceof _?t.copy():t}AR(t){let e=this.pi;if(e.has(t)){let i=e.get(t);i.eb=!0}}qx(t){if(!this.Ae)return!1;let e=this.pi.get(t);return e!==null&&e.eb}NM(t){if(!this.Ae)return!1;let e=this.pi.get(t);return e!==null&&!!(e.ae.position||e.ae["position:part"]||e.ae.location)}NR(){if(this.Kc.count>0)return!0;let t=this.pi.iterator;for(;t.next();){let e=t.key;if(e instanceof tt&&e.diagram!==null||e instanceof j)return!0}return!1}FA(t){if(this.Xc&&!t)return;let e=this.Ns;if(this.Ae===!1)return;let i=+new Date,s=i>this.to?this.Ls:i-this.ae;t&&(s=this.vM,s<this.Ls?(this.ae=+new Date-s,this.to=this.ae+this.Ls):s=this.Ls),e.zu(),this.DA(s),this.a.Sr(!0),e.Xu(),i>this.to&&(this.Ku&&!this.Hc?(this.ae=+new Date,this.to=this.ae+this.Ls,this.Hc=!0):this.Gu(!1))}DA(t){let e=this.Ls,i=this.pi.iterator,s=this.Hc;for(;i.next();){let n=i.key;if(n instanceof tt&&n.diagram===null)continue;let o=i.value,r=s?o.Cs:o.ae,a=s?o.ae:o.Cs,h=be.Wx;for(let l in a)l==="position"&&(a["position:placeholder"]||a["position:nodeCollapse"])||h.get(l)!==null&&h.get(l)(n,r[l],a[l],this.Wm,t,e,this)}}stop(){return this.Ae?(this.Gu(!0),this):this}Gu(t){if(this._x!==null&&this._x.TR(this.TM),!this.Ae)return;let e=this.a,i=this.Ns;i.Bc=!1,this.Ae=!1,this.Xc=!1,i.zu();let s=this.pi,n=this.Kc.iterator;for(;n.next();)e.remove(n.value);let o=this.Ku,r=s.iterator,a=be.Wx;for(;r.next();){let l=r.key,c=r.value,u=o?c.Cs:c.ae,d=o?c.ae:c.Cs,f=c.tb;for(let p in d)if(a.get(p)!==null){let m=p;c.ib&&(m==="position:nodeCollapse"||m==="position:placeholder")&&(m="position"),a.get(m)(l,u[p],f[p]!==void 0?f[p]:c.ib?u[p]:d[p],this.Wm,this.Ls,this.Ls,this)}c.ib&&f.location!==void 0&&l instanceof bt&&(l.location=f.location),c.eb&&l instanceof bt&&l.Xe(!1)}this.Qx++;let h=!t&&this.Zx>this.Qx;if(!h&&(this===i.Hm||this===i.defaultAnimation)&&this.pi.clear(),e.sb.clear(),e.pS(!1),e.invalidateDocumentBounds(),e.C(),e.Sr(!0),i.defaultAnimation===this){let l=i.qm.iterator;for(;l.next();)l.value.DR();i.qm.clear()}if(e.Sr(!0),this.isViewportUnconstrained&&(e.scrollMode=this.FM),i.Xu(),h){this.Hc=!1,this.start();return}this.jx(null),e.VA(),i.Gu(this),this.Yu&&this.Yu(this),e.requestUpdate()}Gc(t,e){let i=e.actualBounds,s=null;if(e instanceof ft&&(s=e.placeholder),s!==null&&s.visible){let n=s.getDocumentPoint(T.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new P(i.x+i.width/2,i.y+i.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof ft&&this.vR(t,e)}vR(t,e){let i=t.memberParts;for(;i.next();){let s=i.value;s instanceof it&&this.Gc(s,e)}}Yc(t,e){if(!t.isVisible())return;let i=null;if(e instanceof ft&&(i=e.placeholder),i!==null&&i.visible){let s=i.getDocumentPoint(T.TopLeft),n=i.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,e,!0);this.add(t,"scale",t.scale,.01,!0),this.AR(t),t instanceof ft&&this.FR(t,e)}FR(t,e){let i=t.memberParts;for(;i.next();){let s=i.value;s instanceof it&&this.Yc(s,e)}}get duration(){return this.Io}set duration(t){g.s(t,"number",Te,"duration"),t<1&&g.J(t,">= 1",Te,"duration"),this.Io=t}get reversible(){return this.Ku}set reversible(t){this.Ku=t}get runCount(){return this.Zx}set runCount(t){t>0?this.Zx=t:g.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Yu}set finished(t){this.Yu!==t&&(t!==null&&g.S(t,Te,"finished"),this.Yu=t)}get easing(){return this.Jx}set easing(t){this.Jx=t}get isViewportUnconstrained(){return this.DM}set isViewportUnconstrained(t){this.DM=t}get isAnimating(){return this.Ae}getTemporaryState(t){let e=this.$x.get(t);return e===null&&(e={},this.$x.set(t,e)),e}static EaseLinear=(t,e,i,s)=>i*t/s+e;static EaseInOutQuad=(t,e,i,s)=>(t/=s/2,t<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e);static EaseInQuad=(t,e,i,s)=>i*(t/=s)*t+e;static EaseOutQuad=(t,e,i,s)=>-i*(t/=s)*(t-2)+e;static EaseInExpo=(t,e,i,s)=>t===0?e:i*Math.pow(2,10*(t/s-1))+e;static EaseOutExpo=(t,e,i,s)=>t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}class Qo{ae;Cs;tb;ib;eb;constructor(t,e,i){this.ae=t,this.Cs=e,this.tb={},this.ib=i,this.eb=!1}}var Mn=(x=>(x[x.Default=1]="Default",x[x.Immediate=2]="Immediate",x[x.Bundled=3]="Bundled",x))(Mn||{});class Ri{Ti;yn;ju;jc;constructor(t,e,i){this.Ti=null,this.yn=t,this.ju=i||1,this.jc=null,e!==void 0&&(this.jc=e,i===void 0&&(this.ju=2))}copy(){let t=new Ri(this.yn);t.ju=this.ju;let e=this.jc;if(e!==null){let i={};e.duration!==void 0&&(i.duration=e.duration),e.finished!==void 0&&(i.finished=e.finished),e.easing!==void 0&&(i.easing=e.easing),t.jc=i}return t}get propertyName(){return this.yn}set propertyName(t){this.yn=t}get animationSettings(){return this.jc}set animationSettings(t){this.jc=t}RR(t){let e=this.jc;e!==null&&(e.duration&&(t.duration=e.duration),e.finished&&(t.finished=e.finished),e.easing&&(t.easing=e.easing))}get startCondition(){return this.ju}set startCondition(t){this.ju=t}static Default=1;static Immediate=2;static Bundled=3}class Vt{a;Pt;Zt;Fr;Yl;Kl;Hl;jl;ql;Wl;Jl;$l;Zl;Ql;_l;ta;Uc;ea;nb;Jm;qu;Ct;constructor(t){I.Je(this),this.a=null,this.Ct=new U,this.Pt="",this.Zt=1,this.Fr=!1,this.Yl=!0,this.Kl=!0,this.Hl=!0,this.jl=!0,this.ql=!0,this.Wl=!0,this.Jl=!0,this.$l=!0,this.Zl=!0,this.Ql=!0,this._l=!0,this.ta=!0,this.Uc=!0,this.ea=!0,this.nb=!0,this.Jm=!1,this.qu=[],t&&Object.assign(this,t)}OR(){let t=this.Ct;for(let e=0;e<t.length;e++)t.r[e].OM(null);t.clear(),this.qu.length=0}Eo(t){this.a=t}toString(t){t===void 0&&(t=0);let e='Layer "'+this.name+'"';if(t<=0)return e;let i=0,s=0,n=0,o=0,r=0,a=this.Ct.iterator;for(;a.next();){let l=a.value;l instanceof ft?n++:l instanceof it?s++:l instanceof q?o++:l instanceof Mt?r++:i++}let h="";if(i>0&&(h+=i+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){let l=this.Ct.iterator;for(;l.next();){let c=l.value;h+=`
8
+ `+c.toString();let u=c.data;u!==null&&I.xs(u)&&(h+=" #"+I.xs(u)),c instanceof it?h+=" "+g.toString(u):c instanceof q&&(h+=" "+g.toString(c.fromNode)+" "+g.toString(c.toNode))}}return e+" "+this.Ct.count+": "+h}findObjectAt(t,e,i){if(e===void 0&&(e=null),i===void 0&&(i=null),this.ea===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);let n=P.l(),o=this.Ct.r,r=o.length;for(let a=r;a--;){let h=o[a];if(s===!0&&h.Ul()===!1||!h.isVisible())continue;n.h(t),n.Ki(h.Js);let l=h.BA(n,e,i);if(l!==null&&(e!==null&&(l=e(l)),l!==null&&(i===null||i(l))))return P.i(n),l}return P.i(n),null}findObjectsAt(t,e,i,s){if(e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof U)&&!(s instanceof I)&&(s=new I),this.ea===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);let o=P.l(),r=this.Ct.r,a=r.length;for(let h=a;h--;){let l=r[h];if(n===!0&&l.Ul()===!1||!l.isVisible())continue;o.h(t),o.Ki(l.Js);let c=l;l.zA(o,e,i,s)&&(e!==null&&(c=e(c)),c!==null&&(i===null||i(c))&&s.add(c))}return P.i(o),s}findObjectsIn(t,e,i,s,n){if(e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof U)&&!(n instanceof I)&&(n=new I),this.ea===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);let r=this.Ct.r,a=r.length;for(let h=a;h--;){let l=r[h];if(o===!0&&l.Ul()===!1||!l.isVisible())continue;let c=l;l.$m(t,e,i,s,n)&&(e!==null&&(c=e(c)),c!==null&&(i===null||i(c))&&n.add(c))}return n}SS(t,e,i,s,n,o,r){if(this.ea===!1)return n;let a=this.Ct.r,h=a.length;for(let l=h;l--;){let c=a[l];if(r===!0&&c.Ul()===!1||!o(c)||!c.isVisible())continue;let u=c;c.$m(t,e,i,s,n)&&(e!==null&&(u=e(u)),u!==null&&(i===null||i(u))&&n.add(u))}return n}findObjectsNear(t,e,i,s,n,o){if(i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof U||n instanceof I)&&(o=n),n=!0),!(o instanceof U)&&!(o instanceof I)&&(o=new I),this.ea===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);let a=P.l(),h=P.l(),l=this.Ct.r,c=l.length;for(let u=c;u--;){let d=l[u];if(r===!0&&d.Ul()===!1||!d.isVisible())continue;a.h(t),a.Ki(d.Js),h.e(t.x+e,t.y),h.Ki(d.Js);let f=d;d.XA(a,h,i,s,n,o)&&(i!==null&&(f=i(f)),f!==null&&(s===null||s(f))&&o.add(f))}return P.i(a),P.i(h),o}IM(){return this.Ct.r}As(t,e){if(!this.visible)return;let i=this.Ct.r,s=i.length;if(s===0)return;let n=g.ot(),o=g.ot();for(let r=0;r<s;r++){let a=i[r];if(a.EM=r,a instanceof q){if(a.Fi===!1)continue}else if(a instanceof Mt&&a.adornedPart!==null)continue;let h=a.actualBounds;a.isVisible()&&h.UL(e,10)?(a.As(!0),n.push(a)):(a.As(!1),a.adornments!==null&&a.adornments.count>0&&o.push(a))}for(let r=0;r<n.length;r++){let a=n[r];a.UM();let h=a.adornments;for(;h.next();){let l=h.value;l.ht(1/0,1/0),l.Ut(),l.As(!0)}}for(let r=0;r<o.length;r++)o[r].UM();g.Z(n),g.Z(o)}Wu(t){let e=1;return this.Zt!==1&&(e=t.globalAlpha,t.globalAlpha=e*this.Zt),e}GA(t,e){for(let i=0;i<e;i++)t[i].qc()}Ge(t,e,i){if(!this.visible||this.Zt===0||(i===void 0&&(i=!0),!i&&this.isTemporary))return;let s=this.Ct.r,n=s.length;if(n===0)return;t.Fr&&this.GA(s,n);let o=this.Wu(t),r=this.qu;r.length=0;let a=e.scale,h=B.l();for(let l=0;l<n;l++){let c=s[l];this.Zm(t,c,e,r,a,h,!0)}B.i(h),t.Fr&&this.GA(s,n),t.globalAlpha=o}OU(t,e,i){if(!this.visible||this.Zt===0)return;let s=this.Ct.r,n=s.length;if(n===0)return;let o=this.Wu(t),r=this.qu;r.length=0;let a=e.scale,h=B.l();for(let l=0;l<n;l++){let c=s[l];i.has(c)||this.Zm(t,c,e,r,a,h,!0)}B.i(h),t.globalAlpha=o}IR(t,e,i,s){if(!this.visible||this.Zt===0||!s&&this.isTemporary)return;let n=this.Ct.r,o=n.length;if(o===0)return;let r=this.Wu(t),a=this.qu;a.length=0;let h=e.scale,l=B.l();for(let c=0;c<o;c++){let u=n[c];i.has(u)&&this.Zm(t,u,e,a,h,l,!1)}B.i(l),t.globalAlpha=r}ER(t,e,i,s,n){if(!this.visible||this.opacity===0)return;let o=this.diagram.grid.part;if(!s&&this.isTemporary){if(n&&o.layer===this){let r=this.Wu(t);o.Ge(t,i),t.globalAlpha=r}}else{let r=this.Wu(t),a=i.scale,h=B.l(),l=this.Ct.r,c=l.length;for(let u=0;u<c;u++){let d=l[u];!n&&d===o||this.Zm(t,d,i,null,a,h,!1)}B.i(h),t.globalAlpha=r}}IU(t,e,i){if(!this.visible||this.Zt===0)return;let s=this.Wu(t),n=this.qu;n.length=0;let o=e.scale,r=B.l(),a=this.Ct.r,h=a.length,l=i.length;for(let c=0;c<h;c++){let u=a[c],d=u.lh(u.actualBounds);this.UR(d,i,l,o)&&this.Zm(t,u,e,n,o,r,!0)}B.i(r),t.globalAlpha=s}Zm(t,e,i,s,n,o,r){if(r&&!e.Ul()){t.removePartFromView(e);return}if(s!==null&&e instanceof q&&(e.isOrthogonal&&s.push(e),e.Fi===!1)){t.removePartFromView(e);return}let a=!1,h=e.containingGroup;for(;h!==null;)a?h.he!==null&&o.intersectRect(h.he):h.he!==null&&(a=!0,o.h(h.he)),h=h.containingGroup;let l=e.actualBounds,c=!1;if(a&&e.isVisible()){if(!o.intersectsRect(l)){t.removePartFromView(e);return}c=!o.containsRect(l)}c&&(t.save(),t instanceof ge?t.partClipRect=o.copy():(t.beginPath(),t.rect(o.x,o.y,o.width,o.height),t.clip())),l.width*n>i.Qm||l.height*n>i.Qm?e.Ge(t,i):this.VR(t,e,i),c&&(t.restore(),t.clearContextCache(!0))}VR(t,e,i){if(t instanceof ge){e.Ge(t,i);return}let s=e.actualBounds,n=e.naturalBounds;if(s.width===0||s.height===0||isNaN(s.x)||isNaN(s.y)||!e.isVisible())return;let o=e.v;if(e.background===null){e.kn(t,"rgba(0,0,0,0.3)",!0,!1,n,s),t.fillRect(s.x,s.y,s.width,s.height);return}if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.kn(t,e.background,!0,!1,n,s),t.fillRect(0,0,n.width/2,n.height/2),!o.FP()){let r=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*r,-o.m12*r,-o.m21*r,o.m11*r,r*(o.m21*o.dy-o.m22*o.dx),r*(o.m12*o.dx-o.m11*o.dy))}}UR(t,e,i,s){let n=2/s,o=4/s;for(let r=0;r<i;r++){let a=e[r];if(!(a.width===0||a.height===0)&&t.intersects(a.x-n,a.y-n,a.width+o,a.height+o))return!0}return!1}t(t,e,i,s,n){let o=this.diagram;o!==null&&o.raiseChangedEvent(2,t,this,e,i,s,n)}ah(t,e,i){let s=this.Ct;if(e.OM(this),t>=s.count)t=s.count;else if(s.elt(t)===e)return-1;s.insertAt(t,e),e._m(i);let n=this.diagram;return n!==null&&(i?n.C():n.ah(e)),this.ob(t,e),t}ri(t,e,i){if(!i&&e.layer!==this&&e.layer!==null)return e.layer.ri(t,e,i);let s=this.Ct;if(t<0||t>=s.length){if(t=s.indexOf(e),t<0)return-1}else if(s.elt(t)!==e&&(t=s.indexOf(e),t<0))return-1;e.tp(i),s.removeAt(t);let n=this.diagram;return n!==null&&(i?n.C():n.ri(e)),e.OM(null),t}ob(t,e){t=this.BR(t,e),e instanceof ft&&this.zR(t,e),e.svg!==null&&e.svg.remove()}BR(t,e){let i=e.zOrder;if(isNaN(i))return t;let s=this.Ct,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(e)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let a=t+1,h=NaN;for(;a<n&&(h=s.elt(a).zOrder,!!isNaN(h));)a++;if(!isNaN(r)&&r>i)for(;;){if(o===-1||r<=i)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,e),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h<i)for(;;){if(a===n||h>=i)return a--,a===t?t:(s.removeAt(t),s.insertAt(a,e),a);for(h=NaN;++a<n&&(h=s.elt(a).zOrder,!!isNaN(h)););}return t}zR(t,e){if(e===null||!isNaN(e.zOrder))return;this.XR(t,e);let i=e.containingGroup;i!==null&&this.ob(-1,i)}XR(t,e){if(e.memberParts.count===0)return;let i=-1,s=this.Ct.r,n=s.length;for(let o=0;o<n;o++){let r=s[o];if(r===e&&(t=o,i>=0)||i<0&&r.containingGroup===e&&(i=o,t>=0))break}if(!(i<0)&&i<t){let o=this.Ct;o.removeAt(t),o.insertAt(i,e)}}get parts(){return this.Ct.iterator}get partsBackwards(){return this.Ct.iteratorBackwards}get diagram(){return this.a}get name(){return this.Pt}set name(t){g.s(t,"string",Vt,"name");let e=this.Pt;if(e!==t){let i=this.diagram;if(i!==null){e===""&&g.o("Cannot rename default Layer to: "+t);let n=i.layers;for(;n.next();)n.value.name===t&&g.o("Layer.name is already present in this diagram: "+t)}this.Pt=t,this.t("name",e,t);let s=this.Ct.iterator;for(;s.next();){let n=s.value;n.layerName=this.Pt}}}get opacity(){return this.Zt}set opacity(t){let e=this.Zt;if(e!==t){g.s(t,"number",Vt,"opacity"),(t<0||t>1)&&g.J(t,"0 <= value <= 1",Vt,"opacity"),this.Zt=t;let i=this.diagram;i!==null&&i.C(),this.t("opacity",e,t)}}get isViewportAligned(){return this.Jm}set isViewportAligned(t){let e=this.Jm;e!==t&&(this.Jm=t,this.diagram&&(this.YA(),this.diagram.C()),this.t("isViewportAligned",e,t),t&&(this.isInDocumentBounds=!1))}YA(){if(!this.Jm)return;let t=this.diagram;if(t===null)return;let e=this.Ct.r,i=e.length,s=t.wt,n=t.xt;for(let o=0;o<i;o++){let r=e[o],a=r.naturalBounds.width,h=r.naturalBounds.height,l=r.alignment;(l.isDefault()||!l.isSpot())&&(l=T.BottomRight);let c=r.alignmentFocus;c.isDefault()&&(c=new T(l.x,l.y));let u=l.x*s+l.offsetX-(c.x*a+c.offsetX),d=l.y*n+l.offsetY-(c.y*h+c.offsetY),f=P.z(u,d);t.GR(f),r.Ec(f.x,f.y,!0),P.i(f),r.it=1/t.scale}}get isTemporary(){return this.Fr}set isTemporary(t){let e=this.Fr;e!==t&&(g.s(t,"boolean",Vt,"isTemporary"),this.Fr=t,this.t("isTemporary",e,t))}get visible(){return this.Uc}set visible(t){let e=this.Uc;if(e!==t){g.s(t,"boolean",Vt,"visible"),this.Uc=t;let i=this.Ct.iterator;for(;i.next();)i.value.Xe(t);let s=this.diagram;s!==null&&s.C(),this.t("visible",e,t)}}get pickable(){return this.ea}set pickable(t){let e=this.ea;e!==t&&(g.s(t,"boolean",Vt,"pickable"),this.ea=t,this.t("pickable",e,t))}get isInDocumentBounds(){return this.nb}set isInDocumentBounds(t){let e=this.nb;e!==t&&(this.nb=t,this.diagram!==null&&this.diagram.invalidateDocumentBounds(),this.t("isInDocumentBounds",e,t))}get allowCopy(){return this.Yl}set allowCopy(t){let e=this.Yl;e!==t&&(g.s(t,"boolean",Vt,"allowCopy"),this.Yl=t,this.t("allowCopy",e,t))}get allowDelete(){return this.Kl}set allowDelete(t){let e=this.Kl;e!==t&&(g.s(t,"boolean",Vt,"allowDelete"),this.Kl=t,this.t("allowDelete",e,t))}get allowTextEdit(){return this.Hl}set allowTextEdit(t){let e=this.Hl;e!==t&&(g.s(t,"boolean",Vt,"allowTextEdit"),this.Hl=t,this.t("allowTextEdit",e,t))}get allowGroup(){return this.jl}set allowGroup(t){let e=this.jl;e!==t&&(g.s(t,"boolean",Vt,"allowGroup"),this.jl=t,this.t("allowGroup",e,t))}get allowUngroup(){return this.ql}set allowUngroup(t){let e=this.ql;e!==t&&(g.s(t,"boolean",Vt,"allowUngroup"),this.ql=t,this.t("allowUngroup",e,t))}get allowLink(){return this.Wl}set allowLink(t){let e=this.Wl;e!==t&&(g.s(t,"boolean",Vt,"allowLink"),this.Wl=t,this.t("allowLink",e,t))}get allowRelink(){return this.Jl}set allowRelink(t){let e=this.Jl;e!==t&&(g.s(t,"boolean",Vt,"allowRelink"),this.Jl=t,this.t("allowRelink",e,t))}get allowMove(){return this.$l}set allowMove(t){let e=this.$l;e!==t&&(g.s(t,"boolean",Vt,"allowMove"),this.$l=t,this.t("allowMove",e,t))}get allowReshape(){return this.Zl}set allowReshape(t){let e=this.Zl;e!==t&&(g.s(t,"boolean",Vt,"allowReshape"),this.Zl=t,this.t("allowReshape",e,t))}get allowResize(){return this.Ql}set allowResize(t){let e=this.Ql;e!==t&&(g.s(t,"boolean",Vt,"allowResize"),this.Ql=t,this.t("allowResize",e,t))}get allowRotate(){return this._l}set allowRotate(t){let e=this._l;e!==t&&(g.s(t,"boolean",Vt,"allowRotate"),this._l=t,this.t("allowRotate",e,t))}get allowSelect(){return this.ta}set allowSelect(t){let e=this.ta;e!==t&&(g.s(t,"boolean",Vt,"allowSelect"),this.ta=t,this.t("allowSelect",e,t))}}var bs=(x=>(x[x.None=1]="None",x[x.Uniform=2]="Uniform",x[x.UniformToFill=3]="UniformToFill",x))(bs||{}),Nn=(x=>(x[x.All=1]="All",x[x.NotDirected=2]="NotDirected",x[x.NotDirectedFast=3]="NotDirectedFast",x[x.NotUndirected=4]="NotUndirected",x[x.DestinationTree=5]="DestinationTree",x[x.SourceTree=6]="SourceTree",x))(Nn||{}),Cn=(x=>(x[x.Document=1]="Document",x[x.Infinite=2]="Infinite",x))(Cn||{}),An=(x=>(x[x.TreeParent=1]="TreeParent",x[x.AllParents=2]="AllParents",x[x.AnyParents=3]="AnyParents",x))(An||{});class j{Ns;qt;VM;rb;Rr;Ju;lb;ab;hb;cb;fb;ub;hh;oh;db;gb;pb;ia;Wc;Or;ep;yb;wb;$u;eo;Ir;ch;Vo;ip;Jc;sp;$c;Zu;Er;io;BM;zM;xb;bb;XM;kb;GM;YM;KM;Pb;np;Ur;Vr;Br;zr;Xr;Gr;Sb;Yr;Mb;Kr;Hr;jr;qr;Nb;HM;Bo;jM;Cb;Lb;qM;Ce;WM;Zc;JM;js;zo;Be;Ab;Yl;Kl;Tb;Db;Hl;jl;ql;vb;Wl;Jl;$l;Zl;Ql;_l;ta;Fb;Rb;$M;Qu;_u;Ob;Ib;Eb;Ub;op;Vb;Bb;zb;Qt;KA;Xb;HA;td;Pn;so;li;no;jA;sa;ZM;QM;rp;Gb;ed;lp;Yb;Wr;na;fh;_M;t2;ap;Kb;Hb;ls;sd;hp;nd;Xo;Qc;cp;Jr;uh;e2;fp;Ht;v;qi;Dr;Ye;Ts;i2;oa;$r;Fl;Zr;dh;_c;s2;od;gh;rd;zt;ra;ct;it;ld;wt;xt;st;tf;Sx;jb;mh;ef;qb;Wb;dp;YR;KR;$e;Ol;Qm;gp;o2;l2;qA;mp;HR;jR;qR;Jb;WR;JR;$R;ph;WA;la;yh;wh;xh;bh;Eu;ih;Wt;St;sf;jP;qP;Dc;Zt;static $b=null;static JA=new wt;static a2;static h2=null;Iu;Zb;Qb;ad;_b;t1;pp;c2;yp;wp;xp;Hx;f2;u2;nf;bp;kp;constructor(t,e){if(j.jw||(j.RP(),j.jw=!0),I.Je(this),j.$A(this),this.Ht=!0,this.St=null,this.wt=0,this.xt=0,this.st=null,j.isUsingDOM()){let s=this,n=()=>{s.Le(C.document,"DOMContentLoaded",n,!1),s.setRTL()};C.document.body!==null?this.setRTL():s.Et(C.document,"DOMContentLoaded",n,!1)}this.tf=null,j.d2("Model",Ne);let i=this;return this.WM=s=>i.partManager.doModelDataChanged(s),this.Zc=s=>i.partManager.doModelChanged(s),this.qb=null,this.Wb=null,this.ZA(),this.model=mt.g2(),this.themeManager=new ai,this.Bo=!0,this.QA(),this.layout=new oe,this.Bo=!1,this.HR=null,this.jR=null,this.qR=null,this.Jb=null,this.WR=null,this.JR=null,this.$R=null,this.ph=null,this.WA=null,this.la=null,this.yh=null,this.wh=null,this.xh=null,this.bh=null,this.Eu=()=>{},this.ih=null,this.nd=!1,this.sf=new _o(this),t!==void 0&&(typeof t=="string"||C.Element&&t instanceof Element?this.m2(t):e=t),e&&this.setProperties(e),this.Ht=!1,this.requestUpdate(),this}lR(){return this.st!==null}get renderer(){return this.Qc}set renderer(t){if(this instanceof Ei)return;t===""&&(t="default");let e=t.toLowerCase(),i=this.Qc;if(e===i)return;this.Qc=e;let s=null;e==="default"||e==="canvas"?(s=this.Xo.get("svg"),s!==null&&s.bt.remove(),this.st&&(this.Wt=this.st._t),this.Wt.clearContextCache(!0)):e==="svg"?(this.Xo.has("svg")?s=this.Xo.get("svg"):(s=new Bi(this,C.document),this.addRenderer("svg",s)),this.div!==null&&(s.bt.role="img",this.div.appendChild(s.bt)),this.Wt=s._t,this.st&&(this.st._t.setTransform(this.$e,0,0,this.$e,0,0),this.st._t.clearRect(0,0,this.wt,this.xt))):e==="debug"&&(this.Xo.has("SVG")||(s=new Bi(this,C.document),this.addRenderer("SVG",s),s.bt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.bt))),this.Ht||this.redraw()}ZA(){if(this.nf=new U,this.setupRouters(),this.Ns=new be,this.Ns.Eo(this),this.qt=17,this.VM=!1,this.ld=!1,this.rb="default",this.zt=new U,this.Xo){let t=this.Xo.get("svg");t!==null&&t.bt.remove(),this.st&&(this.Wt=this.st._t,this.Wt.clearContextCache(!0))}this.Xo=new wt,this.Qc="default",this.resetRenderingHints(),this.ZR(),this.Zt=1,this.ct=new P(NaN,NaN).b(),this.Hx=new P(NaN,NaN),this.it=1,this.fp=1,this.lb=new P(NaN,NaN).b(),this.ab=NaN,this.hb=1e-4,this.cb=100,this.v=new Pt,this.fb=new P(NaN,NaN).b(),this.ub=new B(NaN,NaN,NaN,NaN).b(),this.hh=new Dt(0,0,0,0).kt(),this.oh=1,this.db=!1,this.gb=null,this.pb=null,this.ia=1,this.Wc=T.Default,this.Or=1,this.ep=T.Default,this.yb=T.None,this.wb=T.None,this.qi=!0,this.$u=!1,this.eo=new Set,this.Ir=new I,this.ch=new I,this.Vo=!1,this.ra=new wt,this.od=!0,this.ip=250,this.Jc=-1,this.sp=new Dt(16,16,16,16).kt(),this.Dr=!1,this.$c=!1,this.Zu=!0,this.cp=new Se,this.cp.diagram=this,this.Jr=new Se,this.Jr.diagram=this,this.uh=new Se,this.uh.diagram=this,this.Er=null,this.io=null,this.Sx=!1,this.QR(),this.Zr=new I,this.xb=!0,this.bb=1,this.XM=!1,this.kb=1,this.Pb="auto",this.np="auto",this.Ur=null,this.Vr=null,this.Br=null,this.zr=null,this.Xr=null,this.Gr=null,this.Sb=null,this.Yr=null,this.Mb=!1,this.Kr=null,this.Hr=null,this.jr=null,this.qr=null,this.Nb=!1,this.jb={},this.mh=[null,null],this.Bo=!1,this.jM=!1,this.Cb=!1,this.Lb=!1,this.qM=!0,this.Ts=!1,this.gh=!1,this.JM=!0,this.js=-2,this.oa=new wt,this.rd=new U,this.zo=!1,this.Be=!0,this.Ab=!0,this.Yl=!0,this.Kl=!0,this.Tb=!1,this.Db=!0,this.Hl=!0,this.jl=!0,this.ql=!0,this.vb=!0,this.Wl=!0,this.Jl=!0,this.$l=!0,this.Zl=!0,this.Ql=!0,this._l=!0,this.ta=!0,this.Fb=!0,this.Rb=!0,this.$M=!1,this.ef=!1,this.Qu=!0,this._u=!0,this.Ob=!0,this.Ib=!0,this.Eb=16,this.Ub=16,this.op=!1,this.Vb=!1,this.Bb=0,this.zb=0,this.Qt=new Dt(5).kt(),this.KA=new I().b(),this.Xb=999999999,this.HA=new I().b(),this.dh=!0,this.td=!0,this._c=!0,this.Pn=!1,this.so=!1,this.$r=!0,this.Fl=!1,this.no=!1,this.jA=new I,this.s2=new I,this.sa=null,this.ZM=new _(q._A,q.tT),this.QM=999,this.rp=!1,this.jP=1,this.qP=0,this.Ye={scale:1,position:new P,bounds:new B,canvasSize:new _,newCanvasSize:new _,isScroll:!1},this.Ye.canvasSize=this.Ye.canvasSize,this.Ye.newCanvasSize=this.Ye.newCanvasSize,this.Ye.isScroll=!1,this.Gb=new B(NaN,NaN,NaN,NaN).b(),this.ed=new _(NaN,NaN).b(),this.lp=new B(NaN,NaN,NaN,NaN).b(),this.Yb=!1,this.bp=null,this.kp=null,this._R(),this.ls=null,this.sd=!1,this.Dc=null,this.partManager=new Ne,this.toolManager=new de,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.Qb=null,this.ad=new es,this._b=null,this.t1=null,this.Zb=!1,this.Iu=!1,this.commandHandler=new Jt,this.wp=null,this.xp=P.mn,this.f2=!1,this.$e=1,this.Ol=null,this.Qm=1,this.pp=0,this.c2=[0,0,0,0,0],this.yp=0,this.gp=1,this.o2=0,this.l2=new P,this.qA=500,this.hp=new P,this.mp=!1}static eT=C.document!==void 0;static isUsingDOM(){return j.eT}static useDOM(t){j.eT=t?C.document!==void 0:!1}static Wi=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),j.iT(),this.sT(!1),this.rd.clear(),this.nT(),this.sa=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}sT(t){this.animationManager.stopAnimation(!0),this.clearSelection(),this.clearHighlighteds();let e=this.skipsUndoManager,i=this.Ce!==null&&this.Ce!==void 0;i&&(this.skipsUndoManager=!0);let s=null;this.ls!==null&&(s=this.ls.part,s!==null&&this.remove(s));let n=[],o=this.zt.length;if(t){for(let r=0;r<o;r++){let a=this.zt.r[r].parts;for(;a.next();){let h=a.value;h!==s&&h.data===null&&n.push(h)}}for(let r=0;r<n.length;r++){let a=n[r];this.remove(a)}}for(let r=0;r<o;r++)this.zt.r[r].OR();return this.partManager.clear(),this.eo.clear(),this.Ir.clear(),this.ch.clear(),this.ra.clear(),this.Zr.clear(),this.Dc=null,this.rd.clear(),this.nT(),g.CP=[],s!==null&&(this.add(s),this.partManager.parts.delete(s)),i&&(this.skipsUndoManager=e),n}static Pp=null;static e1="";static iT(){j.Pp=null,j.e1=""}static EU(){return null}reset(){this.clear(),this.Ht=!0,this.ZA(),this.themeManager=new ai,this.aa(),this.Bo=!0,this.QA(),this.layout=new oe,this.Bo=!1,this.model=mt.g2(),this.model.undoManager=new _i,this.nd=!1,this.Ht=!1,this.C()}_R(){this.Wr=new wt,this._M=new it().add(new gt({stroke:"black",font:"10pt sans-serif"}).bind("text","",g.toString).theme("stroke","text").theme("font","normal")),this.Wr.set("",this._M),this.Wr.set("Comment",new it().add(new gt({stroke:"brown",font:"10pt sans-serif"}).bind("text","",g.toString).theme("stroke","comment").theme("font","normal"))),this.Wr.set("LinkLabel",new it({selectable:!1,avoidable:!1}).add(new at("Ellipse",{fill:"black",stroke:null,desiredSize:new _(3,3).kt()}).theme("fill","link"))),this.fh=new wt,this.i2=new ft(H.Vertical,{selectionObjectName:"GROUPPANEL"}).add(new gt({stroke:"black",font:"bold 12pt sans-serif"}).bind("text","",g.toString).theme("stroke","text").theme("font","bold"),new H(H.Auto,{name:"GROUPPPANEL"}).add(new at({fill:"rgba(128,128,128,0.2)",stroke:"black",strokeWidth:1}).theme("fill","group").theme("stroke","outline").theme("strokeWidth","group"),new we({padding:5}).theme("padding","group"))),this.fh.set("",this.i2),this.na=new wt,this.t2=new q().add(new at({isPanelMain:!0,stroke:"black"}).theme("stroke","link"),new at({toArrow:"Standard",fill:"black",stroke:null,strokeWidth:0}).theme("toArrow").theme("fill","link")),this.na.set("",this.t2),this.na.set("Comment",new q().add(new at({isPanelMain:!0,stroke:"brown"}).theme("stroke","comment"))),this.ap=new Mt(H.Auto).add(new at({fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"),new we({margin:1.5}).theme("margin","selection","numbers",null,t=>t?new Dt(t/2):1.5)).freezeBindings(),this.Kb=this.ap,this.Hb=new Mt(H.Link).add(new at({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection")).freezeBindings()}setRTL(t){let e=t===void 0?this.div:t;e===null&&(e=C.document.body);let i=g.Ni("div");i.dir="rtl",i.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",i.textContent="A",e.appendChild(i);let s="reverse";i.scrollLeft>0?s="default":(i.scrollLeft=1,i.scrollLeft===0&&(s="negative")),e.removeChild(i),this.rb=s}setScrollWidth(t){let e=t===void 0?this.div:t;e===null&&(e=C.document.body);let i=0;if(j.isUsingDOM()){let s=j.h2,n=j.a2;s===null&&(j.h2=g.Ni("p"),s=j.h2,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",j.a2=g.Ni("div"),n=j.a2,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",e.appendChild(n);let o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),e.removeChild(n),i=o-r,i===0&&!g.ur&&(i=11)}this.qt=i,this.VM=!0}fe(t){t in bs?this.autoScale=t:g.dr(this,t)}toString(t){t===void 0&&(t=0);let e="";this.div&&this.div.id&&(e=this.div.id);let i='Diagram "'+e+'"';if(t<=0)return i;let s=this.zt.iterator;for(;s.next();){let n=s.value;i+=`
9
+ `+n.toString(t-1)}return i}static $A(t){j.$b=t}static Rm(){return j.$b}static fromDiv(t){let e=t;if(typeof t=="string"&&(e=C.document.getElementById(t)),e instanceof HTMLDivElement){let i=j.Wi.get(e);if(i)return i}return null}get div(){return this.St}set div(t){if(t!==null&&g.se(t,HTMLDivElement,j,"div"),this.St!==t){let e=this.St;if(e!==null){if(j.Wi.delete(e),e.goDiagram=void 0,e.go=void 0,e.innerHTML="",this.st!==null){let s=this.st.bt;this.Le(s,"pointermove",this.yh,!1),this.Le(s,"pointerdown",this.la,!1),this.Le(s,"pointerup",this.wh,!1),this.Le(s,"pointerout",this.xh,!1),this.Le(s,"pointercancel",this.bh,!1),this.st.dispose()}this.tf&&(this.tf.disconnect(),this.tf=null);let i=this.toolManager;i!==null&&(i.mouseDownTools.each(s=>s.cancelWaitAfter()),i.mouseMoveTools.each(s=>s.cancelWaitAfter()),i.mouseUpTools.each(s=>s.cancelWaitAfter())),i.cancelWaitAfter(),this.currentTool.doCancel(),this.st=null,this.Le(C,"resize",this.Jb,!1),this.Le(C,"wheel",this.ph,!0),j.Rm()===this&&j.$A(null)}else this.la===null&&(this.no=!1);if(this.St=null,t!==null){let i=j.Wi.get(t);i&&(i.div=null),this.m2(t),this.Eu(),this.themeManager&&this.themeManager.tO()}else this.themeManager&&this.themeManager.eO()}}setupRouters(){this.nf.push(new wr)}m2(t){let e=this;if(!j.isUsingDOM())return;t==null&&g.o("Diagram setup requires an argument DIV."),e.St!==null&&g.o("Diagram has already completed setup."),typeof t=="string"?e.St=C.document.getElementById(t):t instanceof HTMLDivElement?e.St=t:g.o("No DIV or DIV id supplied: "+t),e.St===null&&g.o("Invalid DIV id; could not get element with id: "+t);let i=j.Wi.get(e.St);if(i&&i!==this&&g.o("Invalid div id; div already has a Diagram associated with it."),!e.tf&&C.ResizeObserver){let c=C.ResizeObserver,u=g.NP(()=>e.requestUpdate(),250,!1);e.tf=new c(()=>u()),e.tf.observe(e.St)}C.getComputedStyle(e.St,null).position==="static"&&(e.St.style.position="relative");let s=5,n="rgba(2"+s+"5, 255, 255, 0)";s--,e.St.style["-webkit-tap-highlight-color"]=n,e.St.innerHTML="",j.Wi.set(e.St,e),e.St.goDiagram=e,e.St.go=C.go;let o=new He(e);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",C.getComputedStyle(e.St,null).getPropertyValue("direction")==="rtl"&&(e.ld=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),o.bt.setAttribute("role","application"),e.st=o,e.Wt=o._t;let r=e.Wt;e.$e=e.computePixelRatio(),e.viewSize.isReal()||(e.wt=e.St.clientWidth||1,e.xt=e.St.clientHeight||1),e.oT(e.wt,e.xt);let a=e;e.St.insertBefore(o.bt,e.St.firstChild);let h=new He(null);if(h.width=1,h.height=1,e.YR=h,e.KR=h._t,j.isUsingDOM()){let c=g.Ni("div"),u=g.Ni("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=e.wt+"px",c.style.height=e.xt+"px",c.style.zIndex="1",u.style.position="absolute",u.style.width="1px",u.style.height="1px",e.St.appendChild(c),c.appendChild(u),c.onscroll=j.iO,c.addEventListener("pointerdown",j.sO),c.a=e,c.nO=!0,c.oO=!0,e.qb=c,e.Wb=u}e.Eu=g.NP(()=>{e.Ol=null,e.C()},300,!1),e.Jb=g.NP(()=>{e.SM()},250,!1),e.ih=c=>(c.preventDefault(),!1),e.ph=c=>{if(!a.isEnabled)return;let u=a.of(c,!0);u.bubbles=!0;let d=0,f=0;u.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(d=c.deltaX>0?1:-1),c.deltaY!==0&&(f=c.deltaY>0?1:-1),u.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-d:-f):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(d=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(f=c.wheelDeltaY>0?-1:1),u.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-d:-f):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(u.delta=c.wheelDelta>0?1:-1),a.doMouseWheel(),a.kh(u,c)},e.WA=c=>{if(!a.isEnabled)return;e.ef=!1,a.of(c,!0);let u=a.currentTool;u.cancelWaitAfter(),u.standardMouseOver()},e.la=c=>{if(!a.isEnabled)return;e.ef=!0;let u=a.jb;u[c.pointerId]===void 0&&(u[c.pointerId]=c);let d=a.mh,f=!1;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=c;else if(d[1]!==null&&d[1].pointerId===c.pointerId)d[1]=c,f=!0;else if(d[0]===null)d[0]=c;else if(d[1]===null)d[1]=c,f=!0;else{c.preventDefault();return}let p=c.pointerType==="touch"||c.pointerType==="pen";p&&(a.Sx=!1,a.mp=!0);let m=a.rO(c,c,f),y=a.l2,b=p?25:10;if(c.timeStamp-a.o2<a.qA&&!(Math.abs(y.x-c.screenX)>b||Math.abs(y.y-c.screenY)>b)?a.gp++:a.gp=1,m.clickCount=a.gp,a.o2=c.timeStamp,a.l2.setTo(c.screenX,c.screenY),a.doMouseDown(),c.button===1){c.preventDefault();return}a.kh(m,c)},e.yh=c=>{if(!a.isEnabled)return;e.ef=!0;let u=a.mh;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId){u[1]=c;return}else if(u[0]===null)u[0]=c;else return;if(u[0].pointerId!==c.pointerId)return;let d=a.lO(c,c,u[1]!==null);a.doMouseMove(),a.kh(d,c)},e.wh=c=>{if(!a.isEnabled)return;e.ef=!0;let u=c.pointerType==="touch"||c.pointerType==="pen",d=a.jb;if(u&&a.Sx){delete d[c.pointerId],c.preventDefault();return}let f=a.mh;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=null;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=null;return}else return;let p=a.p2(c,!1,!0,!1,!0,!1),m=C.document.elementFromPoint(c.clientX,c.clientY)||null;m!==null&&m.shadowRoot&&(m=m.shadowRoot.elementFromPoint(c.clientX,c.clientY)||null),m!==null&&m.a instanceof j&&m.a!==a&&m.a.Sp(c,p),m===null&&(m=c.target),a.Sp(c,p),p.clickCount=a.gp,p.targetDiagram=a.i1(c,m),p.targetObject=null,a.doMouseUp(),a.kh(p,c),u&&(a.mp=!1)},e.xh=c=>{if(!a.isEnabled)return;e.ef=!1;let u=a.jb;u[c.pointerId]&&delete u[c.pointerId];let d=a.mh;if(d[0]!==null&&d[0].pointerId===c.pointerId&&(d[0]=null),d[1]!==null&&d[1].pointerId===c.pointerId&&(d[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;let f=a.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},e.bh=c=>{let u=a.mh;u[0]!==null&&u[0].pointerId===c.pointerId?(u[0]=null,a.mp=!1):u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null)};let l=r;if(e.dp=l.F[g.We("7eba17a4ca3b1a8346")][g.We("78a118b7")](l.F,j.Ph,s,s),r.clearContextCache(!0),e.aO(),this.Qc==="svg"){let c=this.Xo.get("svg");this.St&&this.St.appendChild(c.bt),this.Wt=c._t}}addEventListener(t,e,i,s){t.addEventListener(e,i,{capture:s,passive:!1})}Et(t,e,i,s){t.addEventListener(e,i,{capture:s,passive:!1})}removeEventListener(t,e,i,s){t.removeEventListener(e,i,{capture:s})}Le(t,e,i,s){t.removeEventListener(e,i,{capture:s})}aO(){let t=this,e=this.st.bt;e instanceof HTMLCanvasElement||(e=t.div),this.Et(e,"pointerdown",t.la,!1),this.Et(e,"pointermove",t.yh,!1),this.Et(e,"pointerup",t.wh,!1),this.Et(e,"pointerout",t.xh,!1),this.Et(e,"pointercancel",t.bh,!1),this.Et(e,"pointerenter",t.hO,!1),this.Et(e,"pointerleave",t.cO,!1),this.Et(e,"wheel",t.ph,!1),this.Et(e,"keydown",t.fO,!1),this.Et(e,"keyup",t.uO,!1),this.Et(e,"blur",t.dO,!1),this.Et(e,"focus",t.gO,!1),this.Et(e,"selectstart",i=>(i.preventDefault(),!1),!1),this.Et(e,"contextmenu",i=>(i.preventDefault(),!1),!1),this.Et(C,"resize",t.Jb,!1)}Nx(){this.pp>30&&(this.Ol=1)}pS(t){this.Ol!==null&&(this.Ol=null,t&&this.Eu(),this.pp=0,this.c2=[0,0,0,0,0],this.yp=0)}computePixelRatio(){return this.Ol!==null?this.Ol:C.devicePixelRatio||1}get avgSpf(){return this.pp}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){let t=this.commandHandler;if(!this.toggleKeyboardControl()){if((t.isFocusEnabled||t.isVirtualPointerEnabled)&&t.doVirtualFocusKeyDown()){let e=this.lastInput;e.bubbles=!1;let i=e.event;i&&(i.stopPropagation&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault());return}this.currentTool.doKeyDown()}}toggleKeyboardControl(){let t=this.lastInput,e=t.commandKey;if((t.control||t.meta)&&t.alt&&(e==="Enter"||e==="NumpadEnter")){let i=this.commandHandler,s=i.isFocusEnabled||i.isVirtualPointerEnabled;return i.isFocusEnabled=!s,i.isVirtualPointerEnabled=!s,i.focus=i.findFirstFocus(),this.T("FocusOrVirtualPointerEnabledChanged"),!0}return!1}doKeyUp(){let t=this.commandHandler;if((t.isFocusEnabled||t.isVirtualPointerEnabled)&&t.doVirtualFocusKeyUp()){let e=this.lastInput;e.bubbles=!1;let i=e.event;i&&(i.stopPropagation&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault());return}this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.st)if(this.scrollsPageOnFocus)this.st.focus();else{let t=C.scrollX,e=C.scrollY;this.st.focus(),C.scrollTo(t,e)}}gO(t){let e=j.Wi.get(this);e&&e.T("GainedFocus")}dO(t){let e=j.Wi.get(this);e&&e.T("LostFocus")}SM(){if(this.st===null)return;let t=this.St;if(t===null||t.clientWidth===0||t.clientHeight===0)return;this.VM||this.setScrollWidth();let e=this.so?this.qt:0,i=this.Pn?this.qt:0,s=this.$e;if(this.$e=this.computePixelRatio(),this.$e!==s&&(this.$u=!0,this.requestUpdate()),t.clientWidth!==this.wt+e||t.clientHeight!==this.xt+i){this.Sh(),this.qi=!0;let n=this.layout;n!==null&&n.isViewportSized&&this.autoScale===1&&(this.$c=!0,n.p()),this.Ts||this.requestUpdate()}}QA(){let t=0,e=new Vt;e.name="Grid",e.allowSelect=!1,e.pickable=!1,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Qr(e,t++),e=new Vt,e.name="ViewportBackground",e.isViewportAligned=!0,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Qr(e,t++),e=new Vt,e.name="Background",this.Qr(e,t++),e=new Vt,e.name="",this.Qr(e,t++),e=new Vt,e.name="Foreground",this.Qr(e,t++),e=new Vt,e.name="ViewportForeground",e.isViewportAligned=!0,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Qr(e,t++),e=new Vt,e.name="Adornment",e.isTemporary=!0,e.isInDocumentBounds=!1,this.Qr(e,t++),e=new Vt,e.name="Tool",e.isTemporary=!0,e.isInDocumentBounds=!0,this.Qr(e,t++)}rT(){let t=new H(H.Grid,{name:"GRID"}).add(new at("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new at("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new at("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new at("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new at("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new at("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),e=new bt({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(e),this.partManager.parts.delete(e),t.visible=!1,t}static iO(){let t=j.Wi.get(this.parentElement||this);if(t){if(t.Vb){t.Vb=!1;return}if(!t.isEnabled){t.lT();return}t.diagramScroll(this)}}static sO(t){if(!this.a.isEnabled){this.a.updateScroll();return}this.a.Bb=t.target.scrollTop,this.a.zb=t.target.scrollLeft}diagramScroll(t){if(this.st===null)return;let e=this.qb,i=this.Wb;this.op=!0;let s=this.documentBounds,n=this.viewportBounds,o=this.hh,r=s.x-o.left,a=s.y-o.top,h=s.width+o.left+o.right,l=s.height+o.top+o.bottom,c=s.right+o.right,u=s.bottom+o.bottom,d=n.x,f=n.y,p=n.width,m=n.height,y=n.right,b=n.bottom,v=this.scale,w,k=t.scrollLeft;if(this.ld)switch(this.rb){case"negative":k=k+t.scrollWidth-t.clientWidth;break;case"reverse":k=t.scrollWidth-k-t.clientWidth;break}let S=k;if(p<h||m<l){w=P.z(this.position.x,this.position.y),this.allowHorizontalScroll&&this.zb!==S&&(w.x=S/v+r,this.zb=S),this.allowVerticalScroll&&this.Bb!==t.scrollTop&&(w.y=t.scrollTop/v+a,this.Bb=t.scrollTop),this.position=w,P.i(w),this.op=!1,this.td=!1;return}if(w=P.l(),t.nO&&this.allowHorizontalScroll&&(r<d&&(this.position=w.e(S+r,this.position.y)),c>y)){let M=e.scrollWidth-this.wt;this.position=w.e(-M+S-this.wt/v+c,this.position.y)}if(t.oO&&this.allowVerticalScroll&&(a<f&&(this.position=w.e(this.position.x,t.scrollTop+a)),u>b)){let M=e.scrollHeight-this.xt;this.position=w.e(this.position.x,-M+t.scrollTop-this.xt/v+u)}P.i(w),this.ha(),this.op=!1,this.td=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,y=n.right,u=s.bottom,b=n.bottom,r=s.x,d=n.x,a=s.y,f=n.y,p>=h&&r>=d&&c<=y&&(i.style.width="1px"),m>=l&&a>=f&&u<=b&&(i.style.height="1px")}computeBounds(t){return t===void 0&&(t=new B),this.Te(),this.aT(t)}aT(t){if(this.fixedBounds.isReal())return t.h(this.fixedBounds),t.addMargin(this.Qt),t;let e=!0,i=this.zt.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];if(!o.visible||!o.isInDocumentBounds)continue;let r=o.Ct.r,a=r.length;for(let h=0;h<a;h++){let l=r[h];if(!l.isInDocumentBounds||!l.isVisible())continue;let c=l.actualBounds;c.isReal()&&(e?(e=!1,t.h(c)):t.unionRect(c))}}return e&&t.e(0,0,0,0),t.addMargin(this.Qt),t}computePartsBounds(t,e){e===void 0&&(e=!1);let i;if(Array.isArray(t))for(let s=0;s<t.length;s++){let n=t[s];!e&&n instanceof q||(n.ensureBounds(),i===void 0?i=n.actualBounds.copy():i.unionRect(n.actualBounds))}else{let s=t.iterator;for(;s.next();){let n=s.value;!e&&n instanceof q||(n.ensureBounds(),i===void 0?i=n.actualBounds.copy():i.unionRect(n.actualBounds))}}return i===void 0?new B(NaN,NaN,0,0):i}$s(t){if(!t&&!this.no||this.Ht||this.st===null||!this.documentBounds.isReal())return;if(this.Ht=!0,t){let u=this.initialPosition;if(u.isReal()){this.Ht=!1,this.position=u;return}let d=this.initialDocumentSpot,f=this.initialViewportSpot;d.isNoSpot()&&(d=T.TopLeft),f.isNoSpot()&&(f=T.TopLeft);let p=P.l();p.setRectSpot(this.documentBounds,d);let m=this.viewportBounds,y=B.z(0,0,m.width,m.height),b=P.l();b.setRectSpot(y,f),b.e(p.x-b.x,p.y-b.y),this.Ht=!1,this.position=b,B.i(y),P.i(b)}let e=this.ia;t&&this.Or!==1&&(e=this.Or);let i=e!==1?this.hd(e):this.scale,s=this.ct.x,n=this.ct.y,o=this.wt/i,r=this.xt/i,a=this.Wc,h=this.ep;if(t&&!a.isSpot()&&(h.isSpot()||h.isDefault())){let u=this.initialDocumentSpot.isSpot()&&this.initialViewportSpot.isSpot();a=h.isDefault()&&!u?T.Center:h}this.w2(this.documentBounds,o,r,a,t);let l=this.scale;this.scale=i,this.Ht=!1;let c=this.viewportBounds;c.equalsApproxTo(s,n,o,r)||this.onViewportBoundsChanged(new B(s,n,o,r),c,l,!1)}hd(t){let e=this.fp;if(this.st===null)return e;if(t===1)return this.scale;this.ensureBounds();let i=this.documentBounds;if(!i.isReal())return e;let s=i.width,n=i.height,o=this.wt+(this.so?this.qt:0),r=this.xt+(this.Pn?this.qt:0),a=o/s,h=r/n,l=this.hh,c=l.left+l.right!==0,u=l.top+l.bottom!==0;(c||u)&&(h===a?(h=(r-this.qt)/n,a=(o-this.qt)/s):h>a?h=(r-this.qt)/n:a=(o-this.qt)/s);let d=0;return t===2?d=Math.min(h,a):t===3&&(h>a?d=(r-this.qt)/n:d=(o-this.qt)/s),d>e&&(d=e),d<this.minScale&&(d=this.minScale),d>this.maxScale&&(d=this.maxScale),d}zoomToFit(){let t=this.oh;this.oh=1,this.scale=this.hd(2),this.alignDocument(T.Center,T.Center),t!==1&&(this.$s(!1),this.w2(this.documentBounds,this.wt/this.it,this.xt/this.it,this.Wc,!1)),this.oh=t}zoomToRect(t,e){e===void 0&&(e=2);let i=t.width,s=t.height;if(i===0||s===0||isNaN(i)&&isNaN(s))return;let n=1;if(e===2||e===3)if(isNaN(i))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/i;else{let o=this.wt,r=this.xt;e===3?r/s>o/i?n=(r-(this.Pn?this.qt:0))/s:n=(o-(this.so?this.qt:0))/i:n=Math.min(r/s,o/i)}this.scale=n,this.position=new P(t.x,t.y)}get mO(){return this.Ht}set mO(t){this.Ht=t}alignDocument(t,e){this.ensureBounds();let i=this.documentBounds,s=this.viewportBounds;this.position=new P(i.x+(t.x*i.width+t.offsetX)-(e.x*s.width-e.offsetX),i.y+(t.y*i.height+t.offsetY)-(e.y*s.height-e.offsetY))}focusObject(t){if(t instanceof tt){this.wp=t;let e=P.l();this.xp=this.transformDocToView(t.getDocumentPoint(T.TopLeft,e)),P.i(e)}else this.wp=null,this.xp=P.mn}w2(t,e,i,s,n){let o=P.z(this.ct.x,this.ct.y),r=o.x,a=o.y;if(this.wp!==null){let h=P.l();h=this.wp.getDocumentPoint(T.TopLeft,h),r=h.x-this.xp.x/this.scale,a=h.y-this.xp.y/this.scale,s=T.None,P.i(h)}if(n||this.scrollMode===1){s.isSpot()&&(e>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*e-s.offsetX)),i>t.height&&(a=t.y+(s.y*t.height+s.offsetY)-(s.y*i-s.offsetY)));let h=this.hh,l=e-t.width;if(e<t.width+h.left+h.right){let u=r+e/2;u=Math.min(u,t.right+Math.max(l,h.right)-e/2),u=Math.max(u,t.left-Math.max(l,h.left)+e/2),r=u-e/2}else r>t.left?r=t.left:r<t.right-e&&(r=t.right-e);let c=i-t.height;if(i<t.height+h.top+h.bottom){let u=a+i/2;u=Math.min(u,t.bottom+Math.max(c,h.bottom)-i/2),u=Math.max(u,t.top-Math.max(c,h.top)+i/2),a=u-i/2}else a>t.top?a=t.top:a<t.bottom-i&&(a=t.bottom-i)}if(o.x=isFinite(r)?r:-this.Qt.left,o.y=isFinite(a)?a:-this.Qt.top,this.positionComputation!==null){let h=this.positionComputation(this,o);o.x=h.x,o.y=h.y}this.Ns.IA(this.ct,o),this.ct.e(o.x,o.y),this.Mp(),this.aa(),this.pO(),P.i(o)}findPartAt(t,e){if(e===void 0&&(e=!0),e){let i=this.bS(t,s=>s.part,s=>s.canSelect());if(i instanceof bt)return i}else{let i=this.bS(t,s=>s.part);if(i instanceof bt)return i}return null}findObjectAt(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null),this.Te();let s=this.zt.iteratorBackwards;for(;s.next();){let n=s.value;if(!n.visible)continue;let o=n.findObjectAt(t,e,i);if(o!==null)return o}return null}bS(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null),this.Te();let s=this.zt.iteratorBackwards;for(;s.next();){let n=s.value;if(!n.visible||n.isTemporary)continue;let o=n.findObjectAt(t,e,i);if(o!==null)return o}return null}findPartsAt(t,e,i){return e===void 0&&(e=!0),this.yO(t,s=>s.part,e?s=>s instanceof bt&&s.canSelect():null,i)}yO(t,e,i,s){e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof U)&&!(s instanceof I)&&(s=new I),this.Te();let n=this.zt.iteratorBackwards;for(;n.next();){let o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,e,i,s)}return s}findObjectsAt(t,e,i,s){e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof U)&&!(s instanceof I)&&(s=new I),this.Te();let n=this.zt.iteratorBackwards;for(;n.next();){let o=n.value;o.visible&&o.findObjectsAt(t,e,i,s)}return s}findPartsIn(t,e,i,s){return e===void 0&&(e=!1),i===void 0&&(i=!0),this.wO(t,null,n=>n instanceof bt&&(!i||n.canSelect()),e,s)}findObjectsIn(t,e,i,s,n){e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof U)&&!(n instanceof I)&&(n=new I),this.Te();let o=this.zt.iteratorBackwards;for(;o.next();){let r=o.value;r.visible&&r.findObjectsIn(t,e,i,s,n)}return n}SS(t,e,i,s,n,o){let r=new I;this.Te();let a=this.zt.iteratorBackwards;for(;a.next();){let h=a.value;h.visible&&h.SS(t,e,i,s,r,n,o)}return r}wO(t,e,i,s,n){e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof U)&&!(n instanceof I)&&(n=new I),this.Te();let o=this.zt.iteratorBackwards;for(;o.next();){let r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,e,i,s,n)}return n}findPartsNear(t,e,i,s,n){return i===void 0&&(i=!0),s===void 0&&(s=!0),this.xO(t,e,null,o=>o instanceof bt&&(!s||o.canSelect()),i,n)}findObjectsNear(t,e,i,s,n,o){i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof U||n instanceof I)&&(o=n),n=!0),!(o instanceof U)&&!(o instanceof I)&&(o=new I),this.Te();let r=this.zt.iteratorBackwards;for(;r.next();){let a=r.value;a.visible&&a.findObjectsNear(t,e,i,s,n,o)}return o}xO(t,e,i,s,n,o){i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof U||n instanceof I)&&(o=n),n=!0),!(o instanceof U)&&!(o instanceof I)&&(o=new I),this.Te();let r=this.zt.iteratorBackwards;for(;r.next();){let a=r.value;!a.visible||a.isTemporary||a.findObjectsNear(t,e,i,s,n,o)}return o}acceptEvent(t){return this.of(t,t instanceof MouseEvent)}of(t,e){let i=this.Jr;this.Jr=this.uh,this.uh=i,i.diagram=this,i.event=t,e?this.Sp(t,i):(i.viewPoint=this.Jr.viewPoint,i.documentPoint=this.Jr.documentPoint);let s=0,n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),i.modifiers=s,i.button=n.button,n.buttons!==void 0&&(i.buttons=n.buttons),g.ur&&n.button===0&&n.ctrlKey&&(i.button=2),i.down=!1,i.up=!1,i.clickCount=1,i.delta=0,i.handled=!1,i.bubbles=!1,i.timestamp=t.timeStamp,i.isMultiTouch=!1,i.targetDiagram=this.i1(t,t.target),i.targetObject=null,i}i1(t,e){if(e===null)return null;let i=j.Wi.get(e);if(i)return i;let s=t.path;if(!s&&g.nt(t.composedPath)&&(s=t.composedPath()),s&&s[0]){let n=j.Wi.get(s[0]);if(n)return n}return null}rO(t,e,i){let s=this.p2(t,!0,!1,!1,!0,i);return this.Sp(e,s),s.targetDiagram=this.i1(t,t.target),s.targetObject=null,i||s.clone(this.cp),s}lO(t,e,i){let s=this.p2(t,!1,!1,!1,!1,i),n=C.document.elementFromPoint(e.clientX,e.clientY)||null;n!==null&&n.shadowRoot&&(n=n.shadowRoot.elementFromPoint(e.clientX,e.clientY)||null);let o=this,r=t;if(n){let a=this.i1(t,n);a&&(r=e,o=a)}return s.targetDiagram=o,this.Sp(r,s),s.targetObject=null,s}p2(t,e,i,s,n,o){let r=this.Jr;this.Jr=this.uh,this.uh=r,r.diagram=this,r.clickCount=1,r.delta=0;let a=0;return t.ctrlKey&&(a+=1),t.altKey&&(a+=2),t.shiftKey&&(a+=4),t.metaKey&&(a+=8),r.modifiers=a,r.event=t,r.timestamp=t.timeStamp,r.button=i?this.firstInput.button:t.button,r.buttons=t.buttons,g.ur&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=e,r.up=i,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}kh(t,e){return t.bubbles?!0:(e.stopPropagation!==void 0&&e.stopPropagation(),e.cancelable!==!1&&e.preventDefault(),e.cancelBubble=!0,!1)}fO(t){let e=j.Wi.get(this);if(!e||!e.isEnabled)return!1;let i=e.of(t,!1);return i.key=t.key,i.code=t.code,i.down=!0,e.doKeyDown(),e.kh(i,t)}uO(t){let e=j.Wi.get(this);if(!e||!e.isEnabled)return!1;let i=e.of(t,!1);return i.key=t.key,i.code=t.code,i.up=!0,e.doKeyUp(),e.kh(i,t)}hO(t){let e=j.Wi.get(this);if(!e||!e.isEnabled)return!1;let i=e.of(t,!0);return e.mouseEnter!==null&&e.mouseEnter(i),e.currentTool.standardMouseOver(),e.kh(i,t)}cO(t){let e=j.Wi.get(this);if(!e||!e.isEnabled)return!1;let i=e.of(t,!0);return e.mouseLeave!==null&&e.mouseLeave(i),e.kh(i,t)}getMouse(t){let e=this.st;if(e===null)return new P(0,0);let i=e.getBoundingClientRect(),s=(t.clientX-i.left)*(this.wt/i.width),n=(t.clientY-i.top)*(this.xt/i.height);return new P(s,n).Ki(this.v)}Sp(t,e){let i=this.st,s=0,n=0;if(i!==null){let r=i.getBoundingClientRect();s=(t.clientX-r.left)*(this.wt/r.width),n=(t.clientY-r.top)*(this.xt/r.height)}e.viewPoint.e(s,n);let o=P.z(s,n);this.v.Ci(o),e.documentPoint.h(o),P.i(o)}_L(t,e,i){let s;if(this.mh[0]!==null)s=this.mh[e];else return;let n=this.st;if(n!==null){let o=n.getBoundingClientRect();i.e((s.clientX-o.left)*(this.wt/o.width),(s.clientY-o.top)*(this.xt/o.height))}}invalidateDocumentBounds(){this.dh||(this.dh=!0,this.requestUpdate(!1))}bO(){this.Ts||this.Te(),this.ensureBounds()}redraw(){this.Ht||this.Ts||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Dr}delayInitialization(t){t===void 0&&(t=null);let e=this.animationManager,i=e.isEnabled;e.stopAnimation(),e.isEnabled=!1,this.Sr(),this.no=!1,this.Hx=new P(NaN,NaN),e.isEnabled=i,this.Ts=!0;let s=this;t!==null&&g.dn(()=>{s.Ts=!1,e.Gl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Dr===!0||this.Ht||t===!1&&this.Ts)return;this.Dr=!0;let e=this;C.requestAnimationFrame(()=>{e.Dr&&e.maybeUpdate()})}maybeUpdate(){this.Zu&&!this.Dr||(this.Zu&&(this.Zu=!1),this.Sr())}b2(t,e){!this.td||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.lT()||(t&&this.Te(),e&&this.$s(!1))}Sr(t){if(this.Ts||(this.Dr=!1,this.St===null&&!this.ed.isReal()))return;this.Ts=!0;let e=this.animationManager,i=this.rd;if(!e.isAnimating&&i.length!==0){let c=i.r,u=c.length;for(let d=0;d<u;d++){let f=c[d];f.wi(!1),f.c()}i.clear()}let s=this.s2;s.count>0&&(s.each(c=>c.k2()),s.clear());let n=!1,o=!1;e.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),e.ke||this.SM(),t||this.b2(!1,!0);let r=!this.undoManager.isUndoingRedoing&&(this.Fl||this.nf.count!==0&&this.Ir.size!==0),a=!this.no||this.$r;this.Te(!0);let h=!1;(a||r)&&(this.no?this.P2(!this.$c,r):(this.startTransaction("Initial Layout"),e.isEnabled===!1&&e.stopAnimation(),this.P2(!1,r)),h=a),this.$c=!1,this.Fl=!1,this.Te(),this.ls!==null&&(this.ls.visible&&!this.sd&&(this.ca(),this.sd=!0),!this.ls.visible&&this.sd&&(this.sd=!1)),this.Cb||this.bO(),t||this.b2(!0,!1);let l=!1;if(h){let c=B.l();c.h(this.viewportBounds),this.no||(this.no=!0,l=!0,this.skipsUndoManager||(this.undoManager.kx=!0),this.undoManager.Px=!0,this.kO()),this.PO(),this.Te(!1),t||this.b2(!0,!0),B.i(c)}else if(e.Bc&&e.Kx){if(this.Or!==1)this.scale=this.hd(this.Or);else if(this.ia!==1)this.scale=this.hd(this.ia);else{let c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.$s(!0)}h&&l&&this.commitTransaction("Initial Layout"),t||this.Ge(this.Wt),o&&(this.skipsUndoManager=n),this.Ts=!1}get $a(){return this.no}kO(){if(this.Or!==1)this.scale=this.hd(this.Or);else if(this.ia!==1)this.scale=this.hd(this.ia);else{let e=this.initialScale;isFinite(e)&&e>0&&(this.scale=e)}this.$s(!0);let t=this.zt.r;this.As(t,t.length,this,this.viewportBounds),this.T("InitialLayoutCompleted"),this.Hx.h(this.ct),this.ca()}PO(){this.T("LayoutCompleted")}Np(t){this.eo.add(t)}addInvalidRoute(t){this.Vo?this.ch.add(t):this.Ir.add(t)}Te(t){if(this.eo.size!==0&&!(!this.Ts&&this.animationManager.isTicking)){if(this.Ts||(this.Fl=!0),t){this.hT(this.eo);return}for(let e=0;e<23&&this.eo.size!==0;e++){let i=new Set(this.eo);this.eo.clear(),this.k2(i,this.eo)}this.nodes.each(e=>{e instanceof ft&&e.cT(!1)})}}hT(t,e){for(let i of t)!i.Di()||i instanceof ft||(i._r()?(i.ht(1/0,1/0),i.Ut()):e&&e.add(i));for(let i of t)if(i instanceof ft){if(!i.isVisible())continue;this.s1(i)}}k2(t,e){this.hT(t,e);for(let i of t){if(!(i instanceof q))continue;let s=i;s.isVisible()&&(s._r()?(s.ht(1/0,1/0),s.Ut()):e.add(s))}for(let i of t)i instanceof Mt&&i.isVisible()&&(i._r()?(i.ht(1/0,1/0),i.Ut()):e.add(i))}cd(t){let e=t instanceof j,i=e?t.links:t.memberParts,s=this.eo;if(e)this.Te(!0);else{for(;i.next();){let n=i.value;s.has(n)&&(!n.Di()||n instanceof ft||n._r()&&(n.ht(1/0,1/0),n.Ut()))}for(i.reset();i.next();){let n=i.value;if(s.has(n)&&n instanceof ft){if(!n.isVisible())continue;this.s1(n)}}i.reset()}for(;i.next();){let n=i.value;n instanceof q&&s.has(n)&&n.isVisible()&&n._r()&&(n.ht(1/0,1/0),n.Ut())}}s1(t){let e=g.ot(),i=g.ot(),s=t.memberParts;for(;s.next();){let o=s.value;o.isVisible()&&(o instanceof ft?(o.Go()||o.as()||o.fa())&&this.s1(o):o instanceof q?o.fromNode===t||o.toNode===t?i.push(o):e.push(o):(o.ht(1/0,1/0),o.Ut()))}let n=e.length;for(let o=0;o<n;o++){let r=e[o];r.ht(1/0,1/0),r.Ut()}g.Z(e),t.ht(1/0,1/0),t.Ut(),n=i.length;for(let o=0;o<n;o++){let r=i[o];r.ht(1/0,1/0),r.Ut()}g.Z(i)}As(t,e,i,s){if(!(!this._c&&!this.animationManager.isAnimating)){for(let n=0;n<e;n++)t[n].As(i,s);this.Te()}}Ge(t){this.St!==null&&(this.st===null&&g.o("No canvas specified"),this.Qc==="svg"?this.SO(t):this.MO(t))}MO(t){let e=this.animationManager;if(e.ke||e.isAnimating&&!e.isTicking)return;let i=new Date;if(this.Cp(),this.St&&this.St.style.opacity==="0")return;let s=t!==this.Wt,n=this.zt.r,o=n.length,r=this;if(this.As(n,o,r,r.viewportBounds),s)t.clearContextCache(!0),this.ha();else if(!this.qi&&!e.isAnimating)return;let a=this.v,h=this.$e;t.setTransform(h,0,0,h,0,0),t.clearRect(0,0,this.wt,this.xt),this.Zt!==1&&(t.globalAlpha=this.Zt),this.S2(t);for(let f=0;f<o;f++)t.setTransform(h,0,0,h,0,0),t.transform(a.m11,a.m12,a.m21,a.m22,a.dx,a.dy),t.commitTransform(),n[f].Ge(t,r);let l=!1;this.sf?this.sf.Ph(this,t)&&(l=this.dp()):l=!0,l&&(Pt.prototype.Ci=Pt.prototype.Mu),s?(this.Wt.clearContextCache(!0),this.ha()):(this._c=!1,this.qi=!1);let c=+new Date-+i,u=!1,d=this.c2;if(u||this.Ol===null){d[this.yp]=c,this.yp=(this.yp+1)%d.length;let f=0;for(let p=0;p<d.length;p++)f+=d[p];this.pp=f/d.length}if(this.Zt!==1&&(t.globalAlpha=1),u){t.setTransform(1,0,0,1,0,0);for(let f=0;f<d.length;f++)t.fillText(d[f].toString(),20,150+ +(f*20))}}SO(t){if(this.St===null)return;let e=this.animationManager;if(e.ke||e.isAnimating&&!e.isTicking)return;this.Cp();let i=this.wt,s=this.xt;t.surface.resize(i,s,i,s);let n=this.zt.r,o=n.length,r=this;if(this.As(n,o,r,r.viewportBounds),!this.qi&&!e.isAnimating)return;let a=this.v;t.lastDrawnPart=null,t.setDiagramPosScale(a.m11,a.m12,a.m21,a.m22,a.dx,a.dy),this.Zt!==1&&(t.globalAlpha=this.Zt),this.S2(t);let h=this.$e,l=this.st._t;l.setTransform(h,0,0,h,0,0),l.clearRect(0,0,this.wt,this.xt);for(let u=0;u<o;u++)n[u].Ge(t,r);let c=!1;this.sf?this.sf.Ph(this,l)&&(c=this.dp()):c=!0,c&&(Pt.prototype.Ci=Pt.prototype.Mu),this._c=!1,this.qi=!1}o1(t,e,i,s,n,o,r,a,h){if(this.St===null)return;this.st===null&&g.o("No canvas specified"),o===void 0&&(o=null),r===void 0&&(r=null),a===void 0&&(a=!1),h===void 0&&(h=!1),this.Cp(),this.Wt.clearContextCache(!0),this.ha(),this.gh=!0;let l=this.it;this.it=s;let c=this,u=this.zt.r,d=u.length;try{let f=new B(n.x,n.y,i.width/s,i.height/s),p=f.copy();p.addMargin(e),this.ca(p),this.Te(),this.As(u,d,c,f),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,i.width,i.height),r!==null&&r!==""&&(t.fillStyle=r,t.fillBackground(0,0,i.width,i.height));let m=Pt.l();m.Ue(),m.Gs(e.left,e.top),m.it(s),(n.x!==0||n.y!==0)&&m.Gs(-n.x,-n.y),t.setTransform(m.m11,m.m12,m.m21,m.m22,m.dx,m.dy),t.commitTransform(),t instanceof ge&&t.setDiagramPosScale(m.m11,m.m12,m.m21,m.m22,m.dx,m.dy),Pt.i(m),this.S2(t),t.globalAlpha=this.Zt;let y=this.findLayer("Grid");if(o){let b=new I,v=o.iterator;for(v.reset();v.next();){let w=v.value;w instanceof bt&&(!h&&w.layer===y||(w.qc(),b.add(w)))}for(let w=0;w<d;w++)u[w].IR(t,c,b,a);b.each(w=>w.qc())}else for(let b=0;b<d;b++){let v=u[b];v===y?h&&v.Ge(t,c,!0):v.Ge(t,c,a)}this.gh=!1,this.sf&&this.sf.Ph(this,this.Wt)&&this.dp()}finally{this.it=l,this.Wt.clearContextCache(!0),this.ha(),this.As(u,d,c,c.viewportBounds),this.ca(),this.Wt instanceof ge&&(this.Wt.diagramGroup.replaceChildren(),this.redraw())}}getRenderingHint(t){return this.Rr[t]}setRenderingHint(t,e){t==="minDrawingLength"&&(this.Qm=e),this.Rr[t]=e,this.redraw()}resetRenderingHints(){this.Rr=new W,this.Rr.drawShadows=!0,this.Rr.textGreeking=!0,this.Rr.viewportOptimizations=!g.ur,this.Rr.temporaryPixelRatio=!0,this.Rr.pictureRatioOptimization=!0,this.Rr.minDrawingLength=1,this.Qm=1}S2(t){let e=this.Rr;if(e===null)return;if(e.imageSmoothingEnabled!==void 0){let s=!!e.imageSmoothingEnabled;t.setImageSmoothingEnabled(s)}let i=e.defaultFont;i!=null&&(t.font=i)}getInputOption(t){return this.Ju[t]}setInputOption(t,e){this.Ju[t]=e}ZR(){this.Ju=new W,this.Ju.extraTouchArea=10,this.Ju.extraTouchThreshold=10,this.Ju.hasGestureZoom=!0}set(t){return t?(Object.assign(this,t),this):this}attach(t){return this.setProperties(t)}setProperties(t){return j.Lp(this,t),this}static Lp(t,e){if(!e)return;let i=t instanceof H,s=t instanceof j;for(let n in e){n===""&&g.o("Setting properties requires non-empty property names");let o=t,r=n;if(i||s){let h=n.indexOf(".");if(h>0){let l=n.substring(0,h);i?o=t.findObject(l):(o=t[l],o==null&&(o=t.toolManager[l])),g.$(o)?r=n.substring(h+1):g.o("Unable to find object named: "+l+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!g.Hw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(e[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(e[r]);continue}else if(s&&g.Hw(t.toolManager,r))o=t.toolManager;else if(s&&t.fT(r)){t.addDiagramListener(r,e[r]);continue}else if(t instanceof mt&&r==="Changed"){t.addChangedListener(e[r]);continue}else g.o('Trying to set undefined property "'+r+'" on object: '+o.toString());let a=e[n];o[r]=a,r[0]==="_"&&o instanceof tt&&o.addCopyProperty(r)}}VA(){if(this.ra.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.ra.count>0;){let t=this.ra;this.ra=new wt;let e=t.iterator;for(;e.next();){let i=e.key;i.invalidateOtherJumpOvers(e.value),i.Ze()}}this.C()}}C(t){if(t===void 0)this.qi=!0,this.requestUpdate();else{let e=this.viewportBounds;t.isReal()&&e.intersectsRect(t)&&(this.qi=!0,this.requestUpdate())}this.T("InvalidateDraw")}invalidateViewport(t,e){if(this.qi!==!0){if(this.qi=!0,this.Qc==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Nx(),this.maybeUpdate(),this.pS(!0)):this.maybeUpdate()}}Sh(){this.td=!0}ha(){this._c=!0}Cp(){this.$u!==!1&&(this.$u=!1,this.oT(this.wt,this.xt))}oT(t,e){this.aa();let i=this.$e,s=t*i,n=e*i;this.st.resize(s,n,t,e)&&(this.qi=!0,this.Wt.clearContextCache(!0))}lT(){let t=this.st;if(t===null||this.ed.isReal())return!0;let e=this.wt,i=this.xt,s=this.St,n=!1,o=this.so?this.qt:0,r=this.Pn?this.qt:0,a=s.clientWidth||e+o,h=s.clientHeight||i+r,l=this.viewportBounds,c=l.x,u=l.y,d=l.width,f=l.height;if((a!==e+o||h!==i+r)&&(this.so=!1,this.Pn=!1,o=0,r=0,this.wt=a,this.xt=h,this.$u=!0,n=!0,this.aa()),!this.no||!this.viewportBounds.isReal())return!0;let p=this.qb,m=this.Wb;if(this.td=!1,!n&&!this.so&&!this.Pn&&!this.Qu&&!this._u)return!0;let y=this.documentBounds,b=0,v=0,w=0,k=0,S=l.width,M=l.height,F=this.hh;this.contentAlignment.isSpot()?(y.width>S&&(b=F.left,v=F.right),y.height>M&&(w=F.top,k=F.bottom)):(b=F.left,v=F.right,w=F.top,k=F.bottom);let D=y.width+b+v,N=y.height+w+k,L=this.scale,R=L,O=D>a/L,V=N>h/L;if(!n&&!this.so&&!this.Pn&&!O&&!V)return!0;let K=y.x-b,Y=l.x,X=y.right+v,G=l.right+o,rt=y.y-w,lt=l.y,st=y.bottom+k,ht=l.bottom+r,ot="1px",dt="1px";if(this.scrollMode===1&&(O||V)){if(O&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let nt=1;K+1<Y&&(nt=Math.max((Y-K)*L+this.wt,nt)),X>G+1&&(nt=Math.max((X-G)*L+this.wt,nt)),S+o+1<D&&(nt=Math.max((D-S)*L+this.wt,nt)),ot=nt.toString()+"px"}if(V&&this.hasVerticalScrollbar&&this.allowVerticalScroll){let nt=1;rt+1<lt&&(nt=Math.max((lt-rt)*L+this.xt,nt)),st>ht+1&&(nt=Math.max((st-ht)*L+this.xt,nt)),M+r+1<N&&(nt=Math.max((N-M)*L+this.xt,nt)),dt=nt.toString()+"px"}}let pt=ot!=="1px",vt=dt!=="1px";if(!(pt&&vt)&&(pt||vt)){if(O=!(D<S+o),V=!(N<M+r),vt&&(G-=this.qt),pt&&(ht-=this.qt),O&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Nt=1;K+1<Y&&(Nt=Math.max((Y-K)*L+this.wt,Nt)),X>G+1&&(Nt=Math.max((X-G)*L+this.wt,Nt)),S+1<D&&(Nt=Math.max((D-S)*L+this.wt,Nt)),ot=Nt.toString()+"px"}pt=ot!=="1px";let nt=this.xt;if(pt!==this.Pn&&(nt=pt?this.xt-this.qt:this.xt+this.qt),V&&this.hasVerticalScrollbar&&this.allowVerticalScroll){let Nt=1;rt+1<lt&&(Nt=Math.max((lt-rt)*L+nt,Nt)),st>ht+1&&(Nt=Math.max((st-ht)*L+nt,Nt)),M+1<N&&(Nt=Math.max((N-M)*L+nt,Nt)),dt=Nt.toString()+"px"}vt=dt!=="1px"}if(this.op&&!(pt!==this.Pn||vt!==this.so))return(e!==this.wt||i!==this.xt)&&this.maybeUpdate(),!1;if(pt!==this.Pn&&(ot==="1px"?this.xt=this.xt+this.qt:this.xt=Math.max(this.xt-this.qt,1),n=!0),this.Pn=pt,m.style.width=ot,vt!==this.so&&(dt==="1px"?this.wt=this.wt+this.qt:this.wt=Math.max(this.wt-this.qt,1),n=!0,this.ld)){let nt=P.l();vt?(t.style.left=this.qt+"px",this.position=nt.e(this.ct.x+this.qt/this.scale,this.ct.y)):(t.style.left="0px",this.position=nt.e(this.ct.x-this.qt/this.scale,this.ct.y)),P.i(nt)}n&&this.aa(),this.so=vt,m.style.height=dt,this.Vb=!0,n&&(this.$u=!0);let Ct=p.scrollLeft;if(this.hasHorizontalScrollbar&&this.allowHorizontalScroll&&(S+1<D?Ct=(this.position.x-K)*L:K+1<Y?Ct=p.scrollWidth-p.clientWidth:X>G+1&&(Ct=this.position.x*L)),this.ld)switch(this.rb){case"negative":Ct=-(p.scrollWidth-Ct-p.clientWidth);break;case"reverse":Ct=p.scrollWidth-Ct-p.clientWidth;break}if(p.scrollLeft=Ct,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1<N?p.scrollTop=(this.position.y-rt)*L:rt+1<lt?p.scrollTop=p.scrollHeight-p.clientHeight:st>ht+1&&(p.scrollTop=this.position.y*L)),a=this.wt,h=this.xt,p.style.width=a+(this.so?this.qt:0)+"px",p.style.height=h+(this.Pn?this.qt:0)+"px",e!==a||i!==h||this.animationManager.ke){let nt=B.z(c,u,d,f);return this.onViewportBoundsChanged(nt,this.viewportBounds,R,n),B.i(nt),!1}return!0}add(t){let e=t.diagram;if(e===this)return;e!==null&&g.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+e.toString());let i=this.findLayer(t.layerName);if(i===null&&(i=this.findLayer("")),i===null&&g.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===i)return;let s=i.ah(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",i,null,t,null,s),i.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);let n=t.layerChanged;n!==null&&n(t,null,i)}ah(t){this.partManager.ah(t);let e=this;t.Sn(i=>e.uT(i)),t.data||t.Yo(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.Sn(i=>e.partManager.M2(i,null)),(t.as()===!0||t.fa()===!0)&&this.Np(t),t.dT(!0,this),t.gT()?(t.actualBounds.isReal()&&this.C(t.lh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.lh(t.actualBounds)),this.bp!==null&&this.bp(this,t),this.requestUpdate()}ri(t){t.clearAdornments(),this.partManager.ri(t);let e=this;t.data!==null&&t.Sn(i=>e.partManager.N2(i,e)),this.eo.delete(t),t instanceof q&&this.Ir.delete(t),t.gT()?(t.actualBounds.isReal()&&this.C(t.lh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.lh(t.actualBounds)),this.kp!==null&&this.kp(this,t),this.requestUpdate()}remove(t){this.C2(t,!0)}C2(t,e){let i=t.layer;if(i===null||i.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),e&&t.rf();let s=i.ri(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",i,t,null,s,null);let n=t.layerChanged;n!==null&&n(t,i,null)}removeParts(t,e){if(e===void 0&&(e=!1),Array.isArray(t)){let i=t.length;for(let s=0;s<i;s++){let n=t[s];e&&!n.canDelete()||this.remove(n)}}else{let i=new I;i.addAll(t);let s=i.iterator;for(;s.next();){let n=s.value;e&&!n.canDelete()||this.remove(n)}}}copyParts(t,e,i){i===void 0&&(i=!1);let s=null,n=e||this,o=n.model,r=!1,a=!1;try{o.Um()&&(r=o.copiesParentKeyOfNodeData,o.copiesParentKeyOfNodeData=n.commandHandler.copiesParentKey),(o.Em()||o.l1())&&(a=o.copiesGroupKeyOfNodeData,o.copiesGroupKeyOfNodeData=n.commandHandler.copiesGroupKey),s=this.partManager.copyParts(t,e,i)}finally{o.Um()&&(o.copiesParentKeyOfNodeData=r),(o.Em()||o.l1())&&(o.copiesGroupKeyOfNodeData=a)}return s}moveParts(t,e,i,s){if(i===void 0&&(i=!1),s===void 0&&(s=this.Ap()),this.toolManager===null)return;let n=new wt;if(t!==null)if(Array.isArray(t))for(let o=0;o<t.length;o++)this.tl(n,t[o],i,s);else{let o=t.iterator;for(;o.next();)this.tl(n,o.value,i,s)}else{let o=this.parts;for(;o.next();){let r=o.value;this.tl(n,r,i,s)}for(o=this.nodes;o.next();){let r=o.value;this.tl(n,r,i,s)}for(o=this.links;o.next();){let r=o.value;this.tl(n,r,i,s)}}this.Cx(n,e,s,i)}tl(t,e,i,s,n){if(!t.has(e)&&(n===void 0&&(n=!1),!(i&&!n&&!e.canMove()&&!e.canCopy())))if(s===void 0&&(s=this.Ap()),e instanceof it){if(t.set(e,this.Ws(s,e,e.location)),e instanceof ft&&(e.hasPlaceholder()||s.dragsMembers)){let r=e.memberParts;for(;r.next();){let a=r.value;this.tl(t,a,i,s,s.groupsAlwaysMove)}}let o=e.linksConnected;for(;o.next();){let r=o.value;if(t.has(r))continue;let a=r.fromNode,h=r.toNode;a!==null&&t.has(a)&&h!==null&&t.has(h)&&this.tl(t,r,i,s)}if(s.dragsTree){let r=e.findTreeChildrenNodes();for(;r.next();){let a=r.value;this.tl(t,a,i,s)}}}else if(e instanceof q){t.set(e,this.Ws(s,e));let o=e.labelNodes;for(;o.next();){let r=o.value;this.tl(t,r,i,s)}}else e instanceof Mt||t.set(e,this.Ws(s,e,e.location))}Cx(t,e,i,s){if(t===null||t.count===0)return;let n=P.l(),o=P.l();o.h(e),isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0);let r=this.Zb;r||this.uA(t);let a=g.ot(),h=g.ot(),l=t.iterator,c=P.l();for(;l.next();){let m=l.key,y=l.value;if(m.Di()){let b=this.mT(m,t);if(b!==null)a.push(new tr(m,y,b));else if(!s||m.canMove()){let v=y.point;n.h(v),this.computeMove(m,n.add(o),i,c),m.location=c,y.shifted===void 0&&(y.shifted=new P),y.shifted.h(c.subtract(v))}}else l.key instanceof q&&h.push(new Ht(l.key,l.value))}P.i(c);let u=a.length;for(let m=0;m<u;m++){let y=a[m],b=y.pT.point;n.h(b),y.a1.shifted===void 0&&(y.a1.shifted=new P),y.Ri.location=n.add(y.a1.shifted)}let d=P.l(),f=P.l(),p=h.length;for(let m=0;m<p;m++){let y=h[m],b=y.key;if(b instanceof q){if(b.suspendsRouting){b.vr=null;let v=b.fromNode,w=b.toNode;if(this.draggedLink!==null&&i.dragsLink){let k=y.value.point;if(b.dragComputation===null){t.set(b,this.Ws(i,b,o));let S=o.x-k.x,M=o.y-k.y;b.Pr(S,M)}else{let S=P.z(0,0),M=b.getPoint(0);M&&M.isReal()&&S.h(M),c=P.l().h(S).add(o);let F=c;i.isGridSnapEnabled&&(i.isGridSnapRealtime||this.lastInput.up)&&(F=P.l(),this.rM(b,c,F,i)),c.h(b.dragComputation(b,c,F)).subtract(S),t.set(b,this.Ws(i,b,c));let D=c.x-k.x,N=c.y-k.y;b.Pr(D,N),P.i(S),P.i(c),F!==c&&P.i(F)}}else{if(v!==null){d.h(v.location);let k=t.get(v);k!==null&&d.subtract(k.point)}if(w!==null){f.h(w.location);let k=t.get(w);k!==null&&f.subtract(k.point)}if(v!==null&&w!==null)if(d.equalsApprox(f)){let k=y.value.point,S=n;S.h(d),S.subtract(k),t.set(b,this.Ws(i,b,d)),b.Pr(S.x,S.y)}else b.suspendsRouting=!1,b.$t();else{let k=y.value.point,S;v!==null?S=d:w!==null?S=f:S=o,t.set(b,this.Ws(i,b,S));let M=S.x-k.x,F=S.y-k.y;b.Pr(M,F)}}}else if(b.fromNode===null||b.toNode===null){let v=y.value.point;t.set(b,this.Ws(i,b,o));let w=o.x-v.x,k=o.y-v.y;b.Pr(w,k)}}}P.i(n),P.i(o),P.i(d),P.i(f),g.Z(a),g.Z(h),r||(this.Te(),this.mS(t))}computeMove(t,e,i,s){if(s===void 0&&(s=new P),s.h(e),t===null)return s;let n=e,o=i.isGridSnapEnabled;o&&(i.isGridSnapRealtime||this.lastInput.up)&&(n=P.l(),this.rM(t,e,n,i));let r=t.dragComputation!==null?t.dragComputation(t,e,n):n,a=t.minLocation,h=a.x;isNaN(h)&&(h=o?Math.round(t.location.x*1e3)/1e3:t.location.x);let l=a.y;isNaN(l)&&(l=o?Math.round(t.location.y*1e3)/1e3:t.location.y);let c=t.maxLocation,u=c.x;isNaN(u)&&(u=o?Math.round(t.location.x*1e3)/1e3:t.location.x);let d=c.y;return isNaN(d)&&(d=o?Math.round(t.location.y*1e3)/1e3:t.location.y),s.e(Math.max(h,Math.min(r.x,u)),Math.max(l,Math.min(r.y,d))),n!==e&&P.i(n),s}Ap(){let t=this.toolManager.findTool("Dragging");return t instanceof Tt?t.dragOptions:this.ad}rM(t,e,i,s){if(s===void 0&&(s=this.Ap()),i.h(e),t===null)return i;let n=this.grid,o=s.gridSnapCellSize,r=o.width,a=o.height,h=s.gridSnapOrigin,l=h.x,c=h.y,u=s.gridSnapCellSpot;if(n!==null){let f=n.gridCellSize;isNaN(r)&&(r=f.width),isNaN(a)&&(a=f.height);let p=n.gridOrigin;isNaN(l)&&(l=p.x),isNaN(c)&&(c=p.y)}let d=P.z(0,0);return d.setSpot(0,0,r,a,u),A._g(e.x,e.y,l+d.x,c+d.y,r,a,i),P.i(d),i}uA(t){if(t===null)return;this.Zb=!0;let e=t.iterator;for(;e.next();){let i=e.key;i instanceof q&&(i.suspendsRouting=!0)}}mS(t){if(t===null)return;let e=t.iterator;for(;e.next();){let i=e.key;i instanceof q&&(i.suspendsRouting=!1,i.yT()&&i.$t())}this.Zb=!1}get draggedLink(){return this.Qb}set draggedLink(t){this.Qb!==t&&(this.Qb=t,t!==null&&(this._b=t.fromPort,this.t1=t.toPort))}get kS(){return this._b}set kS(t){this._b=t}get PS(){return this.t1}set PS(t){this.t1=t}mT(t,e){let i=t.containingGroup;if(i!==null){let s=this.mT(i,e);if(s!==null||(s=e.get(i),s!==null))return s}return null}Ws(t,e,i){if(i===void 0)return new ni(P.gn);let s=t.isGridSnapEnabled;return!t.groupsSnapMembers&&e.containingGroup!==null&&(s=!1),s?new ni(new P(Math.round(i.x*1e3)/1e3,Math.round(i.y*1e3)/1e3)):new ni(i.copy())}L2(t,e){if(t.diagram!==null&&t.diagram!==this&&g.o("Cannot share a Layer with another Diagram: "+t+" of "+t.diagram),e===null?t.diagram!==null&&g.o("Cannot add an existing Layer to this Diagram again: "+t):(e.diagram!==this&&g.o("Existing Layer must be in this Diagram: "+e+" not in "+e.diagram),t===e&&g.o("Cannot move a Layer before or after itself: "+t)),t.diagram===this)return;let i=t.name,s=this.zt,n=s.count;for(let o=0;o<n;o++)s.elt(o).name===i&&g.o("Cannot add Layer with the name '"+i+"'; a Layer with the same name is already present in this Diagram.")}addLayer(t){this.L2(t,null),t.Eo(this);let e=this.zt,i=e.count-1;if(!t.isTemporary)for(;i>=0&&e.elt(i).isTemporary;)i--;return e.insertAt(i+1,t),this.Ce!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,i+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,e){this.L2(t,e),t.Eo(this);let i=this.zt,s=i.indexOf(t);s>=0&&(i.delete(t),this.Ce!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));let n=i.count,o;for(o=0;o<n;o++)if(i.elt(o)===e){i.insertAt(o,t);break}return this.Ce!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,o),this.C(),s<0&&this.invalidateDocumentBounds(),this}addLayerAfter(t,e){this.L2(t,e),t.Eo(this);let i=this.zt,s=i.indexOf(t);s>=0&&(i.delete(t),this.Ce!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));let n=i.count,o;for(o=0;o<n;o++)if(i.elt(o)===e){i.insertAt(o+1,t);break}return this.Ce!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,o+1),this.C(),s<0&&this.invalidateDocumentBounds(),this}Qr(t,e){t.Eo(this),this.zt.insertAt(e,t)}wT(t){this.zt.removeAt(t)}removeLayer(t){if(t.diagram!==this&&g.o("Cannot remove a Layer from another Diagram: "+t+" of "+t.diagram),t.name==="")return;let e=this.zt,i=e.indexOf(t);if(e.delete(t)){let s=t.Ct.copy().iterator;for(;s.next();){let n=s.value,o=n.layerName;o!==t.name?n.layerName=o:n.layerName=""}this.Ce!==null&&this.raiseChangedEvent(4,"layers",this,t,null,i,null),this.C(),this.invalidateDocumentBounds()}}findLayer(t){let e=this.layers;for(;e.next();){let i=e.value;if(i.name===t)return i}return null}findRouter(t){for(let e of this.nf)if(e.name===t)return e;return null}addModelChangedListener(t){return g.S(t,j,"addModelChangedListener:listener"),this.io===null&&(this.io=new U),this.io.add(t),this.model&&this.model.addChangedListener(t),this}removeModelChangedListener(t){g.S(t,j,"removeModelChangedListener:listener"),this.io!==null&&(this.io.delete(t),this.io.count===0&&(this.io=null)),this.model.removeChangedListener(t)}addChangedListener(t){return g.S(t,j,"addChangedListener:listener"),this.Er===null&&(this.Er=new U),this.Er.add(t),this}removeChangedListener(t){g.S(t,j,"removeChangedListener:listener"),this.Er!==null&&(this.Er.delete(t),this.Er.count===0&&(this.Er=null))}A2(t){if(!this.skipsUndoManager&&!this.model.skipsUndoManager&&this.model.undoManager.handleChanged(t),t.change!==1&&(this.isModified=!0),this.Er!==null){let e=this.Er,i=e.length;for(let s=0;s<i;s++)e.elt(s)(t)}}raiseChangedEvent(t,e,i,s,n,o,r){o===void 0&&(o=null),r===void 0&&(r=null);let a=new si;a.diagram=this,a.change=t,a.propertyName=e,a.object=i,a.oldValue=s,a.oldParam=o,a.newValue=n,a.newParam=r,this.A2(a)}raiseChanged(t,e,i,s,n){this.raiseChangedEvent(2,t,this,e,i,s,n)}t(t,e,i,s,n){this.raiseChangedEvent(2,t,this,e,i,s,n)}get partAdded(){return this.bp}set partAdded(t){this.partAdded!==t&&(this.bp=t)}get partRemoved(){return this.kp}set partRemoved(t){this.partRemoved!==t&&(this.kp=t)}get animationManager(){return this.Ns}get undoManager(){return this.Ce.undoManager}get skipsUndoManager(){return this.Bo}set skipsUndoManager(t){g.s(t,"boolean",j,"skipsUndoManager"),this.Bo=t,this.Ce.skipsUndoManager=t}get delaysLayout(){return this.Lb}set delaysLayout(t){this.Lb=t}tA(t,e){if(t===null||t.diagram!==this)return;let i=this.yi;try{this.yi=!0;let s=t.change;if(s===2){let n=t.object,o=t.propertyName,r=t.getValue(e);if(t.diagram.model.et(n,o,r),n instanceof tt){let a=n.part;a!==null&&a.invalidateAdornments()}this.isModified=!0}else if(s===3){let n=t.object,o=t.newParam,r=t.newValue;if(n instanceof H)if(typeof o=="number"&&r instanceof tt){e?n.ri(o):n.insertAt(o,r);let a=n.part;a!==null&&a.invalidateAdornments()}else typeof o=="number"&&r instanceof Gt&&(r.isRow?n.xT(o,e?void 0:r):n.bT(o,e?void 0:r));else if(n instanceof Vt){let a=t.oldParam===!0;typeof o=="number"&&r instanceof bt&&(e?(a||(r.isSelected=!1,r.isHighlighted=!1,r.invalidateAdornments()),n.ri(a?o:-1,r,a)):n.ah(o,r,a))}else n instanceof j?typeof o=="number"&&r instanceof Vt&&(e?this.wT(o):this.Qr(r,o)):g.o("unknown ChangeType.Insert object: "+t.toString());this.isModified=!0}else if(s===4){let n=t.object,o=t.oldParam,r=t.oldValue;if(n instanceof H)typeof o=="number"&&r instanceof tt?e?n.insertAt(o,r):n.ri(o):typeof o=="number"&&r instanceof Gt&&(r.isRow?n.xT(o,e?r:void 0):n.bT(o,e?r:void 0));else if(n instanceof Vt){let a=t.newParam===!0;typeof o=="number"&&r instanceof bt&&(e?n.Ct.indexOf(r)<0&&n.ah(o,r,a):(a||(r.isSelected=!1,r.isHighlighted=!1,r.invalidateAdornments()),n.ri(a?o:-1,r,a)))}else n instanceof j?typeof o=="number"&&r instanceof Vt&&(e?this.Qr(r,o):this.wT(o)):g.o("unknown ChangeType.Remove object: "+t.toString());this.isModified=!0}else s===1||g.o("unknown ChangedEvent: "+t.toString())}finally{this.yi=i}}startTransaction(t){return this.undoManager.startTransaction(t)}commitTransaction(t){return this.undoManager.commitTransaction(t)}rollbackTransaction(){return this.undoManager.rollbackTransaction()}commit(t,e){let i=e;i===void 0&&(i="");let s=this.skipsUndoManager;i===null&&(this.skipsUndoManager=!0,i=""),this.undoManager.startTransaction(i);let n=!1;try{t(this),n=!0}finally{n?this.undoManager.commitTransaction(i):this.undoManager.rollbackTransaction(),this.skipsUndoManager=s}}updateAllTargetBindings(t){this.partManager.updateAllTargetBindings(t)}updateAllThemeBindings(){if(this.partManager.updateAllThemeBindings(),this.ls!==null){let t=this.ls.part;t!==null&&t.Yo()}}setDivBackground(t){this.div&&(this.div.style.backgroundColor=t)}updateAllRelationshipsFromData(){this.partManager.updateAllRelationshipsFromData()}Mp(){let t=this.v,e=this.it,i=this.ct;t.Ue(),e!==1&&t.it(e),(i.x!==0||i.y!==0)&&t.Gs(-i.x,-i.y)}kT(t,e){let i=this.animationManager;if(this.Ht||this.Ts){this.it=e,this.aa(),this.C(),this.Sh(),i.EA(t,this.it),this.Mp();return}if(this.st===null){this.it=e,this.Mp();return}this.Ht=!0;let s=this.viewportBounds.copy(),n=this.wt,o=this.xt,r=this.zoomPoint.x,a=this.zoomPoint.y,h=this.contentAlignment;isNaN(r)&&(h.isSide()?h.includesSide(T.LeftSide)?r=0:h.includesSide(T.RightSide)&&(r=n-1):h.isSpot()?r=h.x*(n-1):r=n/2),isNaN(a)&&(h.isSide()?h.includesSide(T.TopSide)?a=0:h.includesSide(T.BottomSide)&&(a=o-1):h.isSpot()?a=h.y*(o-1):a=o/2),this.scaleComputation!==null&&!this.animationManager.defaultAnimation.isAnimating&&(e=this.scaleComputation(this,e)),e<this.minScale&&(e=this.minScale),e>this.maxScale&&(e=this.maxScale);let l=P.z(this.ct.x+r/t-r/e,this.ct.y+a/t-a/e);this.position=l,P.i(l),this.it=e,this.Mp(),this.aa(),this.Ht=!1,this.onViewportBoundsChanged(s,this.viewportBounds,t,!1),this.$s(!1),i.EA(t,this.it),this.C()}pO(){let t=this.zt.r;for(let e=0;e<t.length;e++)t[e].YA()}onViewportBoundsChanged(t,e,i,s){if(t.equals(e))return;s===void 0&&(s=!1),s||this.Sh(),this.ha();let n=this.layout;n!==null&&n.isViewportSized&&this.autoScale===1&&(t.width!==e.width||t.height!==e.height)&&n.p();let o=this.currentTool;this.ef===!0&&o instanceof de&&!this.animationManager.isTicking&&(this.lastInput.documentPoint=this.transformViewToDoc(this.lastInput.viewPoint),o.cA(this)),this.Ht||this.invalidateViewport(t,e),this.ca(),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.canvasSize.width=Math.round(t.width*i),this.Ye.canvasSize.height=Math.round(t.height*i),this.Ye.newCanvasSize.width=this.wt,this.Ye.newCanvasSize.height=this.xt,this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t),this.isVirtualized&&this.links.each(r=>{r.isAvoiding&&r.actualBounds.intersectsRect(e)&&r.$t()})}ca(t){let e=this.ls;if(e===null||!e.visible||e.part===null||e.layer===null)return;let i=t!==void 0?t:this.Gb;if(!i.isReal())return;let s=i.width,n=i.height;if(e.scale=1,e.angle=0,e.layer.isViewportAligned)e.width=s*this.scale,e.height=n*this.scale,e.part.alignment=T.TopLeft;else{e.Pe===null&&(e.Pe=new yi);let o=e.Pe.lf;if(!o.isReal())return;e.width=s+o.width*2,e.height=n+o.height*2;let r=P.l();A._g(i.x,i.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),e.part.location=r,P.i(r)}}clearSelection(t){t===void 0&&(t=!1);let e=this.selection;if(e.count===0)return;t||this.T("ChangingSelection",e);let i=e.toArray(),s=i.length;for(let n=0;n<s;n++){let o=i[n];o.isSelected=!1}e.ce(),e.clear(),e.b(),t||this.T("ChangedSelection",e)}select(t){t!==null&&t.diagram===this&&(!t.isSelected||this.selection.count>1)&&(this.T("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.T("ChangedSelection",this.selection))}selectCollection(t){if(this.T("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++){let s=t[i];s instanceof bt||g.o("Diagram.selectCollection given something that is not a Part: "+s),s.isSelected=!0}}else{let e=t.iterator;for(;e.next();){let i=e.value;i instanceof bt||g.o("Diagram.selectCollection given something that is not a Part: "+i),i.isSelected=!0}}this.T("ChangedSelection",this.selection)}clearHighlighteds(){let t=this.highlighteds;if(t.count>0){let e=t.toArray(),i=e.length;for(let s=0;s<i;s++){let n=e[s];n.isHighlighted=!1}t.ce(),t.clear(),t.b()}}highlight(t){t!==null&&t.diagram===this&&(!t.isHighlighted||this.highlighteds.count>1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){let e=new I().addAll(t),i=this.highlighteds.copy().removeAll(e).iterator;for(;i.next();){let n=i.value;n.isHighlighted=!1}let s=e.iterator;for(;s.next();){let n=s.value;n instanceof bt||g.o("Diagram.highlightCollection given something that is not a Part: "+n),n.isHighlighted=!0}}scroll(t,e,i){i===void 0&&(i=1);let s=e==="up"||e==="down",n=0,o=P.l();if(t==="pixel")n=i;else if(t==="line")n=i*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let a=s?this.viewportBounds.height:this.viewportBounds.width;if(a*=this.scale,a!==0){let h=Math.max(a-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=i*h}}else if(t==="document"){let a=this.documentBounds,h=this.viewportBounds;e==="up"?this.position=o.e(h.x,a.y):e==="left"?this.position=o.e(a.x,h.y):e==="down"?this.position=o.e(h.x,a.bottom-h.height):e==="right"&&(this.position=o.e(a.right-h.width,h.y)),P.i(o);return}else g.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;let r=this.position;e==="up"?this.position=o.e(r.x,r.y-n):e==="down"?this.position=o.e(r.x,r.y+n):e==="left"?this.position=o.e(r.x-n,r.y):e==="right"?this.position=o.e(r.x+n,r.y):g.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+e),P.i(o)}scrollToRect(t){let e=this.viewportBounds;if(e.containsRect(t))return;let i=t.center;i.x-=e.width/2,i.y-=e.height/2,this.position=i}centerRect(t){let e=this.viewportBounds,i=t.center;i.x-=e.width/2,i.y-=e.height/2,this.position=i}transformDocToView(t){return t.copy().v(this.v)}transformViewToDoc(t){return t.copy().Ki(this.v)}GR(t){return t.Ki(this.v)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Zt}set opacity(t){let e=this.Zt;e!==t&&(g.s(t,"number",j,"opacity"),(t<0||t>1)&&g.J(t,"0 <= value <= 1",j,"opacity"),this.Zt=t,this.t("opacity",e,t),this.C())}get validCycle(){return this.kb}set validCycle(t){let e=this.kb;e!==t&&(this.kb=t,this.t("validCycle",e,t))}get layers(){return this.zt.iterator}get isModelReadOnly(){let t=this.Ce;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){let e=this.Ce;e!==null&&(e.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){let e=this.zo;e!==t&&(g.s(t,"boolean",j,"isReadOnly"),this.zo=t,this.t("isReadOnly",e,t))}get isEnabled(){return this.Be}set isEnabled(t){let e=this.Be;e!==t&&(g.s(t,"boolean",j,"isEnabled"),this.Be=t,this.t("isEnabled",e,t))}get allowClipboard(){return this.Ab}set allowClipboard(t){let e=this.Ab;e!==t&&(g.s(t,"boolean",j,"allowClipboard"),this.Ab=t,this.t("allowClipboard",e,t))}get allowCopy(){return this.Yl}set allowCopy(t){let e=this.Yl;e!==t&&(g.s(t,"boolean",j,"allowCopy"),this.Yl=t,this.t("allowCopy",e,t))}get allowDelete(){return this.Kl}set allowDelete(t){let e=this.Kl;e!==t&&(g.s(t,"boolean",j,"allowDelete"),this.Kl=t,this.t("allowDelete",e,t))}get allowDragOut(){return this.Tb}set allowDragOut(t){let e=this.Tb;e!==t&&(g.s(t,"boolean",j,"allowDragOut"),this.Tb=t,this.t("allowDragOut",e,t))}get allowDrop(){return this.Db}set allowDrop(t){let e=this.Db;e!==t&&(g.s(t,"boolean",j,"allowDrop"),this.Db=t,this.t("allowDrop",e,t))}get allowTextEdit(){return this.Hl}set allowTextEdit(t){let e=this.Hl;e!==t&&(g.s(t,"boolean",j,"allowTextEdit"),this.Hl=t,this.t("allowTextEdit",e,t))}get allowGroup(){return this.jl}set allowGroup(t){let e=this.jl;e!==t&&(g.s(t,"boolean",j,"allowGroup"),this.jl=t,this.t("allowGroup",e,t))}get allowUngroup(){return this.ql}set allowUngroup(t){let e=this.ql;e!==t&&(g.s(t,"boolean",j,"allowUngroup"),this.ql=t,this.t("allowUngroup",e,t))}get allowInsert(){return this.vb}set allowInsert(t){let e=this.vb;e!==t&&(g.s(t,"boolean",j,"allowInsert"),this.vb=t,this.t("allowInsert",e,t))}get allowLink(){return this.Wl}set allowLink(t){let e=this.Wl;e!==t&&(g.s(t,"boolean",j,"allowLink"),this.Wl=t,this.t("allowLink",e,t))}get allowRelink(){return this.Jl}set allowRelink(t){let e=this.Jl;e!==t&&(g.s(t,"boolean",j,"allowRelink"),this.Jl=t,this.t("allowRelink",e,t))}get allowMove(){return this.$l}set allowMove(t){let e=this.$l;e!==t&&(g.s(t,"boolean",j,"allowMove"),this.$l=t,this.t("allowMove",e,t))}get allowReshape(){return this.Zl}set allowReshape(t){let e=this.Zl;e!==t&&(g.s(t,"boolean",j,"allowReshape"),this.Zl=t,this.t("allowReshape",e,t))}get allowResize(){return this.Ql}set allowResize(t){let e=this.Ql;e!==t&&(g.s(t,"boolean",j,"allowResize"),this.Ql=t,this.t("allowResize",e,t))}get allowRotate(){return this._l}set allowRotate(t){let e=this._l;e!==t&&(g.s(t,"boolean",j,"allowRotate"),this._l=t,this.t("allowRotate",e,t))}get allowSelect(){return this.ta}set allowSelect(t){let e=this.ta;e!==t&&(g.s(t,"boolean",j,"allowSelect"),this.ta=t,this.t("allowSelect",e,t))}get allowUndo(){return this.Fb}set allowUndo(t){let e=this.Fb;e!==t&&(g.s(t,"boolean",j,"allowUndo"),this.Fb=t,this.t("allowUndo",e,t))}get allowZoom(){return this.Rb}set allowZoom(t){let e=this.Rb;e!==t&&(g.s(t,"boolean",j,"allowZoom"),this.Rb=t,this.t("allowZoom",e,t))}get hasVerticalScrollbar(){return this._u}set hasVerticalScrollbar(t){let e=this._u;e!==t&&(g.s(t,"boolean",j,"hasVerticalScrollbar"),this._u=t,this.Sh(),this.C(),this.t("hasVerticalScrollbar",e,t),this.$s(!1))}get hasHorizontalScrollbar(){return this.Qu}set hasHorizontalScrollbar(t){let e=this.Qu;e!==t&&(g.s(t,"boolean",j,"hasHorizontalScrollbar"),this.Qu=t,this.Sh(),this.C(),this.t("hasHorizontalScrollbar",e,t),this.$s(!1))}get allowHorizontalScroll(){return this.Ob}set allowHorizontalScroll(t){let e=this.Ob;e!==t&&(g.s(t,"boolean",j,"allowHorizontalScroll"),this.Ob=t,this.t("allowHorizontalScroll",e,t),this.$s(!1))}get allowVerticalScroll(){return this.Ib}set allowVerticalScroll(t){let e=this.Ib;e!==t&&(g.s(t,"boolean",j,"allowVerticalScroll"),this.Ib=t,this.t("allowVerticalScroll",e,t),this.$s(!1))}get scrollHorizontalLineChange(){return this.Eb}set scrollHorizontalLineChange(t){let e=this.Eb;e!==t&&(g.s(t,"number",j,"scrollHorizontalLineChange"),t<0&&g.J(t,">= 0",j,"scrollHorizontalLineChange"),this.Eb=t,this.t("scrollHorizontalLineChange",e,t))}get scrollVerticalLineChange(){return this.Ub}set scrollVerticalLineChange(t){let e=this.Ub;e!==t&&(g.s(t,"number",j,"scrollVerticalLineChange"),t<0&&g.J(t,">= 0",j,"scrollVerticalLineChange"),this.Ub=t,this.t("scrollVerticalLineChange",e,t))}get lastInput(){return this.uh}set lastInput(t){this.uh=t}get previousInput(){return this.Jr}set previousInput(t){this.Jr=t}get firstInput(){return this.cp}set firstInput(t){this.cp=t}get currentCursor(){return this.Pb}set currentCursor(t){if(t===""&&(t=this.np),this.Pb!==t){g.s(t,"string",j,"currentCursor");let e=this.st,i=this.St;if(e===null||i===null)return;this.Pb=t;let s=e.style.cursor;e.style.cursor=t,i.style.cursor=t,e.style.cursor===s&&(e.style.cursor="-webkit-"+t,i.style.cursor="-webkit-"+t,e.style.cursor===s&&(e.style.cursor="-moz-"+t,i.style.cursor="-moz-"+t,e.style.cursor===s&&(e.style.cursor=t,i.style.cursor=t)))}}get defaultCursor(){return this.np}set defaultCursor(t){t===""&&(t="auto");let e=this.np;e!==t&&(g.s(t,"string",j,"defaultCursor"),this.np=t,this.t("defaultCursor",e,t))}get click(){return this.Ur}set click(t){let e=this.Ur;e!==t&&(t!==null&&g.S(t,j,"click"),this.Ur=t,this.t("click",e,t))}get doubleClick(){return this.Vr}set doubleClick(t){let e=this.Vr;e!==t&&(t!==null&&g.S(t,j,"doubleClick"),this.Vr=t,this.t("doubleClick",e,t))}get contextClick(){return this.Br}set contextClick(t){let e=this.Br;e!==t&&(t!==null&&g.S(t,j,"contextClick"),this.Br=t,this.t("contextClick",e,t))}get mouseOver(){return this.zr}set mouseOver(t){let e=this.zr;e!==t&&(t!==null&&g.S(t,j,"mouseOver"),this.zr=t,this.t("mouseOver",e,t))}get mouseHover(){return this.Xr}set mouseHover(t){let e=this.Xr;e!==t&&(t!==null&&g.S(t,j,"mouseHover"),this.Xr=t,this.t("mouseHover",e,t))}get mouseHold(){return this.Gr}set mouseHold(t){let e=this.Gr;e!==t&&(t!==null&&g.S(t,j,"mouseHold"),this.Gr=t,this.t("mouseHold",e,t))}get mouseDragOver(){return this.Sb}set mouseDragOver(t){let e=this.Sb;e!==t&&(t!==null&&g.S(t,j,"mouseDragOver"),this.Sb=t,this.t("mouseDragOver",e,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){let e=this.Yr;e!==t&&(this.Yr=t,this.t("mouseDrop",e,t))}get handlesDragDropForTopLevelParts(){return this.Mb}set handlesDragDropForTopLevelParts(t){let e=this.Mb;e!==t&&(g.s(t,"boolean",j,"handlesDragDropForTopLevelParts"),this.Mb=t,this.t("handlesDragDropForTopLevelParts",e,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){let e=this.Kr;e!==t&&(t!==null&&g.S(t,j,"mouseEnter"),this.Kr=t,this.t("mouseEnter",e,t))}get mouseLeave(){return this.Hr}set mouseLeave(t){let e=this.Hr;e!==t&&(t!==null&&g.S(t,j,"mouseLeave"),this.Hr=t,this.t("mouseLeave",e,t))}get toolTip(){return this.jr}set toolTip(t){let e=this.jr;e!==t&&(this.jr=t,this.t("toolTip",e,t))}get contextMenu(){return this.qr}set contextMenu(t){let e=this.qr;e!==t&&(this.qr=t,this.t("contextMenu",e,t))}get commandHandler(){return this.HM}set commandHandler(t){let e=this.HM;e!==t&&(e&&e.doStop(),this.HM=t,t.Eo(this),t.doStart())}get toolManager(){return this.GM}set toolManager(t){this.GM!==t&&(this.GM=t,t.diagram=this)}get defaultTool(){return this.YM}set defaultTool(t){let e=this.YM;e!==t&&(this.YM=t,t.diagram=this,this.currentTool===e&&(this.currentTool=t))}get currentTool(){return this.KM}set currentTool(t){let e=this.KM;e&&(e.isActive&&e.doDeactivate(),e.cancelWaitAfter(),e.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.KM=t,t.diagram=this,t.doStart())}get selection(){return this.KA}get maxSelectionCount(){return this.Xb}set maxSelectionCount(t){let e=this.Xb;if(e!==t)if(g.s(t,"number",j,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Xb=t,this.t("maxSelectionCount",e,t),!this.undoManager.isUndoingRedoing){let i=this.selection.count-t;if(i>0){this.T("ChangingSelection",this.selection);let s=this.selection.toArray();for(let n=0;n<i;n++)s[n].isSelected=!1;this.T("ChangedSelection",this.selection)}}}else g.J(t,">= 0",j,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.ap}set nodeSelectionAdornmentTemplate(t){let e=this.ap;e!==t&&(this.ap=t.It(),this.t("nodeSelectionAdornmentTemplate",e,t))}get groupSelectionAdornmentTemplate(){return this.Kb}set groupSelectionAdornmentTemplate(t){let e=this.Kb;e!==t&&(this.Kb=t.It(),this.t("groupSelectionAdornmentTemplate",e,t))}get linkSelectionAdornmentTemplate(){return this.Hb}set linkSelectionAdornmentTemplate(t){let e=this.Hb;e!==t&&(this.Hb=t.It(),this.t("linkSelectionAdornmentTemplate",e,t))}get highlighteds(){return this.HA}get isModified(){let t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.nd&&this.js!==t.historyIndex:this.nd}set isModified(t){if(this.nd!==t){g.s(t,"boolean",j,"isModified"),this.nd=t;let e=this.undoManager;!t&&e.isEnabled&&(this.js=e.historyIndex),t||this.PT()}}PT(){let t=this.isModified;this.JM!==t&&(this.JM=t,this.T("Modified"))}get model(){return this.Ce}set model(t){let e=this.Ce;if(e!==t){this.currentTool.doCancel(),e&&e.undoManager!==t.undoManager&&e.undoManager.isInTransaction&&g.o("Do not replace a Diagram.model while a transaction is in progress.");let i=this.sT(!0);this.no=!1,this.Zu=!0,this.js=-2,this.Dr=!1;let s=this.Ht;this.Ht=!0,this.animationManager.Gl("Model"),e&&(this.io!==null&&this.io.each(n=>e.removeChangedListener(n)),e.removeChangedListener(this.Zc)),this.Ce=t,this.partManager=this.NO(this.Ce.type),this.initializePartManager(this.partManager);for(let n=0;n<i.length;n++)this.add(i[n]);t.addChangedListener(this.WM),this.partManager.T2(),t.removeChangedListener(this.WM),t.addChangedListener(this.Zc),this.io!==null&&this.io.each(n=>t.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),e&&t.undoManager.copyProperties(e.undoManager)}}get themeManager(){return this.u2}set themeManager(t){let e=this.u2;e!==t&&(e&&e.removeDiagram(this),this.u2=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static d2(t,e){j.JA.set(t,e)}static get licenseKey(){return j.D2.last()}static set licenseKey(t){j.D2.add(t.replace(/\s/g,""))}static get version(){return j.CO}static D2=new U;static CO="3.1.0";NO(t){let e=j.JA.get(t);return e!==null?new e:new Ne}get G(){return this.qM}set G(t){this.qM=t}get sb(){return this.jA}LO(t){if(t.model!==this.model)return;let e=t.change,i=t.propertyName;if(e===1&&i[0]==="S"){if(i==="StartingFirstTransaction"){let s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.Ts&&!this.no&&(this.$c=!0,this.Zu&&(this.Dr=!0))}else if(i==="StartingUndo"||i==="StartingRedo"){let s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.T("ChangingSelection",this.selection)}else if(i==="StartedTransaction"){let s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.G){this.G=!1;try{if(t.modelChange===""&&e===1){(i==="FinishedUndo"||i==="FinishedRedo")&&(this.T("ChangedSelection",this.selection),this.Te());let s=this.animationManager;i==="RolledBackTransaction"&&s.stopAnimation(),this.VA(),this.$c=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.PM(),i==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.js=Math.min(this.js,this.undoManager.historyIndex-1)),(i==="CommittedTransaction"||i==="RolledBackTransaction")&&this.undoManager.Px&&g.dn(()=>{this.isModified=!1},1);let n=t.isTransactionFinished;if(n&&(this.PT(),this.sb.clear(),this.animationManager.CR()),!this.Nb&&n&&this.lastInput.targetDiagram){this.Nb=!0;let o=this;g.dn(()=>{o.currentTool.standardMouseOver(),o.Nb=!1},10)}}}finally{this.G=!0}}}get yi(){return this.jM}set yi(t){this.jM=t}get Ou(){return this.Cb}set Ou(t){this.Cb=t}uT(t){let e=t.D.r;for(let i of e)i instanceof zt&&this.v2(i)}v2(t){let e=t.element;if(e===null||!(e instanceof HTMLImageElement)||(e.hs instanceof I&&e.hs.add(this),t.AO(),!e.Tp))return;let i=e.getAttribute("src")||"",s=this.oa.get(i);if(s===null){zt.ST(t,e);let n=[];n.push(t),this.oa.set(i,n)}else{for(let n=0;n<s.length;n++)if(s[n]===t)return;s.push(t)}}TO(t){let e=t.D.r,i=e.length;for(let s=0;s<i;s++)this.F2(e[s])}F2(t){if(!(t instanceof zt))return;let e=t.element;if(e===null||!(e instanceof HTMLImageElement)||!e.Tp)return;let i=e.getAttribute("src")||"",s=this.oa.get(i);if(s!==null){for(let n=0;n<s.length;n++)if(s[n]===t){s.splice(n,1),s.length===0&&(this.oa.delete(i),zt.DO(e),e.hs instanceof I&&e.hs.delete(this),zt.clearCache(i));return}}}nT(){zt.clearCache(),this.oa.clear()}rebuildParts(){this.partManager.rebuildParts()}Yc(t,e){this.Ns.Yc(t,e)}Gc(t,e){this.Ns.Gc(t,e)}findPartForKey(t){return this.partManager.findPartForKey(t)}findNodeForKey(t){return this.partManager.findNodeForKey(t)}findLinkForKey(t){return this.partManager.findLinkForKey(t)}findPartForData(t){return this.partManager.findPartForData(t)}findNodeForData(t){return this.partManager.findNodeForData(t)}findLinkForData(t){return this.partManager.findLinkForData(t)}findNodesByExample(...t){return this.partManager.findNodesByExample(...t)}findLinksByExample(...t){return this.partManager.findLinksByExample(...t)}get nodeTemplate(){return this.Wr.get("")}set nodeTemplate(t){let e=this.Wr.get("");e!==t&&(this.Wr.set("",t),this.t("nodeTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get nodeTemplateMap(){return this.Wr}set nodeTemplateMap(t){let e=this.Wr;e!==t&&(this.Wr=t,this.t("nodeTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get groupTemplate(){return this.fh.get("")}set groupTemplate(t){let e=this.fh.get("");e!==t&&(this.fh.set("",t),this.t("groupTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get groupTemplateMap(){return this.fh}set groupTemplateMap(t){let e=this.fh;e!==t&&(this.fh=t,this.t("groupTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get linkTemplate(){return this.na.get("")}set linkTemplate(t){let e=this.na.get("");e!==t&&(this.na.set("",t),this.t("linkTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get linkTemplateMap(){return this.na}set linkTemplateMap(t){let e=this.na;e!==t&&(this.na=t,this.t("linkTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get isMouseCaptured(){return this.$M}set isMouseCaptured(t){let e=this.st;if(e===null)return;let i=e.bt;i instanceof SVGElement||(t?(this.lastInput.bubbles=!1,this.Le(i,"pointermove",this.yh,!1),this.Le(i,"pointerdown",this.la,!1),this.Le(i,"pointerup",this.wh,!1),this.Le(i,"pointerout",this.xh,!1),this.Le(i,"pointercancel",this.bh,!1),this.Et(C,"pointermove",this.yh,!0),this.Et(C,"pointerdown",this.la,!0),this.Et(C,"pointerup",this.wh,!0),this.Et(C,"pointerout",this.xh,!0),this.Et(C,"pointercancel",this.bh,!0),this.Le(i,"wheel",this.ph,!1),this.Et(C,"wheel",this.ph,!0),this.Et(C,"selectstart",this.ih,!1)):(this.Le(C,"pointermove",this.yh,!0),this.Le(C,"pointerdown",this.la,!0),this.Le(C,"pointerup",this.wh,!0),this.Le(C,"pointerout",this.xh,!0),this.Le(C,"pointercancel",this.bh,!0),this.Et(i,"pointermove",this.yh,!1),this.Et(i,"pointerdown",this.la,!1),this.Et(i,"pointerup",this.wh,!1),this.Et(i,"pointerout",this.xh,!1),this.Et(i,"pointercancel",this.bh,!1),this.Le(C,"wheel",this.ph,!0),this.Le(C,"selectstart",this.ih,!1),this.Et(i,"wheel",this.ph,!1)),this.$M=t)}get position(){return this.ct}set position(t){if(this.ct.equals(t))return;let e=P.l().h(this.ct),i=this.viewportBounds.copy();if(this.ct.h(t),this.animationManager.IA(e,this.ct),!this.Ht&&!(this.st===null&&!this.ed.isReal())){this.Ht=!0;let s=this.scale,n=this.wt/s,o=this.xt/s;this.w2(this.lp,n,o,this.Wc,!1),this.Ht=!1}else this.aa(),this.Mp();if(!this.Ht){let s=this.viewportBounds;this.onViewportBoundsChanged(i,s,this.it,!1)}P.i(e)}get initialPosition(){return this.lb}set initialPosition(t){this.lb.equals(t)||(this.lb=t.N())}get initialScale(){return this.ab}set initialScale(t){this.ab!==t&&(g.s(t,"number",j,"initialScale"),this.ab=t)}get grid(){return this.ls===null&&(this.ls=this.rT()),this.ls}set grid(t){let e=this.ls;if(e!==t){e===null&&(this.ls=this.rT(),e=this.ls),t.type!==H.Grid&&g.o("Diagram.grid must be a Panel of type Panel.Grid");let i=e.panel;i!==null&&i.remove(e),this.ls=t,t.name="GRID",i!==null&&i.add(t),this.sd=!1,this.C(),this.t("grid",e,t)}}get viewportBounds(){return this.Gb}aa(){let t=this.Gb,e=this.ct,i=this.it;t.e(e.x,e.y,Math.max(this.wt,0)/i,Math.max(this.xt,0)/i),this.ha()}get viewSize(){return this.ed}set viewSize(t){let e=this.viewSize;if(!e.equals(t)){t=t.N(),this.ed=t;let i=0,s=0;t.isReal()?(i=t.width,s=t.height):this.St!==null&&(i=this.St.clientWidth||1,s=this.St.clientHeight||1),this.wt=i,this.xt=s,this.aa(),this.invalidateDocumentBounds(),this.t("viewSize",e,t),this.C()}}get fixedBounds(){return this.ub}set fixedBounds(t){let e=this.ub;e.equals(t)||((t.width===-1/0||t.height===1/0||t.height===-1/0)&&g.o("fixedBounds width/height must not be Infinity"),t=t.N(),this.ub=t,this.invalidateDocumentBounds(),this.t("fixedBounds",e,t))}get scrollMargin(){return this.hh}set scrollMargin(t){typeof t=="number"&&(t=new Dt(t));let e=this.hh;e.equals(t)||(t=t.N(),this.hh=t,this.t("scrollMargin",e,t),this.Eu())}get scrollMode(){return this.oh}set scrollMode(t){let e=this.oh;e!==t&&(this.oh=t,t===1&&this.$s(!1),this.t("scrollMode",e,t),this.Sh(),this.C())}get scrollsPageOnFocus(){return this.db}set scrollsPageOnFocus(t){let e=this.db;e!==t&&(g.s(t,"boolean",j,"scrollsPageOnFocus"),this.db=t,this.t("scrollsPageOnFocus",e,t))}get positionComputation(){return this.gb}set positionComputation(t){let e=this.gb;e!==t&&(t!==null&&g.S(t,j,"positionComputation"),this.gb=t,this.$s(!1),this.t("positionComputation",e,t))}get scaleComputation(){return this.pb}set scaleComputation(t){let e=this.pb;e!==t&&(t!==null&&g.S(t,j,"scaleComputation"),this.pb=t,this.kT(this.scale,this.scale),this.t("scaleComputation",e,t))}get documentBounds(){return this.lp}MT(t){this.dh=!1;let e=this.lp;e.equals(t)||(e=e.copy(),this.lp.h(t),this.$s(!1),this.T("DocumentBoundsChanged",void 0,e),this.Sh(),this.C())}ensureBounds(){if(this.dh){let t=B.l();this.MT(this.computeBounds(t)),B.i(t)}}get isVirtualized(){return this.Yb}set isVirtualized(t){let e=this.Yb;e!==t&&(g.s(t,"boolean",j,"isVirtualized"),this.Yb=t,this.t("isVirtualized",e,t))}get scale(){return this.it}set scale(t){let e=this.it;e!==t&&this.kT(e,t)}get defaultScale(){return this.fp}set defaultScale(t){this.fp=t}get autoScale(){return this.ia}set autoScale(t){let e=this.ia;e!==t&&(this.ia=t,this.t("autoScale",e,t),t!==1&&this.$s(!1))}get initialAutoScale(){return this.Or}set initialAutoScale(t){let e=this.Or;e!==t&&(this.Or=t,this.t("initialAutoScale",e,t))}get initialViewportSpot(){return this.wb}set initialViewportSpot(t){let e=this.wb;e!==t&&(t.isSpot()||g.o("initialViewportSpot must be a specific Spot: "+t),this.wb=t,this.t("initialViewportSpot",e,t))}get initialDocumentSpot(){return this.yb}set initialDocumentSpot(t){let e=this.yb;e!==t&&(t.isSpot()||g.o("initialViewportSpot must be a specific Spot: "+t),this.yb=t,this.t("initialDocumentSpot",e,t))}get minScale(){return this.hb}set minScale(t){let e=this.hb;e!==t&&(t>0?(this.hb=t,this.t("minScale",e,t),t>this.scale&&(this.scale=t)):g.J(t,"> 0",j,"minScale"))}get maxScale(){return this.cb}set maxScale(t){let e=this.cb;e!==t&&(t>0?(this.cb=t,this.t("maxScale",e,t),t<this.scale&&(this.scale=t)):g.J(t,"> 0",j,"maxScale"))}get zoomPoint(){return this.fb}set zoomPoint(t){this.fb.equals(t)||(t=t.N(),this.fb=t)}get contentAlignment(){return this.Wc}set contentAlignment(t){let e=this.Wc;e.equals(t)||(t=t.N(),this.Wc=t,this.t("contentAlignment",e,t),this.$s(!1))}get initialContentAlignment(){return this.ep}set initialContentAlignment(t){let e=this.ep;e.equals(t)||(t=t.N(),this.ep=t,this.t("initialContentAlignment",e,t))}get padding(){return this.Qt}set padding(t){typeof t=="number"&&(t=new Dt(t));let e=this.Qt;e.equals(t)||(t=t.N(),this.Qt=t,this.invalidateDocumentBounds(),this.t("padding",e,t))}get partManager(){return this.e2}set partManager(t){let e=this.e2;e!==t&&(t.diagram!==null&&g.o("Cannot share PartManagers between Diagrams: "+t.toString()),e&&e.Eo(null),this.e2=t,t.Eo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){let t=new I,e=this.nodes;for(;e.next();){let s=e.value;s.isTopLevel&&t.add(s)}let i=this.links;for(;i.next();){let s=i.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Zr.iterator}get routers(){return this.nf}doLinkRouting(t){this.Vo=!0;let e=this.nf.r;for(let i=0;i<e.length;i++)e[i].canRoute(t)&&e[i].routeLinks(this.Ir,t);this.Vo=!1}get layout(){return this.li}set layout(t){let e=this.li;e!==t&&(this.li=t,t.diagram=this,t.group=null,this.$r=!0,this.t("layout",e,t),this.requestUpdate())}layoutDiagram(t){this.Te(),t&&this.h1(!0),this.Ts?this.P2(!1,this.Fl||this.nf.count!==0&&this.eo.size!==0):(this.$c=!0,this.Sr())}h1(t){let e=this.Zr.iterator;for(;e.next();)this.NT(e.value,t);this.layout&&(t?this.layout.isValidLayout=!1:this.layout.p())}NT(t,e){if(t===null)return;let i=t.Mh.iterator;for(;i.next();){let s=i.value;this.NT(s,e)}t.layout!==null&&(e?t.layout.isValidLayout=!1:t.layout.p())}P2(t,e){if(this.Lb)return;let i=this.G;this.G=!0;let s="Layout",n=this.undoManager.transactionLevel,o=this.layout,r=this.animationManager;try{n===0&&(this.undoManager.Dl=!0,this.startTransaction(s)),n<=1&&!r.defaultAnimation.isAnimating&&!r.ke&&(t||r.Gl(s)),this.$r=!1;let a=this.Zr.iterator;for(;a.next();)this.cd(a.value),this.CT(a.value,t,n,e);let h=!1;if(o.isValidLayout||(!t||o.isRealtime||o.isRealtime===null||n===0?(o.doLayout(this),this.cd(this),h=!0,o.isValidLayout=!0):this.$r=!0),h||this.cd(this),this.doLinkRouting(this),this.Ir.clear(),this.ch.size!==0){for(let l=0;l<23&&this.ch.size!==0;l++){for(a=this.Zr.iterator;a.next();)this.LT(a.value);let c=this.Ir;this.Ir=this.ch,this.ch=c,this.cd(this),this.doLinkRouting(this)}this.Ir.clear(),this.ch.clear()}}finally{let a=this.undoManager.Dl;n===0&&(this.commitTransaction(s),this.undoManager.Dl=!1),a&&(n===0||n===1)&&r.PM(),this.$r&&(this.$r=!o.isValidLayout),this.G=i}}CT(t,e,i,s){let n=t.Mh.iterator;for(;n.next();)this.CT(n.value,e,i,s);let o=t.layout;o!==null&&!o.isValidLayout?!e||o.isRealtime||i===0?(t.Nh=!t.location.isReal(),o.doLayout(t),t.invalidateLayout(32),this.s1(t),this.cd(t),this.doLinkRouting(t),o.isValidLayout=!0):(this.doLinkRouting(t),this.$r=!0):s&&this.doLinkRouting(t)}LT(t){let e=t.Mh.iterator;for(;e.next();)this.LT(e.value);this.cd(t),this.doLinkRouting(t)}get isTreePathToChildren(){return this.xb}set isTreePathToChildren(t){let e=this.xb;if(e!==t&&(g.s(t,"boolean",j,"isTreePathToChildren"),this.xb=t,this.t("isTreePathToChildren",e,t),!this.undoManager.isUndoingRedoing)){let i=this.nodes;for(;i.next();)i.value.Dp()}}findTreeRoots(){let t=new U,e=this.nodes;for(;e.next();){let i=e.value;i.isTopLevel&&i.findTreeParentLink()===null&&t.add(i)}return t.iterator}get treeCollapsePolicy(){return this.bb}set treeCollapsePolicy(t){let e=this.bb;e!==t&&(t!==1&&t!==2&&t!==3&&g.o("Unknown Diagram.treeCollapsePolicy: "+t),this.bb=t,this.t("treeCollapsePolicy",e,t))}get isCollapsingExpanding(){return this.XM}set isCollapsingExpanding(t){this.XM=t}QR(){let t=new wt,e=new wt;function i(s){let n=s.toLowerCase(),o=new U;t.set(s,o),t.set(n,o),e.set(s,s),e.set(n,s)}i("InitialAnimationStarting"),i("AnimationStarting"),i("AnimationFinished"),i("BackgroundSingleClicked"),i("BackgroundDoubleClicked"),i("BackgroundContextClicked"),i("ClipboardChanged"),i("ClipboardPasted"),i("DocumentBoundsChanged"),i("ExternalObjectsDropped"),i("FocusOrVirtualPointerEnabledChanged"),i("GainedFocus"),i("InitialLayoutCompleted"),i("LayoutCompleted"),i("LinkDrawn"),i("LinkRelinked"),i("LinkReshaped"),i("LostFocus"),i("Modified"),i("ObjectSingleClicked"),i("ObjectDoubleClicked"),i("ObjectContextClicked"),i("PartCreated"),i("PartResized"),i("PartRotated"),i("SelectionMoved"),i("SelectionCopied"),i("SelectionDeleting"),i("SelectionDeleted"),i("SelectionGrouped"),i("SelectionUngrouped"),i("ChangingSelection"),i("ChangedSelection"),i("SubGraphCollapsed"),i("SubGraphExpanded"),i("TextEdited"),i("ThemeChanged"),i("TreeCollapsed"),i("TreeExpanded"),i("ViewportBoundsChanged"),i("InvalidateDraw"),this.BM=t,this.zM=e}fT(t){let e=this.zM.get(t);return e!==null?e:this.zM.get(t.toLowerCase())}R2(t){let e=this.BM.get(t);if(e!==null)return e;let i=t.toLowerCase();if(e=this.BM.get(i),e!==null)return e;g.o("Unknown DiagramEvent name: "+t)}addDiagramListener(t,e){g.s(t,"string",j,"addDiagramListener:name"),g.S(e,j,"addDiagramListener:listener");let i=this.R2(t);return i!==null&&i.add(e),this}removeDiagramListener(t,e){g.s(t,"string",j,"removeDiagramListener:name"),g.S(e,j,"addDiagramListener:listener");let i=this.R2(t);i!==null&&i.delete(e)}raiseDiagramEvent(t,e,i){this.T(t,e,i)}T(t,e,i){let s=this.R2(t),n=new Qi;n.diagram=this;let o=this.fT(t);o!==null&&(n.name=o),e!==void 0&&(n.subject=e),i!==void 0&&(n.parameter=i);let r=s.length;if(r===1)s.elt(0)(n);else if(r!==0){let a=s.toArray();for(let h=0;h<r;h++){let l=a[h];l(n)}}}isUnoccupied(t,e){return this.getPositions(!1,null,e||null).isUnoccupied(t.x,t.y,t.width,t.height)}computeOccupiedArea(t){return this.isVirtualized?this.viewportBounds.copy():this.dh?this.aT(t):t.h(this.documentBounds)}getPositions(t,e,i){let s=this.sa;s===null&&(this.sa=s=new Et(this.avoidanceCellSize));let n=e;if(s.Ko||s.Ch!==n||s.O2!==i){if(s.I2=Math.max(s.af+1,Math.floor(this.avoidanceLimit/this.avoidanceCellSize.width)),s.E2=Math.max(s.af+1,Math.floor(this.avoidanceLimit/this.avoidanceCellSize.height)),n!==null&&(n=this.AT(n)),n===null){let o=B.l();this.computeOccupiedArea(o),o.inflate(100,100),s.c1(o);let r=this.nodes;for(;r.next();){let a=r.value,h=a.layer;h===null||!h.visible||h.isTemporary||this.U2(a,i,o)}B.i(o)}else{if(n.memberParts.count>0){let a=this.computePartsBounds(n.memberParts,!1);a.inflate(20,20),s.c1(a)}let o=B.l(),r=n.memberParts;for(;r.next();){let a=r.value;a instanceof it&&this.U2(a,i,o)}B.i(o)}s.Ch=n,s.O2=i,s.Ko=!1}else t&&s.TT();return s}get avoidanceCellSize(){return this.ZM}set avoidanceCellSize(t){this.sa=null,this.ZM=new _(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.QM}set avoidanceLimit(t){this.QM=Math.max(1,t)}AT(t){return t.canAvoid()?t:t.containingGroup!==null?this.AT(t.containingGroup):null}U2(t,e,i){if(t===e||!t.isVisible())return;let s=t.canAvoid();if(s){let n=t.getAvoidableRect(i);this.sa.vO(n.x,n.y,n.width,n.height)}if(t instanceof ft&&(!s||t.avoidableMembers)){let n=t.memberParts;for(;n.next();){let o=n.value;o instanceof it&&this.U2(o,e,i)}}}V2(t){this.sa!==null&&!this.sa.Ko&&(t===void 0||t.canAvoid())&&(this.sa.Ko=!0)}get autoScrollInterval(){return this.ip}set autoScrollInterval(t){let e=this.ip;e!==t&&(this.ip=t,this.t("autoScrollInterval",e,t))}get autoScrollRegion(){return this.sp}set autoScrollRegion(t){typeof t=="number"&&(t=new Dt(t));let e=this.sp;e.equals(t)||(t=t.N(),this.sp=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",e,t))}doAutoScroll(t){this.hp.h(t);let e=P.l();this.computeAutoScrollPosition(this.hp,e).equalsApprox(this.position)?this.stopAutoScroll():this.DT(),P.i(e)}DT(){if(this.Jc!==-1)return;let t=this.ip,e=this;this.Jc=g.dn(()=>{if(e.Jc===-1||(e.stopAutoScroll(),e.lastInput.event===null))return;let i=P.l(),s=e.computeAutoScrollPosition(e.hp,i);if(!s.equalsApprox(e.position)){e.position=s,e.lastInput.documentPoint=e.transformViewToDoc(e.hp),e.doMouseMove(),e.dh=!0;let n=B.l();e.computeBounds(n),n.unionRect(e.documentBounds),e.MT(n),B.i(n),e.qi=!0,e.maybeUpdate(),e.DT()}P.i(i)},t)}stopAutoScroll(){this.Jc!==-1&&(g.yc(this.Jc),this.Jc=-1)}computeAutoScrollPosition(t,e){let i=this.position;e===void 0&&(e=new P),e.h(i);let s=this.sp;if(s.top<=0&&s.left<=0&&s.right<=0&&s.bottom<=0)return e;let n=this.viewportBounds,o=this.scale,r=B.z(0,0,n.width*o,n.height*o),a=P.z(0,0);if(t.x>=r.x&&t.x<r.x+s.left&&this.allowHorizontalScroll){let h=Math.max(this.scrollHorizontalLineChange,1);h=h|0,a.x-=h,t.x<r.x+s.left/2&&(a.x-=h),t.x<r.x+s.left/4&&(a.x-=4*h)}else if(t.x<=r.x+r.width&&t.x>r.x+r.width-s.right&&this.allowHorizontalScroll){let h=Math.max(this.scrollHorizontalLineChange,1);h=h|0,a.x+=h,t.x>r.x+r.width-s.right/2&&(a.x+=h),t.x>r.x+r.width-s.right/4&&(a.x+=4*h)}if(t.y>=r.y&&t.y<r.y+s.top&&this.allowVerticalScroll){let h=Math.max(this.scrollVerticalLineChange,1);h=h|0,a.y-=h,t.y<r.y+s.top/2&&(a.y-=h),t.y<r.y+s.top/4&&(a.y-=4*h)}else if(t.y<=r.y+r.height&&t.y>r.y+r.height-s.bottom&&this.allowVerticalScroll){let h=Math.max(this.scrollVerticalLineChange,1);h=h|0,a.y+=h,t.y>r.y+r.height-s.bottom/2&&(a.y+=h),t.y>r.y+r.height-s.bottom/4&&(a.y+=4*h)}return a.equalsApprox(P.gn)||(e.x=i.x+a.x/o,e.y=i.y+a.y/o),B.i(r),P.i(a),e}makeSvg(t){this.Xo.has("SVG")||this.addRenderer("SVG",new Bi(this,C.document));let e=new Bi(this,C.document,!0);t===void 0&&(t={});let i=this;function s(n,o){let r=i.vT(n,"SVG",e),a=r!==null?r.svg:null,h=n.svgFinished;return a&&h&&h(a),g.nt(o)?(o(a),null):a}return this.FT(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,e){this.Xo.set(t,e)}removeRenderer(t){this.Xo.delete(t)}cacheGroupExternalLinks(t){this.f2=t,t||this.nodes.each(e=>{e instanceof ft&&(e.vp=null)})}FT(t,e){let i=e.callback,s=!0,n=this.oa.iterator;for(;n.next();)if(!n.value[0].Mn){s=!1;break}if(!g.nt(i)||s)return t(e,i,this);let o=this;function r(){let l=+new Date;for(s=!0,n.reset();n.next();)if(!n.value[0].Mn){s=!1;break}if(s||l-h>a){t(e,i,o);return}C.requestAnimationFrame(r)}let a=e.callbackTimeout||300,h=+new Date;return C.requestAnimationFrame(()=>r()),null}makeImage(t){return j.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.FT(this.FO,t)}static img="image";FO(t,e,i){let s=i.vT(t,"canvas",null);if(s===null)return null;let n=s.F.canvas,o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case j.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case j.img:let a=(t.document||document).createElement("img");a.src=n.toDataURL(t.type,t.details),o=a;break;case"blob":{let h=n;return g.nt(e)||(o="",g.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),g.nt(h.toBlob)?(h.toBlob(e,t.type,t.details),"toBlob"):(e(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return g.nt(e)?(e(o),null):o}static RO=!1;vT(t,e,i){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.st===null)return null;g.$(t)||g.o("properties argument must be an Object.");let s=!1,n=t.size||null,o=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(o="NaN");let r=t.maxSize;t.maxSize===void 0&&(s=!0,e==="SVG"?r=new _(1/0,1/0):r=new _(2e3,2e3));let a=t.position||null,h=t.parts||null;Array.isArray(h)&&(h=new U(h));let l=t.padding===void 0?1:t.padding,c=t.background||null,u=t.omitTemporary;u===void 0&&(u=!0);let d=t.document||document,f=t.elementFinished||null,p=t.showTemporary;p===void 0&&(p=!u);let m=t.showGrid;m===void 0&&(m=p),n!==null&&isNaN(n.width)&&isNaN(n.height)&&(n=null),typeof l=="number"?l=new Dt(l):l instanceof Dt||g.o("MakeImage padding must be a Margin or a number."),l.left=Math.max(l.left,0),l.right=Math.max(l.right,0),l.top=Math.max(l.top,0),l.bottom=Math.max(l.bottom,0),this.Wt.clearContextCache(!0);let y=new He(null,d,void 0,!0),b=y._t;if(!(n||o||h||a))return y.width=this.wt+Math.ceil(l.left+l.right),y.height=this.xt+Math.ceil(l.top+l.bottom),e==="SVG"?i===null?null:(i.resize(y.width,y.height,y.width,y.height),i.el=d,i.fd=f,this.o1(i._t,l,new _(y.width,y.height),this.it,this.ct,h,c,p,m),i._t):(this.od=!1,this.o1(b,l,new _(y.width,y.height),this.it,this.ct,h,c,p,m),this.od=!0,y._t);let v=this.fp,w=this.documentBounds.copy();if(w.subtractMargin(this.Qt),p){let R=this.zt.r,O=R.length;for(let V=0;V<O;V++){let K=R[V];if(!K.visible||!K.isTemporary)continue;let Y=K.Ct.r,X=Y.length;for(let G=0;G<X;G++){let rt=Y[G];if(!rt.isInDocumentBounds||!rt.isVisible())continue;let lt=rt.actualBounds;lt.isReal()&&w.unionRect(lt)}}}let k=new P(w.x,w.y);if(h!==null){let R=new B(0,0,0,0),O=!0,V=h.iterator;for(V.reset();V.next();){let K=V.value;if(!(K instanceof bt))continue;let Y=K.layer;if(Y!==null&&!Y.visible||Y!==null&&!p&&Y.isTemporary||!K.isVisible())continue;let X=K.actualBounds;X.isReal()&&(O?(O=!1,R.h(X)):R.unionRect(X))}w.width=R.width,w.height=R.height,k.x=R.x,k.y=R.y}a!==null&&a.isReal()&&(k=a,o||(o=v));let S=0,M=0;l!==null&&(S=l.left+l.right,M=l.top+l.bottom);let F=0,D=0;n!==null&&(F=n.width,D=n.height,isFinite(F)&&(F=Math.max(0,F-S)),isFinite(D)&&(D=Math.max(0,D-M)));let N=0,L=0;if(n!==null&&o!==null?(o==="NaN"&&(o=v),n.isReal()?(N=F,L=D):isNaN(D)?(N=F,L=w.height*o):(N=w.width*o,L=D)):n!==null?n.isReal()?(o=Math.min(F/w.width,D/w.height),N=F,L=D):isNaN(D)?(o=F/w.width,N=F,L=w.height*o):(o=D/w.height,N=w.width*o,L=D):o!==null?o==="NaN"&&r.isReal()?(o=Math.min((r.width-S)/w.width,(r.height-M)/w.height),o>v?(o=v,N=w.width,L=w.height):(N=r.width,L=r.height)):(N=w.width*o,L=w.height*o):(o=v,N=w.width,L=w.height),l!==null?(N+=S,L+=M):l=new Dt(0),r!==null){let R=r.width,O=r.height;e!=="SVG"&&s&&j.RO,isNaN(R)&&(R=2e3),isNaN(O)&&(O=2e3),isFinite(R)&&(N=Math.min(N,R)),isFinite(O)&&(L=Math.min(L,O))}return y.width=Math.ceil(N),y.height=Math.ceil(L),e==="SVG"?i===null?null:(i.resize(y.width,y.height,y.width,y.height),i.el=d,i.fd=f,this.o1(i._t,l,new _(Math.ceil(N),Math.ceil(L)),o,k,h,c,p,m),i._t):(this.od=!1,this.o1(b,l,new _(Math.ceil(N),Math.ceil(L)),o,k,h,c,p,m),this.od=!0,y._t)}static Ph=null;static B2="5da73c80a36555d5038e4972187c3cae51fd22";static OO="5da73c80a36555d503aa5c72106c30b35bb2006b9cd041b259";static jw=!1;static RP=()=>{if(j.B2[5]===void 0&&(Pt.prototype.Ci=Pt.prototype.Mu),!j.isUsingDOM())return;let t=g.Ni("canvas");t.width=350;let e=t.getContext("2d"),i=g.We("7ca11abfd022028846"),s="7ca11abfd7330390",n=[j.B2,g.jw+"4ae6247590da4bb21c324ba3a84e385776",Pt.RP+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",A.za];e.scale(2,2);let o=8;for(let r=1;r<5;r++)e[g.We(s)](g.We(n[r-1]),o,r*15);e[i]=g.We("39f046ebb36e4b");for(let r=1;r<5;r++)e[g.We(s)](g.We(n[r-1]),o,r*15);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Pt.prototype.Ci=Pt.prototype.Mu),j.Ph=t};static IO=()=>{if(j.B2[5]===void 0&&(Pt.prototype.Ci=Pt.prototype.Mu),!j.isUsingDOM())return;let t=g.Ni("canvas"),e=t.getContext("2d"),i=g.We("7ca11abfd022028846"),s="7ca11abfd7330390",n=[j.OO,A.za],o=5;e.scale(2,2);for(let r=1;r<3;r++)e[g.We(s)](g.We(n[r-1]),o,r*11);e[i]=g.We("39f046ebb36e4b");for(let r=1;r<3;r++)e[g.We(s)](g.We(n[r-1]),o,r*11);(n.length!==2||n[0][0]!=="5")&&(Pt.prototype.Ci=Pt.prototype.Mu),j.Ph=t}}class _o{RT;OT;z2;xi;constructor(t){if(this.RT=null,this.OT="63ad05bbe23a1786468a4c741b6d2",this.z2="@onz",this.OT===this._tk){this.z2=!0,this.xi=this.z2;return}this.xi=null}EO(t,e){let i="f",s=C[g.We("76a715b2f73f148a")][g.We("72ba13b5")]||"",n=g.We;if(this.xi=!0,!j.isUsingDOM())return;let o=j[n("76a115b6ed251eaf4692")];if(!o){let a=s[n("76ad18b4f73e")];for(let l=s[n("73a612b6fb191d")](n("35e7"))+2;l<a;l++)i+=s[l];let h=i[n("73a612b6fb191d")](n("7da71ca0ad381e90"));this.xi=!(h>=0&&h<i[n("73a612b6fb191d")](n("35")));return}let r=j.D2.iterator;for(;r.next();){o=r.value;let a=n(o).split(n("39e9")),h=a.length===7?1:0;if(a.length===1&&o.includes(n("5b8b3797c61b32a7"))){if(j.IO(),!t.st)return;t.dp=t.st._t.F[g.We("7eba17a4ca3b1a8346")][g.We("78a118b7")](t.st._t.F,j.Ph,4,4)}if(a.length<6)return;let l=n(a[1+h]).split(".");if(a[4+h]!=="7da71ca0")return;let c=n(g[n("6cae19")]).split(".");if(!(l[0]>c[0]||l[0]===c[0]&&l[1]>=c[1]))continue;let u="73a612b6fb191d",d=C[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),f=d[n(u)](n("3aad1ab6e022098b4dc4")),p=n(a[2+h]);if(f>-1){let N=d[n(u)](p.toLowerCase()+"/");if(this.xi=!(N>-1&&N<f),!this.xi)return}let m=s[n("76ad18b4f73e")];for(let N=s[n(u)](n("35e7"))+2;N<m;N++)i+=s[N];let y=i[n(u)](p);if(y<0&&p!==n("7da71ca0ad381e90")&&(y=i[n(u)](n("76a715b2ef3e149757"))),y<0&&(y=i[n(u)](n("76a715b2ef3e149757"))),y<0&&(y=i[n(u)](n("2bfa41fdb3784bca12"))),y<0&&(y=s[n(u)](n("7baa19a6f76c1988428554"))),y<0&&(y=s[n(u)](n("7ea902b2b9221e9c57c45767196566"))),this.xi=!(y>=0&&y<i[n(u)](n("35"))||i[n(u)](n("35"))===-1),!this.xi||s[n(u)](n("7fb002b6ed25128b4da25b2e"))&&(this.xi=!(s[n(u)](p)>-1),!this.xi))return;let b=C[g.We("76a715b2f73f148a")][g.We("69ad17a1e03e")],v=b[n(u)](n("7fb002b6ed25128b4da25b2e"));if(v>-1&&(this.xi=!(b[n(u)](p)>v),!this.xi))return;let w=p;if(w[0]!=="#")continue;let k=g.Ni("div"),S=a[0+h].replace(/[A-Za-z]/g,"");for(;S.length<4;)S+="9";let M=S;S=S.substring(S.length-4);let F=parseInt(c[0]),D=parseInt(c[1]);if(F>3||F===3&&D>=1){let N=parseInt(M)%40+30,L=parseInt(w.substring(1,5),16);if(q.IT===N+L){this.xi=!1;return}}else{let N="",L=["gsh","gsf"],R=["Header","Background","Display","Feedback"];if(N+=L[parseInt(S.substring(0,1),10)%2],N+=R[parseInt(S.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=N,C.document[n("78a712aa")]){C.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);let O=C.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),V=C.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(C.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!O)continue;let K=C[n("77a902b0eb1b1e804a8a")],Y="0."+parseInt(M,10)%100;if(V===Y||O.indexOf(parseInt(w[1]+w[2],16).toString())!==-1&&O.indexOf(parseInt(w[3]+w[4],16).toString())!==-1){this.xi=!1;return}else if(K&&K(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){N="."+N;for(let X=0;X<C.document.styleSheets.length;X++){let G=C.document.styleSheets[X].rules||C.document.styleSheets[X].cssRules;for(let rt in G)if(N===G[rt].selectorText){this.xi=!1;return}}}}else this.xi=null,e&&(this.xi=!1)}}}Ph(t,e){return e.setTransform(t.$e/2,0,0,t.$e/2,0,0),e.commitTransform(),this.xi===null&&this.EO(t,!0),0<this.xi&&this!==this.RT}}class ni{X2;G2;constructor(t){this.X2=t===void 0?new P:t,this.G2=new P}get point(){return this.X2}set point(t){this.X2=t}get shifted(){return this.G2}set shifted(t){this.G2=t}}class tr{Ri;pT;a1;constructor(t,e,i){this.Ri=t,this.pT=e,this.a1=i}}class es{isGridSnapEnabled;isGridSnapRealtime;gridSnapCellSize;gridSnapCellSpot;gridSnapOrigin;dragsLink;dragsTree;groupsSnapMembers;groupsAlwaysMove;dragsMembers;constructor(t){this.Ue(),t&&Object.assign(this,t)}Ue(){this.isGridSnapEnabled=!1,this.isGridSnapRealtime=!0,this.gridSnapCellSize=new _(NaN,NaN).b(),this.gridSnapCellSpot=T.TopLeft,this.gridSnapOrigin=new P(NaN,NaN).b(),this.dragsLink=!1,this.dragsTree=!1,this.groupsSnapMembers=!1,this.groupsAlwaysMove=!0,this.dragsMembers=!0}}class er extends j{constructor(t,e){let i;return t===void 0||typeof t=="string"||C.Element&&t instanceof Element?i=t:g.$(t)&&(e=t),super(i),this.ET(),e&&this.setProperties(e),this}ET(){this.allowDragOut=!0,this.allowMove=!1,this.isReadOnly=!0,this.contentAlignment=T.TopCenter,this.layout=new ri}setupRouters(){}reset(){super.reset(),this.ET()}}class Ei extends j{f1;u1;d1;g1;Fp;hf;Bl;Y2;K2;m1;H2;constructor(t,e){let i;return t===void 0||typeof t=="string"||C.Element&&t instanceof Element?i=t:g.$(t)&&(e=t),super(i),this.animationManager.isEnabled=!1,this.Ht=!0,this.f1=null,this.Qu=!1,this._u=!1,this.u1=!0,this.d1=!0,this.g1=0,this.Fp=!1,this.hf=null,this.setRenderingHint("drawShadows",!1),this.Bl=new bt({selectable:!0,selectionAdorned:!1,selectionObjectName:"BOXSHAPE",locationObjectName:"BOXSHAPE",resizeObjectName:"BOXSHAPE",cursor:"move"}).add(new at({name:"BOXSHAPE",fill:"transparent",stroke:"magenta",strokeWidth:2}).theme("stroke","overviewBox")).It(),this.allowCopy=!1,this.allowDelete=!1,this.allowDrop=!1,this.allowSelect=!0,this.autoScrollRegion=new Dt(0,0,0,0),this.ct.e(0,0),this.toolManager.Jt("Dragging",new ir,this.toolManager.mouseMoveTools),this.click=()=>{let s=this.observed;if(s===null)return;let n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new P(o.x-n.width/2,o.y-n.height/2)},this.Y2=s=>{this.invalidateDocumentBounds(),this.Rp()},this.K2=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.m1=s=>{this.updateDelay<1?this.C():this.Fp||(this.Fp=!0,g.dn(()=>this.redraw(),this.updateDelay))},this.H2=s=>{this.observed!==null&&this.Rp()},this.autoScale=2,this.Ht=!1,e&&this.setProperties(e),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.Fp&&this.updateDelay>=1&&(this.Fp=!1,this.UO()),super.redraw()}Ge(){if(this.St===null&&g.o("No div specified"),this.st===null&&g.o("No canvas specified"),this.st instanceof Bi||(this.box.UM(),!this.qi))return;let t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.$a)return;this.Cp();let e=this.st,i=this.Wt;if(i.clearContextCache(!0),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),this.updateDelay<1)this.UT();else if(this.hf!==null){i.drawImage(this.hf.bt,0,0);let o=this.v;i.scale(this.$e,this.$e),i.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),i.commitTransform()}let s=this.zt.r,n=s.length;for(let o=0;o<n;o++)s[o].Ge(i,this);this._c=!1,this.qi=!1}UO(){let t=this.st,e=this.Wt;if(!(t===null||e===null)){if(this.Cp(),this.hf===null){let i=new He(null);i.width=t.width,i.height=t.height,this.hf=i}try{this.st=this.hf,this.Wt=this.st._t,this.Wt.clearContextCache(!0),this.Wt.setTransform(1,0,0,1,0,0),this.Wt.clearRect(0,0,this.st.width,this.st.height),this.UT()}finally{this.st=t,this.Wt=e}}}UT(){let t=this.observed;if(t===null)return;let e=this.drawsTemporaryLayers,i=this.drawsGrid&&e,s=t.grid;if(i&&s!==null&&s.visible&&!(isNaN(s.width)||isNaN(s.height))){let c=B.l().h(this.viewportBounds).unionRect(t.viewportBounds);t.ca(c),B.i(c),t.Te()}let n=this.v,o=this.Wt;o.scale(this.$e,this.$e),o.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),o.commitTransform();let r=this.viewportBounds,a=t.zt.r,h=a.length,l=this.zt.r;this.As(l,l.length,this,this.viewportBounds);for(let c=0;c<h;c++)a[c].ER(o,r,this,e,i)}get observed(){return this.f1}set observed(t){let e=this.f1;if(t!==null&&g.se(t,j,Ei,"observed"),t instanceof Ei&&g.o("Overview.observed Diagram may not be an Overview itself: "+t),e!==t){if(e!==null&&this.VO(e),this.f1=t,t!==null&&this.BO(t),this.invalidateDocumentBounds(),t===null){this.hf=null;let i=this.st,s=this.Wt;i&&s&&(s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,i.width,i.height))}else this.m1(null),this.Rp(),this.C();this.t("observed",e,t)}}get box(){return this.Bl}set box(t){let e=this.Bl;e!==t&&(t.It(),this.Bl=t,this.remove(e),this.add(this.Bl),this.Rp(),this.t("box",e,t))}get drawsTemporaryLayers(){return this.u1}set drawsTemporaryLayers(t){this.u1!==t&&(this.u1=t,this.redraw())}get drawsGrid(){return this.d1}set drawsGrid(t){this.d1!==t&&(this.d1=t,this.redraw())}get updateDelay(){return this.g1}set updateDelay(t){t<0&&(t=0),this.g1!==t&&(this.g1=t)}BO(t){t!==null&&(t.addDiagramListener("ViewportBoundsChanged",this.Y2),t.addDiagramListener("DocumentBoundsChanged",this.K2),t.addDiagramListener("InvalidateDraw",this.m1),t.addDiagramListener("AnimationFinished",this.H2),this.add(this.box))}VO(t){t!==null&&(this.remove(this.box),t.removeDiagramListener("ViewportBoundsChanged",this.Y2),t.removeDiagramListener("DocumentBoundsChanged",this.K2),t.removeDiagramListener("InvalidateDraw",this.m1),t.removeDiagramListener("AnimationFinished",this.H2))}Rp(){let t=this.box,e=this.observed;if(e===null)return;this.qi=!0;let i=e.viewportBounds,s=t.selectionObject,n=_.l();n.e(i.width,i.height),s.desiredSize=n,_.i(n);let o=2/this.scale;s instanceof at&&(s.strokeWidth=o),t.location=new P(i.x-o/2,i.y-o/2),t.isSelected=!0}computeBounds(){let t=this.observed;if(t===null)return B.tm;let e=t.documentBounds.copy();return e.unionRect(t.viewportBounds),e}invalidateViewport(t,e){this.qi!==!0&&(this.qi=!0,this.requestUpdate())}onViewportBoundsChanged(t,e,i,s){this.Ht||(this.ha(),this.C(),this.Sh(),this.invalidateDocumentBounds(),this.Rp(),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t))}}class ir extends Tt{ua;constructor(){super(),this.ua=P.mn}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||!t.allowMove||!t.allowSelect)return!1;let e=t.observed;if(e===null)return!1;let i=t.lastInput;if(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.isTouchEvent&&i.timestamp-t.firstInput.timestamp<this.delay))return!1;if(this.findDraggablePart()===null){let s=e.viewportBounds;this.ua=new P(s.width/2,s.height/2);let n=t.firstInput.documentPoint;e.position=new P(n.x-this.ua.x,n.y-this.ua.y)}return!0}doActivate(){this.ua=P.mn,super.doActivate()}doUpdateCursor(t){let e=this.diagram,i=e.box;i!==null&&i.cursor&&(e.currentCursor=i.cursor)}moveParts(t,e,i){i===void 0&&(i=!1);let s=this.diagram,n=s.observed;if(n===null)return;let o=s.box;if(o===null)return;if(!this.ua.isReal()){let a=s.firstInput.documentPoint,h=o.location;this.ua=new P(a.x-h.x,a.y-h.y)}let r=s.lastInput.documentPoint;n.position=new P(r.x-this.ua.x,r.y-this.ua.y)}}class Jt{a;p1="go._clipboard";w1="go._clipboardFormat";j2;q2;W2;J2;$2;Z2;Q2;_2;tN;da;eN;b1;k1;P1;S1;iN;Ho;sN;nN;Op;oN;M1;rN;N1;lN;aN;ud;Ip;Ep;hN;Zc;cN;fN;uN;dN;gN;dd;mN;Oi;Ps;C1;Up;static gd=["Ctrl","Shft","Alt","Meta"];static VT=Jt.pN(230,40,15);static zO=Jt.pN(270,40,15);static XO=Jt.pN(310,40,15);constructor(t){I.Je(this),this.a=j.Rm(),this.j2=!0,this.q2=!0,this.W2=!0,this.J2=!1,this.$2=!1,this.Z2=!1,this.Q2=!1,this._2="memory",this.tN=null,this.da=null,this.eN=1.05,this.b1=NaN,this.k1=P.mn,this.P1=NaN,this.S1=B.tm,this.iN=!1,this.Ho=null,this.sN=200,this.nN=!1,this.Op=new Mt("Auto",{layerName:"Tool",pickable:!1,selectable:!1}).add(new H("Spot").add(new at({name:"SHAPE",fill:null,stroke:"lime",strokeWidth:4}).bindObject("stroke","adornedPart",e=>e.isSelected?"darkcyan":"lime"),new at({name:"SHAPE2",stretch:2,fill:null,stroke:"magenta",strokeWidth:4,strokeDashArray:[4,4]})),new we({padding:4})),this.oN=null,this.M1="",this.rN="",this.N1=g.ur,this.lN=!1,this.aN=!1,this.ud=new bt({layerName:"Tool",isInDocumentBounds:!1,locationObjectName:"CIRCLE",locationSpot:T.Center,pickable:!1,selectable:!1}).add(new at("Circle",{isGeometryPositioned:!0,width:30,height:30,fill:null,stroke:"darkcyan",strokeWidth:6,visible:!1}).bind("visible","down"),new at({isGeometryPositioned:!0,geometryString:"M15 0L15 30",stroke:"magenta"}),new at({isGeometryPositioned:!0,geometryString:"M0 15L30 15",stroke:"magenta"}),new at("Circle",{name:"CIRCLE",isGeometryPositioned:!0,width:20,height:20,fill:null,stroke:"magenta",position:new P(5,5)}),new at({isGeometryPositioned:!0,geometry:Jt.VT,fill:null,stroke:"cyan",strokeWidth:4}).bind("geometry","button",Jt.GO),new gt({position:new P(12,0),font:"bold 10pt sans-serif"}).bind("text","clickCount",e=>e>1?e.toString():""),new gt({position:new P(0,16)}).bind("text","modifiers",Jt.YO)).freezeBindings(),this.Ip=10,this.Ep=1,this.hN=null,this.Zc=e=>this.KO(e),this.cN=e=>this.HO(e),this.fN=e=>this.jO(e),this.uN=e=>this.qO(e),this.dN=null,this.gN="distance",this.dd=null,this.mN=0,this.Oi={},this.Ps=null,this.C1=!1,this.Up=null,this.yN(),this.ud.data=this.Oi,t&&Object.assign(this,t)}toString(){return"CommandHandler"}get diagram(){return this.a}Eo(t){this.a=t}doStart(){let t=this.a;t&&(t.addModelChangedListener(this.Zc),t.addDiagramListener("ViewportBoundsChanged",this.cN),t.addDiagramListener("GainedFocus",this.fN),t.addDiagramListener("LostFocus",this.uN))}doStop(){let t=this.a;t&&(t.removeDiagramListener("ViewportBoundsChanged",this.cN),t.removeDiagramListener("GainedFocus",this.fN),t.removeDiagramListener("LostFocus",this.uN),t.removeModelChangedListener(this.Zc))}doKeyDown(){let t=this.a,e=t.lastInput,i=e.control||e.meta,s=e.shift,n=e.alt,o=e.commandKey;i&&(o==="Insert"||o==="c")?this.canCopySelection()&&this.copySelection():i&&o==="x"||s&&o==="Delete"?this.canCutSelection()&&this.cutSelection():i&&o==="v"||s&&o==="Insert"?this.canPasteSelection()&&this.pasteSelection():i&&o==="y"||i&&s&&o==="z"||n&&s&&o==="Backspace"?this.canRedo()&&this.redo():i&&o==="z"||n&&o==="Backspace"?this.canUndo()&&this.undo():o==="Delete"||o==="Backspace"?this.canDeleteSelection()&&this.deleteSelection():i&&o==="a"?this.canSelectAll()&&this.selectAll():o==="Escape"?this.canStopCommand()&&this.stopCommand():this.BT.indexOf(o)>=0?this.WO(o,i,s):o==="PageUp"?s&&t.allowHorizontalScroll?t.scroll("page","left"):t.allowVerticalScroll&&t.scroll("page","up"):o==="PageDown"?s&&t.allowHorizontalScroll?t.scroll("page","right"):t.allowVerticalScroll&&t.scroll("page","down"):o==="Home"?i&&t.allowVerticalScroll?t.scroll("document","up"):!i&&t.allowHorizontalScroll&&t.scroll("document","left"):o==="End"?i&&t.allowVerticalScroll?t.scroll("document","down"):!i&&t.allowHorizontalScroll&&t.scroll("document","right"):o==="Space"?this.canScrollToPart()&&this.scrollToPart():o==="Minus"||o==="NumpadSubtract"?this.canDecreaseZoom()&&this.decreaseZoom():o==="Equal"||o==="NumpadAdd"?this.canIncreaseZoom()&&this.increaseZoom():i&&o==="Digit0"?this.canResetZoom()&&this.resetZoom():s&&o==="z"?this.canZoomToFit()&&this.zoomToFit():i&&!s&&o==="g"?this.canGroupSelection()&&this.groupSelection():i&&s&&o==="g"?this.canUngroupSelection()&&this.ungroupSelection():o==="F2"?this.canEditTextBlock()&&this.editTextBlock():o==="ContextMenu"||s&&o==="F10"||i&&s&&o==="Backslash"?this.canShowContextMenu()&&this.showContextMenu():e.bubbles=!0}doKeyUp(){let t=this.a.lastInput;t.bubbles=!0}stopCommand(){let t=this.a,e=t.currentTool;if(e instanceof de){if(e.currentToolTip!==null){e.hideToolTip();return}t.allowSelect&&t.clearSelection()}e!==null&&e.doCancel()}canStopCommand(){return!0}selectAll(){let t=this.a;t.C();try{t.currentCursor="wait",t.T("ChangingSelection",t.selection);let e=t.parts;for(;e.next();){let n=e.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}let i=t.nodes;for(;i.next();){let n=i.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}let s=t.links;for(;s.next();){let n=s.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}}finally{t.T("ChangedSelection",t.selection),t.currentCursor=""}}canSelectAll(){return this.a.allowSelect}deleteSelection(){let t=this.a;try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),t.startTransaction("Delete"),t.T("SelectionDeleting",t.selection);let e=new I,i=t.selection.iterator;for(;i.next();){let s=i.value;bt.ga(e,s,!0,this.deletesTree?1/0:0,this.deletesConnectedLinks?null:!1,n=>n.canDelete())}t.removeParts(e,!0),t.T("SelectionDeleted",e)}finally{t.commitTransaction("Delete"),t.T("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){let t=this.a;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){let t=this.a;try{let e=new I,i=t.selection.iterator;for(;i.next();){let s=i.value;bt.ga(e,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(e)}finally{}}canCopySelection(){let t=this.a;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){let t=this.a;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){let e=this.a,i=this.storageLocation==="systemClipboard";if(i||this.storageLocation!=="memory")try{if(t===null)if(i&&C.navigator.clipboard)C.navigator.clipboard.writeText("");else{let n=C[this.storageLocation];if(!n)return;n.setItem(this.p1,""),n.setItem(this.w1,"")}else{let n=new j;if(n.isTreePathToChildren=e.isTreePathToChildren,n.toolManager.draggingTool.dragsLink=e.toolManager.draggingTool.dragsLink,n.model=e.model.copy(),e.copyParts(t,n,!1),i&&C.navigator.clipboard)C.navigator.clipboard.writeText(n.model.toJson());else{let o=C[this.storageLocation];if(!o)return;o.setItem(this.p1,n.model.toJson()),o.setItem(this.w1,n.model.dataFormat)}}e.T("ClipboardChanged",t);return}catch{return}let s=null;if(t===null)j.iT();else{let n=null;try{n=e.copyParts(t,null,!0)}finally{s=new U,n!==null&&s.addAll(n.iteratorValues),j.Pp=s,j.e1=e.model.dataFormat}}e.T("ClipboardChanged",s)}pasteFromClipboard(){let t=this.a;if(this.storageLocation!=="memory"){let n=new I;try{let o=C[this.storageLocation];if(!o)return n;let r=o.getItem(this.p1),a=o.getItem(this.w1);if(r===null||r===""||a!==t.model.dataFormat)return n;{let h=new j;h.model=mt.fromJson(r);let l=new I;l.addAll(h.parts).addAll(h.nodes).addAll(h.links);let c=t.copyParts(l,t,!1);return new I().addAll(c.iteratorValues)}}catch{return n}}let e=new I,i=j.Pp;if(i===null||j.e1!==t.model.dataFormat)return e;let s=null;try{s=t.copyParts(i,t,!1)}finally{if(s!==null){let n=s.iterator;for(;n.next();){let o=n.value,r=n.key;o.location.isReal()||(r.location.isReal()?o.location=r.location:!o.position.isReal()&&r.position.isReal()&&(o.position=r.position)),e.add(o)}}}return e}async pasteSelectionAsync(t){let e=this.a;if(C.navigator.clipboard===void 0){g.ne('Cannot paste with storageLocation "clipboard", window.isSecureContext may be false.');return}try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Paste");let i=null,s=await C.navigator.clipboard.readText();try{let o=s;if(!(o===null||o==="")){let r=new j;r.model=mt.fromJson(o);let a=new I;a.addAll(r.parts).addAll(r.nodes).addAll(r.links);let h=e.copyParts(a,e,!1);i=new I().addAll(h.iteratorValues)}}catch{}if(i===null)return;i.count>0&&e.clearSelection(!0);let n=i.iterator;for(;n.next();){let o=n.value;o.isSelected=!0}if(t){let o=e.computePartsBounds(e.selection);if(o.isReal()){let r=this.computeEffectiveCollection(e.selection,e.ad);e.Cx(r,new P(t.x-o.centerX,t.y-o.centerY),e.ad,!1)}}e.T("ClipboardPasted",i)}finally{e.commitTransaction("Paste"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}pasteSelection(t){if(this.storageLocation==="systemClipboard"){this.pasteSelectionAsync(t);return}let e=this.a;try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Paste");let i=this.pasteFromClipboard();i.count>0&&e.clearSelection(!0);let s=i.iterator;for(;s.next();){let n=s.value;n.isSelected=!0}if(t){let n=e.computePartsBounds(e.selection);if(n.isReal()){let o=this.computeEffectiveCollection(e.selection,e.ad);e.Cx(o,new P(t.x-n.centerX,t.y-n.centerY),e.ad,!1)}}e.T("ClipboardPasted",i)}finally{e.commitTransaction("Paste"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}canPasteSelection(t){let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowInsert||!e.allowClipboard)return!1;if(this.storageLocation==="systemClipboard")return!0;if(this.storageLocation!=="memory")try{let i=C[this.storageLocation];if(!i)return!1;let s=i.getItem(this.p1),n=i.getItem(this.w1);return!(s===null||s===""||n!==e.model.dataFormat)}catch{return!1}return!(j.Pp===null||j.Pp.count===0||j.e1!==e.model.dataFormat)}undo(){this.a.undoManager.undo()}canUndo(){let t=this.a;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.a.undoManager.redo()}canRedo(){let t=this.a;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);let e=this.a;if(e.autoScale!==1)return;let i=e.scale*t;i<e.minScale||i>e.maxScale||(e.scale=i)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);let e=this.a;if(e.autoScale!==1)return!1;let i=e.scale*t;return i<e.minScale||i>e.maxScale?!1:e.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);let e=this.a;if(e.autoScale!==1)return;let i=e.scale*t;i<e.minScale||i>e.maxScale||(e.scale=i)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);let e=this.a;if(e.autoScale!==1)return!1;let i=e.scale*t;return i<e.minScale||i>e.maxScale?!1:e.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);let e=this.a;t<e.minScale||t>e.maxScale||(e.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);let e=this.a;return t<e.minScale||t>e.maxScale?!1:e.allowZoom}zoomToFit(t){let e=this.a,i=e.animationManager;i.stopAnimation(),e.redraw();let s=e.position.copy(),n=e.scale;if(i.Gl("Zoom To Fit"),!t&&this.isZoomToFitRestoreEnabled&&n===this.P1&&!isNaN(this.b1)&&this.k1.isReal()&&e.documentBounds.equals(this.S1))e.scale=this.b1,e.position=this.k1,this.P1=NaN,this.S1=B.tm;else{if(this.b1=n,this.k1=s,t){let o=t.copy();if(o.width>0&&o.height>0){let r=e.viewportBounds,a=r.width*n,h=r.height*n,l=Math.min(a/o.width,h/o.height),c=a/l,u=h/l;o.width<c&&(o.x-=(c-o.width)/2),o.height<u&&(o.y-=(u-o.height)/2)}e.zoomToRect(o,2)}else e.zoomToFit();this.P1=e.scale,this.S1=e.documentBounds.copy()}i.PM()}canZoomToFit(t){return this.a.allowZoom}WO(t,e,i){let s=this.a;t==="ArrowUp"?s.allowVerticalScroll&&(e?s.scroll("pixel","up"):s.scroll("line","up")):t==="ArrowDown"?s.allowVerticalScroll&&(e?s.scroll("pixel","down"):s.scroll("line","down")):t==="ArrowLeft"?s.allowHorizontalScroll&&(e?s.scroll("pixel","left"):s.scroll("line","left")):t==="ArrowRight"&&s.allowHorizontalScroll&&(e?s.scroll("pixel","right"):s.scroll("line","right"))}scrollToPart(t){t===void 0&&(t=null),t!==null&&g.se(t,bt,Jt,"part");let e=this.a;if(e.ensureBounds(),t===null){try{this.Ho!==null&&(this.Ho.next()?t=this.Ho.value:this.Ho=null)}catch{this.Ho=null}t===null&&(e.highlighteds.count>0?this.Ho=e.highlighteds.iterator:e.selection.count>0&&(this.Ho=e.selection.iterator),this.Ho!==null&&this.Ho.next()&&(t=this.Ho.value))}if(t!==null){let i=e.animationManager;i.Gl("Scroll To Part");let s=this.scrollToPartPause;if(s>0){let n=this.cf(t,[t]);if(n.length===1)e.startTransaction(),e.centerRect(t.actualBounds),e.commitTransaction("Scroll To Part");else{let o=()=>{e.startTransaction();let a=n.pop();for(;n.length>0&&a instanceof it&&a.isTreeExpanded&&(!(a instanceof ft)||a.isSubGraphExpanded);)a=n.pop();n.length>0?(a instanceof bt&&e.scrollToRect(a.actualBounds),a instanceof it&&!a.isTreeExpanded&&(a.isTreeExpanded=!0),a instanceof ft&&!a.isSubGraphExpanded&&(a.isSubGraphExpanded=!0)):(a instanceof bt&&e.centerRect(a.actualBounds),e.removeDiagramListener("LayoutCompleted",r)),e.commitTransaction("Scroll To Part")},r=()=>{g.dn(o,(i.isEnabled?i.duration:0)+s)};e.addDiagramListener("LayoutCompleted",r),o()}}else{let n=e.position.copy();e.centerRect(t.actualBounds),n.equalsApprox(e.position)&&i.stopAnimation()}}}cf(t,e){if(t.isVisible())return e;if(t instanceof Mt){let i=t.adornedPart;i!==null&&this.cf(i,e)}else if(t instanceof q){let i=t.fromNode;i!==null&&this.cf(i,e);let s=t.toNode;s!==null&&this.cf(s,e)}else{if(t instanceof it){let s=t.labeledLink;s!==null&&this.cf(s,e);let n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&e.push(n),this.cf(n,e))}let i=t.containingGroup;i!==null&&(!i.isSubGraphExpanded&&!i.wasSubGraphExpanded&&e.push(i),this.cf(i,e))}return e}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof bt))return!1;let e=this.a;return e.selection.count===0&&e.highlighteds.count===0?!1:e.allowHorizontalScroll&&e.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);let e=this.a,i="Collapse Tree";try{e.startTransaction(i),e.animationManager.Gl(i);let s=new U;if(t!==null&&t.isTreeExpanded)t.collapseTree(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof it&&o.isTreeExpanded&&(o.collapseTree(),s.add(o))}}e.T("TreeCollapsed",s)}finally{e.commitTransaction(i)}}canCollapseTree(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null){if(!(t instanceof it)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof it){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);let e=this.a,i="Expand Tree";try{e.startTransaction(i),e.animationManager.Gl(i);let s=new U;if(t!==null&&!t.isTreeExpanded)t.expandTree(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof it&&(o.isTreeExpanded||(o.expandTree(),s.add(o)))}}e.T("TreeExpanded",s)}finally{e.commitTransaction(i)}}canExpandTree(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null){if(!(t instanceof it)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof it){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){let t=this.a,e=t.model;if(!e.ff())return;let i=this.archetypeGroupData;if(i===null)return;let s=null;try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),t.startTransaction("Group");let n=new U,o=t.selection.iterator;for(;o.next();){let l=o.value;l.Di()&&l.canGroup()&&n.add(l)}let r=new U,a=n.iterator;for(;a.next();){let l=a.value,c=!1,u=n.iterator;for(;u.next();){let d=u.value;if(l.isMemberOf(d)){c=!0;break}}c||r.add(l)}let h=r.first();if(h!==null){let l=h.containingGroup;if(l!==null)for(;l!==null;){let c=!1,u=r.iterator;for(;u.next();)if(!u.value.isMemberOf(l)){c=!0;break}if(c)l=l.containingGroup;else break}if(i instanceof ft)i.It(),s=i.copy(),s!==null&&t.add(s);else if(e.isGroupForData(i)){let c=e.copyNodeData(i);e.addNodeData(c),s=t.findNodeForData(c)}if(s!==null){l!==null&&this.isValidMember(l,s)&&(s.containingGroup=l);let c=r.iterator;for(;c.next();){let u=c.value;this.isValidMember(s,u)&&(u.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.T("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.T("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){let t=this.a;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.ff()||this.archetypeGroupData===null)return!1;let e=t.selection.iterator;for(;e.next();){let i=e.value;if(i.Di()&&i.canGroup())return!0}return!1}wN(t){let e=g.ot();if(Array.isArray(t))t.forEach(n=>{n instanceof q||n instanceof bt&&e.push(n)});else{let n=t.iterator;for(;n.next();){let o=n.value;o instanceof q||o instanceof bt&&e.push(o)}}let i=new I,s=e.length;for(let n=0;n<s;n++){let o=e[n],r=!0;for(let a=0;a<s;a++)if(o.isMemberOf(e[a])){r=!1;break}r&&i.add(o)}return g.Z(e),i}isValidMember(t,e){if(e===null||t===e||e instanceof q)return!1;let i;return t!==null&&(t===e||t.isMemberOf(e)||(i=t.memberValidation,i!==null&&!i(t,e))||t.data===null&&e.data!==null||t.data!==null&&e.data===null)?!1:(i=this.memberValidation,i!==null?i(t,e):!0)}ungroupSelection(t){t===void 0&&(t=null);let e=this.a,i=e.model;if(i.ff())try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Ungroup");let s=new U;if(t!==null)s.add(t);else{let o=e.selection.iterator;for(;o.next();){let r=o.value;r instanceof ft&&r.canUngroup()&&s.add(r)}}let n=new U;if(s.count>0){e.clearSelection(!0);let o=s.iterator;for(;o.next();){let r=o.value;r.expandSubGraph();let a=r.containingGroup,h=a!==null&&a.data!==null?i.getKeyForNodeData(a.data):void 0;n.addAll(r.memberParts);let l=n.iterator;for(;l.next();){let c=l.value;if(c.isSelected=!0,c instanceof q)continue;let u=c.data;u!==null?i.setGroupForData(u,h):c.containingGroup=a}e.remove(r)}}e.T("SelectionUngrouped",s,n)}finally{e.commitTransaction("Ungroup"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowDelete||!e.allowUngroup||!e.model.ff())return!1;if(t!==null){if(!(t instanceof ft))return!1;if(t.canUngroup())return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ft&&s.canUngroup())return!0}}return!1}addTopLevelParts(t,e){let i=this.wN(t),s=!0,n=i.iterator;for(;n.next();){let o=n.value;o.containingGroup!==null&&(!e||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);let e=this.a,i="Collapse SubGraph";try{e.startTransaction(i),e.animationManager.Gl(i);let s=new U;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof ft&&o.isSubGraphExpanded&&(o.collapseSubGraph(),s.add(o))}}e.T("SubGraphCollapsed",s)}finally{e.commitTransaction(i)}}canCollapseSubGraph(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null)return!(!(t instanceof ft)||!t.isSubGraphExpanded);{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ft&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);let e=this.a,i="Expand SubGraph",s=new U;try{if(e.startTransaction(i),e.animationManager.Gl(i),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof ft&&(o.isSubGraphExpanded||(o.expandSubGraph(),s.add(o)))}}e.T("SubGraphExpanded",s)}finally{for(let n of s)this.zT(e,n);t&&this.zT(e,t),e.commitTransaction(i)}}zT(t,e){for(let i of e.memberParts)i instanceof it&&t.Gc(i,e)}canExpandSubGraph(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null)return!(!(t instanceof ft)||t.isSubGraphExpanded);{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ft&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&g.se(t,gt,Jt,"editTextBlock");let e=this.a,i=e.toolManager.findTool("TextEditing");if(i!==null){if(t===null){let s=null,n=e.selection.iterator;for(;n.next();){let o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof gt&&o.editable)}t!==null&&(e.currentTool=null,i.textBlock=t,e.currentTool=i)}}canEditTextBlock(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowTextEdit||e.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof gt))return!1;let i=t.part;if(i!==null&&i.canEdit())return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof gt&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){let e=this.a,i=e.toolManager.findTool("ContextMenu");if(i===null)return;t===void 0&&(t=null),t===null&&(e.selection.count>0?t=e.selection.first():t=e);let s=i.findObjectWithContextMenu(t);if(s!==null){let n=e.lastInput,o;if(s instanceof tt?o=s.getDocumentPoint(T.Center):e.viewportBounds.containsPoint(n.documentPoint)?o=P.mn:o=e.viewportBounds.center,o.isReal()){let r=new Se;r.diagram=e,r.viewPoint=e.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,e.lastInput=r}e.currentTool=i,i.openMenu(!1,s)}}canShowContextMenu(t){let e=this.a,i=e.toolManager.findTool("ContextMenu");return!(i===null||(t===void 0&&(t=null),t===null&&(e.selection.count>0?t=e.selection.first():t=e),i.findObjectWithContextMenu(t)===null))}downloadSvg(t){let e=this.a,i={scale:1,background:e.div?e.div.style.backgroundColor:"white",name:this.JO("svg")};t&&Object.assign(i,t);let s=e.makeSvg(i);if(s!==null){let n=new XMLSerializer().serializeToString(s);this.$O(i.name,"image/svg+xml",n)}}downloadSVG(t){this.downloadSvg(t)}canDownloadSvg(t){return this.a!==null}$O(t,e,i){let s=null,n=null;try{let o=new Blob([i],{type:e});s=C.URL.createObjectURL(o),n=g.Ni("a"),n.style.display="none",n.href=s,n.download=t,C.document.body.appendChild(n),requestAnimationFrame(()=>{try{n!==null&&n.click()}finally{s!==null&&C.URL.revokeObjectURL(s),n!==null&&C.document.body.removeChild(n)}})}catch{s!==null&&C.URL.revokeObjectURL(s),n!==null&&C.document.body.removeChild(n)}}JO(t){let e="."+t,i=this.diagram.model.name;return i?i.endsWith(e)&&(i=i.substring(0,i.length-e.length)):i="diagram",i+=e,i}get copiesClipboardData(){return this.j2}set copiesClipboardData(t){this.j2=!!t}get copiesConnectedLinks(){return this.q2}set copiesConnectedLinks(t){this.q2=!!t}get deletesConnectedLinks(){return this.W2}set deletesConnectedLinks(t){this.W2=!!t}get copiesTree(){return this.J2}set copiesTree(t){this.J2=!!t}get deletesTree(){return this.$2}set deletesTree(t){this.$2=!!t}get copiesParentKey(){return this.Z2}set copiesParentKey(t){this.Z2=!!t}get copiesGroupKey(){return this.Q2}set copiesGroupKey(t){this.Q2=!!t}get storageLocation(){return this._2}set storageLocation(t){t||(t="memory"),t!=="memory"&&t!=="sessionStorage"&&t!=="localStorage"&&t!=="systemClipboard"&&g.o("Invalid new value for CommandHandler.storageLocation: "+t),this._2=t}get archetypeGroupData(){return this.tN}set archetypeGroupData(t){t!==null&&g.wc(t,Jt,"archetypeGroupData");let e=this.a;this.tN=t}get memberValidation(){return this.da}set memberValidation(t){t!==null&&g.S(t,Jt,"memberValidation"),this.da=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.eN}set zoomFactor(t){t>1||g.o("zoomFactor must be larger than 1.0, not: "+t),this.eN=t}get isZoomToFitRestoreEnabled(){return this.iN}set isZoomToFitRestoreEnabled(t){this.iN=!!t}get scrollToPartPause(){return this.sN}set scrollToPartPause(t){this.sN=t}computeEffectiveCollection(t,e){let i=this.a,s=i.toolManager.findTool("Dragging"),n=i.currentTool===s;e===void 0&&(e=i.Ap());let o=new wt;if(t===null)return o;let r=t.iterator;for(;r.next();){let a=r.value;i.tl(o,a,n,e)}if(i.draggedLink!==null&&e.dragsLink)return o;for(r=t.iterator;r.next();){let a=r.value;if(a instanceof q){let h=a.fromNode;if(h!==null&&!o.has(h))o.delete(a);else{let l=a.toNode;l!==null&&!o.has(l)&&o.delete(a)}}}return o}static getModifierNames(){return Jt.gd}static setModifierNames(t){Jt.gd=t}static YO(t){let e="";return t&1&&(e+=Jt.gd[0]||""),t&4&&(e+=Jt.gd[1]||""),t&2&&(e+=Jt.gd[2]||""),t&8&&(e+=Jt.gd[3]||""),e}static GO(t){return t===1?Jt.zO:t===2?Jt.XO:Jt.VT}static pN(t,e,i){var s=new P(i,0).rotate(t-e/2),n=new St().add(new jt(-i,-i)).add(new jt(i,i)).add(new jt(s.x,s.y).add(new xt(5,t-e/2,e,0,0,i,i)));return n.offset(i,i),n}KO(t){t.isTransactionFinished&&this.updateFocusBox()}HO(t){if(t.subject.scale===this.diagram.scale)return;let e=4/this.diagram.scale,i=this.focusBox.findObject("SHAPE");i!==null&&(i.strokeWidth=e);let s=this.focusBox.findObject("SHAPE2");s!==null&&(s.strokeWidth=e,s.strokeDashArray=[e,e]);let n=this.focusBox.placeholder;n!==null&&(n.padding=e)}jO(t){this.focus===null?g.dn(()=>{this.focus=this.findFirstFocus()},500):this.onFocusChanged(this.focus,this.focus)}qO(t){this.isVirtualPointerShown=!1}get isFocusEnabled(){return this.nN}set isFocusEnabled(t){t=!!t;let e=this.isFocusEnabled;t!==e&&(t||(this.isVirtualPointerShown=!1,this.dN=this.focus,this.focus=null),this.nN=t,t&&(this.focus=this.dN,this.updateFocusBox()))}get focusBox(){return this.Op}set focusBox(t){if(!(t instanceof Mt))return;let e=this.Op;if(t!==e&&(this.Op=t,e.adornedObject!==null)){let i=e.adornedPart;i!==null&&i.removeAdornment("Focus"),t.adornedObject=e.adornedObject,i!==null&&i.addAdornment("Focus",t)}}get focus(){return this.Op.adornedObject}set focus(t){let e=this.focus;if(t!==e){let i=this.a;if(!i||!this.isFocusEnabled||t!==null&&t.diagram!==i)return;i.currentTool instanceof Xt||this.cancelVirtualPointer();let s=this.focusBox.adornedPart;s&&s.removeAdornment("Focus"),t===null?(this.dd=null,this.virtualPointerLocation=i.viewportBounds.center,this.focusBox.adornedObject=null):(this.virtualPointerLocation=t.getDocumentPoint(T.Center),this.focusBox.adornedObject=t,this.updateFocusBox()),this.onFocusChanged(e,t)}}onFocusChanged(t,e){let i=this.a;if(i&&(this.focusChanged!==null?this.focusChanged(t,e,this):this.ZO(this.describe(t,e)),e!==null&&e.part!==null)){let s=e.getDocumentBounds();i.viewportBounds.containsRect(s)||(e instanceof bt?i.commandHandler.scrollToPart(e):i.scrollToRect(s))}}get focusChanged(){return this.oN}set focusChanged(t){t!==null&&g.S(t,Jt,"focusChanged"),this.oN=t}get liveElementId(){return this.M1||this.rN}set liveElementId(t){let e=this.M1;t!==e&&(this.M1=t,this.xN())}xN(){let t=this.diagram;if(!t||!j.isUsingDOM())return;let e=t.st?.bt;if(!e)return;let i=this.liveElementId,s=C.document.getElementById(i);this.isUsingAriaLive?(e.removeAttribute("aria-labelledby"),s&&s.setAttribute("aria-live","polite")):(i&&e.setAttribute("aria-labelledby",i),s&&s.removeAttribute("aria-live"))}get isUsingAriaLive(){return this.N1}set isUsingAriaLive(t){let e=this.N1;t!==e&&(this.N1=t,this.xN())}ZO(t){let e=this.diagram;if(!e||!j.isUsingDOM()||!e.div)return;let i=this.liveElementId;if(!i){let n=g.Ni("span"),o=n.style;for(o.opacity="0",o.position="absolute",o.right="-9999px",o.bottom="-9999px",o.width="0px",o.height="0px",o.overflow="hidden",o.border="0",i=(e.div.id||"diagram")+"_aria";C.document.getElementById(i);)i+=Math.floor(Math.random()*10);n.id=i,this.rN=i,e.div.appendChild(n),this.xN()}let s=C.document.getElementById(i);s&&(s.textContent=t)}describe(t,e){let i="";e instanceof it?e instanceof ft?i="Group":i="Node":e instanceof q?i="Link":e instanceof bt?i="Part":e&&(e.click?i="button":e instanceof gt&&e.editable&&(i="editable"),e.portId!==null&&(i&&(i+=" "),i+="port",e.portId&&(i+=" "+e.portId)));let s=this.bN(e);s&&(i+=" "+s);let n=e;if(t&&n instanceof q&&n.fromNode&&n.toNode){if(t instanceof it&&t.part===n.fromNode||t instanceof q&&t.fromNode===n.fromNode){i+=" to "+this.bN(n.toNode,!0);let o=n.toPort?.portId;o&&(i+=" port "+o)}else if(t instanceof it&&t.part===n.toNode||t instanceof q&&t.toNode===n.toNode){i+=" from "+this.bN(n.fromNode,!0);let o=n.fromPort?.portId;o&&(i+=" port "+o)}}return i}bN(t,e){if(e===void 0&&(e=!1),!t)return"";if(t instanceof gt&&t.text)return t.text;if(t instanceof H){let i="";return t instanceof bt&&t.text&&(i=t.text),e&&i||t.walkVisualTreeFrom(t,(s,n)=>{n.isVisibleObject()&&n instanceof gt&&n.text&&(!e||!i)&&i!==n.text&&(i+=" "+n.text)}),i}return""}updateFocusBox(){let t=this.focus;if(t!==null)if(t.diagram!==null&&(t instanceof bt?t.isVisible():t.isVisibleObject()&&t.part?.isVisible()))this.focusBox.adornedObject=t,t.part?.addAdornment("Focus",this.focusBox);else{let e=null;if(t instanceof bt||(e=t.part),e instanceof bt&&e.isVisible())this.focus=e;else{if(e instanceof it&&!e.isVisible()){let i=e.findTreeParentNode();if(i!==null)e=i;else{let s=e.labeledLink;s!==null&&(e=s)}}for(;e instanceof bt&&!e.isVisible();)e=e.containingGroup;e instanceof bt&&e.isVisible()?this.focus=e:this.focus=null}}}findFirstFocus(){let t=this.a;if(t===null||!t.isEnabled)return null;if(this.focus!==null)return this.focus;if(this.isFocusEnabled)if(t.selection.count>0)this.focus=t.selection.first();else{let e=this.XT(t.isTreePathToChildren).first();if(e!==null)return e}return null}get isVirtualPointerEnabled(){return this.lN}set isVirtualPointerEnabled(t){t=!!t;let e=this.isVirtualPointerEnabled;if(t!==e&&(this.lN=t,t)){let i=this.Up;i&&(this.Up=null,i.commandHandler.Ps=null,i.commandHandler.cancelVirtualPointer())}}get isVirtualPointerShown(){return this.aN}set isVirtualPointerShown(t){t=!!t;let e=this.isVirtualPointerShown;if(t!==e){let i=this.a;if(!i||!this.isVirtualPointerEnabled)return;this.aN=t;let s=this.focus;t?this.virtualPointerBox.diagram===null&&(this.virtualPointerLocation.isReal()||(s!==null?this.virtualPointerLocation=s.getDocumentPoint(T.Center):this.virtualPointerLocation=i.viewportBounds.center),i.add(this.virtualPointerBox),this.ma()):this.virtualPointerBox.diagram!==null&&(i.remove(this.virtualPointerBox),this.ma())}}cancelVirtualPointer(){let t=this.a;t&&(this.yN(),this.isVirtualPointerShown=!1,t.currentTool.doCancel(),this.isVirtualPointerDown=!1,this.kN())}kN(){let t=this.Ps;if(t!==null){this.Ps=null;let e=t.commandHandler;e.Ps=null,e.Up=null,e.isVirtualPointerShown=!1,e.isVirtualPointerDown=!1,e.yN(),this.C1&&(e.isVirtualPointerEnabled=!1),this.C1=!1}}yN(){this.Oi.button=0,this.Oi.modifiers=0,this.Oi.clickCount=1,this.Oi.down=!1,this.ma()}ma(){this.virtualPointerChanged!==null&&this.virtualPointerChanged(this.virtualPointerBox,this),this.updateVirtualPointer()}updateVirtualPointer(){let t=this.virtualPointerBox.diagram;t&&(this.virtualPointerBox.scale=1/t.scale),this.virtualPointerBox.updateTargetBindings()}get virtualPointerBox(){return this.ud}set virtualPointerBox(t){if(!(t instanceof bt))return;let e=this.ud;t!==e&&(e!==null&&(t.location=e.location,e.diagram!==null&&e.diagram.remove(e)),this.ud=t,this.isVirtualPointerShown&&this.diagram&&(this.diagram.add(t),t.data=e.data),this.ma())}get virtualPointerChanged(){return this.hN}set virtualPointerChanged(t){t!==null&&g.S(t,Jt,"virtualPointerChanged"),this.hN=t}get virtualPointerLocation(){return this.virtualPointerBox.location}set virtualPointerLocation(t){this.virtualPointerLocation.equals(t)||this.GT(t.x,t.y)}get isVirtualPointerDown(){return this.virtualPointerBox.data?this.virtualPointerBox.data.down:!1}set isVirtualPointerDown(t){t=!!t;let e=this.isVirtualPointerDown;if(t!==e){let i=this.a;if(!i||!this.isVirtualPointerEnabled||(this.virtualPointerBox.data===null&&(this.ud.data=this.Oi),this.virtualPointerBox.data.down=t,this.ma(),!this.isVirtualPointerShown))return;let s=i.lastInput,n=new Se;n.diagram=i,this.YT(n,t),t?n.down=!0:n.up=!0,n.clickCount=1,n.button=this.Oi.button,n.modifiers=this.Oi.modifiers,t&&(i.firstInput=n.copy()),this.md(n,!0),t||this.Oi.clickCount===2&&(n.clickCount=2,n.down=!0,n.up=!1,this.md(n,!0),n.down=!1,n.up=!0,this.md(n,!0),this.KT(1)),i.lastInput=s}}get virtualPointerShiftMove(){return this.Ip}set virtualPointerShiftMove(t){this.Ip=t}get virtualPointerControlMove(){return this.Ep}set virtualPointerControlMove(t){this.Ep=t}Vp(t,e){this.GT(this.virtualPointerLocation.x+t,this.virtualPointerLocation.y+e)}GT(t,e){this.virtualPointerBox.moveTo(t,e,!0);let i=this.a;if(!i||!this.isVirtualPointerEnabled||!this.isVirtualPointerShown)return;i.ensureBounds();let s=i.lastInput,n=new Se;n.diagram=i,this.YT(n,this.isVirtualPointerDown),n.button=this.Oi.button,n.modifiers=this.Oi.modifiers,this.md(n,!0),i.lastInput=s,this.isVirtualPointerDown&&(i.remove(this.virtualPointerBox),i.add(this.virtualPointerBox)),this.ma()}YT(t,e){let i=this.a;if(i){if(t.targetDiagram=i,t.documentPoint=this.virtualPointerLocation,i.allowDragOut){let s=i.div.getBoundingClientRect(),n=i.transformDocToView(this.virtualPointerLocation),o=s.x+n.x,r=s.y+n.y,a=C.document.elementFromPoint(o,r)||null;a instanceof HTMLCanvasElement&&(a=a.parentElement),a!==null&&a.shadowRoot&&(a=a.shadowRoot.elementFromPoint(o,r)||null,a instanceof HTMLCanvasElement&&(a=a.parentElement));let h=null;if(a instanceof HTMLElement&&(h=j.Wi.get(a))&&h!==i&&h.div){let l=h.div.getBoundingClientRect(),c=new P(n.x-(l.x-s.x),n.y-(l.y-s.y));this.Ps!==null&&this.Ps!==h&&this.kN(),t.targetDiagram=h,t.viewPoint=c,t.documentPoint=h.transformViewToDoc(c),t.viewPoint=h.transformDocToView(t.documentPoint),this.Ps=h;let u=h.commandHandler;this.C1=!u.isVirtualPointerEnabled,u.isVirtualPointerEnabled=!0,u.isVirtualPointerDown=e,u.virtualPointerLocation=t.documentPoint,u.isVirtualPointerShown=!0,u.Up=i;return}}this.Ps!==null&&this.kN(),t.viewPoint=i.transformDocToView(t.documentPoint)}}md(t,e){this.doVirtualPointerEvent(t,e)}doVirtualPointerEvent(t,e){let i=this.a;i&&(t.timestamp=Date.now(),i.lastInput=t,e&&(t.up?i.doMouseUp():t.down?i.doMouseDown():i.doMouseMove()),this.onVirtualPointerEvent(t,e))}onVirtualPointerEvent(t,e){let i=this.a;i&&(t.up?this.isVirtualPointerDown&&!i.viewportBounds.containsPoint(this.virtualPointerLocation)&&(this.virtualPointerLocation=this.focus instanceof tt?this.focus.getDocumentPoint(T.Center):i.viewportBounds.center):t.down)}doVirtualFocusKeyDown(){let t=this.a;if(!t)return!1;let e=t.lastInput,i=e.commandKey;if(this.isVirtualPointerEnabled&&(i==="ShiftLeft"||i==="ShiftRight"))return this.isVirtualPointerShown=!0,!0;if(this.BT.indexOf(i)>=0)if(e.shift&&this.isVirtualPointerShown){let s=this.L1(i),n=e.control||e.meta?this.Ep:this.Ip;s===270?this.Vp(0,-n):s===90?this.Vp(0,n):s===180?this.Vp(-n,0):this.Vp(n,0)}else this.QO();else if(e.shift&&this.isVirtualPointerShown&&(i==="Numpad1"||i==="Numpad2"||i==="Numpad3"||i==="Numpad4"||i==="Numpad6"||i==="Numpad7"||i==="Numpad8"||i==="Numpad9")){let s=e.control||e.meta?this.Ep:this.Ip,n=0;i==="Numpad1"||i==="Numpad4"||i==="Numpad7"?n=-s:(i==="Numpad3"||i==="Numpad6"||i==="Numpad9")&&(n=s);let o=0;i==="Numpad7"||i==="Numpad8"||i==="Numpad9"?o=-s:(i==="Numpad1"||i==="Numpad2"||i==="Numpad3")&&(o=s),this.Vp(n,o)}else if(i==="Enter"||i==="NumpadEnter"||i==="Numpad5")e.shift&&this.isVirtualPointerShown?this.isVirtualPointerDown=!this.isVirtualPointerDown:this._O();else if(i==="Escape")this.tI();else if(i==="Space")this.eI();else if(i==="ContextMenu"||e.shift&&i==="F10"||(e.control||e.meta)&&e.shift&&i==="Backslash")this.iI();else if(e.shift&&i==="c")this.A1(1);else if(e.shift&&i==="a")this.A1(2);else if(e.shift&&i==="KeyS")this.A1(4);else if(e.shift&&i==="KeyM")this.A1(8);else if(e.shift&&i==="Digit1")this.T1(0);else if(e.shift&&i==="Digit2")this.T1(1);else if(e.shift&&i==="Digit3")this.T1(2);else if(e.shift&&i==="Numpad0"){let s=this.Oi.button;this.T1(s===2?0:2)}else if(e.shift&&(i==="KeyD"||i==="NumpadDecimal")){let s=this.Oi.clickCount;this.KT(s===2?1:2)}else if(e.shift&&i==="KeyF"){let s=this.nextFocusFormula;this.nextFocusFormula=s==="distance"?"linear":"distance"}else if(e.shift&&i==="y")this.isUsingAriaLive=!this.isUsingAriaLive;else return!1;return!0}doVirtualFocusKeyUp(){let t=this.a;if(!t)return!1;let e=t.lastInput.commandKey;return this.isVirtualPointerEnabled&&(e==="ShiftLeft"||e==="ShiftRight")&&(this.isVirtualPointerShown=!1),!0}L1(t){switch(t){case"ArrowDown":return 90;case"ArrowLeft":return 180;case"ArrowUp":return 270;default:return 0}}BT=["ArrowRight","ArrowDown","ArrowLeft","ArrowUp"];A1(t){let e=this.Oi.modifiers;this.Oi.modifiers=e&t?e&~t:e|t,this.ma()}KT(t){this.Oi.clickCount=t,this.ma()}T1(t){this.Oi.button=t,this.ma()}QO(){let t=this.a;if(!t)return;let e=t.lastInput,i=this.focus;if(i===null){let s=this.XT(t.isTreePathToChildren).first();s!==null&&(this.focus=s)}else if(i instanceof q)this.sI(i);else if(i instanceof it)this.nI(i);else{i instanceof bt&&(this.dd=null);let s=this.L1(e.commandKey);s===270?this.focus=this.findNextFocus(270):s===90?this.focus=this.findNextFocus(90):s===180?this.focus=this.findNextFocus(180):this.focus=this.findNextFocus(0)}}sI(t){let e=this.a;if(!e)return;let i=e.lastInput,s=this.L1(i.commandKey),n=null,o=this.dd;if(o!==null){let r=this.mN;if(s===r)n=t.getOtherNode(o);else if(s===A.Ee(r+180))n=o;else{let a=r===0||r===180?90:0,h=r===0||r===180?270:180;if(s===a){let l=this.PN(o,r,!0),c=l.indexOf(t);c>=0&&c<l.count-1&&(this.focus=l.elt(c+1))}else if(s===h){let l=this.PN(o,r,!0),c=l.indexOf(t);c>0&&(this.focus=l.elt(c-1))}}}else{let r=t.fromNode,a=t.toNode;if(!r||!a)return;s===270?n=r.location.y<a.location.y?r:a:s==90?n=r.location.y>a.location.y?r:a:s===180?n=r.location.x<a.location.x?r:a:n=r.location.x>a.location.x?r:a}for(;n!==null&&!n.isVisible();)n=n.containingGroup;n!==null&&(this.focus=n)}nI(t){let e=this.a;if(!e)return;let i=e.lastInput,s=this.L1(i.commandKey);if(i.control||i.meta){let n=this.PN(t,s,!0).first();n&&(this.dd=t,this.mN=s,this.focus=n)}else this.dd=null,this.focus=this.findNextFocus(s)}PN(t,e,i){if(t===null)return new U;let s=t.actualBounds;if(!s.isReal())return new U;let n=new Set;(t instanceof ft?t.findExternalLinksConnected():t.findLinksConnected()).each(r=>{if(!r.isVisible())return;let a=null;if(r.fromNode===t?a=r.toNode:r.toNode===t?a=r.fromNode:t instanceof ft&&(r.fromNode?.isMemberOf(t)?a=r.toNode:r.toNode?.isMemberOf(t)&&(a=r.fromNode)),a===null||a.isMemberOf(t))return;for(;a!==null&&!a.isVisible();)a=a.containingGroup;if(a===null)return;let h=a.location;if(h.isReal()&&!(e===270&&(a!==t?h.y>=s.top:r.midPoint.y>=s.top))){if(e===90&&(a!==t?h.y<=s.bottom:r.midPoint.y<=s.bottom)||e===180&&(a!==t?h.x>=s.left:r.midPoint.x>=s.left)||e===0&&(a!==t?h.x<=s.right:r.midPoint.x<=s.right))return;i&&r.actualBounds.isReal()?n.add(r):n.add(a)}});let o=new U(n);return e===90||e===270?o.sort((r,a)=>r.actualBounds.centerX-a.actualBounds.centerX):o.sort((r,a)=>r.actualBounds.centerY-a.actualBounds.centerY),o}findNextFocus(t){t=A.Ee(t);let e=this.focus,i=e instanceof it?e.location:e.getDocumentPoint(T.Center),s=1/0,n=e,o=(r,a,h,l)=>{if(this.nextFocusFormula==="linear"){let c=1/0;t===0&&h>i.x||t===180&&h<i.x?c=Math.abs(h-i.x):(t===90&&l>i.y||t===270&&l<i.y)&&(c=Math.abs(l-i.y)),c<s&&(s=c,n=r)}else{if(t===0&&(a.right<i.x||(a.centerX-i.x)**2>s)||t===90&&(a.bottom<i.y||(a.centerY-i.y)**2>s)||t===180&&(a.x>i.x||(i.x-a.centerX)**2>s)||t===270&&(a.y>i.y||(i.y-a.centerY)**2>s))return;let c=i.direction(h,l),u=A.jF(t,c);if(t===90||t===270?u<=45:u<45){let d=i.distanceSquared(h,l);d<s&&(s=d,n=r)}}};if(e instanceof bt&&e.diagram!==null){let r=e.containingGroup;r!==null?r.memberParts.each(a=>{a===e||a instanceof q||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}):(e.diagram.nodes.each(a=>{a===e||!a.isTopLevel||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}),e.diagram.parts.each(a=>{a===e||!a.isTopLevel||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}))}else if(e.part!==null){let r=new B;this.SN(e.part).each(a=>{a!==e&&(a.getDocumentBounds(r),o(a,r,r.centerX,r.centerY))})}return n}get nextFocusFormula(){return this.gN}set nextFocusFormula(t){this.gN=t}_O(){let t=this.a;if(!t)return;let e=t.currentTool;if(e instanceof Xt){let n=e.currentObject;this.D1(this.focus),e.maybeStopTool(this.focus),t.currentTool instanceof Xt||(this.focus=n);return}let i=this.focus,s=t.lastInput;if(i===null)s.control||s.meta?this.D1(null):this.focus=this.findFirstFocus();else if(i instanceof bt)if(s.control||s.meta)this.D1(i);else{let n=this.SN(i);if(n.count>0)this.focus=n.first();else if(i instanceof q&&i.isLabeledLink){let o=i.labelNodes.first();o!==null&&o.isVisible()&&(this.focus=o)}else if(i instanceof ft&&i.isSubGraphExpanded){let o=i.memberParts.first();o!==null&&o.isVisible()&&(this.focus=o)}}else this.D1(i)}XT(t){let e=new U,i=this.a;if(!i)return e;let s=0;for(;e.count===0&&s<i.nodes.count;){let n=i.nodes;for(;n.next();){let o=n.value;o.isTopLevel&&o.isVisible()&&(t?o.findNodesInto():o.findNodesOutOf()).count===s&&e.add(o)}s++}return e}SN(t){return t instanceof bt?this.Sn(t,new U):new U}Sn(t,e){return!(t instanceof bt)&&t.isVisibleObject()&&t.isEnabledObject()&&(t.contextMenu||t.click||t instanceof gt&&t.editable||t.part instanceof it&&t.portId!==null&&(t.portId!==""||t.part.ports.count>1)||t.toolTip)&&e.add(t),t instanceof H&&t.elements.each(i=>this.Sn(i,e)),e}D1(t){let e=this.a;if(!e)return;let i=e.lastInput,s=t instanceof tt?t:e;if(s.click){let n=new Se;n.diagram=e,n.documentPoint=t instanceof tt?t.getDocumentPoint(T.Center):e.viewportBounds.center,n.viewPoint=e.transformDocToView(n.documentPoint),n.button=0,n.clickCount=1,n.targetObject=t,this.md(n,!1),s instanceof tt?s.click(n,s):s.click(n),e.lastInput=i}else s instanceof gt&&s.editable?this.editTextBlock(s):this.HT(t)}tI(){let t=this.a;if(!t)return;let e=t.currentTool;if(e instanceof de&&e.currentToolTip!==null){e.hideToolTip();return}else if(e instanceof Xt){let i=e.currentObject;e.doKeyDown(),this.focus=i;return}if(this.focus instanceof bt){let i=this.focus;i instanceof it&&i.labeledLink!==null?this.focus=i.labeledLink:i.containingGroup!==null?this.focus=i.containingGroup:this.focus=null}else if(this.focus instanceof tt){let i=this.focus.part;if(i instanceof q&&i.isLabeledLink){let s=i.labelNodes.first();if(s!==null&&s.isVisible()){this.focus=s;return}}else if(i instanceof ft&&i.isSubGraphExpanded){let s=i.memberParts.first();if(s!==null&&s.isVisible()){this.focus=s;return}}this.focus=i}else this.cancelVirtualPointer(),this.stopCommand()}eI(){let t=this.a;if(t)if(t.lastInput.shift&&this.isVirtualPointerShown){let e=t.findPartAt(this.virtualPointerLocation);e!==null&&(e===this.focus?this.jT():this.focus=e)}else this.jT()}jT(){let t=this.a;if(!t)return;let e=t.lastInput,i=this.focus;if(i instanceof bt){let s=i.part;if(e.control||e.meta){for(t.raiseDiagramEvent("ChangingSelection",t.selection);s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.raiseDiagramEvent("ChangedSelection",t.selection)}else if(e.shift){if(s!==null&&!s.isSelected){for(t.raiseDiagramEvent("ChangingSelection",t.selection);s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.raiseDiagramEvent("ChangedSelection",t.selection)}}else if(s!==null&&!s.isSelected){for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}this.HT(i),this.onFocusChanged(i,i)}HT(t){let e=this.a;if(!e)return;e.toolManager.hideToolTip();let i=e.lastInput,s=t instanceof tt?t:e;for(;s instanceof tt&&!s.toolTip;)s=s.panel;if(s&&s.toolTip){let n=new Se;n.diagram=e,n.documentPoint=t!==null?t.getDocumentPoint(T.Center):e.viewportBounds.center,n.viewPoint=e.transformDocToView(n.documentPoint),n.targetObject=t,this.md(n,!1),e.toolManager.showToolTip(s.toolTip,t),e.lastInput=i}}iI(){let t=this.a;if(!t)return;let e=this.focus;if(this.canShowContextMenu(e)){this.showContextMenu(e);let i=t.toolManager.contextMenuTool.currentContextMenu;if(i instanceof Mt){let s=this.SN(i);s.count>0&&(this.focus=s.first())}}}}var ws=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Vertical=4]="Vertical",x[x.Horizontal=5]="Horizontal",x[x.Fill=2]="Fill",x))(ws||{}),vs=(x=>(x[x.None=0]="None",x[x.Along=21]="Along",x[x.Plus90=22]="Plus90",x[x.Minus90=23]="Minus90",x[x.Opposite=24]="Opposite",x[x.Upright=25]="Upright",x[x.Plus90Upright=26]="Plus90Upright",x[x.Minus90Upright=27]="Minus90Upright",x[x.Upright45=28]="Upright45",x))(vs||{}),Tn=(x=>(x[x.None=0]="None",x[x.Vertical=1]="Vertical",x[x.Horizontal=2]="Horizontal",x[x.Both=3]="Both",x))(Tn||{});class tt{n;Bp;zp;pa;w;ya;ft;ct;ai;Zt;Xp;Zs;Lt;cs;il;wa;Se;Lh;it;Xt;sl;De;Ke;pd;de;yd;Ot;he;nl;v1;xa;uf;constructor(){I.Je(this),this.n=30723,this.Zt=1,this.Xp="",this.Zs=null,this.Lt=null,this.ct=new P(NaN,NaN).b(),this.cs=_.$w,this.il=new Pt,this.wa=new Pt,this.Se=null,this.Lh=1,this.it=1,this.Xt=0,this.sl=Dt.em,this.ai=new B(NaN,NaN,NaN,NaN).b(),this.De=new B(NaN,NaN,NaN,NaN).b(),this.Ke=new B(0,0,NaN,NaN).b(),this.pd=null,this.Bp=null,this.ft=null,this.de=T.Default,this.yd=T.Default,this.zp=0,this.pa=0,this.Ot=null,this.w=null,this.ya=null,this.he=null,this.v1=null,this.xa=null,this.nl=null,this.uf=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Zt=this.Zt,t.Xp=this.Xp,t.Lt=this.Lt,t.ct.h(this.ct),t.cs=this.cs.N(),this.Se!==null?t.Se=this.Se.copy():t.Se=null,t.it=this.it,t.Xt=this.Xt,t.sl=this.sl.N(),t.ai.h(this.ai),t.De.h(this.De),t.Ke.h(this.Ke),t.Bp=this.Bp,this.ft!==null&&(t.ft=this.ft.copy()),t.de=this.de.N(),t.yd=this.yd.N(),t.zp=this.zp,t.pa=this.pa,this.Ot!==null&&(t.Ot=this.Ot.copy()),this.w!==null&&(this.w.me?t.w=this.w:t.w=this.w.copy()),this.ya!==null&&(t.ya=this.ya.slice()),this.he!==null&&(t.he=this.he.copy())}addCopyProperty(t){let e=this.ya;if(!Array.isArray(e))e=[],this.ya=e;else for(let i=0;i<e.length;i++)if(e[i]===t)return;e.push(t)}jo(t){t.pd=null,t.nl=null,t.c()}clone(){let t=new this.constructor;if(this.cloneProtected(t),this.ya!==null)for(let e=0;e<this.ya.length;e++){let i=this.ya[e];t[i]=this[i]}return t}copy(){return this.clone()}JS(){let t=this.ve;if(t!==null){this.ve=null;for(let e of t)e.wd()&&(e.isToData?this.themeData(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter):e.isToObject?this.themeObject(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter,e.sourceName):e.isToModel?this.themeModel(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter):this.theme(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter))}return this}fe(t){t in vs?this.segmentOrientation=t:t in ws?this.stretch=t:g.dr(this,t)}toString(){return g.Hn(this.constructor)+"#"+I.xs(this)}static None=0;static Default=1;static Fill=2;static Vertical;static Horizontal;static Uniform=6;static UniformToFill=7;static FlipVertical=1;static FlipHorizontal=2;static FlipBoth=3;ba(){this.w!==null&&(this.w.me=!0)}Yt(){return this.w===null?this.w=new oi:this.w.me&&(this.w=this.w.copy()),this.w}Ji(){if(this.ft===null){let t=new ns;t.Ah=T.None,t.Th=T.None,t.Dh=10,t.vh=10,t.Fh=0,t.Rh=0,this.ft=t}return this.ft}raiseChangedEvent(t,e,i,s,n,o,r){let a=this.part;if(a!==null){a.df(t,e,i,s,n,o,r),i===this&&t===2&&this.gf()&&this.Oh(a,e);let h=this.diagram;if(this.Ds!==null&&h!==null&&h.$a&&!h.undoManager.isUndoingRedoing&&!h.animationManager.Uu){let l=this.Ds.get(e);if(l!==null&&h.animationManager.isEnabled&&!h.animationManager.isTicking){this.uf===null&&(this.uf=new wt);let c=h.undoManager.transactionLevel===0;if(l.startCondition===2?c=!0:l.startCondition===3&&(c=!1),c){let u=new Te;l.RR(u);let d=this.uf.get(l);d!==null&&d.stop(),this.uf.set(l,u),u._x=this,u.TM=l,u.add(this,e,s,n),u.start()}else h.animationManager.getBundleAnimation().add(this,e,s,n)}}if(this instanceof H&&i===a&&a.MN()&&a.data!==null){let l=this.D.r,c=l.length;for(let u=0;u<c;u++){let d=l[u];d instanceof H&&d.Sn(f=>{f.data!==null&&f.MN()&&f.updateTargetBindings(e)})}}}}TR(t){this.uf&&this.uf.delete(t)}Yo(){if(this.diagram!==null&&this.findBindingPanel()===null&&this.ve!==null){let t=this.diagram.model,e=this.ve.iterator;for(;e.next();){let i=e.value;if(!i.isToTheme)continue;let s=null,n=i.sourceName;i.isToObject&&(s=this.qT(n));let o=this,r=i.targetId;r!==-1&&(o=this.Gp(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),i.updateTarget(o,s,void 0,t))}}}Oh(t,e){let i=this.findBindingPanel();if(i!==null){let s=t.diagram,n=this.ve.iterator;for(;n.next();){let o=n.value,r=null;if(o.isToObject){if(r=o.WT(i,this),r===null)continue;o.updateSource(this,r,e,null)}else if(o.isToModel)s!==null&&!s.yi&&o.updateSource(this,s.model.modelData,e,i);else if(!o.isToTheme){let a=i.data;if(a===null)continue;s!==null&&!s.yi&&o.updateSource(this,a,e,i)}if(r===this){let a=o.targetId,h=i.Gp(a);h!==null&&o.updateTarget(h,r,e,s?.model)}}}}Gp(t){return this.oo===t?this:null}qT(t){let e;return t===""?e=this:t==="/"?e=this:t==="."?e=this:t===".."?e=this:e=this.part.findObject(t),e}get oo(){return this.w!==null?this.w.oo:-1}set oo(t){this.oo!==t&&(this.w===null&&(this.w=new oi),this.w.oo=t)}get ve(){return this.w!==null?this.w.ve:null}set ve(t){this.ve!==t&&(this.w===null&&(this.w=new oi),this.w.ve=t)}get ro(){return this.w!==null?this.w.ro:null}set ro(t){this.ro!==t&&(this.w===null&&(this.w=new oi),this.w.ro=t)}raiseChanged(t,e,i){this.raiseChangedEvent(2,t,this,e,i)}t(t,e,i){this.raiseChangedEvent(2,t,this,e,i)}lo(t,e,i,s){let n=this.ai;if(n.e(t,e,i,s),this.it!==1||this.Xt!==0){this.Se===null&&(this.Se=new Pt);let o=this.Se;o.Ue(),this.Yp(o,t,e,i,s),o.im(n)}}JT(t,e,i){return this.pickable===!1?!1:(i.bc(this.v),e?this.intersectsRect(t,i):this.containedInRect(t,i))}$T(t,e,i){if(this.pickable===!1)return!1;let s=this.naturalBounds,n=t.distanceSquaredPoint(e);return i?P.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||P.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||P.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||P.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}Nn(){return!0}containsPoint(t){let e=P.l();e.h(t),this.v.gt(e);let i=this.actualBounds;if(!i.isReal())return P.i(e),!1;let s=this.diagram;if(s!==null&&s.mp){let o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),a=r/2,h=this.naturalBounds,l=this.getDocumentScale()*s.scale,c=1/l;if(h.width*l<o&&h.height*l<o){let u=B.contains(i.x-a*c,i.y-a*c,i.width+r*c,i.height+r*c,e.x,e.y);return P.i(e),u}}let n=!1;return(this instanceof Mt||this instanceof at?B.contains(i.x-5,i.y-5,i.width+10,i.height+10,e.x,e.y):i.containsPoint(e))&&(this.he&&!this.he.containsPoint(e)?n=!1:this.Lt!==null&&this.Ke.containsPoint(t)?n=!0:n=this.ka(t)),P.i(e),n}ka(t){let e=this.naturalBounds;return B.contains(0,0,e.width,e.height,t.x,t.y)}containsRect(t){if(this.angle===0)return this.actualBounds.containsRect(t);let e=this.naturalBounds,i=B.z(0,0,e.width,e.height),s=this.v,n=!1,o=P.z(t.x,t.y);return i.containsPoint(s.Ci(o))&&(o.e(t.x,t.bottom),i.containsPoint(s.Ci(o))&&(o.e(t.right,t.bottom),i.containsPoint(s.Ci(o))&&(o.e(t.right,t.y),i.containsPoint(s.Ci(o))&&(n=!0)))),P.i(o),B.i(i),n}containedInRect(t,e){if(e===void 0)return t.containsRect(this.actualBounds);let i=this.naturalBounds,s=e,n=!1,o=P.z(0,0);return t.containsPoint(s.gt(o))&&(o.e(0,i.height),t.containsPoint(s.gt(o))&&(o.e(i.width,i.height),t.containsPoint(s.gt(o))&&(o.e(i.width,0),t.containsPoint(s.gt(o))&&(n=!0)))),P.i(o),n}intersectsRect(t,e){if(e===void 0&&(e=this.v,this.angle===0))return t.intersectsRect(this.actualBounds);let i=this.naturalBounds,s=e,n=P.z(0,0),o=P.z(0,i.height),r=P.z(i.width,i.height),a=P.z(i.width,0),h=!1;if(t.containsPoint(s.gt(n))||t.containsPoint(s.gt(o))||t.containsPoint(s.gt(r))||t.containsPoint(s.gt(a)))h=!0;else{let l=B.z(0,0,i.width,i.height),c=P.z(t.x,t.y);l.containsPoint(s.Ci(c))?h=!0:(c.e(t.x,t.bottom),l.containsPoint(s.Ci(c))?h=!0:(c.e(t.right,t.bottom),l.containsPoint(s.Ci(c))?h=!0:(c.e(t.right,t.y),l.containsPoint(s.Ci(c))&&(h=!0)))),P.i(c),B.i(l),h||(A.nx(t,n,o)||A.nx(t,o,r)||A.nx(t,r,a)||A.nx(t,a,n))&&(h=!0)}return P.i(n),P.i(o),P.i(r),P.i(a),h}getDocumentPoint(t,e){if(e===void 0&&(e=new P),t instanceof T){let i=t,s=this.naturalBounds;return e.e(i.x*s.width+i.offsetX,i.y*s.height+i.offsetY),this.Js.gt(e),e}else return e.set(t),this.Js.gt(e),e}getDocumentBounds(t){t===void 0&&(t=new B);let e=this.naturalBounds,i=this.Js,s=P.z(0,0).v(i);return t.e(s.x,s.y,0,0),s.e(e.width,0).v(i),t.re(s.x,s.y,0,0),s.e(e.width,e.height).v(i),t.re(s.x,s.y,0,0),s.e(0,e.height).v(i),t.re(s.x,s.y,0,0),P.i(s),t}getDocumentAngle(){return this.Js.YF()}getDocumentScale(){if(this.Kp()===!1)return this.Lh;let t=this.it;return this.panel!==null?t*this.panel.getDocumentScale():t}getLocalPoint(t,e){return e===void 0&&(e=new P),e.h(t),this.Js.Ci(e),e}getNearestIntersectionPoint(t,e,i){return this.mf(t.x,t.y,e.x,e.y,i)}mf(t,e,i,s,n){let o=this.v,r=1/(o.m11*o.m22-o.m12*o.m21),a=o.m22*r,h=-o.m12*r,l=-o.m21*r,c=o.m11*r,u=r*(o.m21*o.dy-o.m22*o.dx),d=r*(o.m12*o.dx-o.m11*o.dy),f=t*a+e*l+u,p=t*h+e*c+d,m=i*a+s*l+u,y=i*h+s*c+d;n.e(0,0);let b=this.naturalBounds,v=A.Cl(0,0,b.width,b.height,f,p,m,y,n);return n.v(o),v}ht(t,e,i,s){if(this.Go()===!1)return;let n=this.sl,o=n.right+n.left,r=n.top+n.bottom;t=Math.max(t-o,0),e=Math.max(e-r,0),i=i||0,s=s||0,i=Math.max(i-o,0),s=Math.max(s-r,0);let a=this.angle,h=0,l=this.desiredSize,c=this.Hp();a===90||a===270?(t=isFinite(l.height)?l.height+c:t,e=isFinite(l.width)?l.width+c:e):(t=isFinite(l.width)?l.width+c:t,e=isFinite(l.height)?l.height+c:e);let u=i||0,d=s||0,f=this instanceof H;switch(this.Qs(!0)){case 0:u=0,d=0,f&&(t=1/0,e=1/0);break;case 2:isFinite(t)&&t>i&&(u=t),isFinite(e)&&e>s&&(d=e);break;case 5:isFinite(t)&&t>i&&(u=t),d=0,f&&(e=1/0);break;case 4:isFinite(e)&&e>s&&(d=e),u=0,f&&(t=1/0);break}let p=this.maxSize,m=this.minSize;u>p.width&&m.width<p.width&&(u=p.width),d>p.height&&m.height<p.height&&(d=p.height),i=Math.max(u,m.width),s=Math.max(d,m.height),p.width<i&&(i=Math.min(m.width,i)),p.height<s&&(s=Math.min(m.height,s)),t=Math.min(p.width,t),e=Math.min(p.height,e),t=Math.max(i,t),e=Math.max(s,e),(a===90||a===270)&&(h=t,t=e,e=h,h=i,i=s,s=h),this.ai.ce(),this.xd(t,e,i,s),this.ai.b(),this.ai.isReal()||g.o("Non-real measuredBounds has been set. Object "+this+", measuredBounds: "+this.ai.toString()),this.wi(!1)}xd(t,e,i,s){}_s(){return!1}Ut(t,e,i,s,n){this.pf();let o=B.l();o.h(this.De),this.De.ce(),this.as()===!1?this.De.e(t,e,i,s):this.Pa(t,e,i,s),this.De.b(),n===void 0?this.he=null:this.he=n;let r=!1;if(n!==void 0)r=!0;else{let a=this.panel;if(a!==null&&a.ol()&&(a=a.panel),a!==null){let h=a.Ke,l=this.measuredBounds,c=e+l.height,u=t+l.width;if(r=!(0<=t+.05&&u<=h.width+.05&&0<=e+.05&&c<=h.height+.05),this instanceof gt){let d=this.naturalBounds;(this.jp>d.height||this.pe>d.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.De.isReal()||g.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.De.toString()),this.bd(o,this.De),this.ao(!1),B.i(o)}Pa(t,e,i,s){}commonArrange(t,e,i,s){if(this.De.e(t,e,i,s),this.desiredSize.isReal())return;let n=this.ai,o=this.sl,r=o.right+o.left,a=o.top+o.bottom,h=n.width+r,l=n.height+a;i+=r,s+=a;let c=this.Qs(!0);switch(h===i&&l===s&&(c=0),c){case 0:(h>i||l>s)&&(this.wi(!0),this.ht(h>i?i:h,l>s?s:l,0,0));break;case 2:this.wi(!0),this.ht(i,s,0,0);break;case 5:this.wi(!0),this.ht(i,l,0,0);break;case 4:this.wi(!0),this.ht(h,s,0,0);break}}bd(t,e){let i=this.part;i!==null&&i.diagram!==null&&((i.selectionObject===this||i.resizeObject===this||i.rotateObject===this)&&i.NN(!0),this.C(),!t.equalsApproxClose(e)&&(i.Sa(),this.qp(i)))}qp(t){this.portId!==null&&(t.NN(!0),t instanceof it&&t.invalidateConnectedLinks(void 0,this))}get shadowVisible(){return this.w!==null?this.w.Wp:null}set shadowVisible(t){let e=this.shadowVisible;e!==t&&(this.Yt().Wp=t,this.$i(!0),this.C(),this.t("shadowVisible",e,t))}oI(t,e){let i=this.naturalBounds,s=this.wa,n=s.m11,o=s.m21,r=s.dx,a=s.m12,h=s.m22,l=s.dy,c=0,u=0,d=c,f=u;c=d*n+f*o+r,u=d*a+f*h+l;let p=c,m=u,y=0,b=0;d=i.width+e,f=0,c=d*n+f*o+r,u=d*a+f*h+l;let v=Math.min(p,c),w=Math.min(m,u);y=Math.max(p+y,c)-v,b=Math.max(m+b,u)-w,p=v,m=w,d=i.width+e,f=i.height+e,c=d*n+f*o+r,u=d*a+f*h+l,v=Math.min(p,c),w=Math.min(m,u),y=Math.max(p+y,c)-v,b=Math.max(m+b,u)-w,p=v,m=w,d=0,f=i.height+e,c=d*n+f*o+r,u=d*a+f*h+l,v=Math.min(p,c),w=Math.min(m,u),y=Math.max(p+y,c)-v,b=Math.max(m+b,u)-w,p=v,m=w;let k=t.viewportBounds,S=k.x,M=k.y,F=k.width,D=k.height;return p>F+S||S>y+p||m>D+M||M>b+m}Ge(t,e){if(this.rI(t,e)||!this.visible)return;let i=this.opacity;if(i===0)return;let s=1;i!==1&&(s=t.globalAlpha,t.globalAlpha=s*i);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);let o=this.v,r=this.panel;this.Kp()===!0&&this.F1();let a=this.part,h=!1,l=0;if(a&&e.getRenderingHint("drawShadows")&&(h=a.isShadowed,h)){let m=a.shadowOffset;l=Math.max(m.y,m.x)*e.scale*e.$e}let c=this instanceof H&&this.ol(),u=this.De;if(c&&(this.ZT(h,t,!1,r),this.lI(t,e),this.QT(h,t,!1,r),this._T(h,t,!1)),c||!c&&(u.width===0||u.height===0||isNaN(u.x)||isNaN(u.y))){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=this._s();if(!e.gh&&d&&this.oI(e,l)){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let f=(this.n&256)!==0;if(t.clipInsteadOfFill&&(f=!1),this instanceof gt&&(t.font=this.font),f){let m=r.Nn()?r.naturalBounds:r.actualBounds,y=Math.max(u.x,m.x),b=Math.max(u.y,m.y),v=Math.min(u.right,m.right)-y,w=Math.min(u.bottom,m.bottom)-b,k=this.he;if(k!==null&&(y=k.x,b=k.y,v=k.width,w=k.height),y>u.width+u.x||u.x>m.width+m.x){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(y,b,v,w),t.clip()}if(d){if(!a.isVisible()){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){let m=a.shadowOffset;t.shadowsSet(m.x*e.scale*this.scale*e.$e,m.y*e.scale*this.scale*e.$e,a.shadowBlur),t.shadowsOn(),t.shadowColor=a.shadowColor}}let p=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.ZT(h,t,d,r),this.Lt!==null&&(t.commitTransform(),this.R1(t,p,u)),this.QT(h,t,d,r),this.Ma(t,e),this._T(h,t,d),f&&(t.restore(),t.clearContextCache(this instanceof H)),!o.FP()){let m=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*m,-o.m12*m,-o.m21*m,o.m11*m,m*(o.m21*o.dy-o.m22*o.dx),m*(o.m12*o.dx-o.m11*o.dy))}i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}ZT(t,e,i,s){t&&this.shadowVisible===!0?e.shadowsOn():t&&this.shadowVisible===!1&&e.shadowsOff(),t&&this.O1(s)&&this.shadowVisible===null&&e.shadowsOff()}QT(t,e,i,s){t&&(this.Lt!==null||this.O1(s))?(this.I1(!0),this.shadowVisible===null&&e.shadowsOff()):this.I1(!1)}_T(t,e,i){t&&this.CN()===!0&&e.shadowsOn(),i&&t&&e.shadowsOff()}aI(t,e,i){let s=this.part,n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),e.clipInsteadOfFill&&(n=!1),this._s()&&n&&e.shadowsOn(),n&&this.shadowVisible===!0?e.shadowsOn():n&&this.shadowVisible===!1&&e.shadowsOff();let o=this.panel;if(n&&this.O1(o)&&this.shadowVisible===null&&e.shadowsOff(),e.rl){let r=t.computePixelRatio(),a=`drop-shadow(${e.shadowOffsetX/r}px ${e.shadowOffsetY/r}px ${e.shadowBlur/r/2}px ${e.shadowColor})`;this.background!==null&&i.Lt.setAttributeNS(null,"filter",a)}return n&&(this.Lt!==null||this.O1(o))?(this.I1(!0),this.shadowVisible===null&&e.shadowsOff()):this.I1(!1),n}hI(t,e,i,s){if(i.rl){let n=e.computePixelRatio(),o=`drop-shadow(${i.shadowOffsetX/n}px ${i.shadowOffsetY/n}px ${i.shadowBlur/n/2}px ${i.shadowColor})`;this.LN(t,o)}s&&this.CN()===!0&&i.shadowsOn(),this._s()&&i.shadowsOff()}O1(t){return t===null?!1:(t.ol()&&(t=t.panel),t.CN()||(t.type===H.Auto||t.type===H.Spot)&&t.findMainElement()!==this)}LN(t,e){}R1(t,e,i){let s=this.Hp(),n=e.x,o=e.y,r=e.width+s,a=e.height+s;this.kn(t,this.Lt,!0,!1,e,i),this.Lt instanceof E&&this.Lt.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,a),t.fillContext(this.Lt,!1,null)):t.fillRect(n-s/2,o-s/2,r,a)}tD(t,e){let i=t.cI(this),s=t.xa!==null?t.xa:t.svg;if(s!==null&&i!==-1)if(i===0)this.eD(t,e,s);else{for(;i!==0&&!t.elt(i-1).isVisibleObject();)i--;if(i===0)this.eD(t,e,s);else{let n=t.elt(i-1).svg;n!==null?n.after(e):s.appendChild(e)}}}eD(t,e,i){if(i.Lt)i.Lt.after(e);else if(t.type===H.Table){let s=i.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(e)}else i.prepend(e)}rI(t,e){if(!(t instanceof ge))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;let i=this.De;if(this._s()&&(!this.isVisible()||i.width===0||i.height===0||isNaN(i.x)||isNaN(i.y)))return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;let s=this.panel,n=this.kd(t);if(this.yf(t,e,n))return this.iD(this.svg),this.svg.parentElement!==null?(this._s()&&(t.lastDrawnPart=this.svg),!0):(this._s()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):s&&this.tD(s,this.svg),!0);if(this.$i(!1),this._s()&&this.isShadowed){let p=this.shadowOffset;t.shadowsSet(p.x*e.scale*this.scale*e.$e,p.y*e.scale*this.scale*e.$e,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof gt&&(t.font=this.font),t.currentElement=null;let o=this.v,r=this instanceof H,a=this instanceof H?this.ol():!1,h=this.svg;if(this.Kp()===!0&&this.F1(),t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,n)if(t.outerGroup=!0,r&&a)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(r&&this.isClipping){let p=this.findMainElement(),m=0,y=0;p!==null&&(m=p.actualBounds.x,y=p.actualBounds.y),t.newGroup(o.m11,o.m12,o.m21,o.m22,o.dx+m,o.dy+y),this.svg=t.lastCreatedElement,p!==null&&t.createOrUpdateClipGroup(this,p.actualBounds),t.currentElement=t.lastCreatedElement}else r?(t.newGroup(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);let l=this.naturalBounds;r||t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.background!==null&&(r?(a&&t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.R1(t,l,i),a&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.R1(t,l,i)),t.currentElement.Lt=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));let c=this.aI(e,t,t.currentElement);this.Ma(t,e),r&&t.endGroup(),t.outerGroup&&t.endGroup();let u=t.surface.fd,d=r?this.svg:t.currentElement;if(h!==null&&h.parentNode!==null&&d!==h&&(this.panel===null||h.parentNode===this.panel.svg)){let p=this.svg.getAttribute("filter");return p!==null&&d.setAttribute("filter",p),this.filter!==""&&d.setAttributeNS(null,"filter",this.filter),h.replaceWith(d),this.svg=d,d!==null&&this.Jp(t,s,i,d),!0}if(this.svg=d,u!==null&&d===null&&t.dummyGroup(),d===null)return!0;this.Jp(t,s,i,d),this.hI(d,e,t,c);let f=this._s()?this.opacity*t.globalAlpha:this.opacity;if(f!==1&&d.setAttributeNS(null,"opacity",f.toString()),this.filter!==""&&d.setAttributeNS(null,"filter",this.filter),this._s()){if(h!==null&&d!==h&&h.parentNode===t.diagramGroup){let p=h.getAttribute("filter");p!==null&&d.setAttribute("filter",p),h.replaceWith(d)}else t.lastDrawnPart?t.lastDrawnPart.after(d):t.diagramGroup.prepend(d);t.lastDrawnPart=d}else s!==null&&this.tD(s,d);return u!==null&&u(this,d),this.iD(d),!0}iD(t){let e=this,i=t.dataset;e instanceof tt&&(e.portId!==null&&(i.portId=e.portId),e instanceof H&&(isNaN(e.itemIndex)||(i.itemIndex=e.itemIndex.toString()),e instanceof bt&&(i.className=g.Hn(e),e.key!==void 0&&(i.key=e.key.toString()),e.containingGroup!==null&&(i.group=e.containingGroup.key.toString()),e instanceof q&&(e.fromNode!==null&&e.fromNode.key!==void 0&&(i.fromKey=e.fromNode.key.toString()),e.fromPortId!==""&&(i.fromPortId=e.fromPortId),e.toNode!==null&&e.toNode.key!==void 0&&(i.toKey=e.toNode.key.toString()),e.toPortId!==""&&(i.toPortId=e.toPortId)))))}Jp(t,e,i,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path");return}let o=e.Nn()?e.naturalBounds:e.actualBounds,r=Math.max(i.x,o.x),a=Math.max(i.y,o.y),h=Math.min(i.right,o.right)-r,l=Math.min(i.bottom,o.bottom)-a,c=this.he;c!==null&&(r=c.x,a=c.y,h=c.width,l=c.height);let u=B.z(r,a,Math.max(h,0),Math.max(l,0));if(this instanceof H){let d=Pt.l();d.set(this.v),d.tx(),d.im(u),Pt.i(d)}s.setAttributeNS(null,"clip-path",`path(' M ${u.x},${u.y} L ${u.width+u.x} ${u.y} L ${u.width+u.x} ${u.height+u.y} L ${u.x} ${u.height+u.y} z') view-box`),B.i(u)}fI(){if(this.svg===null)return;let t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),e=this.svg.ownerDocument;if(t!==null)for(let i of t){let s=e.getElementById(i.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}lI(t,e){let i=this.De,s=this.Ke,n=this.Lt;n!==null&&t.commitTransform(),n!==null&&(this.kn(t,n,!0,!1,s,i),n instanceof E&&n.type===3?(t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fillContext(n,!1,null)):t.fillRect(i.x,i.y,i.width,i.height)),this.Ma(t,e)}Ma(t,e){}wf(){this.$i(!0)}yf(t,e,i){let s=this.svg;if(this.uI()){if(this.wf(),this.$i(!1),s===null)return!1;let c=s.getAttribute("clip-path");if(c!==null&&c.includes("url")){let u=t.svg.getElementById(c.split("#")[1].slice(0,-1));u!==null&&u.remove()}return s.getAttribute("filter")&&s.removeAttribute("filter"),!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&i||s.nodeName==="g"&&!i)return!1;let n=this.v,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof H,a=r?this.ol():!1;if(!(r&&a))if(this instanceof zt){let c=this.E1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),c!==null&&t.amendImageTransform(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]),i?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(i&&!r)if(this instanceof at){let c=s.getElementsByTagName("path");for(let u=0;u<c.length;u++)c[u].setAttributeNS(null,"transform",o)}else if(this instanceof gt){let c=s.getElementsByTagName("text"),u=typeof this.stroke=="string"?this.stroke:null;for(let d=0;d<c.length;d++)c[d].setAttributeNS(null,"transform",o),u&&c[d].setAttributeNS(null,"fill",u)}else(s.lastElementChild||s).setAttributeNS(null,"transform",o);else if(r&&this.isClipping&&this.xa){let c=this.findMainElement(),u=c!==null?c.actualBounds.x:0,d=c!==null?c.actualBounds.y:0;this.xa.setAttributeNS(null,"transform","matrix(1,0,0,1,"+-u+", "+-d+")"),s.setAttributeNS(null,"transform","matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+(n.dx+u)+", "+(n.dy+d)+")")}else s.setAttributeNS(null,"transform",o);let h=this._s()?this.opacity*t.globalAlpha:this.opacity;h===1?s.removeAttribute("opacity"):s.setAttributeNS(null,"opacity",h.toString()),t.setCurrentTransform(1,0,0,1,0,0);let l=this.xa?this.xa:this.v1;if(this.background!==null||l.Lt!==void 0){let c=l.Lt;if(this.background===null)t.removeOldGradient(this,l.Lt,"fill"),l.Lt.remove(),l.Lt=void 0;else{if((a||i&&!(this instanceof H))&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.R1(t,this.naturalBounds,this.actualBounds),l.Lt){t.removeOldGradient(this,l.Lt,"fill");let u=l.Lt.getAttribute("filter");u!==null&&t.lastCreatedElement.setAttribute("filter",u),l.Lt.replaceWith(t.lastCreatedElement)}else l.prepend(t.lastCreatedElement);l.Lt=t.lastCreatedElement}c&&t.removeOldGradient(this,c,"fill")}return this.Jp(t,this.panel,this.actualBounds,s),!0}kd(t){if(this.background!==null)return!0;let e=(this.n&256)!==0;return t.clipInsteadOfFill&&(e=!1),!!e}static UU(t,e,i,s,n,o,r){let a=.001,h=o.length;t.moveTo(e,i);let l=s-e,c=n-i;l===0&&(l=.001);let u=c/l,d=Math.sqrt(l*l+c*c),f=0,p=!0;a=o[f%h];let m=r!==0;for(;d>=.1;){if(m){for(a=o[f++%h],a-=r;a<0;)a+=o[f++%h],p=!p;m=!1}else a=o[f++%h];a>d&&(a=d);let y=Math.sqrt(a*a/(1+u*u));l<0&&(y=-y),e+=y,i+=u*y,p?t.lineTo(e,i):t.moveTo(e,i),d-=a,p=!p}}kn(t,e,i,s,n,o){let r=1,a=1;if(typeof e=="string"){i?t.fillStyle=e:t.strokeStyle=e;return}else if(e.type===1){i?t.fillStyle=e.color:t.strokeStyle=e.color;return}let h,l=this.Hp();r=n.width,a=n.height,s?(r=o.width,a=o.height):i||(r+=l,a+=l);let c=t instanceof Vi;if(c&&e.Cn&&(e.type===4||e.xf===r&&e.U1===a))h=e.Cn;else{let u=0,d=0,f=0,p=0,m=0,y=0,b=0,v=0;if(s?(b=o.x,v=o.y):i||(b-=l/2,v-=l/2),u=e.start.x*r+e.start.offsetX+b,d=e.start.y*a+e.start.offsetY+v,f=e.end.x*r+e.end.offsetX+b,p=e.end.y*a+e.end.offsetY+v,e.type===2)h=t.createLinearGradient(u,d,f,p);else if(e.type===3)y=isNaN(e.endRadius)?Math.max(r,a)/2:e.endRadius,isNaN(e.startRadius)?(m=0,y=Math.max(r,a)/2):m=e.startRadius,h=t.createRadialGradient(u,d,m,f,p,y);else if(e.type===4)try{h=t.createPattern(e.pattern,"repeat")}catch{h=null}else g.si(e.type,"Brush type");if(e.type!==4){let w=e.colorStops;if(w!==null){let k=w.iterator;for(;k.next();)h.addColorStop(k.key,k.value)}}if(c&&(e.Cn=h,h!==null&&(e.xf=r,e.U1=a),h===null&&e.type===4&&e.xf!==-1)){e.xf=-1;let w=this.diagram;w!==null&&e.xf===-1&&g.dn(()=>{w.redraw()},600)}}i?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof H?this.dI(this,t):!1}dI(t,e){if(t===e||e===null)return!1;let i=t.panel;for(;i!==null;){if(i===e)return!0;i=i.panel}return!1}isVisibleObject(){if(!this.visible)return!1;let t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof H?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.w!==null?this.w.$p:null}set enabledChanged(t){let e=this.enabledChanged;e!==t&&(t!==null&&g.S(t,tt,"enabledChanged"),this.Yt().$p=t,this.t("enabledChanged",e,t))}F1(){if(this.V1()===!0){let t=this.il;if(t.Ue(),!this.De.isReal()||!this.ai.isReal()){this.Pd(!1);return}if(t.Gs(this.De.x-this.ai.x,this.De.y-this.ai.y),this.scale!==1||this.angle!==0){let e=this.naturalBounds;this.Yp(t,e.x,e.y,e.width,e.height)}this.Pd(!1),this.Ih(!0)}if(this.Kp()===!0){let t=this.panel;if(t===null)this.wa.set(this.il),this.Lh=this.scale;else if(t.Js!==null){let e=this.wa;e.Ue(),t.Nn()?e.bc(t.wa):t.panel!==null&&e.bc(t.panel.wa),e.bc(this.il),this.Lh=this.scale*t.Lh}this.Ih(!1)}}Yp(t,e,i,s,n){if(this.it!==1&&t.it(this.it),this.Xt===0)return;let o=P.l();o.setSpot(e,i,s,n,T.Center),t.ks(this.Xt,o.x,o.y),P.i(o)}c(t){if(this.Go())return;t===void 0&&(t=!1),this.wi(!0),this.ao(!0);let e=this.panel;e!==null&&!t&&e.c()}bf(){this.Go()||(this.wi(!0),this.ao(!0))}kf(t){if(this.as())return;let e=this.panel;!t&&e!==null&&e.c(),this.ao(!0)}pf(){this.V1()===!1&&(this.Pd(!0),this.Ih(!0))}AN(){this.Ih(!0)}C(){let t=this.part;t!==null&&t.C()}Qs(t){let e=this.stretch,i=this.panel;if(i===null)return this.qo(e===1?0:e,t);if(i.type===H.Table)return this.Zp(i.getRowDefinition(this.row),i.getColumnDefinition(this.column),t);if(i.type===H.Auto&&i.findMainElement()===this)return this.qo(2,t);if(e===1){if(i.type===H.Spot&&i.findMainElement()===this)return this.qo(2,t);let s=i.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(e,t)}Zp(t,e,i){let s=this.stretch;if(s!==1)return this.qo(s,i);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(e.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}let r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,i):n===!0?this.qo(5,i):o===!0?this.qo(4,i):this.qo(0,i)}qo(t,e){if(e)return t;if(t===0)return 0;let i=this.desiredSize;if(i.isReal())return 0;let s=!isNaN(i.width),n=!isNaN(i.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ot!==null?this.Ot.Qp:0}set segmentOrientation(t){let e=this.segmentOrientation;e!==t&&(this.Ot===null&&(this.Ot=new $e),this.Ot.Qp=t,this.c(),this.t("segmentOrientation",e,t),t===0&&(this.angle=0))}gI(){this.segmentOrientation=21}get segmentIndex(){return this.Ot!==null?this.Ot._p:-1/0}set segmentIndex(t){t=Math.round(t);let e=this.segmentIndex;e!==t&&(this.Ot===null&&(this.Ot=new $e),this.Ot._p=t,this.c(),this.t("segmentIndex",e,t))}get segmentFraction(){return this.Ot!==null?this.Ot.t0:0}set segmentFraction(t){t<0?t=0:t>1&&(t=1);let e=this.segmentFraction;e!==t&&(this.Ot===null&&(this.Ot=new $e),this.Ot.t0=t,this.c(),this.t("segmentFraction",e,t))}get segmentOffset(){return this.Ot!==null?this.Ot.e0:P.gn}set segmentOffset(t){let e=this.segmentOffset;e.equals(t)||(t=t.N(),this.Ot===null&&(this.Ot=new $e),this.Ot.e0=t,this.c(),this.t("segmentOffset",e,t))}get stretch(){return this.w!==null?this.w.ho:1}set stretch(t){let e=this.stretch;e!==t&&(this.Yt().ho=t,this.c(),this.t("stretch",e,t))}get name(){return this.w!==null?this.w.Pt:""}set name(t){let e=this.name;e!==t&&(this.Yt().Pt=t,this.part!==null&&this.part.i0(),this.t("name",e,t))}get opacity(){return this.Zt}set opacity(t){t<0?t=0:t>1&&(t=1);let e=this.opacity;if(e!==t){this.Zt=t,this.t("opacity",e,t);let i=this.diagram,s=this.part;i!==null&&s!==null&&i.C(s.lh(s.actualBounds))}}get filter(){return this.Xp}set filter(t){let e=this.filter;if(e!==t){this.Xp=t,this.$i(!0),this.t("filter",e,t);let i=this.diagram,s=this.part;i!==null&&s!==null&&i.C(s.lh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){let e=(this.n&1)!==0;if(e!==t){this.n=this.n^1,this.wf(),this.t("visible",e,t);let i=this.panel;i!==null?i.c():this._s()&&this.Xe(t),this.C(),this.sD()}}get pickable(){return(this.n&2)!==0}set pickable(t){let e=(this.n&2)!==0;e!==t&&(this.n=this.n^2,this.t("pickable",e,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){let e=(this.n&4)!==0;e!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",e,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){let e=(this.n&8)!==0;e!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",e,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){let e=(this.n&16)!==0;e!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",e,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){let e=(this.n&32)!==0;e!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",e,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){let e=(this.n&64)!==0;e!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",e,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){let e=(this.n&128)!==0;e!==t&&(this.n=this.n^128,this.t("isActionable",e,t))}get background(){return this.Lt}set background(t){let e=this.background;e!==t&&(t!==null&&E.Sd(t,"GraphObject.background"),t instanceof E&&t.b(),this.Lt=t,this.C(),this.t("background",e,t))}CN(){return(this.n&512)!==0}I1(t){t?this.n|=512:this.n&=-513}gf(){return(this.n&1024)!==0}TN(t){t?this.n|=1024:this.n&=-1025}V1(){return(this.n&2048)!==0}Pd(t){t?this.n|=2048:this.n&=-2049}Kp(){return(this.n&4096)!==0}Ih(t){t?this.n|=4096:this.n&=-4097}Go(){return(this.n&8192)!==0}wi(t){t?this.n|=8192:this.n&=-8193}as(){return(this.n&16384)!==0}ao(t){t?this.n|=16384:this.n&=-16385}uI(){return(this.n&32768)!==0}$i(t){t?this.n|=32768:this.n&=-32769}get part(){if(this._s())return this;if(this.nl!==null)return this.nl;let t=this;for(t=t.panel;t;){if(t instanceof bt)return this.nl=t,t;t=t.panel}return null}get svg(){return this.v1}set svg(t){this.v1=t}qc(){this.svg=null}get panel(){return this.Zs}Eh(t){this.Zs=t,this.svg!==null&&this.svg.remove()}get layer(){let t=this.part;return t!==null?t.layer:null}get diagram(){let t=this.part;return t!==null?t.diagram:null}get position(){return this.ct}set position(t){let e=t.x,i=t.y,s=this.position,n=s.x,o=s.y;n!==e&&(!isNaN(n)||!isNaN(e))||o!==i&&(!isNaN(o)||!isNaN(i))?(t=t.copy(),this.DN(t,n,o)&&this.t("position",new P(n,o),t.copy())):this.vN()}vN(){}DN(t,e,i){return this.ct=t,this.kf(),!0}Ec(t,e,i){this.ct.x===t&&this.ct.y===e||(this.ct.e(t,e),this.pf())}get actualBounds(){return this.De}get scale(){return this.it}set scale(t){let e=this.scale;e!==t&&(t<=0&&g.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.it=t,this.c(),this.t("scale",e,t))}get angle(){return this.Xt}set angle(t){let e=this.angle;if(e!==t){if(t=t%360,t<0&&(t+=360),e===t)return;this.Xt=t,this.sD(),this.c(),this.t("angle",e,t)}}get desiredSize(){return this.cs}set desiredSize(t){let e=t.width,i=t.height,s=this.desiredSize,n=s.width,o=s.height;if((n!==e&&(!isNaN(n)||!isNaN(e))||o!==i&&(!isNaN(o)||!isNaN(i)))&&(t=t.N(),this.cs=t,this.c(),this instanceof at&&this.Ze(),this.t("desiredSize",s,t),this.gf())){let r=this.part;r!==null&&(this.Oh(r,"width"),this.Oh(r,"height"))}}get width(){return this.cs.width}set width(t){let e=this.cs.width;if(e!==t&&(!isNaN(e)||!isNaN(t))){let i=this.cs,s=new _(t,this.cs.height).b();if(this.cs=s,this.c(),this instanceof at&&this.Ze(),this.t("desiredSize",i,s),this.gf()){let n=this.part;n!==null&&this.Oh(n,"width")}}}get height(){return this.cs.height}set height(t){let e=this.cs.height;if(e!==t&&(!isNaN(e)||!isNaN(t))){let i=this.cs,s=new _(this.cs.width,t).b();if(this.cs=s,this.c(),this instanceof at&&this.Ze(),this.t("desiredSize",i,s),this.gf()){let n=this.part;n!==null&&this.Oh(n,"height")}}}get minSize(){return this.w!==null?this.w.Cr:_.xc}set minSize(t){let e=this.minSize;e.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.b(),this.Yt().Cr=t,this.c(),this.t("minSize",e,t))}get maxSize(){return this.w!==null?this.w.Lr:_.TP}set maxSize(t){let e=this.maxSize;e.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.b(),this.Yt().Lr=t,this.c(),this.t("maxSize",e,t))}get measuredBounds(){return this.ai}get naturalBounds(){return this.Ke}Hp(){return 0}get margin(){return this.sl}set margin(t){typeof t=="number"&&(t=new Dt(t));let e=this.sl;e.equals(t)||(t=t.N(),this.sl=t,this.c(),this.t("margin",e,t))}get v(){return this.V1()===!0&&this.F1(),this.il}get Js(){return this.Kp()===!0&&this.F1(),this.wa}trigger(t,e,i){let s=null;return typeof t=="string"?s=new Ri(t,e,i):s=t,s.Ti=this,this.Ds===null&&(this.Ds=new wt),this.Ds.set(s.propertyName,s),this}get Ds(){return this.w!==null?this.w.Ds:null}set Ds(t){this.Ds!==t&&(this.Yt().Ds=t)}get Nr(){return this.w!==null?this.w.Nr:0}set Nr(t){this.Nr!==t&&(this.Yt().Nr=t)}get alignment(){return this.de}set alignment(t){let e=this.alignment;e.equals(t)||(t.isNoSpot()&&!t.isDefault()&&g.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.de=t,this.kf(),this.t("alignment",e,t))}get column(){return this.pa}set column(t){t=Math.round(t);let e=this.column;e!==t&&(t<0&&g.J(t,">= 0",tt,"column"),this.pa=t,this.c(),this.t("column",e,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.w!==null?this.w.s0:1}set columnSpan(t){t=Math.round(t);let e=this.columnSpan;e!==t&&(t<1&&g.J(t,">= 1",tt,"columnSpan"),this.Yt().s0=t,this.c(),this.t("columnSpan",e,t))}get row(){return this.zp}set row(t){t=Math.round(t);let e=this.row;e!==t&&(t<0&&g.J(t,">= 0",tt,"row"),this.zp=t,this.c(),this.t("row",e,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.w!==null?this.w.o0:1}set rowSpan(t){t=Math.round(t);let e=this.rowSpan;e!==t&&(t<1&&g.J(t,">= 1",tt,"rowSpan"),this.Yt().o0=t,this.c(),this.t("rowSpan",e,t))}get spanAllocation(){return this.w!==null?this.w.r0:null}set spanAllocation(t){let e=this.spanAllocation;e!==t&&(t!==null&&g.S(t,tt,"spanAllocation"),this.Yt().r0=t,this.c(),this.t("spanAllocation",e,t))}get alignmentFocus(){return this.yd}set alignmentFocus(t){let e=this.alignmentFocus;e.equals(t)||(t=t.N(),this.yd=t,this.c(),this.t("alignmentFocus",e,t))}get portId(){return this.Bp}set portId(t){let e=this.portId;if(e!==t){let i=this.part;i!==null&&!(i instanceof it)&&g.o("Cannot set portID on a Link: "+t);let s=i;e!==null&&s!==null&&s.FN(this),this.Bp=t,t!==null&&s!==null&&(s.Ln=!0,s.nD(this)),this.t("portId",e,t)}}Uh(){let t=this.part;if(t instanceof it&&(this.portId!==null||this===t.port)){let e=t.diagram;e!==null&&!e.undoManager.isUndoingRedoing&&t.invalidateConnectedLinks(void 0,this)}}sD(){let t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof H?this instanceof it?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,e=>{e.Uh()}):this.Uh())}get toSpot(){return this.ft!==null?this.ft.Th:T.None}set toSpot(t){let e=this.toSpot;e.equals(t)||(t=t.N(),this.Ji().Th=t,this.t("toSpot",e,t),this.Uh())}get toEndSegmentLength(){return this.ft!==null?this.ft.vh:10}set toEndSegmentLength(t){let e=this.toEndSegmentLength;e!==t&&(t<0&&g.J(t,">= 0",tt,"toEndSegmentLength"),this.Ji().vh=t,this.t("toEndSegmentLength",e,t),this.Uh())}get toShortLength(){return this.ft!==null?this.ft.Rh:0}set toShortLength(t){let e=this.toShortLength;e!==t&&(this.Ji().Rh=t,this.t("toShortLength",e,t),this.Uh())}get toLinkable(){return this.ft!==null?this.ft.l0:null}set toLinkable(t){let e=this.toLinkable;e!==t&&(this.Ji().l0=t,this.t("toLinkable",e,t))}get toMaxLinks(){return this.ft!==null?this.ft.a0:1/0}set toMaxLinks(t){let e=this.toMaxLinks;e!==t&&(t<0&&g.J(t,">= 0",tt,"toMaxLinks"),this.Ji().a0=t,this.t("toMaxLinks",e,t))}get fromSpot(){return this.ft!==null?this.ft.Ah:T.None}set fromSpot(t){let e=this.fromSpot;e.equals(t)||(t=t.N(),this.Ji().Ah=t,this.t("fromSpot",e,t),this.Uh())}get fromEndSegmentLength(){return this.ft!==null?this.ft.Dh:10}set fromEndSegmentLength(t){let e=this.fromEndSegmentLength;e!==t&&(t<0&&g.J(t,">= 0",tt,"fromEndSegmentLength"),this.Ji().Dh=t,this.t("fromEndSegmentLength",e,t),this.Uh())}get fromShortLength(){return this.ft!==null?this.ft.Fh:0}set fromShortLength(t){let e=this.fromShortLength;e!==t&&(this.Ji().Fh=t,this.t("fromShortLength",e,t),this.Uh())}get fromLinkable(){return this.ft!==null?this.ft.h0:null}set fromLinkable(t){let e=this.fromLinkable;e!==t&&(this.Ji().h0=t,this.t("fromLinkable",e,t))}get fromMaxLinks(){return this.ft!==null?this.ft.c0:1/0}set fromMaxLinks(t){let e=this.fromMaxLinks;e!==t&&(t<0&&g.J(t,">= 0",tt,"fromMaxLinks"),this.Ji().c0=t,this.t("fromMaxLinks",e,t))}get cursor(){return this.w!==null?this.w.Il:""}set cursor(t){let e=this.cursor;e!==t&&(g.s(t,"string",tt,"cursor"),this.Yt().Il=t,this.t("cursor",e,t))}get click(){return this.w!==null?this.w.Ur:null}set click(t){let e=this.click;e!==t&&(t!==null&&g.S(t,tt,"click"),this.Yt().Ur=t,this.t("click",e,t))}get doubleClick(){return this.w!==null?this.w.Vr:null}set doubleClick(t){let e=this.doubleClick;e!==t&&(t!==null&&g.S(t,tt,"doubleClick"),this.Yt().Vr=t,this.t("doubleClick",e,t))}get contextClick(){return this.w!==null?this.w.Br:null}set contextClick(t){let e=this.contextClick;e!==t&&(t!==null&&g.S(t,tt,"contextClick"),this.Yt().Br=t,this.t("contextClick",e,t))}get mouseEnter(){return this.w!==null?this.w.Kr:null}set mouseEnter(t){let e=this.mouseEnter;e!==t&&(t!==null&&g.S(t,tt,"mouseEnter"),this.Yt().Kr=t,this.t("mouseEnter",e,t))}get mouseLeave(){return this.w!==null?this.w.Hr:null}set mouseLeave(t){let e=this.mouseLeave;e!==t&&(t!==null&&g.S(t,tt,"mouseLeave"),this.Yt().Hr=t,this.t("mouseLeave",e,t))}get mouseOver(){return this.w!==null?this.w.zr:null}set mouseOver(t){let e=this.mouseOver;e!==t&&(t!==null&&g.S(t,tt,"mouseOver"),this.Yt().zr=t,this.t("mouseOver",e,t))}get mouseHover(){return this.w!==null?this.w.Xr:null}set mouseHover(t){let e=this.mouseHover;e!==t&&(t!==null&&g.S(t,tt,"mouseHover"),this.Yt().Xr=t,this.t("mouseHover",e,t))}get mouseHold(){return this.w!==null?this.w.Gr:null}set mouseHold(t){let e=this.mouseHold;e!==t&&(t!==null&&g.S(t,tt,"mouseHold"),this.Yt().Gr=t,this.t("mouseHold",e,t))}get mouseDragEnter(){return this.w!==null?this.w.f0:null}set mouseDragEnter(t){let e=this.mouseDragEnter;e!==t&&(t!==null&&g.S(t,tt,"mouseDragEnter"),this.Yt().f0=t,this.t("mouseDragEnter",e,t))}get mouseDragLeave(){return this.w!==null?this.w.u0:null}set mouseDragLeave(t){let e=this.mouseDragLeave;e!==t&&(t!==null&&g.S(t,tt,"mouseDragLeave"),this.Yt().u0=t,this.t("mouseDragLeave",e,t))}get mouseDrop(){return this.w!==null?this.w.Yr:null}set mouseDrop(t){let e=this.mouseDrop;e!==t&&(t!==null&&g.S(t,tt,"mouseDrop"),this.Yt().Yr=t,this.t("mouseDrop",e,t))}get actionDown(){return this.w!==null?this.w.d0:null}set actionDown(t){let e=this.actionDown;e!==t&&(t!==null&&g.S(t,tt,"actionDown"),this.Yt().d0=t,this.t("actionDown",e,t))}get actionMove(){return this.w!==null?this.w.g0:null}set actionMove(t){let e=this.actionMove;e!==t&&(t!==null&&g.S(t,tt,"actionMove"),this.Yt().g0=t,this.t("actionMove",e,t))}get actionUp(){return this.w!==null?this.w.m0:null}set actionUp(t){let e=this.actionUp;e!==t&&(t!==null&&g.S(t,tt,"actionUp"),this.Yt().m0=t,this.t("actionUp",e,t))}get actionCancel(){return this.w!==null?this.w.p0:null}set actionCancel(t){let e=this.actionCancel;e!==t&&(t!==null&&g.S(t,tt,"actionCancel"),this.Yt().p0=t,this.t("actionCancel",e,t))}get toolTip(){return this.w!==null?this.w.jr:null}set toolTip(t){let e=this.toolTip;e!==t&&(this.Yt().jr=t,this.t("toolTip",e,t))}get contextMenu(){return this.w!==null?this.w.qr:null}set contextMenu(t){let e=this.contextMenu;e!==t&&(this.Yt().qr=t,this.t("contextMenu",e,t))}findBindingPanel(){let t=this instanceof H?this:this.panel;for(;t!==null;){if(t.RN())return t;t=t.panel}return null}bind(t,e,i,s){return this.Pf(t,e,i,s),this}bindTwoWay(t,e,i,s){return this.Pf(t,e,i,s).makeTwoWay(),this}bindModel(t,e,i,s){return this.Pf(t,e,i,s).ofModel(),this}bindObject(t,e,i,s,n){return this.Pf(t,e,i,s).ofObject(n),this}theme(t,e,i,s,n){return this.Na(t,e,i,s,n),this}themeData(t,e,i,s,n){return this.Na(t,e,i,s,n).ofData(),this}themeObject(t,e,i,s,n,o){return this.Na(t,e,i,s,n).ofObject(o),this}themeModel(t,e,i,s,n){return this.Na(t,e,i,s,n).ofModel(),this}Pf(t,e,i,s){let n=null;return typeof t=="string"?n=new re(t,e,i,s):n=t,this.y0(n),n}Na(t,e,i,s,n){let o=null;return typeof t=="string"?o=new bi(t,e,i,s,n):o=t,this.y0(o),o}y0(t){t.Ti=this;let e=this.findBindingPanel();e!==null&&e.oD()&&g.o("Cannot add a Binding to a template that has already been copied: "+t),this.ve===null&&(this.ve=new U),this.ve.add(t)}set(t){return t?(Object.assign(this,t),this):this}attach(t){return tt.ON(this,t),this}apply(t,...e){return t.apply(this,[this,...e]),this}setProperties(t){return j.Lp(this,t),this}static make(t,...e){let i=arguments,s=null,n=null;if(g.nt(t))n=t;else if(typeof t=="string"){let r=tt.B1.get(t);g.nt(r)?(i=Array.prototype.slice.call(i),s=r(i),g.$(s)||g.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=C.go[t]}s===null&&((n==null||!n.constructor)&&g.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof j&&i.length>1){let r=s,a=i[1];(typeof a=="string"||a instanceof HTMLDivElement)&&(r.m2(a),o++)}for(let r=o;r<i.length;r++){let a=i[r];a===void 0?g.o("Undefined value at argument "+r+" for object being constructed by GraphObject.make: "+s):s&&tt.ON(s,a)}return s}static ON(t,e){if(typeof e=="number")tt.mI(t,e);else if(typeof e=="string")tt.pI(t,e);else if(e instanceof tt)t instanceof H||g.o("A GraphObject can only be added to a Panel, not to: "+t),t.add(e);else if(e instanceof Gt){let i=null;e.isRow&&g.nt(t.getRowDefinition)?i=t.getRowDefinition(e.index):!e.isRow&&g.nt(t.getColumnDefinition)&&(i=t.getColumnDefinition(e.index)),i instanceof Gt?i.z1(e):g.o("A RowColumnDefinition can only be added to an object that implements getRowDefinition/getColumnDefinition, not to: "+t)}else if(e instanceof Ft){let i=t;i.type=e}else if(e instanceof re)t instanceof tt||t instanceof Gt?t.bind(e):g.o("A Binding can only be applied to a GraphObject or RowColumnDefinition, not to: "+t);else if(e instanceof Ri)t instanceof tt?t.trigger(e):g.o("An AnimationTrigger can only be applied to a GraphObject, not to: "+t);else if(e instanceof jt)t instanceof St&&t.type===4?t.figures.add(e):g.o("A PathFigure can only be added to a Path Geometry, not to: "+t);else if(e instanceof xt)t instanceof jt?t.segments.add(e):g.o("A PathSegment can only be added to a PathFigure, not to: "+t);else if(e instanceof oe)t instanceof j||t instanceof ft?t.layout=e:g.o("A Layout can only be assigned to a Diagram or a Group, not to: "+t);else if(Array.isArray(e))for(let i=0;i<e.length;i++){let s=e[i];tt.ON(t,s)}else g.$(e)?tt.yI(t,e):g.o('Unknown initializer "'+e+'" for object being constructed by GraphObject.make: '+t)}static pI(t,e){if(t instanceof gt)t.text=e;else if(t instanceof at)t.figure=e;else if(t instanceof zt)t.source=e;else if(t instanceof H){let i=Ft.fs.get(e);i!==null&&(t.type=i)}else if(t instanceof E){let i=g.Wa(We,e);i!==null?t.type=i:g.o("Unknown Brush type as an argument to GraphObject.make: "+e)}else if(t instanceof St){let i=g.Wa(ii,e);i!==null&&(t.type=i)}else if(t instanceof xt){let i=g.Wa(Di,e);i!==null&&(t.type=i)}}static mI(t,e){g.nt(t.fe)?t.fe(e):g.dr(t,e)}static yI(t,e){if(t instanceof E){let i=new W;for(let s in e){let n=parseFloat(s);isNaN(n)?i[s]=e[s]:t.addColorStop(n,e[s])}j.Lp(t,i)}else if(t instanceof Gt){if(e.row!==void 0){let s=e.row;(s==null||s===1/0||isNaN(s)||s<0)&&g.o("Must specify non-negative integer row for RowColumnDefinition "+e+", not: "+s),t.isRow=!0,t.index=s}else if(e.column!==void 0){let s=e.column;(s==null||s===1/0||isNaN(s)||s<0)&&g.o("Must specify non-negative integer column for RowColumnDefinition "+e+", not: "+s),t.isRow=!1,t.index=s}let i=new W;for(let s in e)s==="row"||s==="column"||(i[s]=e[s]);j.Lp(t,i)}else j.Lp(t,e)}static build(t,e,...i){let s=tt.B1.get(t);if(g.nt(s)){let n=s([t].concat(i));if(n instanceof tt)return e&&n.setProperties(e),n}g.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static defineBuilder(t,e){g.s(t,"string",tt,"defineBuilder:name"),g.S(e,tt,"defineBuilder:func");let i=t.toLowerCase();tt.B1.set(t,e)}static isBuilderDefined(t){return tt.B1.has(t)}static takeBuilderArgument(t,e,i){i===void 0&&(i=null);let s=t[1];return(g.nt(i)?i(s):typeof s=="string")?(t.splice(1,1),s):(e===void 0&&g.o("no "+(g.nt(i)?"satisfactory":"string")+" argument for GraphObject builder "+t[0]),e)}static B1=new wt}tt.Vertical=4,tt.Horizontal=5,tt.defineBuilder("Button",x=>{let t="#f5f5f5",e="#737373",i="#d4d4d4",s="#737373",n="#a3a3a3",o=2.76142374915397,r=2.761423749153969,a=new H(H.Auto,{isActionable:!0,enabledChanged:(h,l)=>{if(h instanceof H){let c=h.findObject("ButtonBorder");if(c!==null)if(h._buttonFillNormal===void 0&&(h._buttonFillNormal=c.fill),l){let u=null;h.layer!==null&&h.diagram!==null&&h.isVisibleObject()&&(u=h.layer.findObjectAt(h.diagram.lastInput.documentPoint)),u===h||u!==null&&u.isContainedBy(h)?c.fill=h._buttonFillOver:c.fill=h._buttonFillNormal}else c.fill=h._buttonFillDisabled}},cursor:"pointer"}).attach({_buttonFillNormal:void 0,_buttonStrokeNormal:void 0,_buttonFillOver:i,_buttonStrokeOver:s,_buttonFillDisabled:n}).add(new at("RoundedRectangle",{name:"ButtonBorder",spot1:new T(0,0,o,r),spot2:new T(1,1,-o,-r),parameter1:2,fill:t,stroke:e}));return a.mouseEnter=(h,l,c)=>{if(!l.isEnabledObject()||!(l instanceof H))return;let u=l.findObject("ButtonBorder");u instanceof at&&(l._buttonFillNormal===void 0&&(l._buttonFillNormal=u.fill),u.fill=l._buttonFillOver,l._buttonStrokeNormal===void 0&&(l._buttonStrokeNormal=u.stroke),u.stroke=l._buttonStrokeOver)},a.mouseLeave=(h,l,c)=>{if(!l.isEnabledObject()||!(l instanceof H))return;let u=l.findObject("ButtonBorder");u instanceof at&&(l._buttonFillNormal!==void 0&&(u.fill=l._buttonFillNormal),l._buttonStrokeNormal!==void 0&&(u.stroke=l._buttonStrokeNormal))},a}),tt.defineBuilder("TreeExpanderButton",x=>{let t=tt.build("Button");return t.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),t.add(new at("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:_.Su}).bindObject("figure","isTreeExpanded",(e,i)=>{let s=i.panel;return e?s._treeExpandedFigure:s._treeCollapsedFigure})),t.bindObject("visible","isTreeLeaf",e=>!e),t.click=(e,i)=>{let s=i.part;if(s instanceof Mt&&(s=s.adornedPart),!(s instanceof it))return;let n=s.diagram;if(n===null)return;let o=n.commandHandler;if(s.isTreeExpanded){if(!o.canCollapseTree(s))return}else if(!o.canExpandTree(s))return;e.handled=!0,s.isTreeExpanded?o.collapseTree(s):o.expandTree(s)},t}),tt.defineBuilder("SubGraphExpanderButton",x=>{let t=tt.build("Button");return t.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),t.add(new at("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:_.Su}).bindObject("figure","isSubGraphExpanded",(e,i)=>{let s=i.panel;return e?s._subGraphExpandedFigure:s._subGraphCollapsedFigure})),t.click=(e,i)=>{let s=i.part;if(s instanceof Mt&&(s=s.adornedPart),!(s instanceof ft))return;let n=s.diagram;if(n===null)return;let o=n.commandHandler;if(s.isSubGraphExpanded){if(!o.canCollapseSubGraph(s))return}else if(!o.canExpandSubGraph(s))return;e.handled=!0,s.isSubGraphExpanded?o.collapseSubGraph(s):o.expandSubGraph(s)},t}),tt.defineBuilder("ToolTip",x=>new Mt(H.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new P(0,2),mouseOver:(t,e)=>{let i=t.diagram.toolManager;i.extendToolTip(i.toolTipDuration)}}).add(new at("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new T(0,0,4,6),spot2:new T(1,1,-4,-4)}))),tt.defineBuilder("ContextMenu",x=>new Mt(H.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new P(0,2)}).bindObject("background","",t=>t.adornedPart!==null&&t.hasPlaceholder()?null:"#f5f5f5")),tt.defineBuilder("ContextMenuButton",x=>{let t=tt.build("Button");t.stretch=5;let e=t.findObject("ButtonBorder");return e instanceof at&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new T(0,0,4,6),e.spot2=new T(1,1,-4,-4)),t}),tt.defineBuilder("PanelExpanderButton",x=>{let t=tt.takeBuilderArgument(x,"COLLAPSIBLE"),e=tt.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8","ButtonBorder.fill":"rgba(0, 0, 0, 0)",_buttonFillNormal:"rgba(0, 0, 0, 0)","ButtonBorder.stroke":null,_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new at({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",s=>s?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,t));let i=e.findObject("ButtonBorder");return i instanceof at&&(i.stroke=null,i.fill="rgba(0, 0, 0, 0)"),e.click=(s,n)=>{if(!(n instanceof H))return;let o=n.diagram;if(o===null||o.isReadOnly)return;let r=n.findBindingPanel();if(r===null&&(r=n.part),r!==null){let a=r.findObject(t);a!==null&&(s.handled=!0,o.startTransaction("Collapse/Expand Panel"),a.visible=!a.visible,o.commitTransaction("Collapse/Expand Panel"))}},e}),tt.defineBuilder("CheckBoxButton",x=>{let t=tt.takeBuilderArgument(x),e=tt.build("Button",{desiredSize:new _(14,14)});e.attach({"ButtonBorder.spot1":new T(0,0,1,1),"ButtonBorder.spot2":new T(1,1,-1,-1)});let i=new at({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return t!==""&&i.bindTwoWay("visible",t),e.add(i),e.click=(s,n)=>{if(!(n instanceof H))return;let o=s.diagram;if(o===null||o.isReadOnly||t!==""&&o.model.isReadOnly)return;s.handled=!0;let r=n.findObject("ButtonIcon");o.startTransaction("checkbox"),r!==null&&(r.visible=!r.visible),g.nt(n._doClick)&&n._doClick(s,n),o.commitTransaction("checkbox")},e}),tt.defineBuilder("CheckBox",x=>{let t=tt.takeBuilderArgument(x),e=tt.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Dt(0,1,0,0)},t),i=new H("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Dt(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return i.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,i}),tt.defineBuilder("AutoRepeatButton",x=>{let t=tt.takeBuilderArgument(x,50,r=>typeof r=="number"),e=tt.takeBuilderArgument(x,500,r=>typeof r=="number");function i(r,a){n(r,a),a.click&&(a.Md=g.dn(()=>s(r,a),e))}function s(r,a){a.Md&&g.yc(a.Md),a.click&&(a.Md=g.dn(()=>{a.click&&(a.click(r,a),s(r,a))},t))}function n(r,a){a.Md&&(g.yc(a.Md),a.Md=void 0)}let o=tt.build("Button");return o.actionDown=(r,a)=>i(r,a),o.actionUp=(r,a)=>n(r,a),o.actionCancel=(r,a)=>n(r,a),o}),tt.defineBuilder("ToggleSwitch",function(x){let t=tt.takeBuilderArgument(x);t||g.o("ToggleSwitch must be data-bound to a property name, not: "+t);let e=tt.takeBuilderArgument(x,!1,r=>typeof r=="boolean"),i="gray",s="transparent",n="white",o=new H("Auto",{width:e?15:28,height:e?28:15}).attach({_buttonFillOff:i,_buttonBorderOff:s,_buttonIconFillOff:n,_buttonFillOn:"green",_buttonBorderOn:"transparent",_buttonIconFillOn:"white"}).add(new at("Capsule",{name:"ButtonBorder",fill:i,stroke:s,strokeWidth:1}).bind("fill",t,(r,a)=>r?a.panel._buttonFillOn:a.panel._buttonFillOff).bind("stroke",t,(r,a)=>r?a.panel._buttonBorderOn:a.panel._buttonBorderOff)).add(new at("Circle",{name:"ButtonIcon",width:11,height:11,fill:n,stroke:null,alignment:e?T.Bottom:T.Left}).bind("fill",t,(r,a)=>r?a.panel._buttonIconFillOn:a.panel._buttonIconFillOff).bind("alignment",t,r=>r?e?T.Top:T.Right:e?T.Bottom:T.Left));return o.click=function(r,a){if(!a.isEnabledObject())return;let h=r.diagram;if(h===null||h.isReadOnly||t!==""&&h.model.isReadOnly)return;r.handled=!0;let l=a.findBindingPanel();l!==null&&(h.startTransaction("toggle switch"),h.model.set(l.data,t,!l.data[t]),typeof a._doClick=="function"&&a._doClick(r,a),h.commitTransaction("toggle switch"))},o}),tt.defineBuilder("Toggle",function(x){let t=tt.takeBuilderArgument(x),e=tt.build("ToggleSwitch",{name:"Button"},t),i=new H("Horizontal",{cursor:e.cursor,margin:1,mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonClick:e.click}).add(e);return e.mouseEnter=null,e.mouseLeave=null,e.click=null,i});class oi{me;Pt;oo;ve;ro;vs;Il;Ur;Vr;Br;Kr;Hr;zr;Xr;Gr;f0;u0;Yr;d0;g0;m0;p0;jr;qr;$p;r0;Ds;Cr;Lr;ho;o0;s0;Nr;Wp;w0;x0;constructor(){this.me=!1,this.Pt="",this.oo=-1,this.ve=null,this.ro=null,this.vs=null,this.Il="",this.Ur=null,this.Vr=null,this.Br=null,this.Kr=null,this.Hr=null,this.zr=null,this.Xr=null,this.Gr=null,this.f0=null,this.u0=null,this.Yr=null,this.d0=null,this.g0=null,this.m0=null,this.p0=null,this.jr=null,this.qr=null,this.$p=null,this.r0=null,this.Ds=null,this.Cr=_.xc,this.Lr=_.TP,this.ho=1,this.o0=1,this.s0=1,this.Nr=0,this.Wp=null,this.w0=null,this.x0="category"}copy(){let t=new oi;return t.Pt=this.Pt,t.oo=this.oo,t.ve=this.ve,t.vs=this.vs,t.Il=this.Il,t.Ur=this.Ur,t.Vr=this.Vr,t.Br=this.Br,t.Kr=this.Kr,t.Hr=this.Hr,t.zr=this.zr,t.Xr=this.Xr,t.Gr=this.Gr,t.f0=this.f0,t.u0=this.u0,t.Yr=this.Yr,t.d0=this.d0,t.g0=this.g0,t.m0=this.m0,t.p0=this.p0,t.jr=this.jr,t.qr=this.qr,t.$p=this.$p,t.r0=this.r0,t.Ds=this.Ds,t.Cr=this.Cr.N(),t.Lr=this.Lr.N(),t.ho=this.ho,t.o0=this.o0,t.s0=this.s0,t.Nr=this.Nr,t.Wp=this.Wp,t.w0=this.w0,t.x0=this.x0,t}}class is{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){let t=new is;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,e){this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e}scale(t,e){this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e}rotate(t,e,i){if(t=A.Ee(t),t===0)return;this.translate(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,a=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=a,this.m[3]=h,this.translate(-e,-i)}}class Ii{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,e){this.colors.push({offset:t,color:e})}}class Bi{bt;_t;el;fd;IN;constructor(t,e,i){let s=e===void 0?C.document:e;this.el=s,this.IN="http://www.w3.org/2000/svg";let n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.bt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",i||(this.style.position="absolute"),this.bt.setAttributeNS(n,"xmlns",this.IN),this.bt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.fd=null,this._t=new ge(this,i)}resize(t,e,i,s){return this.width!==t||this.height!==e?(this.width=t,this.height=e,this.style.width=i+"px",this.style.height=s+"px",this.bt.setAttributeNS(null,"width",i+"px"),this.bt.setAttributeNS(null,"height",s+"px"),this.bt.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),this._t.EN.firstElementChild.setAttributeNS(null,"width",i+"px"),this._t.EN.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,e,i){let s=this.el.createElementNS(this.IN,t);if(g.$(e))for(let n in e)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,e[n]);return i!==void 0&&(s.textContent=i),s}getBoundingClientRect(){return this.bt.getBoundingClientRect()}focus(){this.bt.focus()}get width(){return this.bt.width.baseVal.value}set width(t){this.bt.setAttribute("width",t+"px")}get height(){return this.bt.height.baseVal.value}set height(t){this.bt.setAttribute("height",t+"px")}dispose(){this.el=null}get style(){return this.bt.style}}class ge{Sf;Mf;An;Fe;Zi;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;Nf;Cf;surface;svg;EN;rD;X1;Wo;Ca;Vh;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;rl;Fr;filter;letterSpacing;wordSpacing;partClipRect;constructor(t,e){if(this.surface=t,this.svg=t.bt,this.Nf=[],this.Cf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.rl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.Sf=0,this.Mf=0,this.An=0,this.lastCreatedElement=null,this.currentElement=null,this.Fe=[],this.pathAttributes={},this.X1=!1,this.Wo=null,this.Ca=0,this.rD={},this.Fr=!!e,this.filter="",this.partClipRect=null,this.Zi=new is,this.letterSpacing="0px",this.wordSpacing="0px",t.el===null||t.el===void 0)return;this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;let i=I.qw++,s=this.makeElement("clipPath",{id:"mainClip"+i}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.EN=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+i+")")}setDiagramPosScale(t,e,i,s,n,o){this.diagramGroup===void 0?this.newGroup(t,e,i,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+e+", "+i+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,e,i,s,n,o,r,a){let h=2*Math.PI,l=1e-6,c=h-l,u=i*Math.cos(s),d=i*Math.sin(s),f=t+u,p=e+d,m=o?0:1,y=o?s-n:n-s;(Math.abs(r-f)>l||Math.abs(a-p)>l)&&this.Fe.push(["L",f,+p]),y<0&&(y=y%h+h),y>c?(this.Fe.push(["A",i,i,0,1,m,t-u,e-d]),this.Fe.push(["A",i,i,0,1,m,f,p])):y>l&&this.Fe.push(["A",i,i,0,+(y>=Math.PI),m,t+i*Math.cos(n),e+i*Math.sin(n)])}beginPath(){this.Fe=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.wI(this.Fe,this.Zi,t||0)}bezierCurveTo(t,e,i,s,n,o){this.Fe.push(["C",t,e,i,s,n,o])}clearRect(t,e,i,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Fe.push(["z"])}createLinearGradient(t,e,i,s){let n=new Ii("linear");return n.x1=t,n.y1=e,n.x2=i,n.y2=s,n}createPattern(t,e){let i="";t instanceof HTMLCanvasElement&&(i=t.toDataURL()),t instanceof HTMLImageElement&&(i=t.getAttribute("src"));let s=this.rD;if(s[i])return"url(#"+s[i]+")";let n="PATTERN"+I.qw++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:i},a=this.makeElement("pattern",o);return a.appendChild(this.makeElement(j.img,r)),this.svg.appendChild(a),s[i]=n,"url(#"+n+")"}createRadialGradient(t,e,i,s,n,o){let r=new Ii("radial");return r.x1=t,r.y1=e,r.r1=i,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,e,i,s,n,o,r,a){let h=r/i,l=a/s;(n!==0||o!==0)&&this.Zi.translate(n,o),(h!==1||l!==1)&&this.Zi.scale(h,l),(t!==0||e!==0)&&this.Zi.translate(-t,-e)}drawImage(t,e,i,s,n,o,r,a,h){let l="";t instanceof HTMLCanvasElement&&(l=t.toDataURL()),t instanceof HTMLImageElement&&(l=t.getAttribute("src"));let c=t instanceof HTMLImageElement?t.naturalWidth:t.width,u=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=e,r=i,a=s=c,h=n=u),s=s||0,n=n||0,o=o||0,r=r||0,a=a||0,h=h||0,this.amendImageTransform(e,i,s,n,o,r,a,h);let d={x:0,y:0,width:c||s,height:u||n,href:l};!A.X(s,a)||!A.X(n,h)?d.preserveAspectRatio="none":l.toLowerCase().indexOf(".svg")===-1&&l.toLowerCase().indexOf("data:image/svg")===-1&&(d.preserveAspectRatio="xMidYMid slice"),(e!==0||i!==0||s!==c||n!==u)&&(s+=e,n+=i,d["clip-path"]=`path('M ${e},${i} L ${s} ${i} L ${s} ${n} L ${e} ${n} z')`),this.processCommon(j.img,d,this.Zi),this.Nd(j.img,d)}fill(t,e){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,e,i){this.clipInsteadOfFill?this.clip():this.fill(e,i)}createOrUpdateClipGroup(t,e){let i=this.newGroup(1,0,0,1,-e.x,-e.y);i.setAttributeNS(null,"class","spotClip"),t.xa=i}fillRect(t,e,i,s){this.addRect("fill",[t,e,i,s],this.Zi)}fillBackground(t,e,i,s){let n={x:t,y:e,width:i,height:s};this.processCommon("fill",n,this.Zi),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,e,i){this.addText("fill",[t,e,i],this.Zi)}lineTo(t,e){this.Fe.push(["L",t,e])}moveTo(t,e){this.Fe.push(["M",t,e])}quadraticCurveTo(t,e,i,s){this.Fe.push(["Q",t,e,i,s])}rect(t,e,i,s){this.Fe.push(["M",t,e],["L",t+i,e],["L",t+i,e+s],["L",t,e+s],["z"])}restore(){this.Zi=this.Nf.pop(),this.Fe=this.Nf.pop();let t=this.Nf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect,this.letterSpacing=t.letterSpacing,this.wordSpacing=t.wordSpacing}save(){let t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.Nf.push(t);let e=[];for(let i=0;i<this.Fe.length;i++)e.push(this.Fe[i]);this.Nf.push(e),this.Nf.push(this.Zi.copy())}setTransform(t,e,i,s,n,o){t===1&&e===0&&i===0&&s===1&&n===0&&o===0||this.newGroup(t,e,i,s,n,o)}setCurrentTransform(t,e,i,s,n,o){this.Zi.m=[t,e,i,s,n,o]}getCurrentTransform(){let t=this.Zi.m;return"matrix("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"}scale(t,e){this.Zi.scale(t,e)}translate(t,e){this.Zi.translate(t,e)}transform(t,e,i,s,n,o){}commitTransform(){}stroke(){this.setStroke(this.pathAttributes)}strokeContext(){this.clipInsteadOfFill||this.stroke()}strokeRect(t,e,i,s){this.addRect("stroke",[t,e,i,s],this.Zi)}makeElement(t,e,i){return this.surface.makeElement(t,e,i)}Nd(t,e,i){let s=this.makeElement(t,e,i);return this.currentElement!==null?this.currentElement.appendChild(s):this.currentElement=s,this.lastCreatedElement=s,s}processCommon(t,e,i){if(t==="fill"?this.setFill(e):t==="stroke"&&this.setStroke(e),i!==null){let s=i.m;e.transform="matrix("+s[0]+", "+s[1]+", "+s[2]+", "+s[3]+", "+s[4]+", "+s[5]+")"}}setFill(t){if(this.fillStyle instanceof Ii){t.fill=this.addGradient(this.fillStyle,"fill");return}if(/^rgba\(/.test(this.fillStyle)){let e=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.fillStyle);t.fill="rgb("+e[1]+","+e[2]+","+e[3]+")",t["fill-opacity"]=e[4]}else t.fill=this.fillStyle}setFillOrStrokeInPlace(t,e){let i=e?"fill":"stroke";if(this.fillStyle instanceof Ii){t.setAttributeNS(null,"fill",this.addGradient(this.fillStyle,i));return}if(/^rgba\(/.test(this.fillStyle)){let s=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.fillStyle);t.setAttributeNS(null,i,"rgb("+s[1]+","+s[2]+","+s[3]+")"),t.setAttributeNS(null,i+"-opacity",s[4])}else t.setAttributeNS(null,i,this.fillStyle)}setStroke(t){if(this.strokeStyle instanceof Ii)t.stroke=this.addGradient(this.strokeStyle,"stroke");else if(/^rgba\(/.test(this.strokeStyle)){let e=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.strokeStyle);t.stroke="rgb("+e[1]+","+e[2]+","+e[3]+")",t["stroke-opacity"]=e[4]}else t.stroke=this.strokeStyle;t["stroke-width"]=this.lineWidth,t["stroke-linecap"]=this.lineCap,t["stroke-linejoin"]=this.lineJoin,t["stroke-miterlimit"]=this.miterLimit,this.X1&&(t["stroke-dasharray"]=this.Wo.toString(),t["stroke-dashoffset"]=this.Ca)}addGradient(t,e){let i="",s=this.currentPath!==null?this.currentPath.getAttribute(e):null;if(s!==null&&s.indexOf("GRAD")!==-1){i=s.split("#")[1].slice(0,-1);let a=this.svg.getElementById(i);a!==null&&a.remove()}else i="GRAD"+I.qw++;let n;if(t.type==="linear"){let a={x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,id:i,gradientUnits:"userSpaceOnUse"};n=this.makeElement("linearGradient",a)}else if(t.type==="radial"){let a={x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,r1:t.r1,r2:t.r2,id:i};n=this.makeElement("radialGradient",a)}else g.o("invalid gradient");let o=t.colors.sort((a,h)=>a.offset>h.offset?1:-1),r=o.length;for(let a=0;a<r;a++){let h=o[a],l=h.color;n.appendChild(this.makeElement("stop",{offset:h.offset,"stop-color":l}))}return this.svg.appendChild(n),"url(#"+i+")"}addRect(t,e,i){let s={x:e[0],y:e[1],width:e[2],height:e[3]};this.processCommon(t,s,i),this.Nd("rect",s)}addText(t,e,i){let s=this.textAlign;s==="left"?s="start":s==="right"?s="end":s==="center"&&(s="middle");let n={x:e[1],y:e[2],style:"font: "+this.font,"text-anchor":s};n["letter-spacing"]=this.letterSpacing,n["word-spacing"]=this.wordSpacing,this.processCommon(t,n,i),this.Nd("text",n,e[0])}wI(t,e,i){let s=this.xI(t),n=this.pathAttributes;if(n.clipPath){this.Cf.length>1&&this.Cf[this.Cf.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,e),this.currentPath!==null){let o=this.currentPath;if(o.nodeName!=="g")for(let r in n)r!=="transform"&&o.setAttributeNS(null,r,n[r]);else{let r=o.getElementsByTagName("path");for(let a in n)a!=="transform"&&r[i].setAttributeNS(null,a,n[a])}}else this.Nd("path",n)}xI(t){let e=[];for(let i=0;i<t.length;i++){let s=t[i].slice(),n=[s.shift()];if(n[0]==="A")n.push(s.shift()+","+s.shift(),s.shift(),s.shift()+","+s.shift(),s.shift()+","+s.shift());else for(;s.length;)n.push(s.shift()+","+s.shift());e.push(n.join(" "))}return e.join(" ")}newGroup(t,e,i,s,n,o){let r=new is;r.m=[t,e,i,s,n,o];let a={};this.processCommon("g",a,r);let h=this.Nd("g",a);return this.Cf.push(h),h}newGroup2(t){let e={};t&&(e.class=t);let i=this.Nd("g",e);return this.Cf.push(i),i}endGroup(){return this.Cf.pop()}dummyGroup(){return this.newGroup2(),this.endGroup()}shadowsSet(t,e,i){this.Sf=t,this.Mf=e,this.An=i}shadowsOff(){this.rl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.rl=!0,this.shadowOffsetX=this.Sf,this.shadowOffsetY=this.Mf,this.shadowBlur=this.An}enableDash(t,e){this.X1=!0,this.Wo=t,this.Ca=e}disableDash(){this.X1=!1}clearContextCache(t){}setImageSmoothingEnabled(t){}rotate(t){this.Zi.rotate(t*57.2958,0,0)}getImageData(t,e,i,s){return null}measureText(t){return null}removeOldGradient(t,e,i){let s=e.getAttribute(i);if(s===null)return;let n=s.split("#");if(n.length===1)return;let o=this.svg.getElementById(n[1].slice(0,-1));if(o!==null){let r=new RegExp(o.id,"g");this.svg.innerHTML.match(r).length===1&&o.remove()}}removePartFromView(t){t.svg!==null&&t.svg.parentNode===this.diagramGroup&&t.svg.remove()}}class He{bt;_t;el;fd;constructor(t,e,i,s){let n=e===void 0?C.document:e;this.el=n,this.fd=null;let o=n.createElement("canvas");o.tabIndex=0,this.bt=o,this._t=new Vi(o,i,s),t&&j.Wi.set(o,t)}resize(t,e,i,s){return this.width!==t||this.height!==e?(this.width=t,this.height=e,this.style.width=i+"px",this.style.height=s+"px",!0):!1}toDataURL(t,e){return this.bt.toDataURL(t,e)}getBoundingClientRect(){return this.bt.getBoundingClientRect()}focus(){this.bt.focus()}get width(){return this.bt.width}set width(t){this.bt.width=t}get height(){return this.bt.height}set height(t){this.bt.height=t}dispose(){j.Wi.delete(this.bt),this.el=null}get style(){return this.bt.style}}class Vi{F;G1;Y1;K1;clipInsteadOfFill;Sf;Mf;An;Vh;rl;Fr;constructor(t,e,i){t.getContext||g.o("Browser does not support HTML Canvas Element"),this.F=t.getContext("2d",e),this.G1="",this.Y1="",this.K1="",this.clipInsteadOfFill=!1,this.Sf=0,this.Mf=0,this.An=0,this.rl=!1,this.Vh=new Pt,this.Fr=!!i}createOrUpdateClipGroup(t,e){}setImageSmoothingEnabled(t){this.F.imageSmoothingEnabled=t}get fillStyle(){return this.F.fillStyle}set fillStyle(t){this.K1!==t&&(this.F.fillStyle=t,this.K1=t)}get font(){return this.F.font}set font(t){this.G1!==t&&(this.F.font=t,this.G1=t)}get globalAlpha(){return this.F.globalAlpha}set globalAlpha(t){this.F.globalAlpha=t}get lineCap(){return this.F.lineCap}set lineCap(t){this.F.lineCap=t}get lineDashOffset(){return this.F.lineDashOffset}set lineDashOffset(t){this.F.lineDashOffset=t}get lineJoin(){return this.F.lineJoin}set lineJoin(t){this.F.lineJoin=t}get lineWidth(){return this.F.lineWidth}set lineWidth(t){this.F.lineWidth=t}get miterLimit(){return this.F.miterLimit}set miterLimit(t){this.F.miterLimit=t}get shadowBlur(){return this.F.shadowBlur}set shadowBlur(t){this.F.shadowBlur=t}get shadowColor(){return this.F.shadowColor}set shadowColor(t){this.F.shadowColor=t}get shadowOffsetX(){return this.F.shadowOffsetX}set shadowOffsetX(t){this.F.shadowOffsetX=t}get shadowOffsetY(){return this.F.shadowOffsetY}set shadowOffsetY(t){this.F.shadowOffsetY=t}get strokeStyle(){return this.F.strokeStyle}set strokeStyle(t){this.Y1!==t&&(this.F.strokeStyle=t,this.Y1=t)}get textAlign(){return this.F.textAlign}set textAlign(t){this.F.textAlign=t}get imageSmoothingEnabled(){return this.F.imageSmoothingEnabled}set imageSmoothingEnabled(t){this.F.imageSmoothingEnabled=t}get filter(){return this.F.filter}set filter(t){t===""?this.F.filter="none":this.F.filter=t}get letterSpacing(){return this.F.letterSpacing}set letterSpacing(t){this.F.letterSpacing=t}get wordSpacing(){return this.F.wordSpacing}set wordSpacing(t){this.F.wordSpacing=t}arc(t,e,i,s,n,o,r,a){this.F.arc(t,e,i,s,n,o)}beginPath(){this.F.beginPath()}endPath(){}bezierCurveTo(t,e,i,s,n,o){this.F.bezierCurveTo(t,e,i,s,n,o)}clearRect(t,e,i,s){this.commitTransform(),this.F.clearRect(t,e,i,s)}clip(t){t?this.F.clip(t):this.F.clip()}closePath(){this.F.closePath()}createLinearGradient(t,e,i,s){return this.F.createLinearGradient(t,e,i,s)}createPattern(t,e){return this.F.createPattern(t,e)}createRadialGradient(t,e,i,s,n,o){return this.F.createRadialGradient(t,e,i,s,n,o)}drawImage(t,e,i,s,n,o,r,a,h){s===void 0?this.F.drawImage(t,e,i):this.F.drawImage(t,e,i,s,n,o,r,a,h)}fill(t,e){e?this.F.fill(e,t?"evenodd":"nonzero"):this.F.fill(t?"evenodd":"nonzero")}fillRect(t,e,i,s){this.F.fillRect(t,e,i,s)}fillBackground(t,e,i,s){this.F.fillRect(t,e,i,s)}fillText(t,e,i){this.F.fillText(t,e,i)}getImageData(t,e,i,s){return this.F.getImageData(t,e,i,s)}lineTo(t,e){this.F.lineTo(t,e)}measureText(t){return this.F.measureText(t)}moveTo(t,e){this.F.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this.F.quadraticCurveTo(t,e,i,s)}rect(t,e,i,s){this.F.rect(t,e,i,s)}restore(){this.F.restore()}save(){this.commitTransform(),this.F.save()}rotate(t){this.Vh.ks(t*57.2958,0,0)}setTransform(t,e,i,s,n,o){this.Vh.setTo(t,e,i,s,n,o)}scale(t,e){this.Vh.it(t,e)}translate(t,e){this.Vh.Gs(t,e)}stroke(t){t?this.F.stroke(t):this.F.stroke()}transform(t,e,i,s,n,o){if(t===1&&e===0&&i===0&&s===1&&n===0&&o===0)return;let r=this.Vh,a=r.m11*t+r.m21*e,h=r.m12*t+r.m22*e,l=r.m11*i+r.m21*s,c=r.m12*i+r.m22*s;r.dx=r.m11*n+r.m21*o+r.dx,r.dy=r.m12*n+r.m22*o+r.dy,r.m11=a,r.m12=h,r.m21=l,r.m22=c}commitTransform(){let t=this.Vh;this.F.setTransform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy)}fillContext(t,e,i){this.radialFill(t,e,i)||this.fillOrClip(e,i)}radialFill(t,e,i){if(!(t instanceof E)||t.type!==3)return!1;let s=t.xf,n=t.U1;return n>s?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(e,i),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,e){this.clipInsteadOfFill?this.clip(e):this.fill(t,e)}shadowsSet(t,e,i){this.Sf=t,this.Mf=e,this.An=i}shadowsOff(){this.rl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.rl=!0,this.shadowOffsetX=this.Sf,this.shadowOffsetY=this.Mf,this.shadowBlur=this.An}enableDash(t,e){let i=this.F;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=e)}disableDash(){let t=this.F;t.setLineDash!==void 0&&(t.setLineDash(Vi.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.G1=""),this.Y1="",this.K1=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var We=(x=>(x[x.Solid=1]="Solid",x[x.Linear=2]="Linear",x[x.Radial=3]="Radial",x[x.Pattern=4]="Pattern",x))(We||{}),Ln=(x=>(x[x.Lab=1]="Lab",x[x.HSL=2]="HSL",x[x.Oklch=3]="Oklch",x))(Ln||{});class pi{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class E{f;W;Bh;ae;Cs;b0;k0;Jo;P0;Cn;xf;U1;constructor(t,e){if(I.Je(this),this.f=!1,t===void 0)this.W=1,this.Bh="black";else if(typeof t=="string"){let s=g.Wa(We,t);s!==null?(this.W=s,this.Bh="black"):(this.W=1,this.Bh=t)}else Object.keys(We).hasOwnProperty(t)?(this.W=t,this.Bh="black"):typeof t=="object"&&(this.W=1,e=t);let i=this.W;if(i===2?(this.ae=T.TopCenter,this.Cs=T.BottomCenter):i===3?(this.ae=T.Center,this.Cs=T.Center):(this.ae=T.None,this.Cs=T.None),this.b0=0,this.k0=NaN,this.Jo=null,this.P0=null,this.Cn=null,this.xf=0,this.U1=0,e){let s={};for(let n in e)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),e[n]):s[n]=e[n];Object.assign(this,s)}}copy(){let t=new E;return t.W=this.W,t.Bh=this.Bh,t.ae=this.ae.N(),t.Cs=this.Cs.N(),t.b0=this.b0,t.k0=this.k0,this.Jo!==null&&(t.Jo=this.Jo.copy()),t.P0=this.P0,t}b(){return this.f=!0,this.Jo!==null&&this.Jo.b(),this}fe(t){t in We?this.type=t:g.dr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){let e=this.colorStops.iterator;for(;e.next();){let i=e.key,s=e.value;t+=" "+i+":"+s}}return t+=")",t}addColorStop(t,e){return this.f&&g.L(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&g.J(t,"0 <= loc <= 1",E,"addColorStop:loc"),g.s(e,"string",E,"addColorStop:color"),this.Jo===null&&(this.Jo=new wt),this.Jo.set(t,e),this.W===1&&(this.type=2),this.Cn=null,this}get type(){return this.W}set type(t){this.f&&g.L(this,t),this.W=t,this.start.isNoSpot()&&(t===2?this.start=T.TopCenter:t===3&&(this.start=T.Center)),this.end.isNoSpot()&&(t===2?this.end=T.BottomCenter:t===3&&(this.end=T.Center)),this.Cn=null}get color(){return this.Bh}set color(t){this.f&&g.L(this,t),this.Bh=t,this.Cn=null}get start(){return this.ae}set start(t){this.f&&g.L(this,t),this.ae=t.N(),this.Cn=null}get end(){return this.Cs}set end(t){this.f&&g.L(this,t),this.Cs=t.N(),this.Cn=null}get startRadius(){return this.b0}set startRadius(t){this.f&&g.L(this,t),t<0&&g.J(t,">= zero",E,"startRadius"),this.b0=t,this.Cn=null}get endRadius(){return this.k0}set endRadius(t){this.f&&g.L(this,t),t<0&&g.J(t,">= zero",E,"endRadius"),this.k0=t,this.Cn=null}get colorStops(){return this.Jo}set colorStops(t){this.f&&g.L(this,t),this.Jo=t,this.Cn=null}get pattern(){return this.P0}set pattern(t){this.f&&g.L(this,t),this.P0=t,this.Cn=null}static randomColor(t,e){t===void 0&&(t=128),e===void 0&&(e=Math.max(t,255));let i=Math.abs(e-t),s=Math.floor(t+Math.random()*i).toString(16),n=Math.floor(t+Math.random()*i).toString(16),o=Math.floor(t+Math.random()*i).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return C.CSS?C.CSS.supports("color",t):!0}static lighten(t){return E.lightenBy(t)}lightenBy(t,e){this.f&&g.L(this);let i=t===void 0||typeof t!="number"?.2:t,s=e===void 0?3:e;if(this.type===1)E.Uo(this.color),this.color=E.Cd(i,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){let n=this.colorStops.iterator;for(;n.next();)E.Uo(n.value),this.addColorStop(n.key,E.Cd(i,s))}return this}static lightenBy(t,e,i){let s=e===void 0||typeof e!="number"?.2:e,n=i===void 0?3:i;return E.Uo(t),E.Cd(s,n)}static darken(t){return E.darkenBy(t)}darkenBy(t,e){this.f&&g.L(this);let i=t===void 0||typeof t!="number"?.2:t,s=e===void 0?3:e;if(this.type===1)E.Uo(this.color),this.color=E.Cd(-i,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){let n=this.colorStops.iterator;for(;n.next();)E.Uo(n.value),this.addColorStop(n.key,E.Cd(-i,s))}return this}static darkenBy(t,e,i){let s=e===void 0||typeof e!="number"?.2:e,n=i===void 0?3:i;return E.Uo(t),E.Cd(-s,n)}static mix(t,e,i){E.Uo(t);let s=E.Y.n0,n=E.Y.n1,o=E.Y.n2,r=E.Y.n3;E.Uo(e),i===void 0&&(i=.5);let a=Math.round((E.Y.n0-s)*i+s),h=Math.round((E.Y.n1-n)*i+n),l=Math.round((E.Y.n2-o)*i+o),c=Math.round((E.Y.n3-r)*i+r);return`rgba(${a}, ${h}, ${l}, ${c})`}isDark(){if(this.type===1)return E.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){let t=this.colorStops;if(this.type===3){let a=t.first();return a?E.isDark(a.value):!1}if(t.get(.5)!==null)return E.isDark(t.get(.5));if(t.count===2){let a=t.toArray();return E.isDark(E.mix(a[0].value,a[1].value))}let e=t.iterator,i=-1,s=-1,n=1,o=1;for(;e.next();){let a=e.key,h=Math.abs(.5-e.key);n>o&&h<n?(i=a,n=h):o>=n&&h<o&&(s=a,o=h)}if(i>s){let a=i;i=s,s=a,a=n,n=o,o=a}let r=s-i;return E.isDark(E.mix(t.get(i),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof E?t.isDark():(E.Uo(t),(299*E.Y.n0+587*E.Y.n1+114*E.Y.n2)/1e3<128):!1}static Cd(t,e){switch(e){case 1:return E.bI(),E.co.n0=Math.min(100,Math.max(0,E.co.n0+100*t)),E.kI(),"rgba("+E.Y.n0+", "+E.Y.n1+", "+E.Y.n2+", "+E.Y.n3+")";case 2:return E.RM(),E.ze.n2=Math.min(100,Math.max(0,E.ze.n2+100*t)),"hsla("+E.ze.n0+", "+E.ze.n1+"%, "+E.ze.n2+"%, "+E.ze.n3+")";case 3:return E.SI(),E.fo.n0=Math.min(100,Math.max(0,E.fo.n0+100*t)),E.MI(),"rgba("+E.Y.n0+", "+E.Y.n1+", "+E.Y.n2+", "+E.Y.n3+")";default:g.o("Unknown color space: "+e)}}static Uo(t){E.S0===!1&&(E.S0=!0,E.us=j.isUsingDOM()?new He(null,void 0,{willReadFrequently:!0})._t:null);let e=E.us;if(e===null)return;e.clearRect(0,0,1,1),e.fillStyle="#000000";let i=e.fillStyle;if(e.fillStyle=t,e.fillStyle!==i){e.fillRect(0,0,1,1);let s=e.getImageData(0,0,1,1).data;E.Y.n0=s[0],E.Y.n1=s[1],E.Y.n2=s[2],E.Y.n3=s[3]/255}else{e.fillStyle="#FFFFFF";let s=e.fillStyle;e.fillStyle=t,e.fillStyle,E.Y.n0=0,E.Y.n1=0,E.Y.n2=0,E.Y.n3=1}}static RM(){let t=E.Y.n0/255,e=E.Y.n1/255,i=E.Y.n2/255,s=Math.max(t,e,i),n=Math.min(t,e,i),o=s-n,r,a,h=(s+n)/2;if(o===0)r=a=0;else{switch(s){case t:r=(e-i)/o%6;break;case e:r=(i-t)/o+2;break;case i:r=(t-e)/o+4;break;default:r=0;break}r*=60,r<0&&(r+=360),a=o/(1-Math.abs(2*h-1))}E.ze.n0=Math.round(r),E.ze.n1=Math.round(a*100),E.ze.n2=Math.round(h*100),E.ze.n3=E.Y.n3}static VU(){let t=E.ze.n0,e=E.ze.n1/100,i=E.ze.n2/100,s,n,o,r=(1-Math.abs(2*i-1))*e,a=t/60,h=r*(1-Math.abs(a%2-1));a>=0&&a<1?(s=r,n=h,o=0):a>=1&&a<2?(s=h,n=r,o=0):a>=2&&a<3?(s=0,n=r,o=h):a>=3&&a<4?(s=0,n=h,o=r):a>=4&&a<5?(s=h,n=0,o=r):(s=r,n=0,o=h);let l=i-.5*r;s+=l,n+=l,o+=l,E.Y.n0=Math.round(s*255),E.Y.n1=Math.round(n*255),E.Y.n2=Math.round(o*255),E.Y.n3=E.ze.n3}static bI(){E.lD(),E.NI()}static kI(){E.CI(),E.aD()}static UN(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static VN(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static lD(){let t=E.UN(E.Y.n0),e=E.UN(E.Y.n1),i=E.UN(E.Y.n2);E.At.n0=.4124564*t+.3575761*e+.1804375*i,E.At.n1=.2126729*t+.7151522*e+.072175*i,E.At.n2=.0193339*t+.119192*e+.9503041*i,E.At.n3=E.Y.n3}static aD(){let t=3.2404542*E.At.n0+-1.5371385*E.At.n1+-.4985314*E.At.n2,e=-.969266*E.At.n0+1.8760108*E.At.n1+.041556*E.At.n2,i=.0556434*E.At.n0+-.2040259*E.At.n1+1.0572252*E.At.n2;E.Y.n0=E.VN(t)*255,E.Y.n1=E.VN(e)*255,E.Y.n2=E.VN(i)*255,E.Y.n3=E.At.n3,E.Y.n0=Math.round(E.Y.n0),E.Y.n0>255?E.Y.n0=255:E.Y.n0<0&&(E.Y.n0=0),E.Y.n1=Math.round(E.Y.n1),E.Y.n1>255?E.Y.n1=255:E.Y.n1<0&&(E.Y.n1=0),E.Y.n2=Math.round(E.Y.n2),E.Y.n2>255?E.Y.n2=255:E.Y.n2<0&&(E.Y.n2=0)}static BN=216/24389;static H1=24389/27;static Ld=[95.047,100,108.883];static zN(t){return t>E.BN?Math.pow(t,1/3):(E.H1*t+16)/116}static NI(){let t=E.zN(E.At.n0*100/E.Ld[0]),e=E.zN(E.At.n1*100/E.Ld[1]),i=E.zN(E.At.n2*100/E.Ld[2]);E.co.n0=116*e-16,E.co.n1=500*(t-e),E.co.n2=200*(e-i),E.co.n3=E.At.n3}static hD(t){let e=t*t*t;return e>E.BN?e:(116*t-16)/E.H1}static CI(){let t=(E.co.n0+16)/116,e=E.co.n1/500+t,i=t-E.co.n2/200;E.At.n0=E.Ld[0]/100*E.hD(e),E.At.n1=E.Ld[1]/100*(E.co.n0>E.H1*E.BN?Math.pow(t,3):E.co.n0/E.H1),E.At.n2=E.Ld[2]/100*E.hD(i),E.At.n3=E.co.n3}static LI(){let t=.8190224*E.At.n0+.3619062*E.At.n1+-.1288737*E.At.n2,e=.03298366*E.At.n0+.9292868*E.At.n1+.03614466*E.At.n2,i=.04817719*E.At.n0+.2642395*E.At.n1+.6335478*E.At.n2;t=Math.cbrt(t),e=Math.cbrt(e),i=Math.cbrt(i),E.ge.n0=.2104542*t+.7936177*e+-.004072046*i,E.ge.n1=1.977998*t+-2.428592*e+.4505937*i,E.ge.n2=.02590403*t+.7827717*e+-.8086757*i,E.ge.n3=E.At.n3,E.ge.n0*=100}static AI(){E.ge.n0/=100;let t=.9999999*E.ge.n0+.3963377*E.ge.n1+.2158037*E.ge.n2,e=1.000000009*E.ge.n0+-.1055613*E.ge.n1+-.06385417*E.ge.n2,i=1.00000005*E.ge.n0+-.08948418*E.ge.n1+-1.291485*E.ge.n2;t=t**3,e=e**3,i=i**3,E.At.n0=1.2268798*t+-.5578149*e+.281391*i,E.At.n1=-.04057576*t+1.112286*e+-.07171106*i,E.At.n2=-.07637294*t+-.4214933*e+1.586924*i,E.At.n3=E.ge.n3}static TI(){let t=Math.atan2(E.ge.n2,E.ge.n1)*180/Math.PI;E.fo.n0=E.ge.n0,E.fo.n1=Math.sqrt(E.ge.n1**2+E.ge.n2**2),E.fo.n2=t>=0?t:t+360,E.fo.n3=E.ge.n3}static DI(){E.ge.n0=E.fo.n0,E.ge.n1=E.fo.n1*Math.cos(E.fo.n2*Math.PI/180),E.ge.n2=E.fo.n1*Math.sin(E.fo.n2*Math.PI/180),E.ge.n3=E.fo.n3}static SI(){E.lD(),E.LI(),E.TI()}static MI(){E.DI(),E.AI(),E.aD()}static Sd(t,e){typeof t=="string"||t instanceof E||g.o("Value for "+e+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static us=null;static S0=!1;static Y=new pi;static ze=new pi;static At=new pi;static co=new pi;static ge=new pi;static fo=new pi}class Ft{Pt="Base";static fs=new wt;static Tn(t,e){e.name=t,Ft.fs.set(t,e)}get name(){return this.Pt}set name(t){this.Pt=t}constructor(){}get classType(){return H}measure(t,e,i,s,n,o,r){}measureElement(t,e,i,s,n){t.ht(e,i,s,n)}arrange(t,e,i){}arrangeElement(t,e,i,s,n,o){t.Ut(e,i,s,n,o)}remeasureObject(t){t.bf()}Ge(t,e,i){}}class sr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=t.$o();for(let l=0;l<a;l++){let c=s[l];if(!c.visible&&c!==h)continue;let u=c.margin,d=u.right+u.left,f=u.top+u.bottom;c.ht(e,i,o,r);let p=c.measuredBounds,m=Math.max(p.width+d,0),y=Math.max(p.height+f,0),b=c.position.x,v=c.position.y;if(isFinite(b)||(b=0),isFinite(v)||(v=0),c instanceof at&&c.isGeometryPositioned){let w=c.strokeWidth/2;b-=w,v-=w}n.re(b,v,m,y)}}arrange(t,e,i){let s=e.length,n=t.padding,o=i.x-n.left,r=i.y-n.top;for(let a=0;a<s;a++){let h=e[a],l=h.measuredBounds,c=h.margin,u=h.position.x,d=h.position.y,f=isNaN(u)?-o:u-o,p=isNaN(d)?-r:d-r;if(h instanceof at&&h.isGeometryPositioned){let m=h.strokeWidth/2;f-=m,p-=m}h.visible&&h.Ut(f+c.left,p+c.top,l.width,l.height)}}}Ft.Tn("Position",new sr);class nr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=g.ot(),l=t.$o();for(let u=0;u<a;u++){let d=s[u];if(!d.visible&&d!==l)continue;let f=d.Qs(!1);if(f!==0&&f!==5){h.push(d);continue}d.ht(1/0,i,0,r);let p=d.margin,m=d.measuredBounds,y=Math.max(m.width+p.right+p.left,0),b=Math.max(m.height+p.top+p.bottom,0);n.jn(n.width+y,Math.max(n.height,b))}let c=h.length;t.desiredSize.height?i=Math.min(t.desiredSize.height,t.maxSize.height):n.height!==0&&(i=Math.min(n.height,t.maxSize.height));for(let u=0;u<c;u++){let d=h[u];if(!d.visible&&d!==l)continue;let f=d.margin,p=f.right+f.left,m=f.top+f.bottom;d.ht(1/0,i,0,r);let y=d.measuredBounds,b=Math.max(y.width+p,0),v=Math.max(y.height+m,0);n.width+=b,n.height=Math.max(n.height,v)}g.Z(h)}arrange(t,e,i){let s=e.length,n=t.padding,o=n.top,r=t.isOpposite,a=r?i.width:n.left;for(let h=0;h<s;h++){let l=o,c=e[h];if(!c.visible)continue;let u=c.measuredBounds,d=c.margin,f=d.top+d.bottom,p=o+n.bottom,m=u.height,y=c.Qs(!1);(isNaN(c.desiredSize.height)&&y===2||y===4)&&(m=Math.max(i.height-f-p,0));let b=m+f+p,v=c.alignment;v.isDefault()&&(v=t.defaultAlignment),v.isSpot()||(v=T.Center),r&&(a-=u.width+d.left+d.right),c.Ut(a+v.offsetX+d.left,l+v.offsetY+d.top+(i.height*v.y-b*v.y),u.width,m),r||(a+=u.width+d.left+d.right)}}}Ft.Tn("Horizontal",new nr);class or extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=g.ot(),l=t.$o();for(let u=0;u<a;u++){let d=s[u];if(!d.visible&&d!==l)continue;let f=d.Qs(!1);if(f!==0&&f!==4){h.push(d);continue}d.ht(e,1/0,o,0);let p=d.margin,m=d.measuredBounds,y=Math.max(m.width+p.right+p.left,0),b=Math.max(m.height+p.top+p.bottom,0);n.jn(Math.max(n.width,y),n.height+b)}let c=h.length;t.desiredSize.width?e=Math.min(t.desiredSize.width,t.maxSize.width):n.width!==0&&(e=Math.min(n.width,t.maxSize.width));for(let u=0;u<c;u++){let d=h[u];if(!d.visible&&d!==l)continue;let f=d.margin,p=f.right+f.left,m=f.top+f.bottom;d.ht(e,1/0,o,0);let y=d.measuredBounds,b=Math.max(y.width+p,0),v=Math.max(y.height+m,0);n.width=Math.max(n.width,b),n.height+=v}g.Z(h)}arrange(t,e,i){let s=e.length,n=t.padding,o=n.left,r=t.isOpposite,a=r?i.height:n.top;for(let h=0;h<s;h++){let l=o,c=e[h];if(!c.visible)continue;let u=c.measuredBounds,d=c.margin,f=d.left+d.right,p=o+n.right,m=u.width,y=c.Qs(!1);(isNaN(c.desiredSize.width)&&y===2||y===5)&&(m=Math.max(i.width-f-p,0));let b=m+f+p,v=c.alignment;v.isDefault()&&(v=t.defaultAlignment),v.isSpot()||(v=T.Center),r&&(a-=u.height+d.bottom+d.top),c.Ut(l+v.offsetX+d.left+(i.width*v.x-b*v.x),a+v.offsetY+d.top,m,u.height),r||(a+=u.height+d.bottom+d.top)}}}Ft.Tn("Vertical",new or);class ss extends Ft{constructor(){super()}static cD=!1;measure(t,e,i,s,n,o,r){let a=s.length;if(a===0)return;let h=t.findMainElement(),l=h.margin,c=0,u=0,d=l.right+l.left,f=l.top+l.bottom;h.ht(e,i,o,r);let p=h.measuredBounds,m=p.width,y=p.height,b=Math.max(m+d,0),v=Math.max(y+f,0),w=t.isClipping;w&&h.Hp()!==0&&!ss.cD&&(ss.cD=!0,g.ne("Main Shape for Spot Panel with isClipping = true must have a zero strokeWidth: "+t.toString()));let k=B.z(-l.left,-l.top,b,v),S=B.z(0,0,m,y);this.XN(h,S,!0),m=S.width,y=S.height;let M=!0,F=t.$o(),D;for(let N=0;N<a;N++){let L=s[N],R=e,O=i;if(L===h||!L.visible&&L!==F)continue;l=L.margin;let V=l.left,K=l.top;switch(c=l.right+l.left,u=l.top+l.bottom,D=L.Qs(!1),D){case 2:R=m,O=y,c=0,u=0,V=0,K=0;break;case 5:R=m,c=0,V=0;break;case 4:O=y,u=0,K=0;break}L.ht(R,O,0,0),p=L.measuredBounds,b=Math.max(p.width+c,0),v=Math.max(p.height+u,0);let Y=L.alignment;Y.isDefault()&&(Y=t.defaultAlignment),Y.isSpot()||(Y=T.Center);let X=L.alignmentFocus;X.isDefault()&&(X=T.Center);let G=null;L instanceof H&&L.uo!==""&&(G=L.findObject(L.uo),G===L&&(G=null));let rt=S.x-V,lt=S.y-K;if(G!==null){L.Ut(0,0,p.width,p.height);let st=G.actualBounds,ht=P.z(st.x+(X.x*st.width-X.offsetX),st.y+(X.y*st.height-X.offsetY));for(G=G.panel;G!==null&&G!==L;)G.v.gt(ht),G=G.panel;rt+=Y.x*m+Y.offsetX-ht.x,lt+=Y.y*y+Y.offsetY-ht.y,P.i(ht)}else rt+=Y.x*m+Y.offsetX-(X.x*p.width+X.offsetX),lt+=Y.y*y+Y.offsetY-(X.y*p.height+X.offsetY);M?(M=!1,n.e(rt,lt,b,v)):n.re(rt,lt,b,v)}switch(M?n.h(k):w?n.intersect(S.x,S.y,S.width,S.height):n.re(k.x,k.y,k.width,k.height),B.i(k),B.i(S),D=h.stretch,D===1&&(D=h.Qs(!1)),D){case 0:return;case 2:if(!isFinite(e)&&!isFinite(i))return;break;case 5:if(!isFinite(e))return;break;case 4:if(!isFinite(i))return;break}p=h.measuredBounds,m=p.width,y=p.height,b=Math.max(m+d,0),v=Math.max(y+f,0),l=h.margin,S=B.z(-l.left,-l.top,b,v),this.XN(h,S,!0),m=S.width,y=S.height;for(let N=0;N<a;N++){let L=s[N];if(L===h||!L.visible&&L!==F)continue;l=L.margin,c=l.right+l.left,u=l.top+l.bottom,p=L.measuredBounds,b=Math.max(p.width+c,0),v=Math.max(p.height+u,0);let R=L.alignment;R.isDefault()&&(R=t.defaultAlignment),R.isSpot()||(R=T.Center);let O=L.alignmentFocus;O.isDefault()&&(O=T.Center),M?(M=!1,n.e(R.x*m+R.offsetX-(O.x*p.width+O.offsetX)-l.left,R.y*y+R.offsetY-(O.y*p.height+O.offsetY)-l.top,b,v)):n.re(R.x*m+R.offsetX-(O.x*p.width+O.offsetX)-l.left,R.y*y+R.offsetY-(O.y*p.height+O.offsetY)-l.top,b,v)}M?n.h(k):w?n.intersect(S.x,S.y,S.width,S.height):n.re(k.x,k.y,k.width,k.height),B.i(S)}arrange(t,e,i){let s=e.length;if(s===0)return;let n=t.findMainElement(),o=n.measuredBounds,r=o.width,a=o.height,h=t.padding,l=h.left,c=h.top,u=l-i.x,d=c-i.y;n.Ut(u,d,r,a);let f=B.z(0,0,r,a);this.XN(n,f,!1);for(let p=0;p<s;p++){let m=e[p];if(m===n)continue;let y=m.measuredBounds,b=y.width,v=y.height,w=m.alignment;w.isDefault()&&(w=t.defaultAlignment),w.isSpot()||(w=T.Center);let k=m.alignmentFocus;k.isDefault()&&(k=T.Center);let S=null;if(m instanceof H&&m.uo!==""&&(S=m.findObject(m.uo),S===m&&(S=null)),S!==null){let M=S.actualBounds,F=P.z(M.x+(k.x*M.width-k.offsetX),M.y+(k.y*M.height-k.offsetY));for(S=S.panel;S!==null&&S!==m;)S.v.gt(F),S=S.panel;u=w.x*f.width+w.offsetX-F.x,d=w.y*f.height+w.offsetY-F.y,P.i(F)}else u=w.x*f.width+w.offsetX-(k.x*b+k.offsetX),d=w.y*f.height+w.offsetY-(k.y*v+k.offsetY);u+=f.x-i.x,d+=f.y-i.y,m.visible&&m.Ut(l+u,c+d,b,v)}B.i(f)}XN(t,e,i){let s=null;if(t instanceof H&&t.uo!==""&&(s=t.findObject(t.uo),s===t&&(s=null)),s!==null)for(i&&t.Ut(0,0,e.width,e.height),e.h(s.actualBounds),s=s.panel;s!==null&&s!==t;)s.v.im(e),s=s.panel}}Ft.Tn("Spot",new ss);class rr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length;if(a===0)return;let h=t.findMainElement(),l=h.margin,c=e,u=i,d=l.right+l.left,f=l.top+l.bottom;h.ht(e,i,o,r);let p=h.measuredBounds,m=0,y=null;h instanceof at&&(y=h,m=y.strokeWidth*y.scale);let b=Math.max(p.width+d,0),v=Math.max(p.height+f,0),w=t.GN(h),k=w.x*b+w.offsetX,S=w.y*v+w.offsetY,M=t.YN(h),F=M.x*b+M.offsetX,D=M.y*v+M.offsetY;isFinite(e)&&(c=Math.max(Math.abs(k-F)-m,0)),isFinite(i)&&(u=Math.max(Math.abs(S-D)-m,0));let N=0,L=0;o>0&&(N=Math.max(Math.abs(w.x*o+w.offsetX-(M.x*o+M.offsetX))-m,0)),r>0&&(L=Math.max(Math.abs(w.y*r+w.offsetY-(M.y*r+M.offsetY))-m,0));let R=_.l();R.e(0,0);let O=t.$o();for(let X=0;X<a;X++){let G=s[X];if(G===h||!G.visible&&G!==O)continue;l=G.margin;let rt=l.right+l.left,lt=l.top+l.bottom;G.ht(c,u,N,L),p=G.measuredBounds,b=Math.max(p.width+rt,0),v=Math.max(p.height+lt,0),R.e(Math.max(b,R.width),Math.max(v,R.height))}if(a===1){p=h.measuredBounds,n.width=b,n.height=v,_.i(R);return}w=t.GN(h),M=t.YN(h);let V=0,K=0;M.x!==w.x&&M.y!==w.y&&(V=R.width/Math.abs(M.x-w.x),K=R.height/Math.abs(M.y-w.y)),_.i(R),m=0,y!==null&&(m=y.strokeWidth*y.scale,y.QS()===6&&(V=K=Math.max(V,K))),V+=Math.abs(w.offsetX)+Math.abs(M.offsetX)+m,K+=Math.abs(w.offsetY)+Math.abs(M.offsetY)+m;let Y=h.stretch;switch(Y===1&&(Y=h.Qs(!1)),Y){case 0:o=0,r=0;break;case 2:isFinite(e)&&(V=e),isFinite(i)&&(K=i);break;case 5:isFinite(e)&&(V=e),r=0;break;case 4:o=0,isFinite(i)&&(K=i);break}h.bf(),h.ht(V,K,o,r),n.width=h.measuredBounds.width+d,n.height=h.measuredBounds.height+f}arrange(t,e,i){let s=e.length;if(s===0)return;let n=t.findMainElement(),o=n.measuredBounds,r=B.l();r.e(0,0,1,1);let a=n.margin,h=a.left,l=a.top,c=t.padding,u=c.left,d=c.top,f=h,p=l,m=o.width,y=o.height;n.Ut(u+f,d+p,m,y);let b=t.GN(n),v=t.YN(n),w=0+b.x*o.width+b.offsetX,k=0+b.y*o.height+b.offsetY,S=0+v.x*o.width+v.offsetX,M=0+v.y*o.height+v.offsetY;r.x=w,r.y=k,r.re(S,M,0,0),r.x+=h+u,r.y+=l+d;for(let F=0;F<s;F++){let D=e[F];if(D===n)continue;let N=D.measuredBounds;a=D.margin;let L=Math.max(N.width+a.right+a.left,0),R=Math.max(N.height+a.top+a.bottom,0),O=D.alignment;O.isDefault()&&(O=t.defaultAlignment),O.isSpot()||(O=T.Center),f=r.width*O.x+O.offsetX-L*O.x+a.left+r.x,p=r.height*O.y+O.offsetY-R*O.y+a.top+r.y,m=r.width,y=r.height,D.visible&&(B.contains(r.x,r.y,r.width,r.height,f,p,N.width,N.height)?D.Ut(f,p,N.width,N.height):D.Ut(f,p,N.width,N.height,new B(r.x,r.y,r.width,r.height)))}B.i(r)}}Ft.Tn("Auto",new rr);class ar extends Ft{constructor(){super(),this.name="Table"}measure(t,e,i,s,n,o,r){let a=s.length,h=g.ot(),l=g.ot();for(let ut=0;ut<a;ut++){let Q=s[ut],yt=Q instanceof H?Q:null;if(yt!==null&&yt.ol()&&Q.visible){l.push(yt);let At=yt.D.r,_t=At.length;for(let Wt=0;Wt<_t;Wt++){let Zt=At[Wt];yt.type===H.TableRow?Zt.row=Q.row:yt.type===H.TableColumn&&(Zt.column=Q.column),h.push(Zt)}}else h.push(Q)}a=h.length,a===0&&(t.getRowDefinition(0),t.getColumnDefinition(0));let c=[];for(let ut=0;ut<a;ut++){let Q=h[ut];Q.visible&&(Q.wi(!0),Q.ao(!0),c[Q.row]||(c[Q.row]=[]),c[Q.row][Q.column]||(c[Q.row][Q.column]=[]),c[Q.row][Q.column].push(Q))}g.Z(h);let u=g.ot(),d=g.ot(),f=g.ot(),p={count:0},m={count:0},y=e,b=i,v=t.Qi,w=t._i,k;a=v.length;for(let ut=0;ut<a;ut++)k=v[ut],k!==void 0&&(k.actual=0,k.Re=0);a=w.length;for(let ut=0;ut<a;ut++)k=w[ut],k!==void 0&&(k.actual=0,k.Re=0);let S=c.length,M=0;for(let ut=0;ut<S;ut++)c[ut]&&(M=Math.max(M,c[ut].length));let F=Math.min(t.topIndex,S-1),D=Math.min(t.leftIndex,M-1),N=0,L;S=c.length;let R=t.$o();for(let ut=0;ut<S;ut++){if(!c[ut])continue;M=c[ut].length;let Q=t.getRowDefinition(ut);Q.actual=0,Q.Re=0;for(let yt=0;yt<M;yt++){if(!c[ut][yt])continue;let At=t.getColumnDefinition(yt);u[yt]===void 0&&(At.actual=0,At.Re=0,u[yt]=!0);let _t=c[ut][yt],Wt=_t.length;for(let Zt=0;Zt<Wt;Zt++){let Qt=_t[Zt];if(!Qt.visible&&Qt!==R)continue;let Fe=Qt.rowSpan>1,ve=Qt.columnSpan>1;(Fe||ve)&&!(ut<F)&&!(yt<D)&&d.push(Qt);let Pe=Qt.margin,te=Pe.right+Pe.left,ne=Pe.top+Pe.bottom;L=Qt.Zp(Q,At,!1);let Ce=Qt.desiredSize,Ot=!isNaN(Ce.width),Ve=!isNaN(Ce.height);if(L!==0&&!(Ot&&Ve)&&!(ut<F)&&!(yt<D)&&(!ve&&p[yt]===void 0&&(L===2||L===5)&&(p[yt]=-1,p.count++),!Fe&&m[ut]===void 0&&(L===2||L===4)&&(m[ut]=-1,m.count++),!Fe&&!ve&&f.push(Qt)),Qt.ht(1/0,1/0,0,0),ut<F||yt<D)continue;let ue=Qt.measuredBounds,Oe=Math.max(ue.width+te,0),je=Math.max(ue.height+ne,0);if(Qt.rowSpan===1&&(L===0||L===5)){k=t.getRowDefinition(ut);let Re=k.computeEffectiveSpacing(),Yi=k.j===0;N=Math.max(je-k.actual,0),N+(Yi?Re:0)>b&&(N=Math.max(b-Re,0)),k.Re=k.Re+N,k.actual=k.j+N,b=Math.max(b-(N+(Yi?Re:0)),0)}if(Qt.columnSpan===1&&(L===0||L===4)){k=t.getColumnDefinition(yt);let Re=k.computeEffectiveSpacing(),Yi=k.j===0;N=Math.max(Oe-k.actual,0),N+(Yi?Re:0)>y&&(N=Math.max(y-Re,0)),k.Re=k.Re+N,k.actual=k.j+N,y=Math.max(y-(N+(Yi?Re:0)),0)}(Fe||ve)&&Qt.bf()}}}g.Z(u);let O=0,V=0;a=t.columnCount;for(let ut=0;ut<a;ut++){let Q=w[ut];Q!==void 0&&(O+=isNaN(Q.bi)?Q.Re:Q.bi,Q.Re!==0&&(O+=Q.computeEffectiveSpacing()))}a=t.rowCount;for(let ut=0;ut<a;ut++){let Q=v[ut];Q!==void 0&&(V+=isNaN(Q.bi)?Q.Re:Q.bi,Q.Re!==0&&(V+=Q.computeEffectiveSpacing()))}y=Math.max(e-O,0),b=Math.max(i-V,0);let K=b,Y=y;a=f.length;for(let ut=0;ut<a;ut++){let Q=f[ut],yt=t.getRowDefinition(Q.row),At=t.getColumnDefinition(Q.column),_t=Q.measuredBounds,Wt=Q.margin,Zt=Wt.right+Wt.left,Qt=Wt.top+Wt.bottom;At.Re===0&&p[Q.column]!==void 0?p[Q.column]=Math.max(_t.width+Zt,p[Q.column]):p[Q.column]=null,yt.Re===0&&m[Q.row]!==void 0?m[Q.row]=Math.max(_t.height+Qt,m[Q.row]):m[Q.row]=null}let X=0,G=0,rt;for(rt in m)rt!=="count"&&(X+=m[rt]);for(rt in p)rt!=="count"&&(G+=p[rt]);let lt=_.l();for(let ut=0;ut<a;ut++){let Q=f[ut];if(!Q.visible&&Q!==R)continue;let yt=t.getRowDefinition(Q.row),At=t.getColumnDefinition(Q.column),_t=0;isFinite(At.width)?_t=At.width:(isFinite(y)&&p[Q.column]!==null?G===0?_t=At.actual+y:_t=p[Q.column]/G*Y:p[Q.column]!==null?_t=y:_t=At.actual||y,_t=Math.max(0,_t-At.computeEffectiveSpacing()));let Wt=0;switch(isFinite(yt.height)?Wt=yt.height:(isFinite(b)&&m[Q.row]!==null?X===0?Wt=yt.actual+b:Wt=m[Q.row]/X*K:m[Q.row]!==null?Wt=b:Wt=yt.actual||b,Wt=Math.max(0,Wt-yt.computeEffectiveSpacing())),lt.e(Math.max(At.minimum,Math.min(_t,At.maximum)),Math.max(yt.minimum,Math.min(Wt,yt.maximum))),L=Q.Zp(yt,At,!1),L){case 5:lt.height=Math.max(lt.height,yt.actual+b);break;case 4:lt.width=Math.max(lt.width,At.actual+y);break}let Zt=Q.margin,Qt=Zt.right+Zt.left,Fe=Zt.top+Zt.bottom;Q.bf();let ve=At.minimum,Pe=yt.minimum,te=Q.measuredBounds;te.width===0&&p[Q.column]!==null&&(ve=Math.max(ve,p[Q.column])),te.height===0&&m[Q.row]!==null&&(Pe=Math.max(ve,m[Q.row])),Q.ht(lt.width,lt.height,ve,Pe);let ne=Q.measuredBounds,Ce=Math.max(ne.width+Qt,0),Ot=Math.max(ne.height+Fe,0);isFinite(y)&&(Ce=Math.min(Ce,lt.width)),isFinite(b)&&(Ot=Math.min(Ot,lt.height));let Ve=0;Ve=yt.actual,yt.actual=Math.max(yt.actual,Ot),yt.Re=Math.max(yt.Re,Ot),N=yt.actual-Ve,b=Math.max(b-N,0),m[Q.row]===null&&(K=Math.max(K-N,0)),Ve=At.actual,At.actual=Math.max(At.actual,Ce),At.Re=Math.max(At.Re,Ce),N=At.actual-Ve,y=Math.max(y-N,0),p[Q.column]===null&&(Y=Math.max(Y-N,0))}g.Z(f);let st=_.l(),ht=g.ot(),ot=g.ot();if(a=d.length,a!==0)for(let ut=0;ut<S;ut++){if(!c[ut])continue;M=c[ut].length;let Q=t.getRowDefinition(ut);ht[ut]=Q.actual;for(let yt=0;yt<M;yt++){if(!c[ut][yt])continue;let At=t.getColumnDefinition(yt);ot[yt]=At.actual}}for(let ut=0;ut<a;ut++){let Q=d[ut];if(!Q.visible&&Q!==R)continue;let yt=t.getRowDefinition(Q.row),At=t.getColumnDefinition(Q.column);switch(lt.e(Math.max(At.minimum,Math.min(e,At.maximum)),Math.max(yt.minimum,Math.min(i,yt.maximum))),L=Q.Zp(yt,At,!1),L){case 2:ot[At.index]!==0&&(lt.width=Math.min(lt.width,ot[At.index])),ht[yt.index]!==0&&(lt.height=Math.min(lt.height,ht[yt.index]));break;case 5:ot[At.index]!==0&&(lt.width=Math.min(lt.width,ot[At.index]));break;case 4:ht[yt.index]!==0&&(lt.height=Math.min(lt.height,ht[yt.index]));break}isFinite(At.width)&&(lt.width=At.width),isFinite(yt.height)&&(lt.height=yt.height),st.e(0,0);let _t=At.minimum,Wt=yt.minimum;for(let Ot=1;Ot<Q.rowSpan&&!(Q.row+Ot>=t.rowCount);Ot++){if(k=t.getRowDefinition(Q.row+Ot),N=0,L===2||L===4){if(k.j===0)continue;N=Math.max(k.minimum,k.j===0?k.maximum:Math.min(k.j,k.maximum))}else N=Math.max(k.minimum,isNaN(k.bi)?k.maximum:Math.min(k.bi,k.maximum));st.height+=N,Wt+=k.minimum}for(let Ot=1;Ot<Q.columnSpan&&!(Q.column+Ot>=t.columnCount);Ot++){if(k=t.getColumnDefinition(Q.column+Ot),N=0,L===2||L===5){if(k.j===0)continue;N=Math.max(k.minimum,k.j===0?k.maximum:Math.min(k.j,k.maximum))}else N=Math.max(k.minimum,isNaN(k.bi)?k.maximum:Math.min(k.bi,k.maximum));st.width+=N,_t+=k.minimum}lt.width+=st.width,lt.height+=st.height;let Zt=Q.margin,Qt=Zt.right+Zt.left,Fe=Zt.top+Zt.bottom;Q.ht(lt.width,lt.height,_t,Wt);let ve=Q.measuredBounds,Pe=Math.max(ve.width+Qt,0),te=Math.max(ve.height+Fe,0),ne=0;for(let Ot=0;Ot<Q.rowSpan&&!(Q.row+Ot>=t.rowCount);Ot++)k=t.getRowDefinition(Q.row+Ot),ne+=k.total||0;if(ne<te){let Ot=te-ne,Ve=te-ne;if(Q.spanAllocation!==null){let ue=Q.spanAllocation;for(let Oe=0;Oe<Q.rowSpan&&!(Ot<=0||Q.row+Oe>=t.rowCount);Oe++){k=t.getRowDefinition(Q.row+Oe);let je=k.j||0,Re=ue(Q,k,Ve);k.actual=Math.min(k.maximum,je+Re),k.j!==je&&(Ot-=k.j-je)}}for(;Ot>0&&k!==void 0;){let ue=k.j||0;if(isNaN(k.height)&&k.maximum>ue&&(k.actual=Math.min(k.maximum,ue+Ot),k.j!==ue&&(Ot-=k.j-ue)),k.index===0)break;k=t.getRowDefinition(k.index-1)}}let Ce=0;for(let Ot=0;Ot<Q.columnSpan&&!(Q.column+Ot>=t.columnCount);Ot++)k=t.getColumnDefinition(Q.column+Ot),Ce+=k.total||0;if(Ce<Pe){let Ot=Pe-Ce,Ve=Pe-Ce;if(Q.spanAllocation!==null){let ue=Q.spanAllocation;for(let Oe=0;Oe<Q.columnSpan&&!(Ot<=0||Q.column+Oe>=t.columnCount);Oe++){k=t.getColumnDefinition(Q.column+Oe);let je=k.j||0,Re=ue(Q,k,Ve);k.actual=Math.min(k.maximum,je+Re),k.j!==je&&(Ot-=k.j-je)}}for(;Ot>0&&k!==void 0;){let ue=k.j||0;if(isNaN(k.width)&&k.maximum>ue&&(k.actual=Math.min(k.maximum,ue+Ot),k.j!==ue&&(Ot-=k.j-ue)),k.index===0)break;k=t.getColumnDefinition(k.index-1)}}}g.Z(d),_.i(st),_.i(lt),ht!==void 0&&g.Z(ht),ot!==void 0&&g.Z(ot);let dt=0,pt=0,vt=t.desiredSize,Ct=t.maxSize;L=t.Qs(!0),O=0,V=0;let nt=0,Nt=0;a=t.columnCount;for(let ut=0;ut<a;ut++)if(w[ut]!==void 0){if(k=t.getColumnDefinition(ut),isFinite(k.width)){nt+=k.width,nt+=k.computeEffectiveSpacing();continue}else if(k.j1()===2){nt+=k.j,nt+=k.computeEffectiveSpacing();continue}k.j!==0&&(O+=k.j,O+=k.computeEffectiveSpacing())}isFinite(vt.width)?dt=Math.min(vt.width,Ct.width):L!==0&&isFinite(e)?dt=e:dt=O,dt=Math.max(dt,isFinite(e)?Math.min(o,e):o),dt=Math.max(dt-nt,0);let kt=O===0?1:Math.max(dt/O,1);for(let ut=0;ut<a;ut++)w[ut]!==void 0&&(k=t.getColumnDefinition(ut),!isFinite(k.width)&&k.j1()!==2&&(k.actual=k.j*kt),k.position=n.width,k.j!==0&&(n.width+=k.j,n.width+=k.computeEffectiveSpacing()));a=t.rowCount;for(let ut=0;ut<a;ut++)if(v[ut]!==void 0){if(k=t.getRowDefinition(ut),isFinite(k.height)){Nt+=k.height,Nt+=k.computeEffectiveSpacing();continue}else if(k.j1()===2){Nt+=k.j,Nt+=k.computeEffectiveSpacing();continue}k.j!==0&&(V+=k.j,V+=k.computeEffectiveSpacing())}isFinite(vt.height)?pt=Math.min(vt.height,Ct.height):L!==0&&isFinite(i)?pt=i:pt=V,pt=Math.max(pt,isFinite(i)?Math.min(r,i):r),pt=Math.max(pt-Nt,0);let qt=V===0?1:Math.max(pt/V,1);for(let ut=0;ut<a;ut++)v[ut]!==void 0&&(k=t.getRowDefinition(ut),!isFinite(k.height)&&k.j1()!==2&&(k.actual=k.j*qt),k.position=n.height,k.j!==0&&(n.height+=k.j,n.height+=k.computeEffectiveSpacing()));a=l.length;for(let ut=0;ut<a;ut++){let Q=l[ut],yt=0,At=0;Q.type===H.TableRow?(yt=n.width,k=t.getRowDefinition(Q.row),At=k.actual):(k=t.getColumnDefinition(Q.column),yt=k.actual,At=n.height),Q.measuredBounds.e(0,0,yt,At),Q.wi(!1)}g.Z(l),t.La=c}arrange(t,e,i){let s=e.length,n=t.padding,o=n.left,r=n.top,a=t.La;if(a===null)return;let h=0,l=0,c=a.length,u=0;for(let D=0;D<c;D++)a[D]&&(u=Math.max(u,a[D].length));let d=t.Qi,f=t._i,p=0,m=0,y=Math.min(t.topIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].j===0);)y++;y=Math.max(Math.min(y,c-1),0),p=-d[y].position}let b=Math.min(t.leftIndex,u-1);if(f.length>0){for(;b!==u&&(f[b]===void 0||f[b].j===0);)b++;b=Math.max(Math.min(b,u-1),0),m=-f[b].position}let v=0,w=0;for(;v!==c&&d[v]===void 0;)v++;for(;w!==c&&f[w]===void 0;)w++;let k=t.part,S=t.getRowDefinition(v),M=t.getColumnDefinition(w);for(let D=0;D<e.length;D++){let N=e[D];if(!(N instanceof H&&N.visible&&N.ol()))continue;N.type===H.TableRow?(S=t.getRowDefinition(N.row),M=t.getColumnDefinition(w)):(S=t.getRowDefinition(v),M=t.getColumnDefinition(N.column)),l=S.position+p+r,S.j!==0&&(l+=S.computeEffectiveSpacingTop(Math.max(v,y))),h=M.position+m+o,M.j!==0&&(h+=M.computeEffectiveSpacingTop(Math.max(w,b)));let L=N.measuredBounds;N.pf(),N.actualBounds.ce();let R=N.actualBounds,O=B.z(R.x,R.y,R.width,R.height);if(R.x=N.type===H.TableRow?o:h,R.y=N.type===H.TableColumn?r:l,R.width=L.width,R.height=L.height,N.actualBounds.b(),N.ao(!1),O.equalsApproxClose(R)){B.i(O);continue}k!==null&&(k.Sa(),N.qp(k)),B.i(O)}let F=_.l();for(let D=0;D<c;D++){if(!a[D])continue;u=a[D].length;let N=t.getRowDefinition(D);l=N.position+p+r,N.j!==0&&(l+=N.computeEffectiveSpacingTop(Math.max(v,y)));for(let L=0;L<u;L++){if(!a[D][L])continue;let R=t.getColumnDefinition(L);h=R.position+m+o,R.j!==0&&(h+=R.computeEffectiveSpacingTop(Math.max(w,b)));let O=a[D][L],V=O.length;for(let K=0;K<V;K++){let Y=O[K],X=Y.measuredBounds;F.e(0,0);for(let te=1;te<Y.rowSpan&&!(D+te>=t.rowCount);te++){let ne=t.getRowDefinition(D+te);ne.j!==0&&(F.height+=ne.total)}for(let te=1;te<Y.columnSpan&&!(L+te>=t.columnCount);te++){let ne=t.getColumnDefinition(L+te);ne.j!==0&&(F.width+=ne.total)}let G=R.j+F.width,rt=N.j+F.height,lt=h,st=l,ht=G,ot=rt,dt=h,pt=l,vt=G,Ct=rt;h+G>i.width&&(vt=Math.max(i.width-h,0)),l+rt>i.height&&(Ct=Math.max(i.height-l,0));let nt=Y.alignment,Nt=0,kt=0,qt=0,ut=0;if(nt.isDefault()){nt=t.defaultAlignment,nt.isSpot()||(nt=T.Center),Nt=nt.x,kt=nt.y,qt=nt.offsetX,ut=nt.offsetY;let te=R.alignment,ne=N.alignment;te.isSpot()&&(Nt=te.x,qt=te.offsetX),ne.isSpot()&&(kt=ne.y,ut=ne.offsetY)}else Nt=nt.x,kt=nt.y,qt=nt.offsetX,ut=nt.offsetY;(isNaN(Nt)||isNaN(kt))&&(Nt=.5,kt=.5,qt=0,ut=0);let Q=X.width,yt=X.height,At=Y.margin,_t=At.left+At.right,Wt=At.top+At.bottom,Zt=Y.Zp(N,R,!1);isNaN(Y.desiredSize.width)&&(Zt===2||Zt===5)&&(Q=Math.max(G-_t,0)),isNaN(Y.desiredSize.height)&&(Zt===2||Zt===4)&&(yt=Math.max(rt-Wt,0));let Qt=Y.maxSize,Fe=Y.minSize;Q=Math.min(Qt.width,Q),yt=Math.min(Qt.height,yt),Q=Math.max(Fe.width,Q),yt=Math.max(Fe.height,yt);let ve=Q+_t,Pe=yt+Wt;lt+=ht*Nt-ve*Nt+qt+At.left,st+=ot*kt-Pe*kt+ut+At.top,Y.visible&&(B.contains(dt,pt,vt,Ct,lt,st,X.width,X.height)?Y.Ut(lt,st,Q,yt):Y.Ut(lt,st,Q,yt,new B(dt,pt,vt,Ct)))}}}_.i(F);for(let D=0;D<s;D++){let N=e[D],L=N instanceof H?N:null;if(L!==null&&L.ol()){let R=N.actualBounds;N.naturalBounds.ce(),N.naturalBounds.e(0,0,R.width,R.height),N.naturalBounds.b()}}}}Ft.Tn("Table",new ar);class hr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){}arrange(t,e,i){}}Ft.Tn("TableRow",new hr);class lr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){}arrange(t,e,i){}}Ft.Tn("TableColumn",new lr);class cr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){s.length!==1&&g.o("Viewbox Panel must contain exactly one GraphObject.");let a=s[0];a.it=1,a.bf(),a.ht(1/0,1/0,o,r);let h=a.measuredBounds,l=a.margin,c=l.right+l.left,u=l.top+l.bottom;if(isFinite(e)||isFinite(i)){let d=a.scale,f=h.width,p=h.height,m=Math.max(e-c,0),y=Math.max(i-u,0),b=1;t.viewboxStretch===6?(f!==0&&p!==0&&(b=Math.min(m/f,y/p)),b===0&&(b=1e-4),a.it*=b):(f!==0&&p!==0&&(b=Math.max(m/f,y/p)),b===0&&(b=1e-4),a.it*=b),d!==a.scale&&(a.wi(!0),a.ht(1/0,1/0,o,r))}h=a.measuredBounds,n.width=isFinite(e)?e:Math.max(h.width+c,0),n.height=isFinite(i)?i:Math.max(h.height+u,0)}arrange(t,e,i){let s=e[0],n=s.measuredBounds,o=s.margin,r=o.right+o.left,a=o.top+o.bottom,h=Math.max(n.width+r,0),l=Math.max(n.height+a,0),c=s.alignment;c.isDefault()&&(c=t.defaultAlignment),c.isSpot()||(c=T.Center),s.Ut(i.width*c.x-h*c.x+c.offsetX,i.height*c.y-l*c.y+c.offsetY,n.width,n.height)}}Ft.Tn("Viewbox",new cr);class ur extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){t.Pe===null&&(t.Pe=new yi),this.vI(t),this.FI(t)}arrange(t,e,i){}Ge(t,e,i){let s=t.naturalBounds;e.save(),e.beginPath(),e.rect(0,0,s.width,s.height),e.clip(),e.endPath(),this.RI(t,e,i),e.restore(),e.clearContextCache(!1)}RI(t,e,i){let s=t.getDocumentScale()*i.scale;s<=0&&(s=1);let n=t.gridCellSize,o=n.width,r=n.height,a=t.naturalBounds,h=t.actualBounds,l=a.width,c=a.height,u=Math.ceil(l/o),d=Math.ceil(c/r),f=t.gridOrigin,p=f.x,m=f.y,y=t.Pe.M0,b=t.D.r,v=b.length;for(let w=0;w<v;w++){let k=b[w];if(!k.visible)continue;let S=k.interval||1,M=Math.abs(S);if(o*M*s<2)continue;let F=k.segmentIndex;(!isFinite(F)||isNaN(F))&&(F=0),F<0&&(F=M-Math.min(-F,M)),F=Math.round(F%M);let D=k.opacity,N=1;if(D!==1){if(D===0)continue;N=e.globalAlpha,e.globalAlpha=N*D}let L=y[w],R=!1,O=k.strokeDashArray;if(O!==null&&(R=!0,e.enableDash(O,k.strokeDashOffset)),k.stroke!==null&&k.strokeWidth>0&&(k.figure==="LineV"||k.figure==="LineH")){if(e.lineWidth=k.strokeWidth,t.kn(e,k.stroke,!1,!1,a,h),e.beginPath(),k.figure==="LineV"){let V=Math.floor((p-o)/o);for(let K=V;K<=V+u;K++){let Y=K*o+p;0<=Y&&Y<=l&&this.q1(K,S,F,L)&&(e.moveTo(Y,0),e.lineTo(Y,c))}}else if(k.figure==="LineH"){let V=Math.floor((m-r)/r);for(let K=V;K<=V+d;K++){let Y=K*r+m;0<=Y&&Y<=c&&this.q1(K,S,F,L)&&(e.moveTo(0,Y),e.lineTo(l,Y))}}e.stroke(),e.endPath()}else if(k.fill!==null){if(t.kn(e,k.fill,!0,!1,a,h),k.figure==="BarV"){let V=k.width;isNaN(V)&&(V=o);let K=Math.floor((p-o)/o);for(let Y=K;Y<=K+u;Y++){let X=Y*o+p;0<=X+V&&X<=l&&this.q1(Y,S,F,L)&&e.fillRect(X,0,V,c)}}else if(k.figure==="BarH"){let V=k.height;isNaN(V)&&(V=r);let K=Math.floor((m-r)/r);for(let Y=K;Y<=K+d;Y++){let X=Y*r+m;0<=X+V&&X<=c&&this.q1(Y,S,F,L)&&e.fillRect(0,X,l,V)}}}R&&e.disableDash(),D!==1&&(e.globalAlpha=N)}}q1(t,e,i,s){if(e<0)return t%e===i;if(t%e!==i)return!1;let n=s.length;for(let o=0;o<n;o++){let r=s[o];if(t%r===i)return!1}return!0}FI(t){let e=[],i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n],r=[];if(e.push(r),!o.visible)continue;let a=o.interval;if(a<0)continue;let h=o.figure,l=this.KN(h);for(let c=0;c<s;c++){if(c===n)continue;let u=i[c];if(!u.visible)continue;let d=u.figure;if(this.KN(d)!==l)continue;let f=u.interval;f>a&&r.push(f)}}t.Pe.M0=e}KN(t){return t==="LineV"||t==="BarV"}vI(t){let e=1,i=1,s=t.D.r,n=s.length;for(let a=0;a<n;a++){let h=s[a],l=Math.abs(h.interval);l<2||(this.KN(h.figure)?i=i*l/A.HL(i,l):e=e*l/A.HL(e,l))}let o=t.gridCellSize,r=t.Pe;r.lf.isReal()?r.lf.e(i*o.width,e*o.height):r.lf=new _(i*o.width,e*o.height)}}Ft.Tn("Grid",new ur);class dr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length;if(!(t instanceof Mt||t instanceof q))return;let h=null,l=null;if(t instanceof q&&(h=t),t instanceof Mt&&(l=t,h=l.adornedPart,t.Lf===null&&(t.Lf=[])),!(h instanceof q))return;let c=h;if(a===0){t.naturalBounds.jn(0,0),t.measuredBounds.e(0,0,0,0);return}let u=t instanceof Mt?null:h.path,d=h.routeBounds,f=t.Zo;f.e(0,0,d.width,d.height);let p=c.points,m=h.pointsCount;l!==null?l.Ad(!1):h!==null&&h.Ad(!1);let y=d.width,b=d.height,v=t.Lf;if(v.length=0,u!==null){this.measureLinkPath(t,y,b,u);let M=u.measuredBounds;f.unionRect(M),v.push(M)}let w=Pt.l(),k=P.l(),S=P.l();for(let M=0;M<a;M++){let F=s[M];if(F===u)continue;let D=F.measuredBounds;if(F.isPanelMain&&F instanceof at){this.measureLinkPath(t,y,b,F),D=F.measuredBounds,f.unionRect(D),v.push(D);continue}if(m<2){F.ht(1/0,1/0,0,0),D=F.measuredBounds,f.unionRect(D),v.push(D);continue}let N=F.segmentIndex,L=F.segmentFraction,R=F.alignmentFocus;R.isNoSpot()&&(R=T.Center);let O=F.segmentOrientation,V=F.segmentOffset,K=0,Y=0,X=0,G=0;if(isNaN(N)){let nt=c.ut,Nt=g.ot();nt.getPointAndAngleAlongPath(L,Nt);let kt=P.z(Nt[0],Nt[1]);G=Nt[2],O!==0&&(X=c.computeAngle(F,O,G),F.Xt=X,F.wi(!0),F.ao(!0)),K=kt.x,Y=kt.y,P.i(kt),g.Z(Nt)}else if(N<-m||N>=m){let nt=P.l();c.HN(nt),G=c.midAngle,O!==0&&(X=c.computeAngle(F,O,G),F.Xt=X,F.wi(!0),F.ao(!0)),K=nt.x-d.x,Y=nt.y-d.y,P.i(nt)}else{let nt,Nt,kt=0;if(N>=0?(nt=p.elt(N),Nt=N<m-1?p.elt(N+1):nt):(kt=m+N,nt=p.elt(kt),Nt=kt>0?p.elt(kt-1):nt),nt.equalsApprox(Nt)){let qt,ut;N>=0?(qt=N>0?p.elt(N-1):nt,ut=N<m-2?p.elt(N+2):Nt):(qt=kt<m-1?p.elt(kt+1):nt,ut=kt>1?p.elt(kt-2):Nt);let Q=qt.distanceSquaredPoint(nt),yt=Nt.distanceSquaredPoint(ut);Q>yt+10?G=N>=0?qt.directionPoint(nt):nt.directionPoint(qt):yt>Q+10?G=N>=0?Nt.directionPoint(ut):ut.directionPoint(Nt):G=N>=0?qt.directionPoint(ut):ut.directionPoint(qt)}else G=N>=0?nt.directionPoint(Nt):Nt.directionPoint(nt);O!==0&&(X=c.computeAngle(F,O,G),F.Xt=X,F.wi(!0),F.ao(!0)),K=nt.x+(Nt.x-nt.x)*L-d.x,Y=nt.y+(Nt.y-nt.y)*L-d.y}F.ht(1/0,1/0,0,0),D=F.measuredBounds;let rt=F.naturalBounds,lt=0;F instanceof at&&(lt=F.strokeWidth);let st=rt.width+lt,ht=rt.height+lt;w.Ue(),w.Gs(-D.x,-D.y),w.it(F.scale,F.scale),w.ks(O===0?F.angle:G,st/2,ht/2),(O===22||O===26)&&w.ks(90,st/2,ht/2),(O===23||O===27)&&w.ks(-90,st/2,ht/2),O===28&&(G>45&&G<135||G>225&&G<315)&&w.ks(-G,st/2,ht/2);let ot=new B(0,0,st,ht);k.setRectSpot(ot,R),w.gt(k);let dt=-k.x+lt/2*F.scale,pt=-k.y+lt/2*F.scale;S.h(V);let vt=isNaN(V.x),Ct=isNaN(V.y);if(vt||Ct){let nt=st/2+q.W1,Nt=ht/2+q.W1,kt=G>=45&&G<=135,qt=G>=225&&G<=315;O===0&&(kt||qt)?(S.x=Ct?nt:V.y,S.y=vt?Nt:V.x,kt?N>=0||isNaN(N)&&L<.5||vt&&(S.y=-Nt):qt&&((N>=0||isNaN(N)&&L<.5)&&vt&&(S.y=-Nt),Ct&&(S.x=-nt))):(vt&&(N>=0||isNaN(N)&&L<.5?S.x=nt:S.x=-nt),Ct&&(S.y=-Nt),S.rotate(G))}else S.rotate(G);K+=S.x,Y+=S.y,ot.e(K+dt,Y+pt,D.width,D.height),v.push(ot),f.unionRect(ot)}if(h!==null){let M=h.labelNodes;for(;M.next();)M.value.ht(1/0,1/0)}t.Zo=f,t.position.e(d.x+f.x,d.y+f.y),n.jn(f.width||0,f.height||0),Pt.i(w),P.i(k),P.i(S)}arrange(t,e,i){let s=e.length;if(!(t instanceof Mt||t instanceof q))return;let n=t,o=null;t instanceof Mt&&(o=t,n=o.adornedPart);let r=t,a=t instanceof Mt?null:n.path,h=t.Lf;if(h.length!==0){let d=0;if(a!==null&&d<h.length){let f=h[d];d++,a.Ut(f.x-r.Zo.x,f.y-r.Zo.y,f.width,f.height)}for(let f=0;f<s;f++){let p=e[f];if(p!==a&&d<h.length){let m=h[d];d++,p.Ut(m.x-r.Zo.x,m.y-r.Zo.y,m.width,m.height)}}}let l=n.points,c=l.count;if(c>=2&&r instanceof q){let d=r.labelNodes;for(;d.next();){let f=d.value;r.OI(f,c,l)}}o!==null?o.Ad(!1):n.Ad(!1);let u=t.fD(P.l());t.location.e(t.position.x+u.x,t.position.y+u.y),P.i(u)}measureLinkPath(t,e,i,s){if(s.Go()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Mt&&t.type===H.Link&&t.adornedObject instanceof at&&(n=t.adornedObject.strokeWidth),n=n*s.it,t instanceof q&&t.ut!==null){let o=t.geometry.bounds;s.lo(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Mt&&t.adornedPart.ut!==null){let o=t.adornedPart.ut.bounds;s.lo(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.lo(-(n/2),-(n/2),e+n,i+n);s.II(),s.wi(!1)}}Ft.Tn("Link",new dr);class fr extends Ft{constructor(){super()}measure(t,e,i,s,n,o,r){let a=t.findMainElement();if(!(a instanceof at))return;t.ts=[];let h=a.margin,l=h.right+h.left,c=h.top+h.bottom;a.ht(e,i,o,r);let u=a.measuredBounds,d=u.width,f=u.height,p=Math.max(d+l,0),m=Math.max(f+c,0),y=new B(-h.left,-h.top,p,m);t.ts.push(y),n.h(y),this.determineGraduatedMarks(t,a);let b=t.Fs;if(b===null)return;let v=s.length;for(let w=0;w<v;w++){let k=s[w],S=b[w];!k.visible||k===a||S.length===0||(k instanceof at?this.measureGraduatedTicks(t,k,S,n):k instanceof gt&&this.measureGraduatedLabels(t,k,S,n),k.wi(!1))}}arrange(t,e,i){if(t.ts===null)return;let s=t.findMainElement(),n=t.Fs;if(n===null)return;let o=t.ts,r=0,a=o[r];r++,s!==null&&s.Ut(a.x-i.x,a.y-i.y,a.width,a.height);let h=e.length;for(let l=0;l<h;l++){let c=e[l],u=n[l];!c.visible||c===s||u.length===0||(a=o[r],r++,c.Ut(a.x-i.x,a.y-i.y,a.width,a.height))}t.ts=null}measureGraduatedTicks(t,e,i,s){let n=e.alignmentFocus;n.isNoSpot()&&(n=T.TopCenter);let o=e.angle;e.Xt=0,e.ht(1/0,1/0,0,0),e.Xt=o;let r=e.measuredBounds,a=r.width,h=r.height,l=B.z(0,0,a,h),c=P.l();c.setRectSpot(l,n),B.i(l);let u=-c.x,d=-c.y,f=new B,p=i.length;for(let m=0;m<p;m++){let y=i[m],b=y.pt.x,v=y.pt.y,w=y.angle;for(let k=0;k<4;k++){switch(k){case 0:c.e(u,d);break;case 1:c.e(u+a,d);break;case 2:c.e(u,d+h);break;case 3:c.e(u+a,d+h);break}c.rotate(w+e.angle),c.offset(b,v),m===0&&k===0?f.e(c.x,c.y,0,0):f.unionPoint(c),c.offset(-b,-v),c.rotate(-w-e.angle)}}P.i(c),t.ts!==null&&t.ts.push(f),s.re(f.x,f.y,f.width,f.height)}measureGraduatedLabels(t,e,i,s){t.vi===null&&(t.vi=new gt);let n=t.vi;this.uD(e,n);let o=e.alignmentFocus;o.isNoSpot()&&(o=T.TopCenter);let r=e.segmentOrientation,a=e.segmentOffset,h=new B,l=0,c=0,u=0,d=0,f=0,p=i.length;for(let m=0;m<p;m++){let y=i[m];l=y.pt.x,c=y.pt.y,u=y.angle,d=e.angle,f=e.angle,r!==0&&(r===21||r===25?f=u+e.angle:f=u,d=q.computeAngle(r,f)),n.Xt=d,n.text=y.text||"",n.ht(1/0,1/0,0,0);let b=n.measuredBounds,v=n.naturalBounds,w=v.width,k=v.height,S=Pt.l();S.Ue(),S.Gs(-b.x,-b.y),S.it(n.scale,n.scale),S.ks(f,w/2,k/2),(r===22||r===26)&&S.ks(90,w/2,k/2),(r===23||r===27)&&S.ks(-90,w/2,k/2),r===28&&(u>45&&u<135||u>225&&u<315)&&S.ks(-u,w/2,k/2);let M=B.z(0,0,w,k),F=P.l();F.setRectSpot(M,o),S.gt(F);let D=-F.x,N=-F.y,L=P.l();L.h(a),isNaN(L.x)&&(L.x=w/2+3),isNaN(L.y)&&(L.y=-(k/2+3)),L.rotate(u),l+=L.x+D,c+=L.y+N;let R=new B(l,c,b.width,b.height),O=new B(b.x,b.y,b.width,b.height),V=new B(v.x,v.y,v.width,v.height);y.labelAngle=d,y.lineCount=n.lineCount,y.lines=n.getMetrics(),y.actualBounds=R,y.measuredBounds=O,y.naturalBounds=V,m===0?h.h(R):h.unionRect(R),P.i(L),P.i(F),B.i(M),Pt.i(S)}t.ts!==null&&t.ts.push(h),s.re(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,e){let i=e.geometry,s=e.strokeWidth,n=i.flattenedSegments,o=i.flattenedLengths,r=i.flattenedTotalLength,a=n.length,h=0,l=0,c=g.ot();for(let v=0;v<a;v++){let w=n[v],k=[];h=0,l=0;let S=w.length;for(let M=0;M<S;M+=2){let F=w[M],D=w[M+1];if(M===0){h=F,l=D;continue}let N=Math.atan2(D-l,F-h)*180/Math.PI;N<0&&(N+=360),k.push(N),h=F,l=D}c.push(k)}let u=this.EI(t),d=t.D.r,f=d.length,p=0,m=0,y=r;t.Fs=[];let b;for(let v=0;v<f;v++){let w=d[v];if(b=[],!w.visible||w===e){t.Fs.push(b);continue}let k=Math.abs(w.interval),S=t.graduatedTickUnit;if(S*k*r/t.graduatedRange<2&&w.graduatedSkip===null){t.Fs.push(b);continue}let M=o[0][0],F=0,D=0;m=r*w.graduatedStart-1e-4,y=r*w.graduatedEnd+1e-4;let N=S*k,L=t.graduatedTickBase;if(L<t.graduatedMin){let K=(t.graduatedMin-L)/N;K=K%1===0?K:Math.floor(K+1),L+=K*N}else if(L>t.graduatedMin+N){let K=Math.floor((L-t.graduatedMin)/N);L-=K*N}let R=u[v],O=L,V=t.graduatedMax*1e-6;for(let K=1;L<=t.graduatedMax+V;K++){if(this.UI(t,L-t.graduatedTickBase,R)&&(L>t.graduatedMax&&(L=t.graduatedMax),(w.graduatedSkip===null||w instanceof gt&&!w.graduatedSkip(L,w)||w instanceof at&&!w.graduatedSkip(L,w))&&(p=(L-t.graduatedMin)*r/t.graduatedRange,p>r&&(p=r),m<=p&&p<=y))){let Y=c[F][D],X=o[F][D];for(;F<o.length;){for(;p>M&&D<o[F].length-1;)D++,Y=c[F][D],X=o[F][D],M+=X;if(p<=M)break;F++,D=0,Y=c[F][D],X=o[F][D],M+=X}let G=n[F],rt=G[D*2],lt=G[D*2+1],st=G[D*2+2],ht=G[D*2+3],ot=(p-(M-X))/X,dt=new P(rt+(st-rt)*ot+s/2-i.bounds.x,lt+(ht-lt)*ot+s/2-i.bounds.y);if(dt.scale(e.scale,e.scale),Y=this.VI(Y,ot,G,c[F],D),w instanceof gt){let pt="";w.graduatedFunction!==null?(pt=w.graduatedFunction(L,w),pt=pt!=null?pt.toString():""):pt=(+L.toFixed(2)).toString(),pt!==""&&b.push({pt:dt,angle:Y,text:pt})}else b.push({pt:dt,angle:Y})}L=O+K*N}t.Fs.push(b)}g.Z(c)}VI(t,e,i,s,n){if(e<.5005&&e>.4995)return t;let o=t;if(e<.5?n>0?o=s[n-1]:A.X(i[0],i[i.length-2])&&A.X(i[1],i[i.length-1])&&(o=s[s.length-1]):e>.5&&(n+1<s.length?o=s[n+1]:A.X(i[0],i[i.length-2])&&A.X(i[1],i[i.length-1])&&(o=s[0])),t!==o){let r=Math.abs(t-o);if(r>180&&(t<o?t+=360:o+=360,r=Math.abs(t-o)),e<5e-4||e>.9995)return(t+o)/2%360;if(r<10){let a=1-Math.abs(.5-e);return(t*a+o*(1-a))%360}}return t}EI(t){if(t.ds===null){let e=[],i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n],r=[];if(e.push(r),!o.visible)continue;let a=o.interval;if(!(a<0))for(let h=0;h<s;h++){if(h===n)continue;let l=i[h];if(!l.visible||o.constructor!==l.constructor)continue;let c=l.interval;c>a&&r.push(c)}}t.ds=e}return t.ds}UI(t,e,i){let s=i.length;for(let n=0;n<s;n++){let o=i[n]*t.graduatedTickUnit,r=e%o,a=t.graduatedTickUnit*1e-6;if(r<a&&r>-a)return!1}return!0}Ge(t,e,i){let s=i.gh;i.gh=!0;let n=t.naturalBounds,o=n.width,r=n.height,a=e instanceof ge;e.save(),e.beginPath(),e.rect(-1,-1,o+1,r+1),e.clip(),e.endPath();let h=t.findMainElement();h.Ge(e,i);let l=t.getDocumentScale()*i.scale;l<=0&&(l=1);let c=h.actualBounds,u=t.D.r,d=t.Fs,f=u.length;for(let p=0;p<f;p++){let m=u[p],y=d[p],b=y.length;if(!(!m.visible||m===h||y.length===0)){if(m instanceof at){if(t.graduatedTickUnit*m.interval*h.geometry.flattenedTotalLength/t.graduatedRange*l<2&&m.graduatedSkip===null)continue;let v=m.measuredBounds,w=m.strokeWidth*m.scale,k=m.alignmentFocus;k.isNoSpot()&&(k=T.TopCenter);for(let S=0;S<b;S++){let M=y[S].pt,F=y[S].angle;this.BI(m,M,c,F,v,w,k),m.Ge(e,i),a&&(t.svg.appendChild(m.svg),m.svg=null),m.il.Ue()}}else if(m instanceof gt){t.vi===null&&(t.vi=new gt);let v=t.vi;this.uD(m,v),v.jN=!0;for(let w=0;w<b;w++){let k=y[w];if(k.actualBounds&&k.measuredBounds&&k.naturalBounds){v.zI(k);let S=k.actualBounds;v.Ut(S.x,S.y,S.width,S.height),this.XI(v,c,S,k.measuredBounds,k.naturalBounds),v.nl=m.part,v.Zs=m.panel,v.Ge(e,i),v.Zs=null,v.nl=null,a&&(t.svg.appendChild(v.svg),v.svg=null)}}}}}i.gh=s,e.restore(),e.clearContextCache(!0)}BI(t,e,i,s,n,o,r){let a=t.il;a.Ue(),a.Gs(e.x+i.x,e.y+i.y),a.ks(s+t.angle,0,0),a.Gs(-n.width*r.x+r.offsetX+o/2,-n.height*r.y+r.offsetY+o/2),a.it(t.scale,t.scale),t.Pd(!1),t.wa.set(t.il),t.Lh=t.scale,t.Ih(!1)}XI(t,e,i,s,n){let o=t.il;o.Ue(),o.Gs(i.x+e.x,i.y+e.y),o.Gs(-s.x,-s.y),t.Yp(o,n.x,n.y,n.width,n.height),t.Pd(!1),t.wa.set(t.il),t.Lh=t.scale,t.Ih(!1)}uD(t,e){e.GI(t)}}Ft.Tn("Graduated",new fr);var Dn=(x=>(x[x.Uniform=6]="Uniform",x[x.UniformToFill=7]="UniformToFill",x))(Dn||{});class H extends tt{W;D;Qt;Td;Qn;ll;uo;Zo;qN;O;Dd;rt;Pe;te;vd;Aa;tn;constructor(t,e){if(super(),t===void 0)this.W=H.Position;else if(typeof t=="string"){let i=Ft.fs.get(t);i!==null?this.W=i:g.o("PanelLayout not loaded: "+t)}else t instanceof Ft?this.W=t:(this.W=H.Position,t&&(e=t));this.n|=4194304|(this.W===H.Grid?1048576:0),this.D=new U,this.Qt=Dt.em,this.Td=T.Default,this.Qn=1,this.ll=null,this.uo="",this.Zo=new B(NaN,NaN,NaN,NaN),this.qN=null,this.O=null,this.Dd=6,this.Pe=null,this.rt=null,this.te=null,this.vd=NaN,this.Aa=null,this.tn=null,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.W=this.W,t.Qt=this.Qt.N(),t.Td=this.Td.N(),t.Qn=this.Qn,t.uo=this.uo,t.Zo.h(this.Zo),this.O!==null&&(t.O=this.O.copy(t)),t.Dd=this.Dd,this.rt!==null&&(t.rt=this.rt.copy()),this.Pe!==null&&(t.Pe=this.Pe.copy()),t.te=this.te,t.vd=this.vd,t.Aa=this.Aa}jo(t){super.jo(t),t.D=this.D;let e=t.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s];n.Zs=t}t.ll=null}copy(){let t=super.copy(),e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s].copy();t.YI(n)}return t}toString(){return"Panel("+this.type.name+")#"+I.xs(this)}get type(){return this.W}set type(t){let e=this.W;e!==t&&(this.W=t,this.Af=this.W===H.Grid,this.c(),this.t("type",e,t))}get elements(){return this.D.iterator}get naturalBounds(){return this.Ke}get padding(){return this.Qt}set padding(t){typeof t=="number"?(t<0&&g.J(t,">= 0",H,"padding"),t=new Dt(t)):(t.left<0&&g.J(t.left,">= 0",H,"padding:value.left"),t.right<0&&g.J(t.right,">= 0",H,"padding:value.right"),t.top<0&&g.J(t.top,">= 0",H,"padding:value.top"),t.bottom<0&&g.J(t.bottom,">= 0",H,"padding:value.bottom"));let e=this.Qt;e.equals(t)||(t=t.N(),this.Qt=t,this.c(),this.t("padding",e,t))}get defaultAlignment(){return this.Td}set defaultAlignment(t){let e=this.Td;e.equals(t)||(t=t.N(),this.Td=t,this.c(),this.t("defaultAlignment",e,t))}get defaultStretch(){return this.Qn}set defaultStretch(t){let e=this.Qn;e!==t&&(this.Qn=t,this.c(),this.t("defaultStretch",e,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.N0:Dt.em}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Dt(t));let e=this.defaultSeparatorPadding;e.equals(t)||(t=t.N(),this.O===null&&(this.O=new ce),this.O.N0=t,this.c(),this.t("defaultSeparatorPadding",e,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O.C0:null}set defaultRowSeparatorStroke(t){let e=this.defaultRowSeparatorStroke;e!==t&&(t===null||typeof t=="string"||t instanceof E)&&(t instanceof E&&t.b(),this.O===null&&(this.O=new ce),this.O.C0=t,this.C(),this.t("defaultRowSeparatorStroke",e,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.L0:1}set defaultRowSeparatorStrokeWidth(t){let e=this.defaultRowSeparatorStrokeWidth;e!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new ce),this.O.L0=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",e,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.A0:null}set defaultRowSeparatorDashArray(t){let e=this.defaultRowSeparatorDashArray;if(e!==t){if(t!==null&&!Array.isArray(t)&&g.si(t,"Array",H,"defaultRowSeparatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&g.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.O===null&&(this.O=new ce),this.O.A0=t,this.C(),this.t("defaultRowSeparatorDashArray",e,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.T0:null}set defaultColumnSeparatorStroke(t){let e=this.defaultColumnSeparatorStroke;e!==t&&(t===null||typeof t=="string"||t instanceof E)&&(t instanceof E&&t.b(),this.O===null&&(this.O=new ce),this.O.T0=t,this.C(),this.t("defaultColumnSeparatorStroke",e,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.D0:1}set defaultColumnSeparatorStrokeWidth(t){let e=this.defaultColumnSeparatorStrokeWidth;e!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new ce),this.O.D0=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",e,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.v0:null}set defaultColumnSeparatorDashArray(t){let e=this.defaultColumnSeparatorDashArray;if(e!==t){if(t!==null&&!Array.isArray(t)&&g.si(t,"Array",H,"defaultColumnSeparatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&g.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.O===null&&(this.O=new ce),this.O.v0=t,this.C(),this.t("defaultColumnSeparatorDashArray",e,t)}}get La(){return this.O!==null?this.O.La:null}set La(t){this.O===null&&(this.O=new ce),this.O.La=t}get viewboxStretch(){return this.Dd}set viewboxStretch(t){let e=this.Dd;e!==t&&(this.Dd=t,this.c(),this.t("viewboxStretch",e,t))}get gridCellSize(){return this.Pe!==null?this.Pe.Fd:_.OL}set gridCellSize(t){this.Pe===null&&(this.Pe=new yi);let e=this.Pe.Fd;if(!e.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&g.o("Invalid Panel.gridCellSize: "+t),this.Pe.Fd=t.N();let i=this.diagram;i!==null&&this===i.grid&&i.ca(),this.C(),this.t("gridCellSize",e,t)}}get gridOrigin(){return this.Pe!==null?this.Pe.Rd:P.gn}set gridOrigin(t){this.Pe===null&&(this.Pe=new yi);let e=this.Pe.Rd;if(!e.equals(t)){t.isReal()||g.o("Invalid Panel.gridOrigin: "+t),this.Pe.Rd=t.N();let i=this.diagram;i!==null&&this===i.grid&&i.ca(),this.C(),this.t("gridOrigin",e,t)}}get graduatedMin(){return this.rt!==null?this.rt.F0:0}set graduatedMin(t){let e=this.graduatedMin;if(e!==t&&(this.rt===null&&(this.rt=new Ie),this.rt.F0=t,this.c(),this.t("graduatedMin",e,t),this.gf())){let i=this.part;i!==null&&this.Oh(i,"graduatedRange")}}get graduatedMax(){return this.rt!==null?this.rt.R0:100}set graduatedMax(t){let e=this.graduatedMax;if(e!==t&&(this.rt===null&&(this.rt=new Ie),this.rt.R0=t,this.c(),this.t("graduatedMax",e,t),this.gf())){let i=this.part;i!==null&&this.Oh(i,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.rt!==null?this.rt.O0:10}set graduatedTickUnit(t){let e=this.graduatedTickUnit;e!==t&&t>0&&(this.rt===null&&(this.rt=new Ie),this.rt.O0=t,this.c(),this.t("graduatedTickUnit",e,t))}get graduatedTickBase(){return this.rt!==null?this.rt.I0:0}set graduatedTickBase(t){let e=this.graduatedTickBase;e!==t&&(this.rt===null&&(this.rt=new Ie),this.rt.I0=t,this.c(),this.t("graduatedTickBase",e,t))}get Fs(){return this.rt!==null?this.rt.Fs:null}set Fs(t){this.rt!==null?this.rt.Fs=t:t!==null&&(this.rt=new Ie,this.rt.Fs=t)}get ts(){return this.rt!==null?this.rt.ts:null}set ts(t){this.rt!==null?this.rt.ts=t:t!==null&&(this.rt=new Ie,this.rt.ts=t)}get ds(){return this.rt!==null?this.rt.ds:null}set ds(t){this.rt!==null?this.rt.ds=t:t!==null&&(this.rt=new Ie,this.rt.ds=t)}get vi(){return this.rt!==null?this.rt.vi:null}set vi(t){this.rt!==null?this.rt.vi=t:t!==null&&(this.rt=new Ie,this.rt.vi=t)}qp(t){super.qp(t);let e=this.D.r,i=e.length;for(let s=0;s<i;s++)e[s].qp(t)}Ma(t,e){if(this.W===H.Grid){t.commitTransform(),this.W.Ge(this,t,e);return}if(this.W===H.Graduated){t.commitTransform(),this.W.Ge(this,t,e);return}if(this.W===H.Table)if(t.commitTransform(),t instanceof ge){let r=t.currentElement;t.currentElement=t.newGroup2("gojs-ts"),this.WN(t,e),t.endGroup(),t.currentElement=r}else this.WN(t,e);let i=this.isClipping&&this.W===H.Spot;i&&t.save();let s=this.findMainElement(),n=this.D.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];i&&a===s&&(t.clipInsteadOfFill=!0),a.Ge(t,e),i&&a===s&&(t.clipInsteadOfFill=!1)}i&&(t.restore(),t.clearContextCache(!0))}WN(t,e){t.lineCap="butt";let i=this.rowCount>0?this.Qi:null,s=this.columnCount>0?this._i:null;i!==null&&this.J1(t,e,!0,i,!0),s!==null&&this.J1(t,e,!1,s,!0),i!==null&&this.dD(t,!0,i),s!==null&&this.dD(t,!1,s),i!==null&&this.J1(t,e,!0,i,!1),s!==null&&this.J1(t,e,!1,s,!1)}dD(t,e,i){let s=i.length,n=this.actualBounds,o=this.naturalBounds,r=!0;for(let a=0;a<s;a++){let h=i[a];if(h===void 0||h.actual===0)continue;if(r){r=!1;continue}if(e){if(h.position>o.height)continue}else if(h.position>o.width)continue;let l=h.separatorStrokeWidth;isNaN(l)&&(l=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),l===0||c===null)continue;this.kn(t,c,!1,!1,o,n);let u=!1,d=h.separatorDashArray;d===null&&(d=e?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),d!==null&&(u=!0,t.enableDash(d,0)),t.beginPath();let f=h.position+l;e?f>o.height&&(l-=f-o.height):f>o.width&&(l-=f-o.width);let p=h.position+l/2;t.lineWidth=l;let m=this.Qt;if(e){p+=m.top;let y=m.left,b=o.width-m.right;t.moveTo(y,p),t.lineTo(b,p)}else{p+=m.left;let y=m.top,b=o.height-m.bottom;t.moveTo(p,y),t.lineTo(p,b)}t.stroke(),t.endPath(),u&&t.disableDash()}}J1(t,e,i,s,n){let o=s.length,r=this.actualBounds,a=this.naturalBounds,h=this.gD(!0),l=this.gD(!1);for(let c=0;c<o;c++){let u=s[c];if(u===void 0||u.background===null||u.coversSeparators===n||u.actual===0)continue;let d=i?r.height:r.width;if(u.position>d)continue;let f=u.computeEffectiveSpacing(),p=u.separatorStrokeWidth;isNaN(p)&&(p=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let m=u.separatorStroke;m===null&&(m=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(m===null||u.index===(i?h:l))&&(p=0),f-=p;let y=u.position+p,b=f+u.actual;if(y+b>d&&(b=d-y),b<=0)continue;let v=this.Qt;this.kn(t,u.background,!0,!1,a,r),i?t.fillRect(v.left,y+v.top,r.width-(v.left+v.right),b):t.fillRect(y+v.left,v.top,b,r.height-(v.top+v.bottom))}}gD(t){let e=t?this.rowCount:this.columnCount;for(let i=0;i<e;i++){let s=t?this.Qi[i]:this._i[i];if(s!==void 0)return s.index}return 0}wf(){let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].wf();this.$i(!0)}yf(t,e,i){let s=this.svg;if(s===null)return!1;if(this.type===H.Table){let r=s.getElementsByClassName("gojs-ts"),a=r.length!==0?r[0]:null;a!==null&&(a.innerHTML=""),t.currentElement=a,this.WN(t,e),t.currentElement=null}else{if(this.W===H.Grid||this.W===H.Graduated)return s.innerHTML="",s.remove(),!1;if(this.W===H.Spot&&this.isClipping)return s.innerHTML="",s.remove(),this.xa=null,this.wf(),!1}if(!super.yf(t,e,i))return!1;let n=this.D.r,o=n.length;for(let r=0;r<o;r++)n[r].Ge(t,e);return!0}kd(t){return!0}Jp(t,e,i,s){if(!this.isClipping){if(this._s()&&t.partClipRect!==null){let n=t.partClipRect,o=this.D.r,r=0,a=0;for(let h=0;h<o.length;h++){if(!o[h].isVisibleObject())continue;let l=o[h].actualBounds;r=h===0?l.x:Math.min(l.x,r),a=h===0?l.y:Math.min(l.y,a)}s.setAttributeNS(null,"clip-path",`path('M ${n.x-i.x-r},${n.y-i.y-a} l ${n.width} 0 l 0 ${n.height} l -${n.width} 0 z')`);return}super.Jp(t,e,i,s)}}mf(t,e,i,s,n){let o=this.Nn(),r=this.v,a=1/(r.m11*r.m22-r.m12*r.m21),h=r.m22*a,l=-r.m12*a,c=-r.m21*a,u=r.m11*a,d=a*(r.m21*r.dy-r.m22*r.dx),f=a*(r.m12*r.dx-r.m11*r.dy);if(this.background!==null){let p=t*h+e*c+d,m=t*l+e*u+f,y=i*h+s*c+d,b=i*l+s*u+f;n.e(0,0);let v=this.naturalBounds,w=A.Cl(0,0,v.width,v.height,p,m,y,b,n);return n.v(r),w}else{o||(h=1,l=0,c=0,u=1,d=0,f=0);let p=t*h+e*c+d,m=t*l+e*u+f,y=i*h+s*c+d,b=i*l+s*u+f;n.e(y,b);let v=(y-p)**2+(b-m)**2,w=!1,k=this.D.r,S=k.length,M=P.l(),F=null,D=1/0,N=null,L=this.isClipping&&this.W===H.Spot;L&&(N=P.l(),F=this.findMainElement(),w=F.mf(p,m,y,b,N),w&&(D=(p-N.x)**2+(m-N.y)**2));for(let R=0;R<S;R++){let O=k[R];if(!O.visible||O===F||!O.mf(p,m,y,b,M))continue;w=!0;let V=(p-M.x)**2+(m-M.y)**2;V<v&&(v=V,n.set(M))}return L&&(D>v&&n.set(N),P.i(N)),P.i(M),o&&n.v(r),w}}qc(){let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].qc();super.qc()}c(t){if(this.Go())return;super.c(t);let e=null;(this.W===H.Auto||this.W===H.Link)&&(e=this.findMainElement());let i=this.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];if((o===e||o.isPanelMain)&&o.c(!0),o.desiredSize.isReal()||!o.visible)continue;let r=o.Qs(!1);!(o instanceof we)&&!(o instanceof H)&&!(o instanceof gt)&&r===0||o.c(!0)}}bf(){if(this.Go())return;this.wi(!0),this.ao(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].bf()}pf(){if(this.V1()===!1){this.Pd(!0),this.Ih(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].AN()}}AN(){this.Ih(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].AN()}xd(t,e,i,s){let n=this.Zo;n.e(0,0,0,0);let o=this.desiredSize,r=this.minSize;i===void 0&&(i=r.width,s=r.height),i=Math.max(i,r.width),s=Math.max(s,r.height);let a=this.maxSize;isNaN(o.width)||(t=Math.min(o.width,a.width)),isNaN(o.height)||(e=Math.min(o.height,a.height)),t=Math.max(i,t),e=Math.max(s,e);let h=this.Qt;t=Math.max(t-h.left-h.right,0),e=Math.max(e-h.top-h.bottom,0);let l=this.D.r;this.W.measure(this,t,e,l,n,i,s);let c=n.width+h.left+h.right,u=n.height+h.top+h.bottom;isFinite(o.width)&&(c=o.width),isFinite(o.height)&&(u=o.height),c=Math.min(a.width,c),u=Math.min(a.height,u),c=Math.max(r.width,c),u=Math.max(r.height,u),c=Math.max(i,c),u=Math.max(s,u),n.jn(c,u),this.naturalBounds.jn(c,u),this.lo(0,0,c,u)}findMainElement(){if(this.ll===null){let t=this.D.r,e=t.length;if(e===0)return null;for(let i=0;i<e;i++){let s=t[i];if(s.isPanelMain===!0)return this.ll=s,s}this.ll=t[0]}return this.ll}$o(){return this.part!==null?this.part.locationObject:null}get panelLayoutState(){return this.qN}set panelLayoutState(t){this.qN=t}Pa(t,e,i,s){let n=this.D.r;if(this.actualBounds.e(t,e,i,s),!this.desiredSize.isReal()){let o=this.Qs(!0),r=this.measuredBounds,a=r.width,h=r.height,l=this.sl,c=l.left+l.right,u=l.top+l.bottom;switch(a===i&&h===s&&(o=0),o){case 0:(a>i||h>s)&&(this.c(),this.ht(a>i?i:a,h>s?s:h,0,0));break;case 2:this.c(!0),this.ht(i+c,s+u,0,0);break;case 5:this.c(!0),this.ht(i+c,h+u,0,0);break;case 4:this.c(!0),this.ht(a+c,s+u,0,0);break}}this.W.arrange(this,n,this.Zo)}ka(t){let e=this.naturalBounds,i=this.$o();if(B.contains(0,0,e.width,e.height,t.x,t.y)){let s=this.D.r,n=s.length,o=P.z(0,0);for(let r=n;r--;){let a=s[r];if(!(!a.visible&&a!==i)&&(o.set(t).Ki(a.v),a.containsPoint(o)))return P.i(o),!0}return P.i(o),this.Lt!==null}return!1}Gp(t){if(this.oo===t)return this;let e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s].Gp(t);if(n!==null)return n}return null}walkVisualTreeFrom(t,e){if(e(this,t),t instanceof H){let i=t.D.r,s=i.length;for(let n=0;n<s;n++)this.walkVisualTreeFrom(i[n],e)}}Sn(t){this.mD(this,t)}mD(t,e){e(t);let i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];o instanceof H&&this.mD(o,e)}}KI(t){this.pD(this,t)}pD(t,e){if(e(t),t instanceof H){let i=t.D.r,s=i.length;for(let n=0;n<s;n++)this.pD(i[n],e)}}findInVisualTree(t){return this.yD(this,t)}yD(t,e){if(e(t))return t;if(t instanceof H){let i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=this.yD(i[n],e);if(o!==null)return o}}return null}findObject(t){if(this.name===t)return this;let e=this.D.r,i=e.length;this.HI()&&(i=this.E0());for(let s=0;s<i;s++){let n=e[s];if(n instanceof H){let o=n.findObject(t);if(o!==null)return o}if(n.name===t)return n}return null}wD(){let t=this.D.r,e=t.length,i=0;for(let s=0;s<e;s++){let n=t[s];n instanceof H?i=Math.max(i,n.wD()):n instanceof at&&(i=Math.max(i,n.jI()))}return i}Nn(){return!(this.type===H.TableRow||this.type===H.TableColumn)}ol(){return this.type===H.TableRow||this.type===H.TableColumn}BA(t,e,i){if(this.pickable===!1||(e===void 0&&(e=null),i===void 0&&(i=null),this.as()))return null;let s=this.naturalBounds,n=1/this.getDocumentScale(),o=this.Nn(),r=o?t:P.z(t.x,t.y).Ki(this.v),a=this.diagram,h=10,l=5;if(a!==null&&(h=a.getInputOption("extraTouchArea"),l=h/2),B.contains(-(l*n),-(l*n),s.width+h*n,s.height+h*n,r.x,r.y)){if(!this.Af){let u=this.D.r,d=u.length,f=P.l(),p=this.isClipping&&this.W===H.Spot,m=p?this.findMainElement():null;if(p&&m&&(m.Nn()?f.set(t).Ki(m.v):f.set(t),!m.containsPoint(f)))return P.i(f),o||P.i(r),null;let y=this.$o();for(let b=d;b--;){let v=u[b];if(!v.visible&&v!==y||(v.Nn()?f.set(t).Ki(v.v):f.set(t),p&&v===m))continue;let w=null;if(v instanceof H?w=v.BA(f,e,i):v.pickable===!0&&v.containsPoint(f)&&(w=v),w!==null&&(e!==null&&(w=e(w)),w!==null&&(i===null||i(w))))return P.i(f),o||P.i(r),w}P.i(f)}if(this.background===null)return o||P.i(r),null;let c=B.contains(0,0,s.width,s.height,r.x,r.y)?this:null;return o||P.i(r),c}return o||P.i(r),null}zA(t,e,i,s){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let n=this.naturalBounds,o=this.Nn(),r=o?t:P.z(t.x,t.y).Ki(this.v),a=this.ol(),h=B.contains(0,0,n.width,n.height,r.x,r.y);if(a||h){if(!this.Af){let l=this.D.r,c=l.length,u=P.l(),d=this.$o();for(let f=c;f--;){let p=l[f];if(!p.visible&&p!==d)continue;p.Nn()?u.set(t).Ki(p.v):u.set(t);let m=p,y=p instanceof H?p:null;if(y!==null?y.zA(u,e,i,s):m.containsPoint(u)){if(m.pickable===!1)continue;e!==null&&(m=e(m)),m!==null&&(i===null||i(m))&&s.add(m)}}P.i(u)}return o||P.i(r),h&&this.background!==null}return o||P.i(r),!1}$m(t,e,i,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let r=o;if(r===void 0&&(r=Pt.l(),r.Ue()),r.bc(this.v),this.containedInRect(t,r))return this.JN(e,i,n),o===void 0&&Pt.i(r),!0;if(this.intersectsRect(t,r)){if(!this.Af){let a=this.$o(),h=this.D.r,l=h.length;for(let c=l;c--;){let u=h[c];if(!u.visible&&u!==a)continue;let d=u.actualBounds,f=this.naturalBounds;if(d.x>f.width||d.y>f.height||d.x+d.width<0||d.y+d.height<0)continue;let p=u,m=u instanceof H?u:null,y=Pt.l();y.set(r),(m!==null?m.$m(t,e,i,s,n,y):p.JT(t,s,y))&&(e!==null&&(p=e(p)),p!==null&&(i===null||i(p))&&n.add(p)),Pt.i(y)}}return o===void 0&&Pt.i(r),s}return o===void 0&&Pt.i(r),!1}JN(t,e,i){let s=this.D.r,n=s.length;for(let o=n;o--;){let r=s[o];if(!r.visible)continue;let a=r.actualBounds,h=this.naturalBounds;if(a.x>h.width||a.y>h.height||a.x+a.width<0||a.y+a.height<0)continue;r instanceof H&&r.JN(t,e,i);let l=r;t!==null&&(l=t(l)),l!==null&&(e===null||e(l))&&i.add(l)}}XA(t,e,i,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),s===void 0&&(s=null);let r=this.naturalBounds,a=this.Nn(),h=a?t:P.z(t.x,t.y).Ki(this.v),l=a?e:P.z(e.x,e.y).Ki(this.v),c=h.distanceSquaredPoint(l),u=h.x>0&&h.x<r.width&&h.y>0&&h.y<r.height||P.distanceLineSegmentSquared(h.x,h.y,0,0,0,r.height)<=c||P.distanceLineSegmentSquared(h.x,h.y,0,r.height,r.width,r.height)<=c||P.distanceLineSegmentSquared(h.x,h.y,r.width,r.height,r.width,0)<=c||P.distanceLineSegmentSquared(h.x,h.y,r.width,0,0,0)<=c,d=h.distanceSquared(0,0)<=c&&h.distanceSquared(0,r.height)<=c&&h.distanceSquared(r.width,0)<=c&&h.distanceSquared(r.width,r.height)<=c;if(a||(P.i(h),P.i(l)),u){if(!this.Af){let f=P.l(),p=P.l(),m=this.$o(),y=this.D.r,b=y.length;for(let v=b;v--;){let w=y[v];if(!w.visible&&w!==m)continue;let k=w.actualBounds,S=this.naturalBounds;if(a&&(k.x>S.width||k.y>S.height||k.x+k.width<0||k.y+k.height<0))continue;if(w.Nn()){let D=w.v;f.set(t).Ki(D),p.set(e).Ki(D)}else f.set(t),p.set(e);let M=w,F=w instanceof H?w:null;(F!==null?F.XA(f,p,i,s,n,o):M.$T(f,p,n))&&(i!==null&&(M=i(M)),M!==null&&(s===null||s(M))&&o.add(M))}P.i(f),P.i(p)}return n?u:d}return!1}GN(t){let e=null;if(t instanceof at){e=t.spot1,e===T.Default&&(e=null);let i=t.geometry;i!==null&&e===null&&(e=i.spot1)}return e===null&&(e=T.TopLeft),e}YN(t){let e=null;if(t instanceof at){e=t.spot2,e===T.Default&&(e=null);let i=t.geometry;i!==null&&e===null&&(e=i.spot2)}return e===null&&(e=T.BottomRight),e}add(...t){for(let e=0;e<t.length;e++)this.insertAt(this.D.count,t[e]);return this}elt(t){return this.D.elt(t)}insertAt(t,e){e instanceof bt&&g.o("Cannot add a Part to a Panel: "+e+"; use a Panel instead"),(this===e||this.isContainedBy(e))&&(this===e&&g.o("Cannot make a Panel contain itself: "+this.toString()),g.o("Cannot make a Panel indirectly contain itself: "+this.toString()+" already contains "+e.toString()));let i=e.panel;if(i!==null&&i!==this&&g.o("Cannot add a GraphObject that already belongs to another Panel to this Panel: "+e.toString()+", already contained by "+i.toString()+", cannot be shared by this Panel: "+this.toString()),this.W===H.Grid&&!(e instanceof at)&&g.o("Can only add Shapes to a Grid Panel, not: "+e),this.W===H.Graduated&&!(e instanceof at||e instanceof gt)&&g.o("Can only add Shapes or TextBlocks to a Graduated Panel, not: "+e),e.Eh(this),e.nl=null,this.itemArray!==null){let r=e.data;g.$(r)&&(this.tn===null&&(this.tn=new wt),this.tn.set(r,e))}let s=this.D,n=-1;if(i===this){let r=-1,a=this.D.r,h=a.length;for(let l=0;l<h;l++)if(a[l]===e){r=l;break}if(r!==-1){if(r===t||r+1>=s.count&&t>=s.count)return;s.removeAt(r),n=r}else g.o("element "+e.toString()+" has panel "+i.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,e),(t===0||e.isPanelMain)&&(this.ll=null),this.Go()||this.c(),e.c(!1),e.portId!==null?this.Ln=!0:e instanceof H&&e.Ln===!0&&(this.Ln=!0),this.ds=null,this.isEnabledObject()||this.$1(e,!1);let o=this.part;if(o!==null){o.i0(),o.Tf(),this.Ln&&o instanceof it&&(o.Ln=!0),o.Ln&&o instanceof it&&(o.hi=null);let r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,e,null,n,null),o.raiseChangedEvent(3,"elements",this,null,e,null,t)}}get Ln(){return(this.n&8388608)!==0}set Ln(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}MN(){return(this.n&16777216)!==0}$N(t){t?this.n|=16777216:this.n&=-16777217}YI(t){t.Eh(this),t.nl=null;let e=this.D,i=e.count;e.insertAt(i,t);let s=this.part;if(s!==null){s.i0(),t.portId!==null&&s instanceof it&&(s.Ln=!0);let n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,i)}}cI(t){let e=this.D.r,i=e.length,s=-1;for(let n=0;n<i;n++)if(e[n]===t){s=n;break}return s}remove(t){let e=this.D.r,i=e.length,s=-1;for(let n=0;n<i;n++)if(e[n]===t){s=n;break}s!==-1&&this.ri(s,!0)}removeAt(t){t>=0&&this.ri(t,!0)}ri(t,e){let i=this.D,s=i.elt(t);if(s.nl=null,s.Eh(null),this.tn!==null){let o=s.data;g.$(o)&&this.tn.delete(o)}i.removeAt(t),this.wi(!1),this.c(),this.ll===s&&(this.ll=null),this.ds=null;let n=this.part;if(n!==null){n.i0(),n.Tf(),n.invalidateAdornments(),n instanceof it&&(s instanceof H?s.walkVisualTreeFrom(s,(r,a)=>n.FN(a,e)):n.FN(s,e));let o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Qi(){return this.O===null&&(this.O=new ce),this.O.Qi}get rowCount(){return this.O===null?0:this.Qi.length}getRowDefinition(t){t<0&&g.J(t,">= 0",H,"getRowDefinition:idx"),t=Math.round(t);let e=this.Qi;if(e[t]===void 0){let i=new Gt;i.Eh(this),i.isRow=!0,i.index=t,e[t]=i,this.raiseChangedEvent(3,"rowdefs",this,null,i,null,t)}return e[t]}removeRowDefinition(t){if(t<0&&g.J(t,">= 0",H,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);let e=this.Qi,i=e[t];if(i){e[t]=void 0;let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--;this.raiseChangedEvent(4,"rowdefs",this,i,null,t,null),this.c()}}xT(t,e){let i=this.Qi;if(!(t<0)){if(i[t]=e instanceof Gt?e:void 0,!e){let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--}this.c()}}get _i(){return this.O===null&&(this.O=new ce),this.O._i}get columnCount(){return this.O===null?0:this._i.length}getColumnDefinition(t){t<0&&g.J(t,">= 0",H,"getColumnDefinition:idx"),t=Math.round(t);let e=this._i;if(e[t]===void 0){let i=new Gt;i.Eh(this),i.isRow=!1,i.index=t,e[t]=i,this.raiseChangedEvent(3,"coldefs",this,null,i,null,t)}return e[t]}removeColumnDefinition(t){if(t<0&&g.J(t,">= 0",H,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);let e=this._i,i=e[t];if(i){e[t]=void 0;let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--;this.raiseChangedEvent(4,"coldefs",this,i,null,t,null),this.c()}}bT(t,e){let i=this._i;if(!(t<0)){if(i[t]=e instanceof Gt?e:void 0,!e){let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--}this.c()}}addRowColumnDefinition(t){let e=null;return t.isRow?e=this.getRowDefinition(t.index):t.isRow||(e=this.getColumnDefinition(t.index)),e&&e.z1(t),this}addRowDefinition(t,e){let i=this.getRowDefinition(t);return i&&i.z1(new Gt(e)),this}addColumnDefinition(t,e){let i=this.getColumnDefinition(t);return i&&i.z1(new Gt(e)),this}get rowSizing(){return this.O!==null?this.O.U0:3}set rowSizing(t){let e=this.rowSizing;e!==t&&(this.O===null&&(this.O=new ce),this.O.U0=t,this.c(),this.t("rowSizing",e,t))}get columnSizing(){return this.O!==null?this.O.V0:3}set columnSizing(t){let e=this.columnSizing;e!==t&&(this.O===null&&(this.O=new ce),this.O.V0=t,this.c(),this.t("columnSizing",e,t))}get topIndex(){return this.O!==null?this.O.B0:0}set topIndex(t){let e=this.topIndex;e!==t&&((!isFinite(t)||t<0)&&g.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new ce),this.O.B0=t,this.c(),this.t("topIndex",e,t))}get leftIndex(){return this.O!==null?this.O.z0:0}set leftIndex(t){let e=this.leftIndex;e!==t&&((!isFinite(t)||t<0)&&g.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new ce),this.O.z0=t,this.c(),this.t("leftIndex",e,t))}findRowForLocalY(t){if(t<0||this.type!==H.Table||this.rowCount===0)return-1;let e=0,i=this.Qi,s=i.length,n=this.topIndex;for(;n<s;n++){let o=i[n];if(o!==void 0&&(e+=o.total,t<e))return n}return n}findColumnForLocalX(t){if(t<0||this.type!==H.Table||this.columnCount===0)return-1;let e=0,i=this._i,s=i.length,n=this.leftIndex;for(;n<s;n++){let o=i[n];if(o!==void 0&&(e+=o.total,t<e))return n}return n}graduatedPointForValue(t,e){if(e===void 0&&(e=new P(NaN,NaN)),this.type!==H.Graduated)return e.e(NaN,NaN),e;t=Math.min(Math.max(t,this.graduatedMin),this.graduatedMax);let i=this.findMainElement();return i.geometry.getPointAlongPath((t-this.graduatedMin)/this.graduatedRange,e),i.v.gt(e)}graduatedValueForPoint(t){if(this.type!==H.Graduated)return NaN;let e=this.findMainElement();return e.v.Ci(t),e.geometry.getFractionForPoint(t)*this.graduatedRange+this.graduatedMin}get data(){return this.te}set data(t){let e=this.te;if(e!==t){let i=this instanceof bt&&!(this instanceof Mt);i&&g.s(t,"object",H,"data"),this.It(),this.te=t;let s=this.diagram;if(s!==null)if(i){s.partManager.qI(this,e,t);let n=this.adornments;for(;n.next();){let o=n.value,r=o.adornedObject;if(r!==null){let a=r.findBindingPanel();a!==null&&(o.data=a.data)}}}else{let n=this.panel;n!==null&&n.tn!==null&&(e!==null&&n.tn.delete(e),t!==null&&n.tn.set(t,this))}if(this.t("data",e,t),s!==null&&s.undoManager.isUndoingRedoing)return;t!==null&&this.updateTargetBindings()}}get itemIndex(){return this.vd}set itemIndex(t){let e=this.vd;e!==t&&(this.vd=t,this.t("itemIndex",e,t))}get vs(){return this.w!==null?this.w.vs:null}set vs(t){this.ve!==t&&(this.w===null&&(this.w=new oi),this.w.vs=t)}RN(){return this.vs!==null}oD(){let t=this.vs;return t!==null&&t.f}freezeBindings(){return this.It()}It(){let t=this.vs;if(t===null)this.data!==null&&g.o("Template cannot have .data be non-null: "+this),this.vs=t=new U;else if(t.f)return this;let e=new U;this.$N(!1),this.walkVisualTreeFrom(this,(n,o)=>{o.ba();let r=o.ve;if(r!==null){o.TN(!1);let a=r.iterator;for(;a.next();){let h=a.value;h.mode===2&&o.TN(!0);let l=h.sourceName;if(h.isToObject){l==="/"&&n.$N(!0);let c=h.WT(n,o);c!==null&&(e.add(c),c.ro===null&&(c.ro=new U),c.ro.add(h))}t.add(h)}}if(o instanceof H&&o.type===H.Table){if(o.rowCount>0){let a=o.Qi,h=a.length;for(let l=0;l<h;l++){let c=a[l];if(c!==void 0&&c.Rs!==null){let u=c.Rs.iterator;for(;u.next();){let d=u.value;d.Ti=c,d.Od=2,d.Df=c.index,t.add(d)}}}}if(o.columnCount>0){let a=o._i,h=a.length;for(let l=0;l<h;l++){let c=a[l];if(c!==void 0&&c.Rs!==null){let u=c.Rs.iterator;for(;u.next();){let d=u.value;d.Ti=c,d.Od=1,d.Df=c.index,t.add(d)}}}}}});let i=e.iterator;for(;i.next();){let n=i.value;if(n.ro!==null){n.TN(!0);let o=n.ro.iterator;for(;o.next();){let r=o.value;n.ve===null&&(n.ve=new U),n.ve.add(r)}}n.ro=null}let s=t.iterator;for(;s.next();){let n=s.value,o=n.Ti;if(o!==null){n.Ti=null;let r=n.targetProperty,a=r.indexOf(".");if(a>0&&o instanceof H){let h=r.substring(0,a),l=r.substring(a+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=l):(g.ne('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof Gt){let h=I.xs(o.panel);n.targetId=h===void 0?-1:h,o.panel.oo=n.targetId}else if(o instanceof tt){let h=I.xs(o);n.targetId=h===void 0?-1:h,o.oo=n.targetId}else g.o("Unknown type of binding target: "+o);n.check(o)}}return t.b(),this instanceof bt&&this.Di()&&this.ensureBounds(),this}static BU=!1;copyTemplate(t){t===void 0&&(t=!1);let e=this.copy();return e.KI(i=>{i instanceof H&&(i.vs=null,i.te=null);let s=i.ve;s!==null&&(i.ve=null,s.each(o=>i.bind(o.copy())));let n=i.Ds;n!==null&&(i.Ds=null,n.each(o=>i.trigger(o.value.copy())))}),t&&e.It(),e}updateTargetBindings(t){let e=this.vs;if(e===null)return;t===void 0&&(t="");let i=this.diagram?.model,s=e.iterator;for(;s.next();){let n=s.value,o=this.ZN(n,t);if(o===null)continue;let{data:r,elt:a}=o;n.isToTheme&&this.diagram===null||a!==void 0&&n.updateTarget(a,r,void 0,i)}}WI(t){if(t===""){this.updateTargetBindings(t);return}let e=this.vs;if(e===null)return;let i=this.diagram?.model,s=e.iterator;for(;s.next();){let n=s.value;if(n.isToData&&n.sourceProperty!=="")continue;let o=this.ZN(n,"");if(o===null)continue;let{data:r,elt:a}=o;a!==void 0&&n.updateTarget(a,r,void 0,i)}}Yo(){if(this.diagram!==null)if(this.RN()){let t=this.diagram.model,e=this.vs.iterator;for(;e.next();){let i=e.value;if(!i.isToTheme)continue;let s=this.ZN(i);if(s===null)continue;let{data:n,elt:o}=s;o!==void 0&&i.updateTarget(o,n,void 0,t)}}else{let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].Yo()}}ZN(t,e=""){let i=t.sourceProperty;if(e!==""&&i!==""&&i!==e)return null;let s=t.targetProperty;if(t.converter===null&&s==="")return null;let n=this.data,o=t.sourceName;if(t.isToObject){if(n=this.qT(o),n===null)return null}else if(t.isToModel){let l=this.diagram;if(l===null)return null;n=l.model.modelData}let r=this,a=t.targetId;if(a!==-1){if(r=this.Gp(a),r===null)return null}else t.Ti!==null&&(r=t.Ti);o==="/"?n=r.part:o==="."?n=r:o===".."&&(n=r.panel);let h=t.Od;if(h!==0){if(!(r instanceof H))return null;h===1?r=r.getColumnDefinition(t.Df):h===2&&(r=r.getRowDefinition(t.Df))}return{data:n,elt:r}}get itemArray(){return this.Aa}set itemArray(t){let e=this.Aa;if(e!==t||t!==null&&this.JI(t)){let i=this.diagram;if(e!==t&&(i!==null&&e!==null&&i.partManager.N2(this,i),this.Aa=t,i!==null&&t!==null&&i.partManager.M2(this,i)),this.t("itemArray",e,t),i!==null&&i.undoManager.isUndoingRedoing)return;this.xD(e,t)}}findItemPanelForData(t){return t==null||this.tn===null?null:(g.wc(t,H,"findItemPanelForData"),this.tn.get(t))}JI(t){let e=this.D.r,i=e.length,s=t.length,n=0,o=null;for(;n<i&&(o=e[n],!(o instanceof H)||o.data===null);)n++,o=e[n];if(i-n!==s)return!0;if(o===null)return s>0;let r=0;for(;n<i&&r<s;){if(o=e[n],!(o instanceof H)||o.data!==t[r])return!0;n++,r++}return!1}E0(){if(this.type===H.Spot||this.type===H.Auto)return Math.min(this.D.length,1);if(this.type===H.Link){let t=this.D,e=t.length,i=0;for(;i<e;i++){let s=t.elt(i);if(!(s instanceof at)||!s.isPanelMain)return i}return i}if(this.type===H.Table&&this.D.length>0){let t=this.D.elt(0);if(t.isPanelMain&&t instanceof H&&t.ol())return 1}return 0}rebuildItemElements(){let t=this.E0();for(;this.D.length>t;)this.ri(this.D.length-1,!1);this.xD(null,this.itemArray)}xD(t,e){let i=this.E0(),s=e;if(s===null||s.length===0){for(;this.D.length>i;)this.ri(this.D.length-1,!1);return}if(this.D.length<=i){let n=s.length;for(let o=0;o<n;o++)this.Z1(s[o],o,!0)}else{let n=i;for(let r=0;r<s.length;r++,n++){let a=s[r],h=n<this.D.length?this.D.elt(n):null;if(h instanceof H){if(h.data!==a){let l=this.QN(h.data,r),c=this.QN(a,r),u=c!==l;if(!u){let d=this._N(h.data,r,l);u=this._N(a,r,c)!==d}u?(this.ri(n,!1),this.Z1(a,r,!1)):h.data=a}}else this.Z1(a,r,!1)}for(;n<this.D.length;)this.ri(n,!1);this.ll=null,this.tC(i,0),this.Go()||this.c(),this.ds=null,this.isEnabledObject()||this.$1(this,!1);let o=this.part;o!==null&&(o.i0(),o.Tf(),this.Ln&&o instanceof it&&(o.Ln=!0),o.Ln&&o instanceof it&&(o.hi=null))}}Z1(t,e,i){if(t==null||e<0)return;let s=this.QN(t,e),n=this._N(t,e,s);if(n!==null){n.It();let o=n.copy();if(o.MN()){let a=this.findBindingPanel();a!==null&&a.$N(!0)}g.$(t)&&(this.tn===null&&(this.tn=new wt),this.tn.set(t,o));let r=e+this.E0();this.insertAt(r,o),i&&(o.te=t,this.tC(r,e),o.te=null),o.data=t}}$I(t){if(t<0)return;let e=t+this.E0();this.ri(e,!0),this.tC(e,t)}tC(t,e){let i=this.D,s=t,n=e;for(;s<i.length;){let o=i.elt(s);o instanceof H&&o.ZI(s,n),s++,n++}}ZI(t,e){this.type===H.TableRow?this.row=t:this.type===H.TableColumn&&(this.column=t),this.itemIndex=e}HI(){return this.Aa!==null||this.itemTemplateMap!==null}get itemTemplate(){let t=this.itemTemplateMap;if(t!==null){let e=t.get("");if(e)return e}return H.bD()}set itemTemplate(t){let e=this.itemTemplate;if(e!==t){(t instanceof bt||t.isPanelMain)&&g.o("Panel.itemTemplate must not be a Part or be Panel.isPanelMain: "+t),this.itemTemplateMap===null&&(this.itemTemplateMap=new wt),this.itemTemplateMap.set("",t),this.t("itemTemplate",e,t);let i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.rebuildItemElements()}}get itemTemplateMap(){return this.w!==null?this.w.w0:null}set itemTemplateMap(t){let e=this.itemTemplateMap;if(e!==t){let i=t.iterator;for(;i.next();){let n=i.value}this.Yt().w0=t,this.t("itemTemplateMap",e,t);let s=this.diagram;if(s!==null&&s.undoManager.isUndoingRedoing)return;this.rebuildItemElements()}}get itemCategoryProperty(){return this.w!==null?this.w.x0:"category"}set itemCategoryProperty(t){let e=this.itemCategoryProperty;e!==t&&(typeof t!="string"&&!g.nt(t)&&g.si(t,"string or function",H,"itemCategoryProperty"),this.Yt().x0=t,this.t("itemCategoryProperty",e,t))}QN(t,e){if(t===null)return"";let i=this.itemCategoryProperty,s="";if(g.nt(i))s=i(t);else if(typeof i=="string"&&g.$(t)){if(i==="")return"";let n=this.diagram,o=n!==null?n.model:null;o?s=o.Mt(t,i):s=mt.Mt(t,i)}else return"";if(s===void 0)return"";if(typeof s=="string")return s;g.o("Panel.getCategoryForItemData found a non-string category for "+t+": "+s)}static kD=!1;static eC;static bD(){return H.eC||(H.eC=new H().add(new gt().bind("text","",g.toString).theme("stroke","text"))),H.eC}_N(t,e,i){let s=null,n=this.itemTemplateMap;return n!==null&&(s=n.get(i),s===null&&(s=n.get(""))),s===null&&(H.kD||(H.kD=!0,g.ne('No item template Panel found for category "'+i+'" on '+this),g.ne(" Using default item template.")),s=H.bD()),s}get Af(){return(this.n&1048576)!==0}set Af(t){let e=(this.n&1048576)!==0;e!==t&&(g.s(t,"boolean",H,"isAtomic"),this.n=this.n^1048576,this.t("isAtomic",e,t))}get isClipping(){return(this.n&2097152)!==0}set isClipping(t){let e=(this.n&2097152)!==0;e!==t&&(this.wf(),this.n=this.n^2097152,this instanceof ft&&(this.he=null),this.c(),this.t("isClipping",e,t))}get isOpposite(){return(this.n&33554432)!==0}set isOpposite(t){let e=(this.n&33554432)!==0;e!==t&&(this.n=this.n^33554432,this.c(),this.t("isOpposite",e,t))}get isEnabled(){return(this.n&4194304)!==0}set isEnabled(t){let e=(this.n&4194304)!==0;if(e!==t){let i=this.panel===null||this.panel.isEnabledObject();this.n=this.n^4194304,this.t("isEnabled",e,t);let s=this.diagram;if(s!==null&&s.undoManager.isUndoingRedoing)return;i&&this.$1(this,t)}}$1(t,e){let i=t.enabledChanged;if(i!==null&&i(t,e),t instanceof H){let s=t.D.r,n=s.length;for(let o=0;o<n;o++){let r=s[o];e&&r instanceof H&&!r.isEnabled||this.$1(r,e)}}}get alignmentFocusName(){return this.uo}set alignmentFocusName(t){let e=this.uo;e!==t&&(this.uo=t,this.c(),this.t("alignmentFocusName",e,t))}static definePanelLayout(t,e){Ft.Tn(t,e)}static isLayoutDefined(t){return Ft.fs.has(t)}static Position=Ft.fs.get("Position");static Horizontal=Ft.fs.get("Horizontal");static Vertical=Ft.fs.get("Vertical");static Spot=Ft.fs.get("Spot");static Auto=Ft.fs.get("Auto");static Table=Ft.fs.get("Table");static Viewbox=Ft.fs.get("Viewbox");static TableRow=Ft.fs.get("TableRow");static TableColumn=Ft.fs.get("TableColumn");static Link=Ft.fs.get("Link");static Grid=Ft.fs.get("Grid");static Graduated=Ft.fs.get("Graduated")}H.definePanelLayout=H.definePanelLayout;class Ie{F0;R0;O0;I0;Fs;ts;ds;vi;constructor(){this.F0=0,this.R0=100,this.O0=10,this.I0=0,this.Fs=null,this.ts=null,this.ds=null,this.vi=null}copy(){let t=new Ie;return t.F0=this.F0,t.R0=this.R0,t.O0=this.O0,t.I0=this.I0,t.Fs=this.Fs,t.ts=this.ts,t.ds=this.ds,t.vi=this.vi,t}}class yi{Fd;Rd;lf;M0;constructor(){this.Fd=_.OL,this.Rd=P.gn,this.lf=_.$w,this.M0=[]}copy(){let t=new yi;return t.Fd=this.Fd.copy(),t.Rd=this.Rd.copy(),t.lf=this.lf.copy(),t.M0=this.M0,t}}class ce{Qi;_i;U0;V0;B0;z0;N0;L0;C0;A0;D0;T0;v0;La;constructor(){this.Qi=[],this._i=[],this.U0=3,this.V0=3,this.B0=0,this.z0=0,this.N0=Dt.em,this.L0=1,this.C0=null,this.A0=null,this.D0=1,this.T0=null,this.v0=null,this.La=null}copy(t){let e=new ce,i=this.Qi,s=i.length,n=e.Qi;for(let h=0;h<s;h++){let l=i[h];if(l===void 0)continue;let c=l.copy();c.Eh(t),n[h]=c}let o=this._i,r=o.length,a=e._i;for(let h=0;h<r;h++){let l=o[h];if(l===void 0)continue;let c=l.copy();c.Eh(t),a[h]=c}return e.U0=this.U0,e.V0=this.V0,e.B0=this.B0,e.z0=this.z0,e.N0=this.N0.N(),e.L0=this.L0,e.C0=this.C0,e.A0=this.A0,e.D0=this.D0,e.T0=this.T0,e.v0=this.v0,e.La=this.La,e}}var ks=(x=>(x[x.Default=1]="Default",x[x.None=2]="None",x[x.ProportionalExtra=3]="ProportionalExtra",x))(ks||{});class Gt{Zs;X0;Tt;zh;Xh;de;ct;Id;ho;al;Ed;Ud;Gh;Lt;Vd;Rs;j;Re;bi;constructor(t){I.Je(this),this.Zs=null,this.X0=!0,this.Tt=0,this.bi=NaN,this.zh=0,this.Xh=1/0,this.de=T.Default,this.j=0,this.Re=0,this.ct=0,this.Rs=null,this.Id=1,this.ho=1,this.al=null,this.Ed=null,this.Ud=NaN,this.Gh=null,this.Lt=null,this.Vd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){let t=new Gt;return t.X0=this.X0,t.Tt=this.Tt,t.bi=this.bi,t.zh=this.zh,t.Xh=this.Xh,t.de=this.de,t.j=this.j,t.Re=this.Re,t.ct=this.ct,t.ho=this.ho,t.Id=this.Id,this.al===null?t.al=null:t.al=this.al.N(),t.Ed=this.Ed,t.Ud=this.Ud,t.Gh=null,this.Gh!==null&&(t.separatorDashArray=this.Gh.slice()),t.Lt=this.Lt,t.Vd=this.Vd,t.Rs=this.Rs,t}z1(t){t.isRow?t.height!==void 0&&(this.height=t.height):t.width!==void 0&&(this.width=t.width),t.minimum!==void 0&&(this.minimum=t.minimum),t.maximum!==void 0&&(this.maximum=t.maximum),t.alignment!==void 0&&(this.alignment=t.alignment),t.stretch!==void 0&&(this.stretch=t.stretch),t.sizing!==void 0&&(this.sizing=t.sizing),t.separatorPadding!==void 0&&(this.separatorPadding=t.separatorPadding),t.separatorStroke!==void 0&&(this.separatorStroke=t.separatorStroke),t.separatorStrokeWidth!==void 0&&(this.separatorStrokeWidth=t.separatorStrokeWidth),t.separatorDashArray!==void 0&&(this.Gh=t.separatorDashArray),t.background!==void 0&&(this.background=t.background),t.coversSeparators!==void 0&&(this.coversSeparators=t.coversSeparators),t.Rs!==void 0&&(this.Rs=t.Rs)}fe(t){t in ks?this.sizing=t:g.dr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+I.xs(this)}static Default=1;static None=2;static ProportionalExtra=3;Eh(t){this.Zs=t}computeEffectiveSpacingTop(t){let e=0,i=this.Zs;if(this.index!==t){let n=this.separatorStroke;n===null&&i!==null&&(n=this.isRow?i.defaultRowSeparatorStroke:i.defaultColumnSeparatorStroke),n!==null&&(e=this.separatorStrokeWidth,isNaN(e)&&(i!==null?e=this.isRow?i.defaultRowSeparatorStrokeWidth:i.defaultColumnSeparatorStrokeWidth:e=0))}let s=this.al;if(s===null)if(i!==null)s=i.defaultSeparatorPadding;else return e;return e+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0,e=this.Zs,i=0,s=this.isRow;if(e!==null&&e.type===H.Table){let o=s?e.Qi.length:e._i.length;for(let r=0;r<o;r++){let a=s?e.Qi[r]:e._i[r];if(a!==void 0&&a.j!==0){i=a.index;break}}}if(this.index!==i){let o=this.separatorStroke;o===null&&e!==null&&(o=s?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),o!==null&&(t=this.separatorStrokeWidth,isNaN(t)&&(e!==null?t=s?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:t=0))}let n=this.al;if(n===null)if(e!==null)n=e.defaultSeparatorPadding;else return t;return t+(this.isRow?n.top+n.bottom:n.left+n.right)}t(t,e,i,s,n){let o=this.Zs;if(o!==null&&(o.raiseChangedEvent(2,t,this,e,i,s,n),this.Rs!==null)){let r=o.diagram;if(r!==null&&!r.yi){let a=o.findBindingPanel();if(a!==null){let h=a.data;if(h!==null){let l=this.Rs.iterator;for(;l.next();)l.value.updateSource(this,h,t,a)}}}}}get panel(){return this.Zs}get isRow(){return this.X0}set isRow(t){this.X0=t}get index(){return this.Tt}set index(t){this.Tt=t}get height(){return this.bi}set height(t){let e=this.bi;e!==t&&(t<0&&g.J(t,">= 0",Gt,"height"),this.bi=t,this.actual=this.j,this.panel!==null&&this.panel.c(),this.t("height",e,t))}get width(){return this.bi}set width(t){let e=this.bi;e!==t&&(t<0&&g.J(t,">= 0",Gt,"width"),this.bi=t,this.actual=this.j,this.panel!==null&&this.panel.c(),this.t("width",e,t))}get minimum(){return this.zh}set minimum(t){let e=this.zh;e!==t&&((t<0||!isFinite(t))&&g.J(t,">= 0",Gt,"minimum"),this.zh=t,this.actual=this.j,this.panel!==null&&this.panel.c(),this.t("minimum",e,t))}get maximum(){return this.Xh}set maximum(t){let e=this.Xh;e!==t&&(t<0&&g.J(t,">= 0",Gt,"maximum"),this.Xh=t,this.actual=this.j,this.panel!==null&&this.panel.c(),this.t("maximum",e,t))}get alignment(){return this.de}set alignment(t){let e=this.de;e.equals(t)||(this.de=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",e,t))}get stretch(){return this.ho}set stretch(t){let e=this.ho;e!==t&&(this.ho=t,this.panel!==null&&this.panel.c(),this.t("stretch",e,t))}get separatorPadding(){return this.al}set separatorPadding(t){typeof t=="number"&&(t=new Dt(t));let e=this.al;(t===null||e===null||!e.equals(t))&&(t!==null&&(t=t.N()),this.al=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",e,t))}get separatorStroke(){return this.Ed}set separatorStroke(t){let e=this.Ed;e!==t&&(t!==null&&E.Sd(t,"RowColumnDefinition.separatorStroke"),t instanceof E&&t.b(),this.Ed=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",e,t))}get separatorStrokeWidth(){return this.Ud}set separatorStrokeWidth(t){let e=this.Ud;e!==t&&(this.Ud=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",e,t))}get separatorDashArray(){return this.Gh}set separatorDashArray(t){let e=this.Gh;if(e!==t){if(t!==null&&!Array.isArray(t)&&g.si(t,"Array",Gt,"separatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&g.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.Gh=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",e,t)}}get background(){return this.Lt}set background(t){let e=this.Lt;e!==t&&(t!==null&&E.Sd(t,"RowColumnDefinition.background"),t instanceof E&&t.b(),this.Lt=t,this.panel!==null&&this.panel.C(),this.t("background",e,t))}get coversSeparators(){return this.Vd}set coversSeparators(t){let e=this.Vd;e!==t&&(g.s(t,"boolean",Gt,"coversSeparators"),this.Vd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",e,t))}get sizing(){return this.Id}set sizing(t){let e=this.Id;e!==t&&(this.Id=t,this.panel!==null&&this.panel.c(),this.t("sizing",e,t))}j1(){if(this.sizing===1){let t=this.Zs;return t===null?2:this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.j}set actual(t){isNaN(this.bi)?this.j=Math.max(Math.min(this.Xh,t),this.zh):this.j=Math.max(Math.min(this.Xh,this.bi),this.zh)}get measured(){return this.Re}set measured(t){this.Re=t}get total(){return this.j+this.computeEffectiveSpacing()}get position(){return this.ct}set position(t){this.ct=t}bind(t,e,i,s){return this.Pf(t,e,i,s),this}bindTwoWay(t,e,i,s){let n=this.Pf(t,e,i,s);return s===void 0&&n.makeTwoWay(),this}theme(t,e,i,s,n){return this.Na(t,e,i,s,n),this}themeData(t,e,i,s,n){return this.Na(t,e,i,s,n).ofData(),this}themeObject(t,e,i,s,n,o){return this.Na(t,e,i,s,n).ofObject(o),this}themeModel(t,e,i,s,n){return this.Na(t,e,i,s,n).ofModel(),this}Pf(t,e,i,s){let n;return typeof t=="string"?n=new re(t,e,i,s):n=t,this.y0(n),n}Na(t,e,i,s,n){let o;return typeof t=="string"?o=new bi(t,e,i,s,n):o=t,this.y0(o),o}y0(t){t.Ti=this;let e=this.panel;if(e!==null){let i=e.findBindingPanel();i!==null&&i.oD()&&g.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+e)}this.Rs===null&&(this.Rs=new U),this.Rs.add(t)}}class at extends tt{ut;en;Bd;Yh;Qe;Qo;Wo;Kt;zd;Xd;K;constructor(t,e){super(),this.ut=null,this.en=null,this.Bd="None",this.Yh="black",this.Qe="black",this.Qo=1,this.Wo=null,this.Kt=null,this.zd=NaN,this.Xd=NaN,this.K=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.ut=this.ut,t.en=this.en,t.Bd=this.Bd,t.Yh=this.Yh,t.Qe=this.Qe,t.Qo=this.Qo,this.Wo!==null&&(t.Wo=this.Wo.slice()),this.Kt!==null&&(this.Kt.me?t.Kt=this.Kt:t.Kt=this.Kt.copy()),t.zd=this.zd,t.Xd=this.Xd,this.K!==null&&(t.K=this.K.copy())}Kh(){return this.Kt===null?this.Kt=new Ps:this.Kt.me&&(this.Kt=this.Kt.copy()),this.Kt}ba(){super.ba(),this.Kt!==null&&(this.Kt.me=!0)}fe(t){t in ys?this.geometryStretch=t:super.fe(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+I.xs(this)}QI(t,e){let i=this.pathPattern;if(i===null)return;i.ht(1/0,1/0);let s=i.measuredBounds;i.Ut(0,0,s.width,s.height);let n=this.geometry;if(n===null)return;t.save(),t.beginPath();let o=g.ot();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Gd(t,e,o,i);else if(n.type===4){let r=n.figures.iterator;for(;r.next();){let a=r.value;o.length=0,o.push(a.startX),o.push(a.startY);let h=a.startX,l=a.startY,c=h,u=l,d=a.segments.r,f=d.length;for(let p=0;p<f;p++){let m=d[p];switch(m.type){case 1:this.Gd(t,e,o,i),o.length=0,o.push(m.endX),o.push(m.endY),h=m.endX,l=m.endY,c=h,u=l;break;case 2:o.push(m.endX),o.push(m.endY),h=m.endX,l=m.endY;break;case 3:A.Wn(h,l,m.point1X,m.point1Y,m.point2X,m.point2Y,m.endX,m.endY,.5,o),h=m.endX,l=m.endY;break;case 4:A.sm(h,l,m.point1X,m.point1Y,m.endX,m.endY,.5,o),h=m.endX,l=m.endY;break;case 5:{let y=m.Fo(a),b=y.length;if(b===0){o.push(m.centerX),o.push(m.centerY),h=m.centerX,l=m.centerY;break}for(let v=0;v<b;v++){let w=y[v];A.Wn(h,l,w[2],w[3],w[4],w[5],w[6],w[7],.5,o),h=w[6],l=w[7]}break}case 6:{let y=m.Ja(a,h,l),b=y.length;if(b===0){o.push(m.endX),o.push(m.endY),h=m.endX,l=m.endY;break}for(let v=0;v<b;v++){let w=y[v];A.Wn(h,l,w[2],w[3],w[4],w[5],w[6],w[7],.5,o),h=w[6],l=w[7]}break}default:g.o("Segment not of valid type: "+m.type)}m.isClosed&&(o.push(c),o.push(u),this.Gd(t,e,o,i))}this.Gd(t,e,o,i)}}else if(n.type===2)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.startY),o.push(n.endX),o.push(n.endY),o.push(n.startX),o.push(n.endY),o.push(n.startX),o.push(n.startY),this.Gd(t,e,o,i);else if(n.type===3){let r=new jt;r.startX=n.endX,r.startY=(n.startY+n.endY)/2;let a=new xt(5);a.startAngle=0,a.sweepAngle=360,a.centerX=(n.startX+n.endX)/2,a.centerY=(n.startY+n.endY)/2,a.radiusX=Math.abs(n.startX-n.endX)/2,a.radiusY=Math.abs(n.startY-n.endY)/2,r.add(a);let h=a.Fo(r),l=h.length;if(l===0)o.push(a.centerX),o.push(a.centerY);else{let c=r.startX,u=r.startY;for(let d=0;d<l;d++){let f=h[d];A.Wn(c,u,f[2],f[3],f[4],f[5],f[6],f[7],.5,o),c=f[6],u=f[7]}}this.Gd(t,e,o,i)}g.Z(o),t.restore(),t.clearContextCache(!1)}_I(t){let e=t.measuredBounds.width;return t instanceof at&&(e-=t.strokeWidth),e<1&&(e=1),e}Gd(t,e,i,s){let n=i.length;if(n<4)return;let o=s.measuredBounds,r=Math.max(1,o.width),a=o.height,h=i[0],l=i[1],c=0,u=0,d=0,f=0,p=0,m=0,y=0,b=0,v=g.ot();for(let L=2;L<n;L+=2)c=i[L],u=i[L+1],d=c-h,f=u-l,d===0&&(d=.001),p=f/d,m=Math.atan2(f,d),y=Math.sqrt(d*d+f*f),v.push([d,m,p,y]),b+=y,h=c,l=u;h=i[0],l=i[1];let w=this._I(s),k=w,S=r/2,M=S!==0,F=0,D=v[F];d=D[0],m=D[1],p=D[2],y=D[3];let N=0;for(;b>=.1;){if(N===0&&(M?(k=w,k-=S,b-=S,M=!1):k=w,k===0&&(k=1)),k>b){k=b,g.Z(v);return}k>y?(N=k-y,k=y):N=0;let L=Math.sqrt(k*k/(1+p*p));if(d<0&&(L=-L),h+=L,l+=p*L,t.translate(h,l),t.rotate(m),t.translate(-(r/2),-(a/2)),N===0&&s.Ma(t,e),t.translate(r/2,a/2),t.rotate(-m),t.translate(-h,-l),b-=k,y-=k,N!==0){if(F++,F===v.length){g.Z(v);return}D=v[F],d=D[0],m=D[1],p=D[2],y=D[3],k=N}}g.Z(v)}Ma(t,e){let i=t instanceof ge,s=this.Qe,n=this.Yh;if(s===null&&n===null)return;let o=this.ut;if(o===null)return;t.commitTransform();let r=this.actualBounds,a=this.naturalBounds;n!==null&&this.kn(t,n,!0,!1,a,r);let h=this.part,l=this.Qo;s!==null&&l===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(l=h.tE()),l===0&&(s=null),s!==null&&l!==0&&(this.kn(t,s,!1,!1,a,r),t.lineWidth=l,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&e.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.rl===!1&&(c=!1);let u=!0;s!==null&&(n===null||n==="transparent")&&(u=!1);let d=!1,f=this.strokeDashArray;if(f!==null&&(d=!0,t.enableDash(f,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){let p=o.startX,m=o.startY,y=o.endX,b=o.endY,v=Math.min(p,y),w=Math.min(m,b),k=Math.abs(y-p),S=Math.abs(b-m);t.beginPath(),t.rect(v,w,k,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(u&&c&&t.shadowsOff(),t.strokeContext(),u&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){let p=o.startX,m=o.startY,y=o.endX,b=o.endY,v=Math.abs(y-p)/2,w=Math.abs(b-m)/2,k=Math.min(p,y)+v,S=Math.min(m,b)+w;t.beginPath(),t.moveTo(k,S-w),t.bezierCurveTo(k+A.qn*v,S-w,k+v,S-A.qn*w,k+v,S),t.bezierCurveTo(k+v,S+A.qn*w,k+A.qn*v,S+w,k,S+w),t.bezierCurveTo(k-A.qn*v,S+w,k-v,S+A.qn*w,k-v,S),t.bezierCurveTo(k-v,S-A.qn*w,k-A.qn*v,S-w,k,S-w),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(u&&c&&t.shadowsOff(),t.strokeContext(),u&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){let p=o.figures,m=p.length;for(let y=0;y<m;y++){let b=p.r[y];i?(t.beginPath(),this.PD(t,b)):b.ji===null&&(b.ji=new Path2D,this.PD(b.ji,b));let v=b.isFilled;c?b.isShadowed?(v===!0&&n!=="transparent"&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&(v&&u&&t.shadowsOff(),t.stroke(b.ji),v&&u&&t.shadowsOn())):(t.shadowsOff(),v&&n!=="transparent"&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&t.stroke(b.ji),t.shadowsOn()):(v&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&t.stroke(b.ji)),t.endPath(y)}}d&&t.disableDash(),this.QI(t,e)}PD(t,e){t.moveTo(e.startX,e.startY);let i=e.segments.r,s=i.length,n=null;for(let o=0;o<s;o++){let r=i[o];switch(r.type){case 1:t.moveTo(r.endX,r.endY);break;case 2:t.lineTo(r.endX,r.endY);break;case 3:t.bezierCurveTo(r.point1X,r.point1Y,r.point2X,r.point2Y,r.endX,r.endY);break;case 4:t.quadraticCurveTo(r.point1X,r.point1Y,r.endX,r.endY);break;case 5:if(r.radiusX===r.radiusY){let a=n!==null?n.endX:e.startX,h=n!==null?n.endY:e.startY,l=Math.PI/180;t.arc(r.point1X,r.point1Y,r.radiusX,r.startAngle*l,(r.startAngle+r.sweepAngle)*l,r.sweepAngle<0,a,h)}else{let a=r.Fo(e),h=a.length;if(h===0){t.lineTo(r.centerX,r.centerY);break}for(let l=0;l<h;l++){let c=a[l];l===0&&t.lineTo(c[0],c[1]),t.bezierCurveTo(c[2],c[3],c[4],c[5],c[6],c[7])}}break;case 6:{let a=0,h=0,l;if(n!==null&&n.type===5){l=n.Fo(e);let u=l.length;if(u===0){t.lineTo(r.endX,r.endY);break}let d=l[u-1]||null;d!==null&&(a=d[6],h=d[7])}else a=n!==null?n.endX:e.startX,h=n!==null?n.endY:e.startY;l=r.Ja(e,a,h);let c=l.length;if(c===0){t.lineTo(r.endX,r.endY);break}for(let u=0;u<c;u++){let d=l[u];t.bezierCurveTo(d[2],d[3],d[4],d[5],d[6],d[7])}break}}r.isClosed&&t.closePath(),n=r}}yf(t,e,i){if(!super.yf(t,e,i)||this.Qe===null&&this.Yh===null||this.ut===null||this.pathPattern!==null)return!1;let s=this.svg.getElementsByTagName("path");return this.geometry.figures.length!==s.length?!1:(t.currentPath=this.svg,this.Ma(t,e),t.currentPath=null,!0)}kd(t){return this.geometry!==null&&this.geometry.figures.length>1||this.pathPattern!==null?!0:super.kd(t)}LN(t,e){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",e);else{let i=t.getElementsByTagName("path");for(let s=0;s<i.length;s++)i[s].setAttributeNS(null,"filter",e)}}getDocumentPoint(t,e){if(e===void 0&&(e=new P),t instanceof T){let i=t;i.isNoSpot()&&g.o("getDocumentPoint Spot must be a real, specific Spot, not: "+i.toString());let s=this.naturalBounds,n=this.strokeWidth;return e.e(i.x*(s.width+n)-n/2+s.x+i.offsetX,i.y*(s.height+n)-n/2+s.y+i.offsetY),this.Js.gt(e),e}else return e.set(t),this.Js.gt(e),e}getDocumentBounds(t){t===void 0&&(t=new B);let e=this.naturalBounds,i=this.Js,s=B.z(e.x,e.y,e.width,e.height),n=this.strokeWidth;s.inflate(n/2,n/2);let o=P.z(s.x,s.y).v(i);return t.e(o.x,o.y,0,0),o.e(s.right,s.y).v(i),t.re(o.x,o.y,0,0),o.e(s.right,s.bottom).v(i),t.re(o.x,o.y,0,0),o.e(s.x,s.bottom).v(i),t.re(o.x,o.y,0,0),B.i(s),P.i(o),t}ka(t,e){let i=this.geometry;if(i===null||this.fill===null&&this.stroke===null)return!1;let s=i.bounds,n=this.strokeWidth/2;i.type===1&&!e&&(n+=2);let o=B.l();if(o.h(s),o.inflate(n+2,n+2),!o.containsPoint(t))return B.i(o),!1;let r=n+1e-4;if(i.type===1){if(this.stroke===null)return!1;let a=(i.startX-i.endX)*(t.x-i.endX)+(i.startY-i.endY)*(t.y-i.endY),h=(i.endX-i.startX)*(t.x-i.startX)+(i.endY-i.startY)*(t.y-i.startY);return a<0||h<0?!1:(B.i(o),A.Ve(i.startX,i.startY,i.endX,i.endY,n,t.x,t.y))}else if(i.type===2){let a=i.startX,h=i.startY,l=i.endX,c=i.endY;if(o.x=Math.min(a,l),o.y=Math.min(h,c),o.width=Math.abs(l-a),o.height=Math.abs(c-h),this.fill===null){if(o.inflate(-r,-r),o.containsPoint(t))return B.i(o),!1;o.inflate(r,r)}this.stroke!==null&&o.inflate(n,n);let u=o.containsPoint(t);return B.i(o),u}else if(i.type===3){let a=i.startX,h=i.startY,l=i.endX,c=i.endY,u=Math.min(a,l),d=Math.min(h,c),f=Math.abs(l-a),p=Math.abs(c-h),m=f/2,y=p/2;if(u=t.x-(u+m),d=t.y-(d+y),this.fill===null){if(m-=r,y-=r,m<=0||y<=0||u*u/(m*m)+d*d/(y*y)<=1)return B.i(o),!1;m+=r,y+=r}return this.stroke!==null&&(m+=r,y+=r),B.i(o),m<=0||y<=0?!1:u*u/(m*m)+d*d/(y*y)<=1}else{if(i.type===4)return B.i(o),this.fill===null?i.ZL(t.x,t.y,n):i.UP(t,n,this.strokeWidth>1,e);g.o("Unknown Geometry type: "+i.type)}}xd(t,e,i,s){let n=this.desiredSize,o=this.Qo;t=Math.max(t,0),e=Math.max(e,0);let r;if(this.en!==null)r=this.geometry.bounds;else{let p=this.figure,m=at.iC[p];if(m===void 0){let y=A.Jn[p];typeof y=="string"&&(y=A.Jn[y]),g.nt(y)?(m=y(null,100,100),at.iC[p]=m):g.o("Unsupported Figure: "+p)}r=m.bounds}let a=r.width,h=r.height,l=r.width,c=r.height;switch(this.Qs(!0)){case 0:i=0,s=0;break;case 2:l=Math.max(t-o,0),c=Math.max(e-o,0);break;case 5:l=Math.max(t-o,0),s=0;break;case 4:i=0,c=Math.max(e-o,0);break}isFinite(n.width)&&(l=n.width),isFinite(n.height)&&(c=n.height);let u=this.maxSize,d=this.minSize;i=Math.max(i-o,d.width),s=Math.max(s-o,d.height),l=Math.min(u.width,l),c=Math.min(u.height,c),l=isFinite(l)?Math.max(i,l):Math.max(a,i),c=isFinite(c)?Math.max(s,c):Math.max(h,s);let f=this.QS();switch(f){case 0:break;case 2:a=l,h=c;break;case 6:{let p=Math.min(l/a,c/h);isFinite(p)||(p=1),a=a*p,h=h*p;break}default:g.o(f+" is not a valid geometryStretch.")}if(this.en!==null){a===0&&(a=.001),h===0&&(h=.001);let p=this.en.sR(a,h);this.ut=p}else(this.ut===null||!A.X(this.ut.Pc,t-o)||!A.X(this.ut.Sc,e-o))&&(this.ut=at.eE(this,a,h));r=this.ut.bounds,t===1/0||e===1/0?this.lo(r.x-o/2,r.y-o/2,t===0&&a===0?0:r.width+o,e===0&&h===0?0:r.height+o):this.lo(-(o/2),-(o/2),l+o,c+o),n.isReal()?(l=n.width,c=n.height,l=Math.min(u.width,l),c=Math.min(u.height,c),l=Math.max(d.width,l),c=Math.max(d.height,c),this.Ke.e(0,0,l,c)):this.Ke.h(r)}QS(){let t=this.geometryStretch;return this.en!==null?t===1?2:t:t===1?at.iC[this.figure].defaultStretch:t}Pa(t,e,i,s){this.commonArrange(t,e,i,s)}getNearestIntersectionPoint(t,e,i){return this.mf(t.x,t.y,e.x,e.y,i)}mf(t,e,i,s,n){let o=this.v,r=1/(o.m11*o.m22-o.m12*o.m21),a=o.m22*r,h=-o.m12*r,l=-o.m21*r,c=o.m11*r,u=r*(o.m21*o.dy-o.m22*o.dx),d=r*(o.m12*o.dx-o.m11*o.dy),f=t*a+e*l+u,p=t*h+e*c+d,m=i*a+s*l+u,y=i*h+s*c+d,b=this.Qo/2,v=this.ut;v===null&&(this.ht(1/0,1/0),v=this.ut);let w=v.bounds,k=!1;if(v.type===1)if(this.strokeWidth<=1.5)k=A.vo(v.startX,v.startY,v.endX,v.endY,f,p,m,y,n);else{let S=0,M=0;if(v.startX===v.endX)S=b,M=0;else{let R=(v.endY-v.startY)/(v.endX-v.startX);M=b/Math.sqrt(1+R*R),S=M*R}let F=g.ot(),D=new P;A.vo(v.startX+S,v.startY+M,v.endX+S,v.endY+M,f,p,m,y,D)&&F.push(D),D=new P,A.vo(v.startX-S,v.startY-M,v.endX-S,v.endY-M,f,p,m,y,D)&&F.push(D),D=new P,A.vo(v.startX+S,v.startY+M,v.startX-S,v.startY-M,f,p,m,y,D)&&F.push(D),D=new P,A.vo(v.endX+S,v.endY+M,v.endX-S,v.endY-M,f,p,m,y,D)&&F.push(D);let N=F.length;if(N===0)return g.Z(F),!1;k=!0;let L=1/0;for(let R=0;R<N;R++){let O=F[R],V=(O.x-f)**2+(O.y-p)**2;V<L&&(L=V,n.x=O.x,n.y=O.y)}g.Z(F)}else if(v.type===2)k=A.Cl(w.x-b,w.y-b,w.x+w.width+b,w.y+w.height+b,f,p,m,y,n);else if(v.type===3){let S=B.z(w.x,w.y,w.width,w.height).inflate(b,b);k=this.iE(S,f,p,m,y,n),B.i(S)}else if(v.type===4){let S=0,M=0,F=0,D=0,N=P.l(),L=m-f,R=y-p,O=L*L+R*R,V=f,K=p;if(O>0&&w.contains(V,K)&&(N.x=V,N.y=K,this.containsPoint(N)))for(L!==0&&Math.abs(L)<.5?(R*=.5/L,L=.5):R!==0&&Math.abs(R)<.5&&(L*=.5/R,R=.5),V-=L,K-=R;w.contains(V,K);)V-=L,K-=R;let Y=.6;n.x=m,n.y=y;for(let lt=0;lt<v.figures.count;lt++){let st=v.figures.r[lt],ht=st.isFilled?V:f,ot=st.isFilled?K:p,dt=st.segments;S=st.startX,M=st.startY;let pt=S,vt=M;for(let Ct=0;Ct<dt.count;Ct++){let nt=dt.r[Ct],Nt=nt.type;F=nt.endX,D=nt.endY;let kt=!1;switch(Nt){case 1:pt=F,vt=D;break;case 2:kt=this.Q1(S,M,F,D,ht,ot,m,y,N);break;case 3:{kt=A.nm(S,M,nt.point1X,nt.point1Y,nt.point2X,nt.point2Y,F,D,ht,ot,m,y,Y,N);break}case 4:{kt=A.nm(S,M,S+2/3*(nt.point1X-S),M+2/3*(nt.point1Y-M),F+2/3*(nt.point1X-F),D+2/3*(nt.point1Y-D),F,D,ht,ot,m,y,Y,N);break}case 5:case 6:{let qt=nt.type===5?nt.Fo(st):nt.Ja(st,S,M),ut=qt.length;if(ut===0){kt=this.Q1(S,M,nt.type===5?nt.centerX:nt.endX,nt.type===5?nt.centerY:nt.endY,ht,ot,m,y,N);break}let Q=null;for(let yt=0;yt<ut;yt++){if(Q=qt[yt],yt===0&&this.Q1(S,M,Q[0],Q[1],ht,ot,m,y,N)){let At=this._1(ht,ot,N,O,n);At<O&&(O=At,k=!0)}if(A.nm(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5],Q[6],Q[7],ht,ot,m,y,Y,N)){let At=this._1(ht,ot,N,O,n);At<O&&(O=At,k=!0)}}F=Q[6],D=Q[7];break}default:g.o("Unknown Segment type: "+Nt)}if(S=F,M=D,kt){let qt=this._1(ht,ot,N,O,n);qt<O&&(O=qt,k=!0)}if(nt.isClosed&&(F=pt,D=vt,this.Q1(S,M,F,D,ht,ot,m,y,N))){let qt=this._1(ht,ot,N,O,n);qt<O&&(O=qt,k=!0)}}}let X=i-t,G=s-e,rt=Math.sqrt(X*X+G*G);rt!==0&&(X/=rt,G/=rt),n.x-=X*b,n.y-=G*b,P.i(N)}else g.o("Unknown Geometry type: "+v.type);return k?(this.v.gt(n),!0):!1}_1(t,e,i,s,n){let o=i.x-t,r=i.y-e,a=o*o+r*r;return a<s?(n.x=i.x,n.y=i.y,a):s}Q1(t,e,i,s,n,o,r,a,h){if(A.X(t,i)&&A.X(e,s)||A.X(n,r)&&A.X(o,a))return!1;let l=!1,c=(n-r)*(e-s)-(o-a)*(t-i);if(c===0)return!1;if(h.x=((n*a-o*r)*(t-i)-(n-r)*(t*s-e*i))/c,h.y=((n*a-o*r)*(e-s)-(o-a)*(t*s-e*i))/c,(t>i?t-i:i-t)<(e>s?e-s:s-e)){let u=e<s?e:s,d=e<s?s:e;(h.y>u||A.X(h.y,u))&&(h.y<d||A.X(h.y,d))&&(l=!0)}else{let u=t<i?t:i,d=t<i?i:t;(h.x>u||A.X(h.x,u))&&(h.x<d||A.X(h.x,d))&&(l=!0)}return l}sE(t,e,i){return this.pickable===!1?!1:(i.bc(this.v),e?this.nE(t,i):this.containedInRect(t,i))}containedInRect(t,e){if(e===void 0)return t.containsRect(this.actualBounds);let i=this.ut;i===null&&(this.ht(1/0,1/0),i=this.ut);let s=i.bounds,n=this.strokeWidth/2,o=!1,r=P.l();return r.e(s.x-n,s.y-n),t.containsPoint(e.gt(r))&&(r.e(s.x-n,s.bottom+n),t.containsPoint(e.gt(r))&&(r.e(s.right+n,s.bottom+n),t.containsPoint(e.gt(r))&&(r.e(s.right+n,s.y-n),t.containsPoint(e.gt(r))&&(o=!0)))),P.i(r),o}intersectsRect(t,e){if(this.containedInRect(t,e)||e===void 0&&(e=this.v,t.containsRect(this.actualBounds)))return!0;let i=Pt.l();i.set(e),i.tx();let s=t.left,n=t.right,o=t.top,r=t.bottom,a=P.l();if(a.e(s,o),i.gt(a),this.ka(a,!0)||(a.e(n,o),i.gt(a),this.ka(a,!0))||(a.e(s,r),i.gt(a),this.ka(a,!0))||(a.e(n,r),i.gt(a),this.ka(a,!0)))return P.i(a),!0;let h=P.l(),l=P.l();i.set(e),i.zL(this.v),i.tx(),h.x=n,h.y=o,h.v(i),a.x=s,a.y=o,a.v(i);let c=!1;return this.Hh(a,h,l)?c=!0:(a.x=n,a.y=r,a.v(i),this.Hh(a,h,l)?c=!0:(h.x=s,h.y=r,h.v(i),this.Hh(a,h,l)?c=!0:(a.x=s,a.y=o,a.v(i),this.Hh(a,h,l)&&(c=!0)))),P.i(a),Pt.i(i),P.i(h),P.i(l),c}Hh(t,e,i){if(!this.getNearestIntersectionPoint(t,e,i))return!1;let s=t.x,n=t.y,o=e.x,r=e.y,a=i.x,h=i.y;if(s===o){let l=0,c=0;return n<r?(l=n,c=r):(l=r,c=n),h>=l&&h<=c}else{let l=0,c=0;return s<o?(l=s,c=o):(l=o,c=s),a>=l&&a<=c}}nE(t,e){if(this.containedInRect(t,e)||e===void 0&&(e=this.v,t.containsRect(this.actualBounds)))return!0;let i=t.left,s=t.right,n=t.top,o=t.bottom,r=P.l(),a=P.l(),h=P.l(),l=Pt.l();l.set(e),l.zL(this.v),l.tx(),a.x=s,a.y=n,a.v(l),r.x=i,r.y=n,r.v(l);let c=!1;return this.Hh(r,a,h)?c=!0:(r.x=s,r.y=o,r.v(l),this.Hh(r,a,h)?c=!0:(a.x=i,a.y=o,a.v(l),this.Hh(r,a,h)?c=!0:(r.x=i,r.y=n,r.v(l),this.Hh(r,a,h)&&(c=!0)))),Pt.i(l),P.i(r),P.i(a),P.i(h),c}$T(t,e,i){if(i&&this.fill!==null&&this.ka(t,!0))return!0;let s=t.distanceSquaredPoint(e),n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ut;if(o===null&&(this.ht(1/0,1/0),o=this.ut,o===null))return!1;if(!i){let u=o.bounds,d=u.x,f=u.y,p=u.x+u.width,m=u.y+u.height;if(P.distanceSquared(t.x,t.y,d,f)<=s&&P.distanceSquared(t.x,t.y,p,f)<=s&&P.distanceSquared(t.x,t.y,d,m)<=s&&P.distanceSquared(t.x,t.y,p,m)<=s)return!0}function r(u,d){let f=u.length;for(let p=0;p<f;p+=2)if(d.distanceSquared(u[p],u[p+1])>s)return!0;return!1}let a=o.startX,h=o.startY,l=o.endX,c=o.endY;if(o.type===1){let u=P.distanceLineSegmentSquared(t.x,t.y,a,h,l,c),d=(l-a)*(t.x-a)+(c-h)*(t.y-h),f=(a-l)*(t.x-l)+(h-c)*(t.y-c),p=d>=0&&f>=0?s:n;return u<=p}else if(o.type===2){let u=!1;return i&&(u=P.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||P.distanceLineSegmentSquared(t.x,t.y,a,h,l,h)<=s||P.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||P.distanceLineSegmentSquared(t.x,t.y,a,c,l,c)<=s),u}else if(o.type===3){let u=(a+l)/2,d=(h+c)/2,f=t.x-u,p=t.y-d,m=Math.abs(l-a)/2,y=Math.abs(c-h)/2;if(m===0||y===0)return P.distanceLineSegmentSquared(t.x,t.y,a,h,l,c)<=s;if(i){let b=A.WF(m,y,f,p);return b*b<=s}else return!(P.distanceSquared(f,p,-m,0)>=s||P.distanceSquared(f,p,0,-y)>=s||P.distanceSquared(f,p,0,y)>=s||P.distanceSquared(f,p,m,0)>=s)}else if(o.type===4){let u=o.bounds,d=u.x,f=u.y,p=u.x+u.width,m=u.y+u.height;if(t.x>p&&t.x<d&&t.y>m&&t.y<f&&P.distanceLineSegmentSquared(t.x,t.y,d,f,d,m)>s&&P.distanceLineSegmentSquared(t.x,t.y,d,f,p,f)>s&&P.distanceLineSegmentSquared(t.x,t.y,p,m,d,m)>s&&P.distanceLineSegmentSquared(t.x,t.y,p,m,p,f)>s)return!1;let y=Math.sqrt(s);if(i){if(this.fill===null?o.ZL(t.x,t.y,y):o.UP(t,y,!0,!1))return!0}else{let b=o.figures;for(let v=0;v<b.count;v++){let w=b.r[v],k=w.startX,S=w.startY;if(t.distanceSquared(k,S)>s)return!1;let M=w.segments.r,F=M.length;for(let D=0;D<F;D++){let N=M[D];switch(N.type){case 1:case 2:if(k=N.endX,S=N.endY,t.distanceSquared(k,S)>s)return!1;break;case 3:{let L=g.ot();A.Wn(k,S,N.point1X,N.point1Y,N.point2X,N.point2Y,N.endX,N.endY,.8,L);let R=r(L,t);if(g.Z(L),R||(k=N.endX,S=N.endY,t.distanceSquared(k,S)>s))return!1;break}case 4:{let L=g.ot();A.sm(k,S,N.point1X,N.point1Y,N.endX,N.endY,.8,L);let R=r(L,t);if(g.Z(L),R||(k=N.endX,S=N.endY,t.distanceSquared(k,S)>s))return!1;break}case 5:case 6:{let L=N.type===5?N.Fo(w):N.Ja(w,k,S),R=L.length;if(R===0){if(k=N.type===5?N.centerX:N.endX,S=N.type===5?N.centerY:N.endY,t.distanceSquared(k,S)>s)return!1;break}let O=null,V=g.ot();for(let K=0;K<R;K++)if(O=L[K],V.length=0,A.Wn(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],.8,V),r(V,t))return g.Z(V),!1;g.Z(V),O!==null&&(k=O[6],S=O[7]);break}default:g.o("Unknown Segment type: "+N.type)}}}return!0}}return!1}iE(t,e,i,s,n,o){if(t.width===0)return A.vo(t.x,t.y,t.x,t.y+t.height,e,i,s,n,o);if(t.height===0)return A.vo(t.x,t.y,t.x+t.width,t.y,e,i,s,n,o);{let r=t.width/2,a=t.height/2,h=t.x+r,l=t.y+a,c=9999;if(e!==s&&(c=(i-n)/(e-s)),Math.abs(c)<9999){let u=i-l-c*(e-h);if(r*r*(c*c)+a*a-u*u<0)return o.x=NaN,o.y=NaN,!1;let d=Math.sqrt(r*r*(c*c)+a*a-u*u),f=(-(r*r*c*u)+r*a*d)/(a*a+r*r*(c*c))+h,p=(-(r*r*c*u)-r*a*d)/(a*a+r*r*(c*c))+h,m=c*(f-h)+u+l,y=c*(p-h)+u+l,b=Math.abs((e-f)**2)+Math.abs((i-m)**2),v=Math.abs((e-p)**2)+Math.abs((i-y)**2);b<v?(o.x=f,o.y=m):(o.x=p,o.y=y)}else{let u=a*a,d=r*r,f=e-h,p=u-u/d*(f*f);if(p<0)return o.x=NaN,o.y=NaN,!1;let m=Math.sqrt(p),y=l+m,b=l-m,v=Math.abs(y-i),w=Math.abs(b-i);v<w?(o.x=e,o.y=y):(o.x=e,o.y=b)}return!0}}jI(){return this.Qo/2*this.strokeMiterLimit*this.getDocumentScale()}get geometry(){return this.ut!==null?this.ut:this.en}set geometry(t){let e=this.ut,i=this.en;if(e===t)return;t!==null?(this.ut=t.b(),this.en=this.ut):(this.ut=null,this.en=null);let s=this.part;if(s!==null&&s.Tf(),this.c(),this.t("geometry",e||i,t),this.gf()){let n=this.part;n!==null&&this.Oh(n,"geometryString")}}get geometryString(){return this.geometry===null?"":this.geometry.toString()}set geometryString(t){let e=St.parse(t),i=e.normalize();this.geometry=e;let s=P.z(-i.x,-i.y);this.position=s,P.i(s)}get isGeometryPositioned(){return(this.n&1048576)!==0}set isGeometryPositioned(t){let e=(this.n&1048576)!==0;e!==t&&(this.n=this.n^1048576,this.c(),this.t("isGeometryPositioned",e,t))}Ze(){this.ut=null}get fill(){return this.Yh}set fill(t){let e=this.Yh;e!==t&&(t!==null&&E.Sd(t,"Shape.fill"),t instanceof E&&t.b(),this.Yh=t,this.C(),this.t("fill",e,t))}get stroke(){return this.Qe}set stroke(t){let e=this.Qe;e!==t&&(t!==null&&E.Sd(t,"Shape.stroke"),t instanceof E&&t.b(),this.Qe=t,this.C(),this.t("stroke",e,t))}get strokeWidth(){return this.Qo}set strokeWidth(t){let e=this.Qo;if(e!==t)if(t>=0){this.Qo=t,this.c();let i=this.part;i!==null&&i.Tf(),this.t("strokeWidth",e,t)}else g.J(t,"value >= 0",at,"strokeWidth:value")}Hp(){return this.Qo}get strokeCap(){return this.Kt!==null?this.Kt.G0:"butt"}set strokeCap(t){let e=this.strokeCap;e!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Kh().G0=t,this.C(),this.t("strokeCap",e,t)):g.J(t,'"butt", "round", or "square"',at,"strokeCap"))}get strokeJoin(){return this.Kt!==null?this.Kt.Y0:"miter"}set strokeJoin(t){let e=this.strokeJoin;e!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Kh().Y0=t,this.C(),this.t("strokeJoin",e,t)):g.J(t,'"miter", "bevel", or "round"',at,"strokeJoin"))}get strokeMiterLimit(){return this.Kt!==null?this.Kt.K0:10}set strokeMiterLimit(t){let e=this.strokeMiterLimit;if(e!==t&&t>=1){this.Kh().K0=t,this.C();let i=this.part;i!==null&&i.Tf(),this.t("strokeMiterLimit",e,t)}}get strokeDashArray(){return this.Wo}set strokeDashArray(t){let e=this.Wo;if(e!==t){if(t!==null&&!Array.isArray(t)&&g.si(t,"Array",at,"strokeDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(!(o>=0)||!isFinite(o))&&g.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.Wo=t,this.C(),this.t("strokeDashArray",e,t)}}get strokeDashOffset(){return this.Kt!==null?this.Kt.Ca:0}set strokeDashOffset(t){let e=this.strokeDashOffset;e!==t&&t>=0&&(this.Kh().Ca=t,this.C(),this.t("strokeDashOffset",e,t))}get figure(){return this.Bd}set figure(t){let e=this.Bd;if(e!==t){let i=A.Jn[t];if(g.nt(i)?i=t:(i=A.Jn[t.toLowerCase()],(!i||typeof i=="function")&&g.o("Unknown Shape.figure: "+t)),e!==i){let s=this.part;s!==null&&s.Tf(),this.Bd=i,this.en=null,this.Ze(),this.c(),this.t("figure",e,i)}}}get toArrow(){return this.Ot!==null?this.Ot.H0:"None"}set toArrow(t){let e=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),e!==t){let i=at.SD(t);i===null?g.o("Unknown Shape.toArrow: "+t):e!==i&&(this.Ot===null&&(this.Ot=new $e),this.Ot.H0=i,this.en=null,this.Ze(),this.c(),this.MD(i),this.t("toArrow",e,i))}}get fromArrow(){return this.Ot!==null?this.Ot.j0:"None"}set fromArrow(t){let e=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),e!==t){let i=at.SD(t);i===null?g.o("Unknown Shape.fromArrow: "+t):e!==i&&(this.Ot===null&&(this.Ot=new $e),this.Ot.j0=i,this.en=null,this.Ze(),this.c(),this.MD(i),this.t("fromArrow",e,i))}}MD(t){let e=this.diagram;e!==null&&e.undoManager.isUndoingRedoing||(this.gI(),this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=T.Right):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=T.Left))}get spot1(){return this.Kt!==null?this.Kt.$n:T.Default}set spot1(t){let e=this.spot1;e.equals(t)||(t=t.N(),this.Kh().$n=t,this.c(),this.t("spot1",e,t))}get spot2(){return this.Kt!==null?this.Kt.Zn:T.Default}set spot2(t){let e=this.spot2;e.equals(t)||(t=t.N(),this.Kh().Zn=t,this.c(),this.t("spot2",e,t))}get parameter1(){return this.zd}set parameter1(t){let e=this.zd;e!==t&&(this.zd=t,this.Ze(),this.c(),this.t("parameter1",e,t))}get parameter2(){return this.Xd}set parameter2(t){let e=this.Xd;e!==t&&(this.Xd=t,this.Ze(),this.c(),this.t("parameter2",e,t))}get naturalBounds(){return this.Ke}II(){let t=this.desiredSize;if(!t.isReal()&&this.ut!==null){let e=this.ut.bounds;this.Ke.h(e)}else this.Ke.e(0,0,t.width,t.height)}get pathPattern(){return this.Kt!==null?this.Kt.q0:null}set pathPattern(t){let e=this.pathPattern;e!==t&&(this.Kh().q0=t,this.C(),this.t("pathPattern",e,t))}get geometryStretch(){return this.Kt!==null?this.Kt.W0:1}set geometryStretch(t){let e=this.geometryStretch;e!==t&&(this.Kh().W0=t,this.c(),this.t("geometryStretch",e,t))}get interval(){return this.K!==null?this.K.vf:1}set interval(t){let e=this.interval;if(t=Math.round(t),e!==t&&t!==0&&isFinite(t)){this.K===null&&(this.K=new Le),this.K.vf=t;let i=this.diagram;i!==null&&this.panel===i.grid&&i.ca(),this.c();let s=this.panel;s!==null&&(s.ds=null),this.t("interval",e,t)}}get graduatedStart(){return this.K!==null?this.K.Ff:0}set graduatedStart(t){let e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new Le),this.K.Ff=t,this.c(),this.t("graduatedStart",e,t))}get graduatedEnd(){return this.K!==null?this.K.Rf:1}set graduatedEnd(t){let e=this.graduatedEnd;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new Le),this.K.Rf=t,this.c(),this.t("graduatedEnd",e,t))}get graduatedSkip(){return this.K!==null?this.K.Of:null}set graduatedSkip(t){let e=this.graduatedSkip;e!==t&&(t!==null&&g.S(t,at,"graduatedSkip"),this.K===null&&(this.K=new Le),this.K.Of=t,this.c(),this.t("graduatedSkip",e,t))}polygonContainsRect(t){let e=this;if(!e.part||!e.part.actualBounds.containsRect(t))return!1;let i=e.geometry;if(!i)return!1;let s=t.x,n=t.y,o=t.width,r=t.height,a=P.l();if(a.x=s,a.y=n,e.getLocalPoint(a,a),!i.containsPoint(a)||o>0&&r>0&&(a.x=s+o,a.y=n+r,e.getLocalPoint(a,a),!i.containsPoint(a))||o>0&&(a.x=s+o,a.y=n,e.getLocalPoint(a,a),!i.containsPoint(a))||r>0&&(a.x=s,a.y=n+r,e.getLocalPoint(a,a),!i.containsPoint(a))||i.type===1)return!1;if(i.type===4){let h=i.figures.iterator;for(;h.next();){let l=h.value;if(!l.isFilled)continue;a.x=l.startX,a.y=l.startY,e.getDocumentPoint(a,a);let c=a.x,u=a.y,d=c,f=u,p=c,m=u,y=l.segments.iterator;for(;y.next();){let b=y.value;if(a.x=b.endX,a.y=b.endY,e.getDocumentPoint(a,a),p=a.x,m=a.y,b.type===1)c=p,u=m;else if(b.type!==5&&(B.intersectsLineSegment(s,n,o,r,d,f,p,m)||b.isClosed&&B.intersectsLineSegment(s,n,o,r,p,m,c,u)))return!1;d=p,f=m}}}return P.i(a),!0}static eE(t,e,i){let s=null;if(t.toArrow!=="None")s=at.Dn[t.toArrow];else if(t.fromArrow!=="None")s=at.Dn[t.fromArrow];else{let n=A.Jn[t.figure];typeof n=="string"&&(n=A.Jn[n]),n===void 0&&g.o("Unknown Shape.figure: "+t.figure),s=n(t,e,i),s.Pc=e,s.Sc=i}if(s===null){let n=A.Jn.Rectangle;g.nt(n)&&(s=n(t,e,i))}return s}static getFigureGenerators(){let t=new wt;for(let e in A.Jn){if(e===e.toLowerCase())continue;let i=A.Jn[e];t.set(e,i)}return t.b(),t}static defineFigureGenerator(t,e){g.s(t,"string",at,"defineFigureGenerator:name"),typeof e=="string"||g.S(e,at,"defineFigureGenerator:func");let i=t.toLowerCase(),s=A.Jn;s[t]=e,s[i]=t}static isFigureDefined(t){return t in A.Jn}static getArrowheadGeometries(){let t=new wt;for(let e in A.rm)if(at.Dn[e]===void 0){let i=St.parse(A.rm[e],!1);at.Dn[e]=i;let s=e.toLowerCase();s!==e&&(at.Dn[s]=e)}for(let e in at.Dn){if(e===e.toLowerCase())continue;let i=at.Dn[e];i instanceof St&&t.set(e,i)}return t.b(),t}static defineArrowheadGeometry(t,e){g.s(t,"string",at,"defineArrowheadGeometry:name");let i=null;typeof e=="string"?(g.s(e,"string",at,"defineArrowheadGeometry:pathstr"),i=St.parse(e,!1)):i=e;let s=t.toLowerCase();(s==="none"||t===s)&&g.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);let n=at.Dn;n[t]=i,n[s]=t}static isArrowheadDefined(t){return at.Dn.has(t)}static Dn=new W;static iC=new W;static SD(t){let e=at.Dn[t];if(e===void 0){let i=t.toLowerCase();if(i==="none")return"None";if(e=at.Dn[i],e===void 0){let s=null;for(let n in A.rm)if(n.toLowerCase()===i){s=n;break}if(s!==null){let n=St.parse(A.rm[s],!1);return at.Dn[s]=n,i!==s&&(at.Dn[i]=s),s}}}return typeof e=="string"?e:e instanceof St?t:null}}class Ps{me;G0;Y0;K0;Ca;q0;W0;$n;Zn;constructor(){this.me=!1,this.G0="butt",this.Y0="miter",this.K0=10,this.Ca=0,this.q0=null,this.W0=1,this.$n=T.Default,this.Zn=T.Default}copy(){let t=new Ps;return t.G0=this.G0,t.Y0=this.Y0,t.K0=this.K0,t.Ca=this.Ca,t.q0=this.q0,t.W0=this.W0,t.$n=this.$n.N(),t.Zn=this.Zn.N(),t}}var Ss=(x=>(x[x.None=0]="None",x[x.Fit=1]="Fit",x[x.DesiredSize=2]="DesiredSize",x[x.BreakAll=3]="BreakAll",x))(Ss||{}),Fn=(x=>(x[x.Clip=0]="Clip",x[x.Ellipsis=1]="Ellipsis",x))(Fn||{}),Ms=(x=>(x[x.Trim=0]="Trim",x[x.None=1]="None",x))(Ms||{});class gt extends tt{ue;Qe;vn;ki;pe;jp;Yd;K;tt;Xl;go;Fn;Ii;ye;Rn;constructor(t,e){return super(),gt.S0===!1&&(gt.S0=!0,gt.us=j.isUsingDOM()?new He(null)._t:null),this.n|=2097152,this.ue="",this.Qe="black",this.vn="13px sans-serif",this.ki=0,this.pe=0,this.jp=0,this.Yd=null,this.K=null,this.tt=null,this.Xl=0,this.go=null,this.Fn=0,this.Ii=null,this.ye=null,this.Rn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),e&&Object.assign(this,e),this}cloneProtected(t){super.cloneProtected(t),t.ue=this.ue,t.Qe=this.Qe,t.vn=this.vn,t.ki=this.ki,t.pe=this.pe,t.jp=this.jp,t.Yd=this.Yd,this.K!==null&&(t.K=this.K.copy()),this.tt!==null&&(this.tt.me?t.tt=this.tt:t.tt=this.tt.copy()),t.Xl=this.Xl,t.go=this.go,t.Fn=this.Fn,t.Ii=this.Ii,t.ye=this.ye,t.Rn=this.Rn}Os(){return this.tt===null?this.tt=new Ns:this.tt.me&&(this.tt=this.tt.copy()),this.tt}ba(){super.ba(),this.tt!==null&&(this.tt.me=!0)}GI(t){this.n=t.n|2048|4096,this.Zt=t.opacity,this.Lt=t.background,this.cs=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.Se!==null?this.Se=t.Se.copy():this.Se=null,this.it=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.sl=t.margin.N(),this.de=t.alignment.N(),this.yd=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.he!==null&&(this.he=t.he.copy()),this.shadowVisible=t.shadowVisible,this.ue=t.ue,this.Qe=t.Qe,this.vn=t.vn,this.K!==null&&(this.K=t.K.copy()),t.tt!==null&&(t.tt.me?this.tt=t.tt:this.tt=t.tt.copy()),this.Xl=t.Xl}zI(t){if(this.ue=t.text||"",this.Xt=t.labelAngle||0,this.ki=t.lineCount||0,this.oE(t.lines),t.naturalBounds&&(this.Ke=t.naturalBounds),t.actualBounds){let e=t.actualBounds;this.Ut(e.x,e.y,e.width,e.height)}}fe(t){t in Ss?this.wrap=t:super.fe(t)}toString(){return this.ue.length>22?'TextBlock("'+this.ue.substring(0,20)+'"...)':'TextBlock("'+this.ue+'")'}static getEllipsis(){return gt.J0}static setEllipsis(t){gt.J0=t,gt.tk=new W,gt.sC=0}static getBaseline(){return gt.ek}static setBaseline(t){gt.ek=t}static ek=null;static getUnderline(){return gt.ik}static setUnderline(t){gt.ik=t}static ik=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c(),this.$i(!0)}get font(){return this.vn}set font(t){let e=this.vn;e!==t&&(this.vn=t,this.go=null,this.c(),this.t("font",e,t))}static isValidFont(t){return C.CSS?C.CSS.supports("font",t):!0}get text(){return this.ue}set text(t){let e=this.ue;t!=null?t=t.toString():t="",e!==t&&(this.ue=t,this.c(),this.t("text",e,t))}get textAlign(){return this.tt!==null?this.tt.$0:"start"}set textAlign(t){let e=this.textAlign;e!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Os().$0=t,this.C(),this.t("textAlign",e,t))}get flip(){return this.tt!==null?this.tt.mo:0}set flip(t){let e=this.flip;e!==t&&(this.Os().mo=t,this.C(),this.t("flip",e,t))}get verticalAlignment(){return this.tt!==null?this.tt.hl:T.Top}set verticalAlignment(t){let e=this.verticalAlignment;e.equals(t)||(t=t.N(),this.Os().hl=t,this.kf(),this.t("verticalAlignment",e,t))}get naturalBounds(){if(!this.Ke.isReal()){let t=_.l();this.nC(this.ue,999999,t);let e=t.width;_.i(t);let i=this.ND(e),s=this.desiredSize;isNaN(s.width)||(e=s.width),isNaN(s.height)||(i=s.height),this.Ke.jn(e,i)}return this.Ke}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){let e=(this.n&2097152)!==0;e!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",e,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){let e=(this.n&4194304)!==0;e!==t&&(this.n=this.n^4194304,this.$i(!0),this.C(),this.t("isUnderline",e,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){let e=(this.n&8388608)!==0;e!==t&&(this.n=this.n^8388608,this.$i(!0),this.C(),this.t("isStrikethrough",e,t))}get wrap(){return this.tt!==null?this.tt.Z0:2}set wrap(t){let e=this.wrap;e!==t&&(this.Os().Z0=t,this.c(),this.t("wrap",e,t))}get overflow(){return this.tt!==null?this.tt.Q0:0}set overflow(t){let e=this.overflow;e!==t&&(this.Os().Q0=t,this.c(),this.t("overflow",e,t))}get isOverflowed(){return(this.n&16777216)!==0}oC(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Qe}set stroke(t){let e=this.Qe;e!==t&&(t!==null&&E.Sd(t,"TextBlock.stroke"),t instanceof E&&t.b(),this.Qe=t,typeof t!="string"&&this.wf(),this.C(),this.t("stroke",e,t))}get lineCount(){return this.ki}get lineHeight(){return this._0()}get editable(){return(this.n&1048576)!==0}set editable(t){let e=(this.n&1048576)!==0;e!==t&&(this.n=this.n^1048576,this.t("editable",e,t))}get jN(){return(this.n&33554432)!==0}set jN(t){this.n=this.n^33554432}get textEditor(){return this.tt!==null?this.tt.ty:null}set textEditor(t){let e=this.textEditor;e!==t&&(this.Os().ty=t,this.t("textEditor",e,t))}get errorFunction(){return this.tt!==null?this.tt.gs:null}set errorFunction(t){let e=this.errorFunction;e!==t&&(t!==null&&g.S(t,gt,"errorFunction"),this.Os().gs=t,this.t("errorFunction",e,t))}get interval(){return this.K!==null?this.K.vf:1}set interval(t){let e=this.interval;if(t=Math.round(t),e!==t&&t!==0&&isFinite(t)){this.K===null&&(this.K=new Le),this.K.vf=t,this.c();let i=this.panel;i!==null&&(i.ds=null),this.t("interval",e,t)}}get graduatedStart(){return this.K!==null?this.K.Ff:0}set graduatedStart(t){let e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new Le),this.K.Ff=t,this.c(),this.t("graduatedStart",e,t))}get graduatedEnd(){return this.K!==null?this.K.Rf:1}set graduatedEnd(t){let e=this.graduatedEnd;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new Le),this.K.Rf=t,this.c(),this.t("graduatedEnd",e,t))}get graduatedFunction(){return this.K!==null?this.K.ey:null}set graduatedFunction(t){let e=this.graduatedFunction;e!==t&&(t!==null&&g.S(t,gt,"graduatedFunction"),this.K===null&&(this.K=new Le),this.K.ey=t,this.c(),this.t("graduatedFunction",e,t))}get graduatedSkip(){return this.K!==null?this.K.Of:null}set graduatedSkip(t){let e=this.graduatedSkip;e!==t&&(t!==null&&g.S(t,gt,"graduatedSkip"),this.K===null&&(this.K=new Le),this.K.Of=t,this.c(),this.t("graduatedSkip",e,t))}Ma(t,e){if(this.Qe===null||this.ue.length===0||this.vn===null)return;let i=this.naturalBounds,s=this.actualBounds,n=i.width,o=i.height,r=this._0(),a=t.textAlign=this.textAlign,h=e.ld;a==="start"?a=h?"right":"left":a==="end"&&(a=h?"left":"right");let l=this.isUnderline,c=this.isStrikethrough;this.kn(t,this.Qe,!0,!1,i,s),(l||c)&&this.kn(t,this.Qe,!1,!1,i,s);let u=0,d=0,f=n,p=!1;e.Wt===t&&!(e.Wt instanceof ge)&&!this.jN&&e.getRenderingHint("textGreeking")===!0&&r*this.Lh*e.scale<3&&(p=!0);let m=this.spacingAbove,y=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();let b=this.ki,v=(m+r+y)*b;if(o>v){let w=this.verticalAlignment;d=w.y*o-w.y*v+w.offsetY}if(gt.sk&&(t.letterSpacing=this.letterSpacing,t.wordSpacing=this.wordSpacing),b===1&&this.Rn!==null){let w=this.pe;w>f&&(w=f),d+=m,this.CD(this.Rn,t,u,d,f,r,w,p,a,l,c)}else if(this.Ii!==null&&this.ye!==null)for(let w=0;w<b;w++){let k=this.Ii[w];k>f&&(k=f),d+=m,this.CD(this.ye[w],t,u,d,f,r,k,p,a,l,c),d+=r+y}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}CD(t,e,i,s,n,o,r,a,h,l,c){let u=0;if(a){h==="left"?u=0:h==="right"?u=n-r:h==="center"&&(u=(n-r)/2);let p=e.globalAlpha;e.globalAlpha=p/2,e.fillRect(i+u,s+o/4,r,o/2),e.globalAlpha=p;return}h==="left"?u=0:h==="right"?u=n:h==="center"&&(u=n/2);let d=gt.ek!==null?gt.ek(this,o):o*.75;e.fillText(t,i+u,s+d);let f=o/20|0;if(f===0&&(f=1),h==="right"?u-=r:h==="center"&&(u-=r/2),l){let p=gt.ik!==null?gt.ik(this,o):o*.8;this.LD(i+u,s+p,i+u+r,s+p,f,e),e instanceof ge&&e.lastCreatedElement.classList.add("gojs-td")}if(c){let p=s+o-o/2.2|0;f%2!==0&&(p+=.5),this.LD(i+u,p,i+u+r,p,f,e),e instanceof ge&&e.lastCreatedElement.classList.add("gojs-td")}}LD(t,e,i,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,e),o.lineTo(i,s),o.stroke(),o.endPath()}yf(t,e,i){if(!super.yf(t,e,i))return!1;if(this.kn(t,this.Qe,!0,!1,this.naturalBounds,this.actualBounds),i){if(this.svg.getElementsByTagName("text").length===0)return!0;let s=this.svg.getElementsByClassName("gojs-td");for(let n=0;n<s.length;n++)t.setFillOrStrokeInPlace(s[n],!1)}else this.rE(this.svg,this.ye?this.ye[0]:this.text,t);return!0}rE(t,e,i){t.innerHTML=e,i.setFillOrStrokeInPlace(t,!0)}kd(t){return this.lineCount>1||this.isUnderline||this.isStrikethrough?!0:super.kd(t)}LN(t,e){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",e);else{let i=t.getElementsByTagName("text");for(let s=0;s<i.length;s++)i[s].setAttributeNS(null,"filter",e)}}lE(){this.Fn=0,this.pe=0,this.go=null,this.Ii=null,this.ye=null,this.Rn=null}xd(t,e,i,s){let n=this.ki;this.Xl=t,this.oC(!1);let o=this.vn;gt.us!==null&&(gt.AD!==o&&(gt.us.font=o,gt.AD=o),gt.sk&&(gt.us.letterSpacing=this.letterSpacing,gt.us.wordSpacing=this.wordSpacing)),this.lE();let r=0,a=0;isNaN(this.desiredSize.width)?(r=this.aE(),r=Math.min(r,t/this.scale)):r=this.desiredSize.width,this.panel!==null&&(r=Math.min(r,this.panel.maxSize.width)),a=this.ND(r),isNaN(this.desiredSize.height)?a=Math.min(a,e/this.scale):a=this.desiredSize.height,this.hE(t,a),(this.wrap===1||isNaN(this.desiredSize.width))&&(r=isNaN(t)?this.pe:Math.min(t,this.pe)),r=Math.max(i,r),a=Math.max(s,a),this.Ke.jn(r,a),this.lo(0,0,r,a),this.svg!==null&&n!==this.ki&&this.$i(!0)}Pa(t,e,i,s){this.commonArrange(t,e,i,s)}On(t,e){this.Rn===null?(this.Rn=t,this.pe=e):((this.ye===null||this.Ii===null)&&(this.ye=[],this.Ii=[],this.ye.push(this.Rn),this.Ii.push(this.pe)),this.ye.push(t),this.Ii.push(e),this.ye.length>this.maxLines&&(this.n|=16777216))}nC(t,e,i){let s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0,a=this.vn,h=this.spacingAbove+this.spacingBelow,l=Math.max(0,this._0()+h),c=this.overflow===1?this.TD(a):0;if(this.ki>=this.maxLines){i!==void 0&&i.e(0,l);return}let u=t;if(this.wrap===0){if(this.Fn=1,o=this.getStringWidth(t),c===0||o<=e){this.pe=Math.max(this.pe,o),this.On(t,this.pe),i!==void 0&&i.e(o,l);return}let f=this.Kd(u);u=u.substring(f.length);let p=this.Kd(u);for(o=this.getStringWidth(f+p),r=0;p.length>0&&o<=e;){f+=p,u=u.substring(p.length),p=this.Kd(u),r=o;let m=f+p;s&&(m=m.trim()),o=this.getStringWidth(m)}for(s&&(p=p.trim()),f+=p,e=Math.max(1,e-c);this.getStringWidth(f)>e&&f.length>1;)f=f.substring(0,f.length-1);this.oC(!0),f+=gt.J0,r=this.getStringWidth(f),this.pe=r,this.On(f,r),i!==void 0&&i.e(r,l);return}let d=0;for(u.length===0&&(d=1,this.On(u,0));u.length>0;){let f=this.Kd(u);for(u=u.substring(f.length);this.getStringWidth(f)>e;){let y=1;for(o=this.getStringWidth(f.substring(0,y)),r=0;o<=e;)y++,r=o,o=this.getStringWidth(f.substring(0,y));let b=0;y===1?(b=o,n=Math.max(n,o)):(b=r,n=Math.max(n,r)),y--,y<1&&(y=1);let v=f.substring(0,y);if(this.On(v,b),d++,f=f.substring(y),this.ki+d>this.maxLines)break}let p=this.Kd(u);for(o=this.getStringWidth(f+p),r=0;p.length>0&&o<=e;){f+=p,u=u.substring(p.length),p=this.Kd(u),r=o;let y=f+p;s&&(y=y.trim()),o=this.getStringWidth(y)}if(s&&(f=f.trim()),f==="")continue;f[f.length-1]==="\xAD"&&(f=f.substring(0,f.length-1)+"\u2010");let m=0;if(p.length===0?(m=o,n=Math.max(n,o)):(r=this.getStringWidth(f),m=r,n=Math.max(n,r)),this.On(f,m),d++,this.ki+d>this.maxLines)break}this.Fn=Math.min(this.maxLines-this.ki,d),this.pe=Math.max(this.pe,n),i!==void 0&&i.e(this.pe,l*this.Fn)}hE(t,e){if(this.pe===0||this.Ii===null||this.ye===null||this.overflow!==1)return;let i=this.vn,s=this.overflow===1?this.TD(i):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this._0()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(e/o+.01)-1,0));if(r+1>=this.ye.length)return;this.oC(!0);let a=this.ye[r],h=Math.max(1,t-s);for(;this.getStringWidth(a)>h&&a.length>1;)a=a.substring(0,a.length-1);a+=gt.J0;let l=this.getStringWidth(a);this.ye[r]=a,this.ye=this.ye.slice(0,r+1),this.Ii[r]=l,this.Ii=this.Ii.slice(0,r+1),this.Fn=this.ye.length,this.pe=Math.max(this.pe,l),this.ki=this.Fn,this.ki===1&&(this.Rn=this.ye[0])}Kd(t){if(this.wrap===3)return t.substring(0,1);let e=t.length,i=0,s=gt.cE;for(;i<e&&!s.test(t.charAt(i));)i++;for(this.formatting===1&&(e=Math.min(e,i+1));i<e&&s.test(t.charAt(i));)i++;return i>=t.length?t:t.substring(0,i)}getStringWidth(t){return gt.us===null?t.length*8:gt.us.measureText(t).width}_0(){if(this.go!==null)return this.go;let t=this.vn,e=0;if(gt.us===null)return e=16,this.go=e,e;if(gt.rC[t]!==void 0&&gt.DD<5e3)e=gt.rC[t];else{gt.us.letterSpacing="0px";let i=gt.us.measureText("M");gt.us.letterSpacing=this.letterSpacing,e=i.width*1.3,gt.rC[t]=e,gt.DD++}return this.go=e,e}TD(t){if(gt.us===null)return 6;let e=0;return gt.tk[t]!==void 0&&gt.sC<5e3?e=gt.tk[t]:(e=gt.us.measureText(gt.J0).width,gt.tk[t]=e,gt.sC++),e}nk(t,e){return t.indexOf(`
10
+ `,e)}ND(t){let e=this.ue.replace(/\r\n/g,`
11
+ `).replace(/\r/g,`
12
+ `),i=this.spacingAbove+this.spacingBelow,s=Math.max(0,this._0()+i);if(e.length===0)return this.pe=0,this.ki=1,s;if(!this.isMultiline){let h=this.nk(e,0);h>=0&&(e=e.substring(0,h))}let n=0;this.ki=0;let o=0,r=-1,a=!1;for(;!a;){if(r=this.nk(e,o),r===-1&&(r=e.length,a=!0),o<=r){let h=e.substring(o,r);if(this.wrap!==0){this.Fn=0;let l=_.l();this.nC(h,t,l),n+=l.height,_.i(l),this.ki+=this.Fn}else this.nC(h,t),n+=s,this.ki++;this.ki===this.maxLines&&(a=!0)}o=r+1}return this.jp=n,n}aE(){let t=this.ue.replace(/\r\n/g,`
13
+ `).replace(/\r/g,`
14
+ `);if(t.length===0)return 8;if(this.isMultiline){let e=0,i=0,s=!1;for(;!s;){let n=this.nk(t,i);n===-1&&(n=t.length,s=!0);let o=t.substring(i,n);this.formatting===0&&(o=o.trim()),e=Math.max(e,this.getStringWidth(o)),i=n+1}return e}else{let e=this.nk(t,0);return e>=0&&(t=t.substring(0,e)),this.getStringWidth(t)}}get textValidation(){return this.tt!==null?this.tt.zl:null}set textValidation(t){let e=this.textValidation;e!==t&&(t!==null&&g.S(t,gt,"textValidation"),this.Os().zl=t,this.t("textValidation",e,t))}get textEdited(){return this.tt!==null?this.tt.iy:null}set textEdited(t){let e=this.textEdited;e!==t&&(t!==null&&g.S(t,gt,"textEdited"),this.Os().iy=t,this.t("textEdited",e,t))}get spacingAbove(){return this.tt!==null?this.tt.ny:0}set spacingAbove(t){let e=this.spacingAbove;e!==t&&(this.Os().ny=t,this.c(),this.t("spacingAbove",e,t))}get spacingBelow(){return this.tt!==null?this.tt.ly:0}set spacingBelow(t){let e=this.spacingBelow;e!==t&&(this.Os().ly=t,this.c(),this.t("spacingBelow",e,t))}get letterSpacing(){return this.tt!==null?this.tt.hy:"0px"}set letterSpacing(t){let e=this.letterSpacing;e!==t&&(gt.sk=!0,this.Os().hy=t,this.c(),this.t("letterSpacing",e,t))}get wordSpacing(){return this.tt!==null?this.tt.cy:"0px"}set wordSpacing(t){let e=this.wordSpacing;e!==t&&(gt.sk=!0,this.Os().cy=t,this.c(),this.t("wordSpacing",e,t))}get formatting(){return this.tt!==null?this.tt.fy:0}set formatting(t){let e=this.formatting;e!==t&&(this.Os().fy=t,this.c(),this.t("formatting",e,t))}get maxLines(){return this.tt!==null?this.tt.uy:1/0}set maxLines(t){let e=this.maxLines;e!==t&&(t=Math.floor(t),t<=0&&g.J(t,"> 0",gt,"maxLines"),this.Os().uy=t,this.c(),this.t("maxLines",e,t))}getMetrics(){return[this.pe,this.Xl,this.go,this.Fn,this.Ii,this.ye,this.Rn||""]}oE(t){t!==void 0&&(this.pe=t[0],this.Xl=t[1],this.go=t[2],this.Fn=t[3],this.Ii=t[4],this.ye=t[5],this.Rn=t[6])}get metrics(){return{arrSize:this.Ii!==null?this.Ii:[this.pe],arrText:this.ye!==null?this.ye:[this.Rn],maxLineWidth:this.pe,fontHeight:this.go}}get choices(){return this.Yd}set choices(t){let e=this.Yd;e!==t&&(this.Yd=t,this.t("choices",e,t))}static cE=new RegExp("[ \u200B\xAD]");static rC=new W;static DD=0;static tk=new W;static sC=0;static J0="...";static AD="";static us=null;static S0=!1;static sk=!1}class Ns{me;gs;mo;fy;uy;Q0;ny;ly;$0;iy;ty;zl;hl;Z0;hy;cy;constructor(){this.me=!1,this.gs=null,this.mo=0,this.fy=0,this.uy=1/0,this.Q0=0,this.ny=0,this.ly=0,this.$0="start",this.iy=null,this.ty=null,this.zl=null,this.hl=T.Top,this.Z0=2,this.hy="0px",this.cy="0px"}copy(){let t=new Ns;return t.gs=this.gs,t.mo=this.mo,t.fy=this.fy,t.uy=this.uy,t.Q0=this.Q0,t.ny=this.ny,t.ly=this.ly,t.$0=this.$0,t.iy=this.iy,t.ty=this.ty,t.zl=this.zl,t.hl=this.hl,t.Z0=this.Z0,t.hy=this.hy,t.cy=this.cy,t}}class Le{vf;Ff;Rf;ey;Of;constructor(){this.vf=1,this.Ff=0,this.Rf=1,this.ey=null,this.Of=null}copy(){let t=new Le;return t.vf=this.vf,t.Ff=this.Ff,t.Rf=this.Rf,t.ey=this.ey,t.Of=this.Of,t}}var Cs=(x=>(x[x.None=0]="None",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x[x.UniformToFill=7]="UniformToFill",x))(Cs||{});class zt extends tt{cl;sn;fl;If;gs;ul;Ef;mo;Uf;Vf;E1;constructor(t,e){super(),this.n|=2097152,this.cl=null,this.sn="",this.fl=B.GF,this.If=2,this.gs=null,this.ul=null,this.Ef=T.Center,this.mo=0,this.Uf=null,this.Vf=null,this.E1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.sn=this.sn,t.element=this.cl,t.fl=this.fl.N(),t.If=this.If,t.mo=this.mo,t.gs=this.gs,t.ul=this.ul,t.Ef=this.Ef.N(),t.Vf=this.Vf}fe(t){t in Cs?this.imageStretch=t:super.fe(t)}toString(){return"Picture("+this.source+")#"+I.xs(this)}get Bf(){return(this.n&1048576)!==0}set Bf(t){this.Bf!==t&&(this.n=this.n^1048576)}get gy(){return(this.n&2097152)!==0}set gy(t){this.gy!==t&&(this.n=this.n^2097152)}get Mn(){return(this.n&4194304)!==0}set Mn(t){this.Mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),g.s(t,"string",zt,"clearCache:url"),t!==""?zt.my[t]&&(delete zt.my[t],zt.ok--):(zt.my=new W,zt.ok=0)}static ST(t,e){e.vD||(e.rk=i=>{zt.fE(e,i),t.desiredSize.isReal()||(t.wi(!1),t.c())},e.lk=i=>zt.uE(e,i),e.addEventListener("load",e.rk),e.addEventListener("error",e.lk),e.vD=!0)}static DO(t){t.rk&&t.removeEventListener("load",t.rk),t.lk&&t.removeEventListener("error",t.lk),delete t.rk,delete t.lk,t.vD=!1}get element(){return this.cl}set element(t){let e=this.cl;if(this.$i(!0),e!==t){this.Bf=t instanceof HTMLCanvasElement;let i=t instanceof HTMLImageElement;t!==null&&!(i||t instanceof HTMLVideoElement||this.Bf)&&g.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);let s=this.diagram;s!==null&&s.F2(this),this.cl=t,t!==null&&i&&t.hs===void 0&&(t.hs=new I),s!==null&&i&&s.v2(this),this.t("element",e,t),this.C()}}AO(){let t=this.cl;if(t===null)return;let e=this.desiredSize.isReal();(this.Bf||t.complete===!0)&&(t.Tp&&(t.yy instanceof Event&&this.gs!==null?this.gs(this,t.yy):t.Mn===!0&&!t.yy&&this.ul!==null&&t.lC&&this.ul(this,t.lC)),t.Mn=!0),t.Mn&&e&&this.diagram!==null&&this.diagram.rd.add(this)}dE(){if(this.cl===null){this.Uf=!1;return}let t=new He(null)._t;try{t.drawImage(this.cl,0,0)}catch{this.gy=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Uf=!1),this.Uf=!1}catch{this.Uf=!0}}get source(){return this.sn}set source(t){let e=this.sn;if(e!==t){this.$i(!0),g.s(t,"string",zt,"source"),this.sn=t;let i=zt.my;if(!j.isUsingDOM()){this.t("source",e,t);return}let s=null;if(i[t]!==void 0)s=i[t];else if(t!==""){zt.ok>30&&(zt.clearCache(),i=zt.my),s=g.Ni("img"),s.Tp=!0,zt.ST(this,s);let n=this.Vf;n!==null&&(s.crossOrigin=n(this)),s.src=t,i[t]=s,zt.ok++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new gr),this.c(),this.C(),this.t("source",e,t)}}static fE(t,e){t.Mn=!0,t.yy=!1;let i,s=t.hs.copy();if(s==null)return;let n=s.iterator;for(;n.next();){let o=n.value;o.C();let r=t.getAttribute("src")||"",a=o.oa.get(r);if(a===null)continue;let h=a.length;for(let l=0;l<h;l++)i=a[l],i.desiredSize.isReal()||o.rd.add(i),i.$i(!0),o.requestUpdate(),t.Tp&&(t.lC===void 0&&(t.lC=e),i.ul!==null&&i.ul(i,e))}t.hs.clear()}static uE(t,e){t.yy=e;let i,s=t.hs.copy();if(s==null)return;let n=s.iterator;for(;n.next();){let o=n.value,r=t.getAttribute("src")||"",a=o.oa.get(r);if(a===null)continue;let h=a.length,l=g.ot();for(let c=0;c<h;c++)l.push(a[c]);if(t.Tp)for(let c=0;c<h;c++)i=l[c],i.gs!==null&&i.gs(i,e);g.Z(l)}t.hs.clear()}reloadSource(){if(this.source==="")return;zt.clearCache(this.source);let t=this.source;this.source="",this.source=t}redraw(){this.C(),this.$i(!0)}get sourceCrossOrigin(){return this.Vf}set sourceCrossOrigin(t){if(this.Vf!==t&&(t!==null&&g.S(t,zt,"sourceCrossOrigin"),this.Vf=t,this.element!==null)){let e=this.element.getAttribute("src");this.element instanceof HTMLImageElement&&(t===null&&typeof e=="string"?this.element.crossOrigin=null:t!==null&&(this.element.crossOrigin=t(this)),e&&(this.element.src=e))}}get sourceRect(){return this.fl}set sourceRect(t){let e=this.fl;e.equals(t)||(t=t.N(),this.fl=t,this.C(),this.t("sourceRect",e,t))}get imageStretch(){return this.If}set imageStretch(t){let e=this.If;e!==t&&(this.If=t,this.C(),this.t("imageStretch",e,t))}get flip(){return this.mo}set flip(t){let e=this.mo;e!==t&&(this.mo=t,this.C(),this.t("flip",e,t))}get imageAlignment(){return this.Ef}set imageAlignment(t){let e=this.Ef;e.equals(t)||(t=t.N(),this.Ef=t,this.C(),this.t("imageAlignment",e,t))}get errorFunction(){return this.gs}set errorFunction(t){let e=this.gs;e!==t&&(t!==null&&g.S(t,zt,"errorFunction"),this.gs=t,this.t("errorFunction",e,t))}get successFunction(){return this.ul}set successFunction(t){let e=this.ul;e!==t&&(t!==null&&g.S(t,zt,"successFunction"),this.ul=t,this.t("successFunction",e,t))}Ma(t,e){let i=this.cl;if(i===null)return;let s=i.getAttribute("src");if(i instanceof HTMLImageElement&&(s===null||s==="")||i.yy instanceof Event&&t instanceof Vi)return;let n=t instanceof ge,o=this.naturalBounds,r=0,a=0,h=this.Bf,l=h?+i.width:i.naturalWidth,c=h?+i.height:i.naturalHeight;if(l===void 0&&i.videoWidth&&(l=i.videoWidth),c===void 0&&i.videoHeight&&(c=i.videoHeight),l===0||c===0)return;let u=l,d=c;this.sourceRect.isReal()&&(r=this.fl.x,a=this.fl.y,l=this.fl.width,c=this.fl.height);let f=l,p=c,m=this.If,y=this.Ef;switch(m){case 0:if(this.sourceRect.isReal())break;f>=o.width&&(r=r+y.offsetX+(f*y.x-o.width*y.x)),p>=o.height&&(a=a+y.offsetY+(p*y.y-o.height*y.y)),l=Math.min(o.width,f),c=Math.min(o.height,p);break;case 2:f=o.width,p=o.height;break;case 6:case 7:let O=0;m===6?(O=Math.min(o.height/p,o.width/f),f*=O,p*=O):m===7&&(O=Math.max(o.height/p,o.width/f),f*=O,p*=O,f>=o.width&&(r=(r+y.offsetX+(f*y.x-o.width*y.x)/f)*l),p>=o.height&&(a=(a+y.offsetY+(p*y.y-o.height*y.y)/p)*c),l*=1/(f/o.width),c*=1/(p/o.height),f=o.width,p=o.height);break}let b=l*c,v=this.getDocumentScale()*e.scale,w=f*v,k=p*v,S=w*k,M=b/S,F=i.__goCache,D=null,N=zt.gE;if(!n){if(i.Mn&&F!==void 0&&u<8e3&&d<8e3&&S>4&&M>N*N){F.Vt===null&&(F.FD(4,u,d,i),F.FD(16,u,d,i));let O=F.Vt,V=O.length;for(let K=0;K<V&&O[K].Hd*O[K].Hd<M;K++)D=O[K]}if(!e.od&&(this.Uf===null&&this.dE(),this.Uf))return}let L=f<o.width?y.offsetX+(o.width*y.x-f*y.x):0,R=p<o.height?y.offsetY+(o.height*y.y-p*y.y):0;switch(this.flip){case 0:break;case 2:t.translate(Math.min(o.width,f),0),t.scale(-1,1);break;case 1:t.translate(0,Math.min(o.height,p)),t.scale(1,-1);break;case 3:t.translate(Math.min(o.width,f),Math.min(o.height,p)),t.scale(-1,-1);break}if(t.commitTransform(),e.getRenderingHint("pictureRatioOptimization")&&!e.gh&&F!==void 0&&D!==null&&D.Hd!==1){t.save();let O=D.Hd;try{t.drawImage(D.sn,r/O,a/O,Math.min(D.sn.width,l/O),Math.min(D.sn.height,c/O),L,R,Math.min(o.width,f),Math.min(o.height,p)),t instanceof ge&&(this.E1=[r/O,a/O,Math.min(D.sn.width,l/O),Math.min(D.sn.height,c/O),L,R,Math.min(o.width,f),Math.min(o.height,p)])}catch{this.gy=!1}t.restore()}else try{t.drawImage(i,r,a,l,c,L,R,Math.min(o.width,f),Math.min(o.height,p)),t instanceof ge&&(this.E1=[r,a,l,c,L,R,Math.min(o.width,f),Math.min(o.height,p)])}catch{this.gy=!1}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-Math.min(o.width,f),0);break;case 1:t.scale(1,-1),t.translate(0,-Math.min(o.height,p));break;case 3:t.scale(-1,-1),t.translate(-Math.min(o.width,f),-Math.min(o.height,p));break}}get naturalBounds(){return this.Ke}xd(t,e,i,s){let n=this.desiredSize,o=this.Qs(!0),r=this.cl,a=this.Bf,h=0,l=0;(a||!this.Mn&&r&&r.complete)&&(this.Mn=!0),r===null?(isFinite(n.width)||(t=i),isFinite(n.height)||(e=s)):(h=a?+r.width:r.naturalWidth,l=a?+r.height:r.naturalHeight),!isFinite(n.width)&&o!==2&&o!==5?r!==null&&this.Mn!==!1&&(this.sourceRect.isReal()?t=this.sourceRect.width:t=h):(isFinite(t)||(this.sourceRect.isReal()?t=this.sourceRect.width:r!==null&&(t=h)),i=0),!isFinite(n.height)&&o!==2&&o!==4?r!==null&&this.Mn!==!1&&(this.sourceRect.isReal()?e=this.sourceRect.height:e=l):(isFinite(e)||(this.sourceRect.isReal()?e=this.sourceRect.height:r!==null&&(e=l)),s=0),isFinite(n.width)&&(t=n.width),isFinite(n.height)&&(e=n.height);let c=this.maxSize,u=this.minSize;i=Math.max(i||0,u.width),s=Math.max(s||0,u.height),t=Math.min(c.width,t),e=Math.min(c.height,e),t=Math.max(i,t),e=Math.max(s,e),r!==null&&!r.complete&&(isFinite(t)||(t=0),isFinite(e)||(e=0)),this.Ke.jn(t,e),this.lo(0,0,t,e)}Pa(t,e,i,s){this.commonArrange(t,e,i,s)}static my=new W;static ok=0;static gE=4}class gr{Vt;constructor(){this.Vt=null}FD(t,e,i,s){this.Vt===null&&(this.Vt=[]);let n=new He(null),o=n._t,r=1/t;if(n.width=e/t,n.height=i/t,n.width===0||n.height===0)return;let a=new mr(n.bt,t),h=s,l=1;if(this.Vt.length>0){let c=this.Vt[this.Vt.length-1];h=c.sn,l=c.Hd}o.setTransform(r*l,0,0,r*l,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Vt.push(a)}}class mr{sn;Hd;constructor(t,e){this.sn=t,this.Hd=e}}class Ye{Ne;fm;constructor(){this.fm=new St,this.Ne=null}Ue(t){t!==null?(this.fm=t,t.figures.clear()):this.fm=new St,this.Ne=null}Au(t,e,i,s,n,o){if(s!==void 0&&s===!0){let r=new xt(1);r.endX=t,r.endY=e,this.Ne.segments.add(r)}else this.Ne=new jt,this.Ne.startX=t,this.Ne.startY=e,this.Ne.isFilled=i,this.Ne.isEvenOdd=o||!1,this.fm.figures.add(this.Ne);n!==void 0&&(this.Ne.isShadowed=n)}_F(){let t=this.Ne.segments.length;t>0&&this.Ne.segments.elt(t-1).close()}tR(){this.Ne.segments.length>0&&(this.Ne.isFilled=!0)}eR(t){this.Ne.isShadowed=t}zU(t){this.Ne.isEvenOdd=t}$F(t,e,i){i===void 0&&(i=!1);let s=new xt(1);s.endX=t,s.endY=e,i&&s.close(),this.Ne.segments.add(s)}Ks(t,e,i){i===void 0&&(i=!1);let s=new xt(2);s.endX=t,s.endY=e,i&&s.close(),this.Ne.segments.add(s)}xr(t,e,i,s,n,o,r){r===void 0&&(r=!1);let a=new xt(3);a.point1X=t,a.point1Y=e,a.point2X=i,a.point2Y=s,a.endX=n,a.endY=o,r&&a.close(),this.Ne.segments.add(a)}Tu(t,e,i,s,n){n===void 0&&(n=!1);let o=new xt(4);o.point1X=t,o.point1Y=e,o.endX=i,o.endY=s,n&&o.close(),this.Ne.segments.add(o)}ZF(t,e,i,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);let a=new xt(5);a.startAngle=t,a.sweepAngle=e,a.centerX=i,a.centerY=s,a.radiusX=n,o!==0?a.radiusY=o:a.radiusY=n,r&&a.close(),this.Ne.segments.add(a)}QF(t,e,i,s,n,o,r,a){a===void 0&&(a=!1);let h=new xt(6,o,r,t,e,i,s,n);a&&h.close(),this.Ne.segments.add(h)}static aC=null;static qL(t){let e=Ye.aC;if(e!==null)return Ye.aC=null,e.Ue(t),e;{let i=new Ye;return i.Ue(t),i}}static WL(t){Ye.aC=t}}{let x=function(n,o){let r=n.toLowerCase(),a=A.Jn;a[n]=o,a[r]=n};x("Rectangle",(n,o,r)=>{let a="r"+o+","+r,h=A.yr[a];return h!==void 0||(h=new St(2),h.endX=o,h.endY=r,A.wr<A.lm&&(A.yr[a]=h,A.wr++)),h}),x("Square",(n,o,r)=>{let a="s"+o+","+r,h=A.yr[a];return h!==void 0||(h=new St(2),h.endX=o,h.endY=r,h.defaultStretch=6,A.wr<A.lm&&(A.yr[a]=h,A.wr++)),h});let t=(n,o,r,a,h)=>{(isNaN(a)||a<0)&&(a=5),isNaN(h)&&(h=15);let l="rr"+o+","+r+","+a+","+h,c=A.yr[l];if(c!==void 0)return c;let u=a;(h&1)===1?(u=Math.min(u,(h&2)===2?o/3:o),u=Math.min(u,(h&8)===8?r/3:r)):u=0;let d=new jt(u,0,!0);c=new St().add(d);let f=T.TopLeft.copy(),p=T.BottomRight.copy();if((h&2)===2){let m=a;m=Math.min(m,(h&1)===1?o/3:o),m=Math.min(m,(h&4)===4?r/3:r);let y=m*A.qn;d.add(new xt(2,o-m,0)).add(new xt(3,o,m,o-y,0,o,y)),f.offsetY=y,p.offsetX=-y}else d.add(new xt(2,o,0));if((h&4)===4){let m=a;m=Math.min(m,(h&8)===8?o/3:o),m=Math.min(m,(h&2)===2?r/3:r);let y=m*A.qn;d.add(new xt(2,o,r-m)).add(new xt(3,o-m,r,o,r-y,o-y,r)),p.offsetX=-y,p.offsetY=-y}else d.add(new xt(2,o,r));if((h&8)===8){let m=a;m=Math.min(m,(h&4)===4?o/3:o),m=Math.min(m,(h&1)===1?r/3:r);let y=m*A.qn;d.add(new xt(2,m,r)).add(new xt(3,0,r-m,y,r,0,r-y)),f.offsetX=y,p.offsetY=-y}else d.add(new xt(2,0,r));if((h&1)===1){let m=u*A.qn;d.add(new xt(2,0,u)).add(new xt(3,u,0,0,m,m,0).close()),f.offsetX=m,f.offsetY=m}else d.add(new xt(2,0,0).close());return c.spot1=f,c.spot2=p,A.wr<A.lm&&(A.yr[l]=c,A.wr++),c};x("RoundedRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,a,h)}),x("Border","RoundedRectangle"),x("RoundedTopRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,3)}),x("RoundedBottomRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,12)}),x("RoundedLeftRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,9)}),x("RoundedRightRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,6)}),x("Ellipse",(n,o,r)=>{let a="e"+o+","+r,h=A.yr[a];return h!==void 0||(h=new St(3),h.endX=o,h.endY=r,h.spot1=T.DP,h.spot2=T.vP,A.wr<A.lm&&(A.yr[a]=h,A.wr++)),h}),x("Circle",(n,o,r)=>{let a="c"+o+","+r,h=A.yr[a];return h!==void 0||(h=new St(3),h.endX=o,h.endY=r,h.spot1=T.DP,h.spot2=T.vP,h.defaultStretch=6,A.wr<A.lm&&(A.yr[a]=h,A.wr++)),h}),x("TriangleRight",(n,o,r)=>new St().add(new jt(0,0).add(new xt(2,o,.5*r)).add(new xt(2,0,r).close())).setSpots(0,.25,.5,.75)),x("TriangleDown",(n,o,r)=>new St().add(new jt(0,0).add(new xt(2,o,0)).add(new xt(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),x("TriangleLeft",(n,o,r)=>new St().add(new jt(o,r).add(new xt(2,0,.5*r)).add(new xt(2,o,0).close())).setSpots(.5,.25,1,.75)),x("TriangleUp",(n,o,r)=>new St().add(new jt(o,r).add(new xt(2,0,r)).add(new xt(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),x("Triangle","TriangleUp"),x("Diamond",(n,o,r)=>new St().add(new jt(.5*o,0).add(new xt(2,0,.5*r)).add(new xt(2,.5*o,r)).add(new xt(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),x("LineH",(n,o,r)=>{let a=new St(1);return a.startX=0,a.startY=r/2,a.endX=o,a.endY=r/2,a}),x("LineV",(n,o,r)=>{let a=new St(1);return a.startX=o/2,a.startY=0,a.endX=o/2,a.endY=r,a}),x("None","Rectangle"),x("BarH","Rectangle"),x("BarV","Rectangle"),x("MinusLine","LineH"),x("PlusLine",(n,o,r)=>new St().add(new jt(0,r/2,!1).add(new xt(2,o,r/2)).add(new xt(1,o/2,0)).add(new xt(2,o/2,r)))),x("XLine",(n,o,r)=>new St().add(new jt(0,r,!1).add(new xt(2,o,0)).add(new xt(1,0,0)).add(new xt(2,o,r)))),x("LineRight",(n,o,r)=>new St().add(new jt(.25*o,0,!1).add(new xt(2,.75*o,.5*r)).add(new xt(2,.25*o,r)))),x("LineDown",(n,o,r)=>new St().add(new jt(0,.25*r,!1).add(new xt(2,.5*o,.75*r)).add(new xt(2,o,.25*r)))),x("LineLeft",(n,o,r)=>new St().add(new jt(.75*o,0,!1).add(new xt(2,.25*o,.5*r)).add(new xt(2,.75*o,r)))),x("LineUp",(n,o,r)=>new St().add(new jt(0,.75*r,!1).add(new xt(2,.5*o,.25*r)).add(new xt(2,o,.75*r)))),x("Capsule",(n,o,r)=>{let a=new St;if(o<r){let h=o/2,l=new jt(0,h,!0);a.add(l),l.add(new xt(5,180,180,h,h,h,h)),l.add(new xt(2,o,r-h)),l.add(new xt(5,0,180,h,r-h,h,h)),l.add(new xt(2,0,h));let c=isFinite(n.parameter1)?n.parameter1:o*.156;return a.setSpots(0,0,1,1,0,c,0,-c),a}else if(o>r){let h=r/2,l=new jt(h,0,!0);a.add(l),l.add(new xt(2,o-h,0)),l.add(new xt(5,270,180,o-h,h,h,h)),l.add(new xt(2,h,r)),l.add(new xt(5,90,180,h,h,h,h));let c=isFinite(n.parameter1)?n.parameter1:r*.156;return a.setSpots(0,0,1,1,c,0,-c,0),a}else return a.type=3,a.endX=o,a.endY=r,a.spot1=T.DP,a.spot2=T.vP,a});let e=(n,o)=>new jt(n,o,!1,!1),i=(n,o,r)=>n.add(new xt(2,o,r)),s=(n,o,r)=>n.add(new xt(1,o,r));x("Borders",(n,o,r)=>{let a=n?n.parameter1:NaN;isNaN(a)?a=10:a=a&15;let h=new St,l;return a===10?(l=e(o,0),i(l,o,r),s(l,0,r),i(l,0,0)):a===5?(l=e(0,0),i(l,o,0),s(l,o,r),i(l,0,r)):a===1?(l=e(0,0),i(l,o,0),s(l,o,r)):a===2?(l=e(o,0),i(l,o,r)):a===4?(l=e(o,r),i(l,0,r)):a===8?(l=e(0,r),i(l,0,0),s(l,o,r)):a===3?(l=e(0,0),i(l,o,0),i(l,o,r)):a===6?(l=e(o,0),i(l,o,r),i(l,0,r)):a===12?(l=e(o,r),i(l,0,r),i(l,0,0)):a===9?(l=e(0,r),i(l,0,0),i(l,o,0)):a===7?(l=e(0,0),i(l,o,0),i(l,o,r),i(l,0,r)):a===14?(l=e(o,0),i(l,o,r),i(l,0,r),i(l,0,0)):a===13?(l=e(o,r),i(l,0,r),i(l,0,0),i(l,o,0)):a===11?(l=e(0,r),i(l,0,0),i(l,o,0),i(l,o,r)):a===15?(l=e(0,0),i(l,o,0),i(l,o,r),i(l,0,r),l.add(new xt(2,0,0).close())):(l=e(0,0),s(l,o,r)),h.add(l),h})}A.rm={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var On=(x=>(x[x.None=0]="None",x[x.Added=1]="Added",x[x.Removed=2]="Removed",x[x.Shown=4]="Shown",x[x.Hidden=8]="Hidden",x[x.NodeSized=16]="NodeSized",x[x.GroupLayout=32]="GroupLayout",x[x.NodeReplaced=64]="NodeReplaced",x[x.Standard=127]="Standard",x[x.All=16777215]="All",x))(On||{});class bt extends H{k;_o;H;dl;gl;tr;ue;pl;Ta;nn;er;jd;EM;RD;wy;xy;constructor(t,e){let i;t===void 0||t instanceof Ft||typeof t=="string"?i=t:t&&(e=t),super(i),this.k=2408959,this._o="",this.H=null,this.dl="",this.gl=null,this.tr=null,this.ue="",this.pl=null,this.Ta=null,this.nn=new P(NaN,NaN).b(),this.er=null,this.jd=NaN,this.EM=-1,this.RD=new B,this.wy=null,this.xy=NaN,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.k=this.k&-4097|16384|32768,t._o=this._o,this.H!==null&&(this.H.me?t.H=this.H:t.H=this.H.copy()),t.dl=this.dl,t.tr=null,t.ue=this.ue,t.nn.h(this.nn),t.jd=this.jd}jo(t){super.jo(t),t.Sa(),t.gl=null,t.er=null,t.wy=null}toString(){let t=g.Hn(this.constructor)+"#"+I.xs(this);return this.data!==null&&(t+="("+g.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;_e(){return this.H===null?this.H=new As:this.H.me&&(this.H=this.H.copy()),this.H}ba(){super.ba(),this.H!==null&&(this.H.me=!0)}df(t,e,i,s,n,o,r){let a=this.diagram;a!==null&&(t===3&&e==="elements"?n instanceof H?n.Sn(h=>{a.partManager.M2(h,a)}):n instanceof zt&&a.v2(n):t===4&&e==="elements"&&(n instanceof H?n.Sn(h=>a.partManager.N2(h,a)):n instanceof zt&&a.F2(n)),a.raiseChangedEvent(t,e,i,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;let e=this.D.r,i=e.length;for(let n=0;n<i;n++){let o=e[n];o instanceof H&&o.Sn(r=>{r.data!==null&&r.WI(t)})}let s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.RN()){let e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s];n instanceof H&&n.Sn(o=>o.Yo())}}let t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){let t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.tr===null?J.instance:this.tr.iteratorValues}findAdornment(t){let e=this.tr;return e===null?null:e.get(t)}addAdornment(t,e){if(e===null)return;let i=null,s=this.tr;if(s!==null&&(i=s.get(t)),i!==e){if(i!==null){let o=i.diagram;o!==null&&o.remove(i)}s===null&&(s=new wt,this.tr=s),e._o!==t&&(e.category=t),s.set(t,e);let n=this.diagram;if(n!==null){n.add(e);let o=e.adornedObject;if(o!==null){let r=o.findBindingPanel();r!==null&&(e.data=r.data)}}}}removeAdornment(t){let e=this.tr;if(e===null)return;let i=e.get(t);if(i!==null){let s=i.diagram;s!==null&&(s.remove(i),i.data=null)}e.delete(t),e.count===0&&(this.tr=null)}clearAdornments(){let t=this.tr;if(t===null)return;let e=g.ot(),i=t.iterator;for(;i.next();){let n=i.key;e.push(n)}let s=e.length;for(let n=0;n<s;n++)this.removeAdornment(e[n]);g.Z(e)}updateAdornments(){let t=this.diagram;if(t===null)return;this.mE(t),this.pE(t);let e=this.adornments;for(;e.next();){let i=e.value;i.c(),i.hasPlaceholder()&&i.placeholder.c()}for(e=this.adornments;e.next();)e.value.updateTargetBindings()}invalidateAdornments(){let t=this.diagram;t!==null&&(t.ha(),this.OD()!==!0&&this.ID(!0))}UM(){this.OD()!==!1&&(this.updateAdornments(),this.ID(!1))}mE(t){let e="Selection";if(this.isSelected&&this.selectionAdorned){let i=this.selectionObject;if(i!==null&&this.actualBounds.isReal()&&this.isVisible()&&i.isVisibleObject()&&i.actualBounds.isReal()){let s=this.findAdornment(e);if(s===null){let n=this.selectionAdornmentTemplate;n===null&&(this.Ar()?n=t.linkSelectionAdornmentTemplate:this instanceof ft?n=t.groupSelectionAdornmentTemplate:n=t.nodeSelectionAdornmentTemplate),s=n.copy(),s!==null&&(this.Ar()&&this.selectionObject===this.path&&(s.type=H.Link),s.adornedObject=i)}if(s!==null){s.type===H.Link&&s.c(),this.addAdornment(e,s);return}}}this.removeAdornment(e)}pE(t){let e=this;t.toolManager.mouseDownTools.each(i=>{i.isEnabled&&i.updateAdornments(e)}),t.toolManager.updateAdornments(e)}OM(t){this.pl=t,t===null&&this.fI()}get layer(){return this.pl}get diagram(){let t=this.pl;return t==null?null:t.diagram}get layerName(){return this.dl}set layerName(t){let e=this.dl;if(e===t)return;let i=this.diagram;if(i!==null&&(i.findLayer(t)===null||i.partManager.addsToTemporaryLayer))return;this.dl=t,i!==null&&i.invalidateDocumentBounds(),this.t("layerName",e,t);let s=this.layer;if(s===null||s.name===t||(i=s.diagram,i===null))return;let n=i.findLayer(t);if(n===null||n===s)return;let o=s.ri(-1,this,!0);o>=0&&i.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.ah(99999999,this,!0),s.visible!==n.visible&&this.Xe(n.visible),o>=0&&i.raiseChangedEvent(3,"parts",n,null,this,!0,o);let r=this.layerChanged;if(r===null)return;let a=i.G;i.G=!0,r(this,s,n),i.G=a}get layerChanged(){return this.H!==null?this.H.ky:null}set layerChanged(t){let e=this.layerChanged;e!==t&&(t!==null&&g.S(t,bt,"layerChanged"),this._e().ky=t,this.t("layerChanged",e,t))}get zOrder(){return this.jd}set zOrder(t){let e=this.jd;if(e===t)return;this.jd=t;let i=this.layer;i!==null&&i.ob(-1,this),this.t("zOrder",e,t);let s=this.diagram;s!==null&&s.C()}yE(){let t=this.layer;t!==null&&t.ob(-1,this)}ak(){if(this.fa()!==!1)return;this.hC(!0),this.pf();let t=this.diagram;t!==null&&(t.Np(this),t.requestUpdate())}ED(){if(this.k|=2097152,this.fa()===!1)return;let t=this.position,e=this.location;(!e.isReal()||!t.isReal())&&this.UD(t,e);let i=this.De,s=B.l().h(i);i.ce(),i.x=t.x,i.y=t.y,i.b(),this.bd(s,i),B.i(s),this.hC(!1),this.pf()}lo(t,e,i,s){let n=this.ai;n.e(t,e,i,s),this.Se===null&&(this.Se=new Pt);let o=this.Se;o.Ue(),this.Yp(o,t,e,i,s),this.Se=o,o.FP()||o.im(n)}Yp(t,e,i,s,n){if(this.it!==1&&t.it(this.it),this.Xt===0)return;let o=T.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);let r=P.l();if(this.locationObject!==this){let a=this.locationObject,h=a.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),a.Se!==null&&a.Se.gt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y);let l=a.panel;for(;l!==null&&l!==this;)l.Se!==null&&l.Se.gt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y),l=l.panel}else r.setSpot(e,i,s,n,o);t.ks(this.Xt,r.x,r.y),P.i(r)}get locationObject(){if(this.er===null)if(this instanceof Mt&&this.type!==H.Link&&this.hasPlaceholder())this.er=this.placeholder;else{let t=this.locationObjectName;if(t!==""){let e=this.findObject(t);e!==null?this.er=e:this.er=this}else this.er=this}return this.er?.visible?this.er:this}get minLocation(){return this.H!==null?this.H.Py:P.DL}set minLocation(t){let e=this.minLocation;e.equals(t)||(t=t.N(),this._e().Py=t,this.t("minLocation",e,t))}get maxLocation(){return this.H!==null?this.H.Sy:P.vL}set maxLocation(t){let e=this.maxLocation;e.equals(t)||(t=t.N(),this._e().Sy=t,this.t("maxLocation",e,t))}get locationObjectName(){return this.H!==null?this.H.My:""}set locationObjectName(t){let e=this.locationObjectName;e!==t&&(this._e().My=t,this.er=null,this.c(),this.t("locationObjectName",e,t))}get locationSpot(){return this.H!==null?this.H.Ny:T.TopLeft}set locationSpot(t){let e=this.locationSpot;e.equals(t)||(t=t.N(),this._e().Ny=t,this.c(),this.t("locationSpot",e,t))}move(t,e){e===!0?this.location=t:this.position=t}moveTo(t,e,i){let s=P.z(t,e);this.move(s,i),P.i(s)}isVisible(){if(!this.visible)return!1;let t=this.layer;if(t!==null){if(!t.visible)return!1;let i=t.diagram;if(i!==null&&i.animationManager.qx(this))return!0}let e=this.containingGroup;return!(e!==null&&(!e.isSubGraphExpanded||!e.isVisible()))}Xe(t){let e=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),e!==null&&e.Np(this)):(this.invalidateLayout(8),this.clearAdornments()),this.Sa(),e!==null&&(e.invalidateDocumentBounds(),e.C())}findObject(t){if(this.name===t)return this;let e=this.wy;if(e===null&&(this.wy=e=new wt),e.get(t)!==null)return e.get(t);let i=super.findObject(t);return i!==null?(e.set(t,i),i):(e.set(t,null),null)}i0(){this.wy=null}getRelativePoint(t,e,i){i===void 0&&(i=new P);let s=e.isNoSpot()?T.Center:e,n=t.naturalBounds;if(i.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return i;t.v.gt(i);let o=t.panel;for(;o!==null&&o!==this;)o.v.gt(i),o=o.panel;return this.Se!==null&&this.Se.gt(i),i.offset(-this.ai.x,-this.ai.y),i}getDocumentBounds(t){return t===void 0&&(t=new B),t.h(this.actualBounds)}ensureBounds(){this.ht(1/0,1/0),this.Ut()}fD(t){let e=this.locationSpot,i=this.locationObject,s=i.naturalBounds;s.isReal()||(s=B.tm);let n=i instanceof at?i.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,e),i!==this){t.offset(-n/2,-n/2),i.v.gt(t);let o=i.panel;for(;o!==null&&o!==this;)o.v.gt(t),o=o.panel}return this.Se!==null&&this.Se.gt(t),t.offset(-this.ai.x,-this.ai.y),t}lh(t,e){let i=e===void 0?this.RD:e,s=this.wE(),n=s*2;if(!this.isShadowed)return i.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),i;let o=t.x,r=t.y,a=t.width,h=t.height,l=this.shadowBlur,c=this.shadowOffset;return a+=l,h+=l,o-=l/2,r-=l/2,c.x>0?a+=c.x:(o+=c.x,a-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),i.e(o-1,r-1,a+2,h+2),i}tE(){return this.type===H.Link&&this instanceof Mt&&this.category==="Selection"&&this.adornedObject instanceof at&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}wE(){return isNaN(this.xy)&&(this.xy=this.wD()),this.xy}Tf(){this.xy=NaN}Ut(){if(this.as()===!1){this.ED();return}this.ao(!1);let t=this.De,e=B.l();e.h(t);let i=this.Ul();this.Pa(0,0,this.ai.width,this.ai.height);let s=this.position;this.UD(s,this.location),t.ce(),t.x=s.x,t.y=s.y,t.b(),this.bd(e,t),e.equals(t)?this.As(i):this.Di()&&(!A.u(e.width,t.width)||!A.u(e.height,t.height))&&this.EM>=0&&this.invalidateLayout(16),B.i(e),this.hC(!1)}bd(t,e){let i=this.diagram;if(i===null)return;let s=!1;if(i.dh===!1&&t.isReal()){let n=B.l();n.h(i.documentBounds),n.subtractMargin(i.padding),t.x>n.x&&t.y>n.y&&t.right<n.right&&t.bottom<n.bottom&&e.x>n.x&&e.y>n.y&&e.right<n.right&&e.bottom<n.bottom&&(s=!0),B.i(n)}(this.xE()===!0||!t.equals(e))&&this.dT(s,i),i.C(),!(!t.isReal()&&!e.isReal()||t.equalsApproxClose(e))&&(this instanceof it&&!i.undoManager.isUndoingRedoing&&this.invalidateConnectedLinks(),this.Sa())}get location(){return this.nn}set location(t){let e=t.x,i=t.y,s=this.nn;(s.x!==e&&(!isNaN(s.x)||!isNaN(e))||s.y!==i&&(!isNaN(s.y)||!isNaN(i)))&&(t=t.copy(),this.bE(t,s)&&this.t("location",s,t.copy()))}bE(t,e){if(this.Ar())return!1;if(this.nn=t,this.k|=2097152,this.as()===!1){this.ak();let i=this.ct;if(i.isReal()){let s=this.diagram;if(s===null||s.animationManager.isTicking||!s.undoManager.isUndoingRedoing){let n=i.copy();i.e(i.x+(t.x-e.x),i.y+(t.y-e.y)),this.VD(s,i,n.x,n.y),this.t("position",n,i.copy())}}}return!0}DN(t,e,i){if(this.Ar()||!t.isReal())return!1;let s=this.diagram;if(s!==null&&this.VD(s,t,e,i),this.ct=t,this.k&=-2097153,this.nn.isReal()&&(s===null||s.animationManager.isTicking||!s.undoManager.isUndoingRedoing)){let n=this.nn;this.nn=new P(n.x+(t.x-e),n.y+(t.y-i)).b(),this.t("location",n,this.nn.copy())}return this.fa()===!1&&this.as()===!1&&(this.ak(),this.ED()),!0}VD(t,e,i,s){if(t===null||this instanceof Mt)return;let n=t.animationManager;n.ke&&n.vA(this,new P(i,s),e,!1)}Ec(t,e,i){let s=this.nn,n=this.ct;if(i){if(s.x===t&&s.y===e)return;this.fa()||this.as()?n.e(NaN,NaN):n.e(n.x+t-s.x,n.y+e-s.y),s.e(t,e)}else{if(n.x===t&&n.y===e)return;s.e(s.x+t-n.x,s.y+e-n.y),n.e(t,e)}this.ak()}vN(){this.k&=-2097153,this.ak()}UD(t,e){let i=this.fD(P.l()),s=this.diagram,n=e.isReal(),o=t.isReal();n&&o?(this.k&2097152)!==0?this.BD(t,e,s,i):this.zD(t,e,s,i):n?this.BD(t,e,s,i):o&&this.zD(t,e,s,i),this.k|=2097152,P.i(i),this.pf()}BD(t,e,i,s){let n=t.x,o=t.y;if(t.e(e.x-s.x,e.y-s.y),i!==null){let r=i.animationManager,a=r.defaultAnimation.isAnimating;!a&&r.ke&&!(this instanceof Mt)&&r.vA(this,new P(n,o),t,!1),!a&&!(t.x===n&&t.y===o)&&this.t("position",new P(n,o),t.copy())}}zD(t,e,i,s){let n=e.copy();e.e(t.x+s.x,t.y+s.y),!e.equals(n)&&i!==null&&this.t("location",n,e.copy())}dT(t,e){this.NN(!1),this instanceof it&&e.V2(this),!this.layer.isTemporary&&!t&&e.invalidateDocumentBounds();let i=this.De,s=e.viewportBounds;s.isReal()?this.Ul()?(i.UL(s,10)||this.As(!1),this.updateAdornments()):this.isVisible()&&i.intersectsRect(s)?(this.As(!0),this.updateAdornments()):this.invalidateAdornments():e._c=!0}_r(){return!0}Di(){return!0}Ar(){return!1}_s(){return!0}hasPlaceholder(){return!1}get category(){return this._o}set category(t){let e=this._o;if(e===t)return;this.svg!==null&&(this.svg.remove(),this.$i(!0));let i=this.diagram,s=this.data,n=null;if(i!==null&&s!==null&&!(this instanceof Mt)){let o=i.model.undoManager;o.isEnabled&&!o.isUndoingRedoing&&(n=this.clone(),n.D.addAll(this.D))}if(this._o=t,this.t("category",e,t),i!==null&&s!==null&&!(this instanceof Mt)){let o=i.model;if(o.undoManager.isUndoingRedoing)return;if(this.Ar()){i.partManager.setLinkCategoryForData(s,t);let r=i.partManager.findLinkTemplateForCategory(t);if(r!==null){r.It();let a=r.copy();a!==null&&this.cC(a,e,t)}}else{o!==null&&o.setCategoryForNodeData(s,t);let r=i.partManager.findTemplateForNodeData(s,t);if(r!==null){r.It();let a=r.copy();if(a!==null&&!(a instanceof q)){let h=this.location.copy();this.cC(a,e,t),this.location.isReal()||(this.location=h)}}}if(n!==null){let r=this.clone();r.D.addAll(this.D),this.t("self",n,r)}}else if(this instanceof Mt){let o=this.adornedPart;if(o!==null){let r=o.tr;r!==null&&r.delete(e),o.addAdornment(this.category,this)}}}get self(){return this}set self(t){this.cC(t,this.category,t.category)}static XD=!1;cC(t,e,i){t.constructor!==this.constructor&&(bt.XD||(bt.XD=!0,g.ne('Should not change the class of the Part when changing category from "'+e+'" to "'+i+'"'),g.ne(" Old class: "+g.Hn(this.constructor)+", new class: "+g.Hn(t.constructor)+", part: "+this.toString()))),this.clearAdornments();let s=this.data,n=this.layerName,o=this.isSelected,r=this.isHighlighted,a=!0,h=!0,l=!1;this instanceof it&&(a=this.isTreeLeaf,h=this.isTreeExpanded,l=this.wasTreeExpanded),t.jo(this),t.cloneProtected(this),this._o=i,this.svg!==null&&(this.svg.remove(),this.qc(),this.$i(!0)),this.c(),this.C();let c=this.diagram,u=!0;c!==null&&(u=c.skipsUndoManager,c.skipsUndoManager=!0),this.te=s,this.k=o?this.k|4096:this.k&-4097,this.k=r?this.k|524288:this.k&-524289,this instanceof it&&(this.E=a?this.E|4:this.E&-5,this.E=h?this.E|1:this.E&-2,this.E=l?this.E|2:this.E&-3),s!==null&&this.updateTargetBindings();let d=this.layerName;d!==n&&(this.dl=n,this.layerName=d),c!==null&&(c.skipsUndoManager=u),this.Di()&&this.invalidateLayout(64)}canCopy(){if(!this.copyable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowCopy)return!1;let e=t.diagram;return e===null?!0:!!e.allowCopy}canDelete(){if(!this.deletable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowDelete)return!1;let e=t.diagram;return e===null?!0:!!e.allowDelete}canEdit(){if(!this.textEditable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowTextEdit)return!1;let e=t.diagram;return e===null?!0:!!e.allowTextEdit}canGroup(){if(!this.groupable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowGroup)return!1;let e=t.diagram;return e===null?!0:!!e.allowGroup}canMove(){if(!this.movable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowMove)return!1;let e=t.diagram;return e===null?!0:!!e.allowMove}canReshape(){if(!this.reshapable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowReshape)return!1;let e=t.diagram;return e===null?!0:!!e.allowReshape}canResize(){if(!this.resizable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowResize)return!1;let e=t.diagram;return e===null?!0:!!e.allowResize}canRotate(){if(!this.rotatable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowRotate)return!1;let e=t.diagram;return e===null?!0:!!e.allowRotate}canSelect(){if(!this.selectable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowSelect)return!1;let e=t.diagram;return e===null?!0:!!e.allowSelect}get copyable(){return(this.k&1)!==0}set copyable(t){let e=(this.k&1)!==0;e!==t&&(this.k=this.k^1,this.t("copyable",e,t))}get deletable(){return(this.k&2)!==0}set deletable(t){let e=(this.k&2)!==0;e!==t&&(this.k=this.k^2,this.t("deletable",e,t))}get textEditable(){return(this.k&4)!==0}set textEditable(t){let e=(this.k&4)!==0;e!==t&&(this.k=this.k^4,this.t("textEditable",e,t),this.invalidateAdornments())}get groupable(){return(this.k&8)!==0}set groupable(t){let e=(this.k&8)!==0;e!==t&&(this.k=this.k^8,this.t("groupable",e,t))}get movable(){return(this.k&16)!==0}set movable(t){let e=(this.k&16)!==0;e!==t&&(this.k=this.k^16,this.t("movable",e,t))}get selectionAdorned(){return(this.k&32)!==0}set selectionAdorned(t){let e=(this.k&32)!==0;e!==t&&(this.k=this.k^32,this.t("selectionAdorned",e,t),this.invalidateAdornments())}get isInDocumentBounds(){return(this.k&64)!==0}set isInDocumentBounds(t){let e=(this.k&64)!==0;if(e!==t){this.k=this.k^64;let i=this.diagram;i!==null&&i.invalidateDocumentBounds(),this.t("isInDocumentBounds",e,t)}}get isLayoutPositioned(){return(this.k&128)!==0}set isLayoutPositioned(t){let e=(this.k&128)!==0;e!==t&&(this.k=this.k^128,this.t("isLayoutPositioned",e,t),this.invalidateLayout(t?4:8))}get selectable(){return(this.k&256)!==0}set selectable(t){let e=(this.k&256)!==0;e!==t&&(this.k=this.k^256,this.t("selectable",e,t),this.invalidateAdornments())}get reshapable(){return(this.k&512)!==0}set reshapable(t){let e=(this.k&512)!==0;e!==t&&(this.k=this.k^512,this.t("reshapable",e,t),this.invalidateAdornments())}get resizable(){return(this.k&1024)!==0}set resizable(t){let e=(this.k&1024)!==0;e!==t&&(this.k=this.k^1024,this.t("resizable",e,t),this.invalidateAdornments())}get rotatable(){return(this.k&2048)!==0}set rotatable(t){let e=(this.k&2048)!==0;e!==t&&(this.k=this.k^2048,this.t("rotatable",e,t),this.invalidateAdornments())}get isSelected(){return(this.k&4096)!==0}set isSelected(t){let e=(this.k&4096)!==0;if(e!==t){let i=this.diagram;if(t){if(!this.canSelect())return;if(i!==null){let o=i.maxSelectionCount;if(i.selection.count>=o)return}}this.k=this.k^4096;let s=!1;if(i!==null){s=i.skipsUndoManager,i.skipsUndoManager=!0;let o=i.selection;o.ce(),t?o.add(this):o.delete(this),o.b()}this.t("isSelected",e,t),this.invalidateAdornments();let n=this.selectionChanged;n!==null&&n(this),i!==null&&(i.requestUpdate(),i.skipsUndoManager=s)}}get isHighlighted(){return(this.k&524288)!==0}set isHighlighted(t){let e=(this.k&524288)!==0;if(e!==t){this.k=this.k^524288;let i=this.diagram;if(i!==null){let n=i.highlighteds;n.ce(),t?n.add(this):n.delete(this),n.b()}this.t("isHighlighted",e,t),this.C();let s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.k&8192)!==0}set isShadowed(t){let e=(this.k&8192)!==0;e!==t&&(this.k=this.k^8192,this.$i(!0),this.t("isShadowed",e,t),this.C())}OD(){return(this.k&16384)!==0}ID(t){t?this.k|=16384:this.k&=-16385}fa(){return(this.k&32768)!==0}hC(t){t?this.k|=32768:this.k&=-32769}xE(){return(this.k&65536)!==0}NN(t){t?this.k|=65536:this.k&=-65537}Ul(){return(this.k&131072)!==0}As(t){t?this.k|=131072:this.k&=-131073}GD(){return(this.k&1048576)!==0}hk(t){t?this.k|=1048576:this.k&=-1048577}get isAnimated(){return(this.k&262144)!==0}set isAnimated(t){let e=(this.k&262144)!==0;e!==t&&(this.k=this.k^262144,this.t("isAnimated",e,t))}get highlightedChanged(){return this.H!==null?this.H.Cy:null}set highlightedChanged(t){let e=this.highlightedChanged;e!==t&&(t!==null&&g.S(t,bt,"highlightedChanged"),this._e().Cy=t,this.t("highlightedChanged",e,t))}get selectionObjectName(){return this.H!==null?this.H.Ly:""}set selectionObjectName(t){let e=this.selectionObjectName;e!==t&&(this._e().Ly=t,this.gl=null,this.t("selectionObjectName",e,t))}get selectionAdornmentTemplate(){return this.H!==null?this.H.Ay:null}set selectionAdornmentTemplate(t){let e=this.selectionAdornmentTemplate;e!==t&&(t!==null&&t.It(),this._e().Ay=t,this.t("selectionAdornmentTemplate",e,t))}get selectionObject(){if(this.gl===null){let t=this.selectionObjectName;if(t!==null&&t!==""){let e=this.findObject(t);e!==null?this.gl=e:this.gl=this}else if(this instanceof q){let e=this.path;e!==null?this.gl=e:this.gl=this}else this.gl=this}return this.gl}get selectionChanged(){return this.H!==null?this.H.Ty:null}set selectionChanged(t){let e=this.selectionChanged;e!==t&&(t!==null&&g.S(t,bt,"selectionChanged"),this._e().Ty=t,this.t("selectionChanged",e,t))}get resizeAdornmentTemplate(){return this.H!==null?this.H.Dy:null}set resizeAdornmentTemplate(t){let e=this.resizeAdornmentTemplate;e!==t&&(this._e().Dy=t!==null?t.It():null,this.t("resizeAdornmentTemplate",e,t))}get resizeObjectName(){return this.H!==null?this.H.vy:""}set resizeObjectName(t){let e=this.resizeObjectName;e!==t&&(this._e().vy=t,this.t("resizeObjectName",e,t))}get resizeObject(){let t=this.resizeObjectName;if(t!==""){let e=this.findObject(t);if(e!==null)return e}return this}get resizeCellSize(){return this.H!==null?this.H.Fy:_.$w}set resizeCellSize(t){let e=this.resizeCellSize;e.equals(t)||(t=t.N(),this._e().Fy=t,this.t("resizeCellSize",e,t))}get rotateAdornmentTemplate(){return this.H!==null?this.H.Ry:null}set rotateAdornmentTemplate(t){let e=this.rotateAdornmentTemplate;e!==t&&(this._e().Ry=t!==null?t.It():null,this.t("rotateAdornmentTemplate",e,t))}get rotateObjectName(){return this.H!==null?this.H.Oy:""}set rotateObjectName(t){let e=this.rotateObjectName;e!==t&&(this._e().Oy=t,this.t("rotateObjectName",e,t))}get rotateObject(){let t=this.rotateObjectName;if(t!==""){let e=this.findObject(t);if(e!==null)return e}return this}get rotationSpot(){return this.H!==null?this.H.Iy:T.Default}set rotationSpot(t){let e=this.rotationSpot;e.equals(t)||(t=t.N(),this._e().Iy=t,this.t("rotationSpot",e,t))}get text(){return this.ue}set text(t){let e=this.ue;e!==t&&(this.ue=t,this.t("text",e,t))}get containingGroup(){return this.Ta}set containingGroup(t){if(this.Di()){let e=this.Ta;if(e!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&g.o("Cannot make a Group a member of itself: "+this.toString()),g.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);let i=this.diagram;if(e!==null?e.fC(this):this instanceof ft&&i!==null&&i.Zr.delete(this),this.Ta=t,t!==null?t.uC(this):this instanceof ft&&i!==null&&i.Zr.add(this),this.invalidateLayout(1),i!==null&&i.G){let n=this.data,o=i.model;if(n!==null&&o.ff()){let r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}let s=this.containingGroupChanged;if(s!==null){let n=!0;i!==null&&(n=i.G,i.G=!0),s(this,e,t),i!==null&&(i.G=n)}if(this instanceof ft){let n=new I;bt.ga(n,this,!0,0,!0);let o=n.iterator;for(;o.next();){let r=o.value;if(r instanceof it){let a=r.linksConnected;for(;a.next();)a.value.qd()}}}if(this instanceof it){let n=this.linksConnected;for(;n.next();)n.value.qd();let o=this.labeledLink;o!==null&&o.qd()}this.t("containingGroup",e,t),t!==null&&t.yE()}}else g.o("cannot set the Part.containingGroup of a Link or Adornment")}Sa(){let t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){let t=this.diagram;t!==null&&!this.as()&&!this.fa()&&this.isVisible()&&this.De.isReal()&&t.C(this.lh(this.De))}c(){if(this.Go())return;super.c();let t=this.diagram;t!==null&&(t.Np(this),this instanceof it&&this.labeledLink!==null&&this.labeledLink.kf(),t.requestUpdate(!0))}kf(t){if(this.as())return;let e=this.diagram;e!==null&&(e.Np(this),this instanceof it&&this.invalidateConnectedLinks(),e.requestUpdate()),this.ao(!0)}_m(t){if(!t){let e=this.Ta;e!==null&&e.uC(this)}}tp(t){if(!t){let e=this.Ta;e!==null&&e.fC(this)}}rf(){let t=this.data;if(t!==null){let e=this.diagram;if(e!==null){let i=e.model;i!==null&&i.removeNodeData(t)}}}get containingGroupChanged(){return this.H!==null?this.H.Ey:null}set containingGroupChanged(t){let e=this.containingGroupChanged;e!==t&&(t!==null&&g.S(t,bt,"containingGroupChanged"),this._e().Ey=t,this.t("containingGroupChanged",e,t))}findSubGraphLevel(){return this.dC(this)}dC(t){let e=t.containingGroup;if(e!==null)return 1+this.dC(e);if(t instanceof it){let i=t.labeledLink;if(i!==null)return this.dC(i)}return 0}findTopLevelPart(){return this.gC(this)}gC(t){let e=t.containingGroup;if(e!==null)return this.gC(e);if(t instanceof it){let i=t.labeledLink;if(i!==null)return this.gC(i)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof it&&this.labeledLink!==null)}isMemberOf(t){return t instanceof ft?this.mC(this,t):!1}mC(t,e){if(t===e||e===null)return!1;let i=t.containingGroup;if(i!==null&&(i===e||this.mC(i,e)))return!0;if(t instanceof it){let s=t.labeledLink;if(s!==null)return this.mC(s,e)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let e=this;for(;e!==null;){if(e instanceof ft&&e.hk(!0),e instanceof it){let s=e.labeledLink;s!==null&&(e=s)}e=e.containingGroup}let i=null;for(e=t;e!==null;){if(e.GD()){i=e;break}if(e instanceof it){let s=e.labeledLink;s!==null&&(e=s)}e=e.containingGroup}for(e=this;e!==null;){if(e instanceof ft&&e.hk(!1),e instanceof it){let s=e.labeledLink;s!==null&&(e=s)}e=e.containingGroup}return i}get layoutConditions(){return this.H!==null?this.H.Uy:127}set layoutConditions(t){let e=this.layoutConditions;e!==t&&(this._e().Uy=t,this.t("layoutConditions",e,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;let t=this.layer;return!(t!==null&&t.isTemporary||this instanceof it&&this.isLinkLabel)}kE(t){if(!this.isLayoutPositioned||(t&this.layoutConditions)===0)return!1;let e=this.layer;if(e!==null&&e.isTemporary||this instanceof it&&this.isLinkLabel)return!1;let i=this.diagram;return!(i!==null&&i.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.kE(t))return;let e=this.Ta;if(e!==null){let i=e.layout;i!==null?i.p():e.invalidateLayout(t)}else{let i=this.diagram;if(i!==null){let s=i.layout;s!==null&&s.p()}}}gT(){if(!this.isVisible())return!1;let t=this.layer;return!(t!==null&&t.isTemporary)}static ga(t,e,i,s,n,o){if(o===void 0&&(o=null),!t.has(e)&&!(o!==null&&!o(e))&&!(e instanceof Mt)){if(t.add(e),e instanceof it){if(i&&e instanceof ft){let r=e.memberParts;for(;r.next();){let a=r.value;bt.ga(t,a,i,s,n,o)}}if(n!==!1){let r=e.linksConnected;for(;r.next();){let a=r.value;if(t.has(a))continue;let h=a.fromNode,l=a.toNode,c=h===null||t.has(h),u=l===null||t.has(l);(n?c&&u:c||u)&&bt.ga(t,a,i,s,n,o)}}if(s>1){let r=e.findTreeChildrenNodes();for(;r.next();){let a=r.value;bt.ga(t,a,i,s-1,n,o)}}}else if(e instanceof q){let r=e.labelNodes;for(;r.next();){let a=r.value;bt.ga(t,a,i,s,n,o)}}}}get dragComputation(){return this.H!==null?this.H.Vy:null}set dragComputation(t){let e=this.dragComputation;e!==t&&(t!==null&&g.S(t,bt,"dragComputation"),this._e().Vy=t,this.t("dragComputation",e,t))}get shadowOffset(){return this.H!==null?this.H.By:P.FL}set shadowOffset(t){let e=this.shadowOffset;e.equals(t)||(t=t.N(),this._e().By=t,this.C(),this.t("shadowOffset",e,t))}get shadowColor(){return this.H!==null?this.H.zy:"gray"}set shadowColor(t){let e=this.shadowColor;e!==t&&(this._e().zy=t,this.C(),this.t("shadowColor",e,t))}get shadowBlur(){return this.H!==null?this.H.An:4}set shadowBlur(t){let e=this.shadowBlur;e!==t&&(this._e().An=t,this.C(),this.t("shadowBlur",e,t))}}class As{me;ky;Ey;Ay;Ly;Ty;Cy;Dy;vy;Fy;Ry;Oy;Iy;My;Ny;Py;Sy;Vy;Uy;By;zy;An;constructor(){this.me=!1,this.ky=null,this.Ey=null,this.Ay=null,this.Ly="",this.Ty=null,this.Cy=null,this.Dy=null,this.vy="",this.Fy=_.$w,this.Ry=null,this.Oy="",this.Iy=T.Default,this.My="",this.Ny=T.TopLeft,this.Py=P.DL,this.Sy=P.vL,this.Vy=null,this.Uy=127,this.By=P.FL,this.zy="gray",this.An=4}copy(){let t=new As;return t.ky=this.ky,t.Ey=this.Ey,t.Ay=this.Ay,t.Ly=this.Ly,t.Ty=this.Ty,t.Cy=this.Cy,t.Dy=this.Dy,t.vy=this.vy,t.Fy=this.Fy.N(),t.Ry=this.Ry,t.Oy=this.Oy,t.Iy=this.Iy.N(),t.My=this.My,t.Ny=this.Ny.N(),t.Py=this.Py.N(),t.Sy=this.Sy.N(),t.Vy=this.Vy,t.Uy=this.Uy,t.By=this.By.N(),t.zy=this.zy,t.An=this.An,t}}class Mt extends bt{Ms;Dt;qS;WS;Lf;constructor(t,e){let i;t===void 0||t instanceof Ft||typeof t=="string"?i=t:t&&(e=t),super(i),this.k&=-257,this.dl="Adornment",this.Ms=null,this.qS=0,this.WS=!1,this.Dt=null,this.Lf=null,e&&Object.assign(this,e)}toString(){let t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}Ad(t){let e=this.adornedObject;if(!(e instanceof at))return;let i=e.part;if(!(i instanceof q))return;let s=i.path,n=s.geometry;i.Ad(t),n=s.geometry;let o=this.D.r,r=o.length;for(let a=0;a<r;a++){let h=o[a];h.isPanelMain&&h instanceof at&&(h.ut=n)}}hasPlaceholder(){return this.Dt!==null&&this.Dt.isVisibleObject()}get placeholder(){return this.Dt}get adornedObject(){return this.Ms}set adornedObject(t){let e=this.adornedPart,i=null;t!==null&&(i=t.part),e!==null&&(t===null||e!==i)&&e.removeAdornment(this.category),this.Ms=t,i!==null&&i.addAdornment(this.category,this)}get adornedPart(){let t=this.Ms;return t!==null?t.part:null}_r(){let t=this.Ms;if(t===null)return!0;let e=t.part;return e===null||!e.as()}Di(){return!1}get containingGroup(){return null}df(t,e,i,s,n,o,r){if(t===3&&e==="elements"){if(n instanceof we)this.Dt===null&&(this.Dt=n);else if(n instanceof H){let a=n.findInVisualTree(h=>h instanceof we);a instanceof we&&this.Dt===null&&(this.Dt=a)}}else t===4&&e==="elements"&&this.Dt!==null&&(s===this.Dt?this.Dt=null:s instanceof H&&this.Dt.isContainedBy(s)&&(this.Dt=null));super.df(t,e,i,s,n,o,r)}updateAdornments(){}rf(){}}var Rn=(x=>(x[x.None=0]="None",x[x.Evenly=1]="Evenly",x[x.Packed=2]="Packed",x))(Rn||{});class it extends bt{E;vt;zf;yl;Da;hi;ee;constructor(t,e){let i;t===void 0||t instanceof Ft||typeof t=="string"?i=t:t&&(e=t),super(i),this.E=13,this.vt=null,this.ee=new U,this.zf=null,this.yl=null,this.hi=null,this.Da=!1,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.vt!==null&&(this.vt.me?t.vt=this.vt:t.vt=this.vt.copy())}jo(t){super.jo(t),t.invalidateConnectedLinks(),t.yl=this.yl,t.hi=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;wl(){return this.vt===null?this.vt=new Ts:this.vt.me&&(this.vt=this.vt.copy()),this.vt}ba(){super.ba(),this.vt!==null&&(this.vt.me=!0)}YD(t){t!==null&&(this.yl===null&&(this.yl=new I),this.yl.add(t))}KD(t){t!==null&&this.yl!==null&&this.yl.delete(t)}HD(t,e,i){if(t===null||this.yl===null)return null;let s=this.yl.iterator;for(;s.next();){let n=s.value;if(n.Xy===this&&n.ck===t&&n.pC===e&&n.yC===i||n.Xy===t&&n.ck===this&&n.pC===i&&n.yC===e)return n}return null}invalidateLinkBundle(t,e,i){e==null&&(e=""),i==null&&(i="");let s=this.HD(t,e,i);s!==null&&s.Wd()}df(t,e,i,s,n,o,r){t===3&&e==="elements"?this.hi=null:t===4&&e==="elements"&&(this.hi=null),super.df(t,e,i,s,n,o,r)}invalidateConnectedLinks(t,e){let i=this.linksConnected;for(;i.next();){let s=i.value;t&&t.has(s)||e&&s.fromPort!==e&&s.toPort!==e||(this.Pi(s.fromPort),this.Pi(s.toPort),s.$t())}}Pi(t){if(t===null)return;let e=t.pd;e!==null&&e.Wd();let i=t.part,s=i.containingGroup;s!==null&&!i.isVisible()&&s.Pi(s.port)}_r(){return!0}get portSpreading(){return this.vt!==null?this.vt.Gy:1}set portSpreading(t){let e=this.portSpreading;if(e!==t){this.wl().Gy=t,this.t("portSpreading",e,t);let i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){let e=(this.E&8)!==0;if(e!==t){this.E=this.E^8;let i=this.diagram;i!==null&&i.V2(this),this.t("avoidable",e,t)}}get avoidableMargin(){return this.vt!==null?this.vt.Yy:Dt.BL}set avoidableMargin(t){typeof t=="number"&&(t=new Dt(t));let e=this.avoidableMargin;if(!e.equals(t)){t=t.N(),this.wl().Yy=t;let i=this.diagram;i!==null&&i.V2(this),this.t("avoidableMargin",e,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,e=1,i=this.diagram;if(i!==null){if(i.animationManager.qx(this))return!0;t=i.isTreePathToChildren,e=i.treeCollapsePolicy}if(e===1){let n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(e===2){let n=t?this.findLinksInto():this.findLinksOutOf(),o=!1,r=!1;for(;n.next();){let a=n.value;if(a.isTreeLink){o=!0;let h=t?a.fromNode:a.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(e===3){let n=t?this.findLinksInto():this.findLinksOutOf(),o=!1,r=!1;for(;n.next();){let a=n.value;if(a.isTreeLink){o=!0;let h=t?a.fromNode:a.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}let s=this.labeledLink;return s!==null?s.isVisible():!0}Xe(t){super.Xe(t);let e=this.linksConnected;for(;e.next();){let i=e.value;if(t&&this.containingGroup!==null){let s=i.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&i.$t()}i.Xe(t)}}get linksConnected(){return this.ee.iterator}findExternalTreeLinksConnected(){let t=new I,e=new I;return this.jD(this,t,e),e.iterator}jD(t,e,i){if(t===null||e.has(t))return;e.add(t);let s=!0,n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.jD(s?o.toNode:o.fromNode,e,i):i.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ee.iterator;let e=new et(this.ee),i=this;return e.predicate=s=>s.fromNode===i&&s.fromPortId===t||s.toNode===i&&s.toPortId===t,e}findLinksOutOf(t){t===void 0&&(t=null);let e=new et(this.ee),i=this;return e.predicate=s=>s.fromNode!==i?!1:t===null?!0:s.fromPortId===t,e}findLinksInto(t){t===void 0&&(t=null);let e=new et(this.ee),i=this;return e.predicate=s=>s.toNode!==i?!1:t===null?!0:s.toPortId===t,e}findNodesConnected(t){t===void 0&&(t=null);let e=null,i=null,s=this.ee.iterator;for(;s.next();){let n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){let o=n.toNode;e!==null?e.add(o):i!==null&&i!==o?(e=new I,e.add(i),e.add(o)):i=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){let o=n.fromNode;e!==null?e.add(o):i!==null&&i!==o?(e=new I,e.add(i),e.add(o)):i=o}}return e!==null?e.iterator:i!==null?new $(i):J.instance}findNodesOutOf(t){t===void 0&&(t=null);let e=null,i=null,s=this.ee.iterator;for(;s.next();){let n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){let o=n.toNode;e!==null?e.add(o):i!==null&&i!==o?(e=new I,e.add(i),e.add(o)):i=o}}return e!==null?e.iterator:i!==null?new $(i):J.instance}findNodesInto(t){t===void 0&&(t=null);let e=null,i=null,s=this.ee.iterator;for(;s.next();){let n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){let o=n.fromNode;e!==null?e.add(o):i!==null&&i!==o?(e=new I,e.add(i),e.add(o)):i=o}}return e!==null?e.iterator:i!==null?new $(i):J.instance}findLinksBetween(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null);let s=new et(this.ee),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i)||o.fromNode===t&&o.toNode===n&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e),s}findLinksTo(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null);let s=new et(this.ee),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||e!==null&&o.fromPortId!==e||i!==null&&o.toPortId!==i),s}findSuccessorParts(t){return t===void 0&&(t=new I),this.qD(this,t),t.remove(this),t}qD(t,e){t!==null&&(e.has(t)||(e.add(t),t.findLinksOutOf().each(i=>{if(e.has(i))return;e.add(i);let s=i.toNode;s!==null&&this.qD(s,e)})))}findPredecessorParts(t){return t===void 0&&(t=new I),this.WD(this,t),t.remove(this),t}WD(t,e){t!==null&&(e.has(t)||(e.add(t),t.findLinksInto().each(i=>{if(e.has(i))return;e.add(i);let s=i.fromNode;s!==null&&this.WD(s,e)})))}get linkConnected(){return this.vt!==null?this.vt.Ky:null}set linkConnected(t){let e=this.linkConnected;e!==t&&(t!==null&&g.S(t,it,"linkConnected"),this.wl().Ky=t,this.t("linkConnected",e,t))}get linkDisconnected(){return this.vt!==null?this.vt.Hy:null}set linkDisconnected(t){let e=this.linkDisconnected;e!==t&&(t!==null&&g.S(t,it,"linkDisconnected"),this.wl().Hy=t,this.t("linkDisconnected",e,t))}get linkValidation(){return this.vt!==null?this.vt.El:null}set linkValidation(t){let e=this.linkValidation;e!==t&&(t!==null&&g.S(t,it,"linkValidation"),this.wl().El=t,this.t("linkValidation",e,t))}fk(t,e){this.Pi(e);let i=this.ee.has(t);if(i||this.ee.add(t),!i||t.fromNode===t.toNode){let s=this.linkConnected;if(s!==null){let n=!0,o=this.diagram;o!==null&&(n=o.G,o.G=!0),s(this,t,e),o!==null&&(o.G=n)}}if(!i){if(!t.isTreeLink)return;let s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0,r=this.diagram;r!==null&&(o=r.isTreePathToChildren);let a=o?n:s,h=o?s:n;if(a.Da||(a.Da=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}uk(t,e){this.Pi(e);let i=this.ee.delete(t),s=null;if(i||t.toNode===t.fromNode){let n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.G,s.G=!0),n(this,t,e),s!==null&&(s.G=o)}}if(i){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);let o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.Da=!1),r!==null&&!r.isTreeLeaf)if(r.ee.count===0){if(r.Da=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.Dp()}}Dp(){if(this.Da=!1,this.ee.count===0)return;let t=!0,e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;e!==null&&(t=e.isTreePathToChildren);let i=this.ee.iterator;for(;i.next();){let s=i.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){let t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}_m(t){if(super._m(t),!t){this.Dp();let e=this.zf;e!==null&&e.JD(this)}}tp(t){if(super.tp(t),!t){let e=this.zf;e!==null&&e.$D(this)}}rf(){if(this.ee.count>0){let t=this.diagram;if(t!==null){let e=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,i=this.ee.copy().iterator;for(;i.next();){let s=i.value;e?t.remove(s):(s.fromNode===this&&(s.fromNode=null),s.toNode===this&&(s.toNode=null))}}}this.labeledLink=null,super.rf()}get isLinkLabel(){return this.zf!==null}get labeledLink(){return this.zf}set labeledLink(t){let e=this.zf;if(e!==t){let i=this.diagram,s=this.data;if(e!==null){if(e.$D(this),i!==null&&s!==null&&!i.undoManager.isUndoingRedoing){let n=e.data,o=i.model;if(n!==null&&o.jh()){let r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.zf=t,t!==null){if(t.JD(this),i!==null&&s!==null&&!i.undoManager.isUndoingRedoing){let n=t.data,o=i.model;if(n!==null&&o.jh()){let r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.kf(),this.t("labeledLink",e,t)}}findVisiblePort(t){let e=t;for(;e!==null&&(!e.actualBounds.isReal()||!e.isVisibleObject());)e=e.panel;return e===null?this.port:e}findPort(t){if(this.hi===null){if(t===""&&this.Ln===!1)return this;this.ZD()}let e=this.hi.get(t);return e!==null||t!==""&&(e=this.hi.get(""),e!==null)?e:this}get port(){return this.findPort("")}get ports(){return this.hi===null&&this.ZD(),this.hi.iteratorValues}ZD(){this.hi===null?this.hi=new wt:this.hi.clear(),this.walkVisualTreeFrom(this,(t,e)=>t.nD(e)),this.hi.count===0&&this.hi.set("",this)}nD(t){let e=t.portId;e!==null&&this.hi!==null&&this.hi.set(e,t)}FN(t,e){let i=t.portId;if(i!==null){this.hi!==null&&this.hi.delete(i);let s=this.diagram;if(s!==null&&e){let n=null,o=this.findLinksConnected(i);for(;o.next();){let r=o.value;n===null&&(n=g.ot()),n.push(r)}if(n!==null){for(let r=0;r<n.length;r++){let a=n[r];s.remove(a)}g.Z(n)}}}}isInTreeOf(t){if(t===null||t===this)return!1;let e=!0,i=this.diagram;i!==null&&(e=i.isTreePathToChildren);let s=this,n=t,o;if(e)for(;s!==n;){o=null;let r=s.ee.iterator;for(;r.next();){let a=r.value;if(a.isTreeLink&&(o=a.fromNode,o!==s&&o!==this))break}if(o===this||o===null||o===s)return!1;s=o}else for(;s!==n;){o=null;let r=s.ee.iterator;for(;r.next();){let a=r.value;if(a.isTreeLink&&(o=a.toNode,o!==s&&o!==this))break}if(o===this||o===null||o===s)return!1;s=o}return!0}findTreeRoot(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=this,s;if(t)for(;;){s=null;let n=i.ee.iterator;for(;n.next();){let o=n.value;if(o.isTreeLink&&(s=o.fromNode,s!==i&&s!==this))break}if(s===this)return this;if(s===null||s===i)return i;i=s}else for(;;){s=null;let n=i.ee.iterator;for(;n.next();){let o=n.value;if(o.isTreeLink&&(s=o.toNode,s!==i&&s!==this))break}if(s===this)return this;if(s===null||s===i)return i;i=s}}findCommonTreeParent(t){if(t===null)return null;if(this===t)return this;let e=this;for(;e!==null;)e.hk(!0),e=e.findTreeParentNode();let i=null;for(e=t;e!==null;){if(e.GD()){i=e;break}e=e.findTreeParentNode()}for(e=this;e!==null;)e.hk(!1),e=e.findTreeParentNode();return i}findTreeParentLink(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=this.ee.iterator;if(t)for(;i.next();){let s=i.value;if(s.isTreeLink&&s.fromNode!==this)return s}else for(;i.next();){let s=i.value;if(s.isTreeLink&&s.toNode!==this)return s}return null}findTreeParentNode(){let t=this.Da;if(t===null)return null;if(t instanceof it)return t;let e=this.diagram,i=e!==null?e.isTreePathToChildren:!0,s=this.ee.iterator;for(;s.next();){let n=s.value;if(!n.isTreeLink)continue;let o=i?n.fromNode:n.toNode;if(o!==this)return this.Da=o,o}return this.Da=null,null}findTreeParentChain(t){function e(i,s){s.add(i);let n=i.findTreeParentLink();if(n!==null){s.add(n);let o=i.findTreeParentNode();if(o===null)return;e(o,s)}}return t===void 0&&(t=new I),e(this,t),t}findTreeLevel(){return this.PE(this)}PE(t){let e=0,i=t.findTreeParentNode();for(;i!==null&&i!==t;)i=i.findTreeParentNode(),e++;return e}findTreeChildrenLinks(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=new et(this.ee),s=this;return t?i.predicate=n=>!(!n.isTreeLink||n.fromNode!==s):i.predicate=n=>!(!n.isTreeLink||n.toNode!==s),i}findTreeChildrenNodes(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=null,s=null,n=this.ee.iterator;if(t)for(;n.next();){let o=n.value;if(o.isTreeLink&&o.fromNode===this){let r=o.toNode;i!==null?i.add(r):s!==null&&s!==r?(i=new U,i.add(s),i.add(r)):s=r}}else for(;n.next();){let o=n.value;if(o.isTreeLink&&o.toNode===this){let r=o.fromNode;i!==null?i.add(r):s!==null&&s!==r?(i=new U,i.add(s),i.add(r)):s=r}}return i!==null?i.iterator:s!==null?new $(s):J.instance}findTreeParts(t,e){return t===void 0&&(t=1/0),g.s(t,"number",it,"findTreeParts:level"),e===void 0&&(e=new I),bt.ga(e,this,!1,t,!0),e}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);let e=this.diagram;if(e===null||e.isCollapsingExpanding)return;e.isCollapsingExpanding=!0;let i=new I;i.add(this),this.QD(i,e.isTreePathToChildren,t,e,this,e.treeCollapsePolicy===1),e.isCollapsingExpanding=!1}QD(t,e,i,s,n,o){if(i>1){let r=e?this.findLinksOutOf():this.findLinksInto();for(;r.next();){let a=r.value;if(!a.isTreeLink)continue;let h=a.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.QD(t,e,i-1,s,n,o))}}else this._D(t,e,s,n,o)}_D(t,e,i,s,n){let o=s===this?!0:this.isTreeExpanded,r=e?this.findLinksOutOf():this.findLinksInto();for(;r.next();){let a=r.value;if(!a.isTreeLink)continue;let h=a.getOtherNode(this);if(h!==null&&h!==this){let l=t.has(h);if(l||t.add(h),o){let c=e?h.findNodesInto():h.findNodesOutOf(),u=this;c.all(d=>d===u||!d.isTreeExpanded)&&i.Yc(h,s),h.Sa(),h.Xe(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,l||h._D(t,e,i,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);let e=this.diagram;if(e===null||e.isCollapsingExpanding)return;e.isCollapsingExpanding=!0;let i=new I;i.add(this),this.tv(i,e.isTreePathToChildren,t,e,this,e.treeCollapsePolicy===1),e.isCollapsingExpanding=!1}tv(t,e,i,s,n,o){let r=n===this?!1:this.isTreeExpanded,a=e?this.findLinksOutOf():this.findLinksInto();for(;a.next();){let h=a.value;if(!h.isTreeLink)continue;r||h.Fi||h.$t();let l=h.getOtherNode(this);if(l!==null&&l!==this&&!t.has(l)){if(t.add(l),!r){l.Xe(!0),l.Sa();let c=e?l.findNodesInto():l.findNodesOutOf(),u=this;c.all(d=>d===u||!d.isTreeExpanded)&&s.Gc(l,n)}(i>2||l.wasTreeExpanded)&&(l.wasTreeExpanded=!1,l.tv(t,e,i-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){let e=(this.E&1)!==0;if(e!==t){this.E=this.E^1;let i=this.diagram;this.t("isTreeExpanded",e,t);let s=this.treeExpandedChanged;if(s!==null){let n=!0;i!==null&&(n=i.G,i.G=!0),s(this),i!==null&&(i.G=n)}if(i!==null&&i.undoManager.isUndoingRedoing){this.Xe(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){let e=(this.E&2)!==0;e!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",e,t))}get treeExpandedChanged(){return this.vt!==null?this.vt.jy:null}set treeExpandedChanged(t){let e=this.treeExpandedChanged;e!==t&&(t!==null&&g.S(t,it,"treeExpandedChanged"),this.wl().jy=t,this.t("treeExpandedChanged",e,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){let e=(this.E&4)!==0;e!==t&&(this.E=this.E^4,this.t("isTreeLeaf",e,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class Ts{me;Ky;Hy;El;jy;Yy;Gy;qy;Wy;da;Jy;constructor(){this.me=!1,this.Ky=null,this.Hy=null,this.El=null,this.jy=null,this.Yy=Dt.BL,this.Gy=1,this.qy=null,this.Wy=null,this.da=null,this.Jy=null}copy(){let t=new Ts;return t.Ky=this.Ky,t.Hy=this.Hy,t.El=this.El,t.jy=this.jy,t.Yy=this.Yy.N(),t.Gy=this.Gy,t.qy=this.qy,t.Wy=this.Wy,t.da=this.da,t.Jy=this.Jy,t}}var Ls=(x=>(x[x.None=0]="None",x[x.End=17]="End",x[x.Scale=18]="Scale",x[x.Stretch=19]="Stretch",x))(Ls||{}),Ds=(x=>(x[x.Normal=1]="Normal",x[x.Orthogonal=2]="Orthogonal",x[x.AvoidsNodes=6]="AvoidsNodes",x[x.AvoidsNodesStraight=7]="AvoidsNodesStraight",x))(Ds||{}),Fs=(x=>(x[x.None=0]="None",x[x.Bezier=9]="Bezier",x[x.JumpGap=10]="JumpGap",x[x.JumpOver=11]="JumpOver",x))(Fs||{});class q extends bt{Nt;po;yo;Jd;wo;xo;$d;Xf;Zd;Qd;_d;qh;tg;on;Me;xl;vr;Gf;ir;wC;xC;dk;bC;kC;Wh;gk;ut;sr;static Jh=null;static $h=null;Lf;PC;SC;constructor(t){super(H.Link),this.Nt=8,this.po=null,this.yo="",this.Jd=null,this.wo=null,this.xo="",this.$d=null,this.Xf=0,this.Zd=0,this.Qd=0,this._d=NaN,this.qh=1,this.tg=.5,this.on=null,this.Me=new U().b(),this.xl=null,this.vr=null,this.Gf=new B,this.ut=new St,this.ir=null,this.sr=null,this.wC=P.mn,this.xC=P.mn,this.PC=0,this.SC=0,this.dk=new P,this.bC=null,this.kC=null,this.Wh=null,this.gk=NaN,this.ft=null,this.Lf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.yo=this.yo,t.Jd=this.Jd,t.xo=this.xo,t.$d=this.$d,t.Xf=this.Xf,t.Zd=this.Zd,t.Qd=this.Qd,t._d=this._d,t.qh=this.qh,t.tg=this.tg,this.ft!==null&&(t.ft=this.ft.copy())}jo(t){super.jo(t),this.yo=t.yo,this.xo=t.xo,t.xl=null,t.$t(),t.sr=this.sr;let e=t.fromPort;e!==null&&t.fromNode.Pi(e);let i=t.toPort;i!==null&&t.toNode.Pi(i)}fe(t){t in Ds||t in Fs||t in Ls?q.MC(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||g.o("Unknown Link enum value for a Link property: "+t):super.fe(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static ev=8;static iv=16;static va=8;static W1=3;static sv=3;static nv=1.333;static NC=1;static CC=0;static ov=10;static Yf=9999;static rv=30;static lv=30;static LC=10;static av=10;static hv=14;static cv=30;static fv=14;static _A=8;static tT=8;static uv=11;static setRoutingParameter(t,e){switch(t){case 1:q.ev=e;break;case 2:q.iv=e;break;case 3:q.va=e;break;case 4:q.W1=e;break;case 5:q.sv=e;break;case 6:q.nv=e;break;case 7:q.NC=e;break;case 8:q.CC=e;break;case 9:q.ov=e;break;case 10:q.Yf=e;break;case 11:q.rv=e;break;case 12:q.lv=e;break;case 13:q.LC=e;break;case 14:q.av=e;break;case 15:q.hv=e;break;case 16:q.cv=e;break;case 17:q.fv=e;break;case 18:q._A=e;break;case 19:q.tT=e;break;case 20:q.uv=e;break}t>29&&t<71&&(q.IT=t+parseInt(e.toString().slice(0,-1)))}static IT;Ji(){return this.ft===null&&(this.ft=new ns),this.ft}OI(t,e,i){let s=t.segmentIndex,n=t.segmentFraction,o=t.alignmentFocus,r=t.segmentOrientation,a=t.segmentOffset,h=0,l=0,c=0,u=0;if(isNaN(s)){let D=this.ut,N=g.ot();D.getPointAndAngleAlongPath(n,N);let L=P.z(N[0],N[1]);if(u=N[2],L.add(this.getPoint(0)),D.type===1)L.offset(-D.startX,-D.startY);else{let R=D.figures.first();L.offset(-R.startX,-R.startY)}r!==0&&(c=this.computeAngle(t,r,u),t.angle=c),h=L.x,l=L.y,P.i(L),g.Z(N)}else if(s<-e||s>=e){let D=P.l();this.HN(D),u=this.midAngle,r!==0&&(c=this.computeAngle(t,r,u),t.angle=c),h=D.x,l=D.y,P.i(D)}else{let D,N,L=0;if(s>=0?(D=i.r[s],N=s<e-1?i.r[s+1]:D):(L=e+s,D=i.r[L],N=L>0?i.r[L-1]:D),D.equalsApprox(N)){let R,O;s>=0?(R=s>0?i.r[s-1]:D,O=s<e-2?i.r[s+2]:N):(R=L<e-1?i.r[L+1]:D,O=L>1?i.r[L-2]:N);let V=R.distanceSquaredPoint(D),K=N.distanceSquaredPoint(O);V>K+10?u=s>=0?R.directionPoint(D):D.directionPoint(R):K>V+10?u=s>=0?N.directionPoint(O):O.directionPoint(N):u=s>=0?R.directionPoint(O):O.directionPoint(R)}else u=s>=0?D.directionPoint(N):N.directionPoint(D);r!==0&&(c=this.computeAngle(t,r,u),t.angle=c),h=D.x+(N.x-D.x)*n,l=D.y+(N.y-D.y)*n}if(o.isNone()){t.moveTo(h,l,!0);return}else o.isNoSpot()&&(o=T.Center);let d=Pt.l();d.Ue(),d.it(t.scale,t.scale),d.ks(t.angle,0,0);let f=t.naturalBounds,p=B.z(0,0,f.width,f.height),m=P.l();m.setRectSpot(p,o),d.gt(m);let y=-m.x,b=-m.y,v=f.width,w=f.height,k=P.bs(a),S=isNaN(a.x),M=isNaN(a.y);if(S||M){let D=v/2+q.W1,N=w/2+q.sv,L=u>=45&&u<=135,R=u>=225&&u<=315;r===0&&(L||R)?(k.x=M?D:a.y,k.y=S?N:a.x,L?s>=0||isNaN(s)&&n<.5||S&&(k.y=-N):R&&((s>=0||isNaN(s)&&n<.5)&&S&&(k.y=-N),M&&(k.x=-D))):(S&&(s>=0||isNaN(s)&&n<.5?k.x=D:k.x=-D),M&&(k.y=-N),k.rotate(u))}else k.rotate(u);h+=k.x,l+=k.y,d.im(p),y+=p.x,b+=p.y;let F=P.z(h+y,l+b);t.move(F),P.i(F),P.i(k),P.i(m),B.i(p),Pt.i(d)}_r(){let t=this.fromNode;if(t!==null){let i=t.findVisibleNode();if(i!==null&&(t=i),t.as()||t.fa())return!1}let e=this.toNode;if(e!==null){let i=e.findVisibleNode();if(i!==null&&(e=i),e.as()||e.fa())return!1}return!0}DN(t,e,i){return!1}vN(){}Di(){return!1}computeAngle(t,e,i){return q.computeAngle(e,i)}static computeAngle(t,e){let i=0;switch(t){default:case 0:i=0;break;case 21:i=e;break;case 22:i=e+90;break;case 23:i=e-90;break;case 24:i=e+180;break;case 25:i=A.Ee(e),i>90&&i<270&&(i-=180);break;case 26:i=A.Ee(e+90),i>90&&i<270&&(i-=180);break;case 27:i=A.Ee(e-90),i>90&&i<270&&(i-=180);break;case 28:if(i=A.Ee(e),i>45&&i<135||i>225&&i<315)return 0;i>90&&i<270&&(i-=180);break}return A.Ee(i)}get fromNode(){return this.po}set fromNode(t){let e=this.po;if(e!==t){let i=this.fromPort;e!==null&&(this.wo!==e&&e.uk(this,i),this.$y(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Xe(t.isVisible()),this.ir=null,this.$t();let s=this.diagram;s!==null&&s.G&&s.partManager.setFromNodeForLink(this,t,e);let n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.G,s.G=!0),o(this,i,n),s!==null&&(s.G=r)}t!==null&&(this.wo!==t&&t.fk(this,n),this.Zy(),this.invalidateLayout(1)),this.t("fromNode",e,t),this.qd()}}get fromPortId(){return this.yo}set fromPortId(t){let e=this.yo;if(e!==t){let i=this.fromPort;i!==null&&this.fromNode?.Pi(i),this.$y(),this.yo=t;let s=this.fromPort;s!==null&&this.fromNode?.Pi(s);let n=this.diagram;if(n!==null){let o=this.data,r=n.model;o!==null&&r.jh()&&r.setFromPortIdForLinkData(o,t)}if(i!==s){this.ir=null,this.$t();let o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.G,n.G=!0),o(this,i,s),n!==null&&(n.G=r)}}this.Zy(),this.t("fromPortId",e,t)}}get fromPort(){let t=this.po;if(t===null)return null;let e=this.yo;return t.findPort(e)}get fromPortChanged(){return this.Jd}set fromPortChanged(t){let e=this.Jd;e!==t&&(t!==null&&g.S(t,q,"fromPortChanged"),this.Jd=t,this.t("fromPortChanged",e,t))}get toNode(){return this.wo}set toNode(t){let e=this.wo;if(e!==t){let i=this.toPort;e!==null&&(this.po!==e&&e.uk(this,i),this.$y(),this.invalidateLayout(2)),this.wo=t,t!==null&&this.Xe(t.isVisible()),this.ir=null,this.$t();let s=this.diagram;s!==null&&s.G&&s.partManager.setToNodeForLink(this,t,e);let n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.G,s.G=!0),o(this,i,n),s!==null&&(s.G=r)}t!==null&&(this.po!==t&&t.fk(this,n),this.Zy(),this.invalidateLayout(1)),this.t("toNode",e,t),this.qd()}}get toPortId(){return this.xo}set toPortId(t){let e=this.xo;if(e!==t){let i=this.toPort;i!==null&&this.toNode?.Pi(i),this.$y(),this.xo=t;let s=this.toPort;s!==null&&this.toNode?.Pi(s);let n=this.diagram;if(n!==null){let o=this.data,r=n.model;o!==null&&r.jh()&&r.setToPortIdForLinkData(o,t)}if(i!==s){this.ir=null,this.$t();let o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.G,n.G=!0),o(this,i,s),n!==null&&(n.G=r)}}this.Zy(),this.t("toPortId",e,t)}}get toPort(){let t=this.wo;if(t===null)return null;let e=this.xo;return t.findPort(e)}get toPortChanged(){return this.$d}set toPortChanged(t){let e=this.$d;e!==t&&(t!==null&&g.S(t,q,"toPortChanged"),this.$d=t,this.t("toPortChanged",e,t))}get fromSpot(){return this.ft!==null?this.ft.Ah:T.Default}set fromSpot(t){let e=this.fromSpot;if(!e.equals(t)){if(t=t.N(),this.Ji().Ah=t,this.t("fromSpot",e,t),e.isSide()||t.isSide()){let i=this.fromNode;i!==null&&i.Pi(this.fromPort)}this.$t()}}get fromEndSegmentLength(){return this.ft!==null?this.ft.Dh:NaN}set fromEndSegmentLength(t){let e=this.fromEndSegmentLength;if(e!==t){if(t<0&&g.J(t,">= 0",q,"fromEndSegmentLength"),this.Ji().Dh=t,this.t("fromEndSegmentLength",e,t),this.computeSpot(!0,this.fromPort).isSide()){let i=this.fromNode;i!==null&&i.Pi(this.fromPort)}this.$t()}}get fromShortLength(){return this.ft!==null?this.ft.Fh:NaN}set fromShortLength(t){let e=this.fromShortLength;e!==t&&(this.Ji().Fh=t,this.Ze(),this.t("fromShortLength",e,t))}get toSpot(){return this.ft!==null?this.ft.Th:T.Default}set toSpot(t){let e=this.toSpot;if(!e.equals(t)){if(t=t.N(),this.Ji().Th=t,this.t("toSpot",e,t),e.isSide()||t.isSide()){let i=this.toNode;i!==null&&i.Pi(this.toPort)}this.$t()}}get toEndSegmentLength(){return this.ft!==null?this.ft.vh:NaN}set toEndSegmentLength(t){let e=this.toEndSegmentLength;if(e!==t){if(t<0&&g.J(t,">= 0",q,"toEndSegmentLength"),this.Ji().vh=t,this.t("toEndSegmentLength",e,t),this.computeSpot(!1,this.toPort).isSide()){let i=this.toNode;i!==null&&i.Pi(this.toPort)}this.$t()}}get toShortLength(){return this.ft!==null?this.ft.Rh:NaN}set toShortLength(t){let e=this.toShortLength;e!==t&&(this.Ji().Rh=t,this.Ze(),this.t("toShortLength",e,t))}qd(){let t=this.fromNode,e=this.toNode,i=null;if(t!==null?e!==null?i=t.findCommonContainingGroup(e):i=t.containingGroup:e!==null?i=e.containingGroup:i=null,this.SE(i),this.isLabeledLink){let s=this.labelNodes;for(;s.next();){let n=s.value;n.containingGroup=i}}}SE(t){let e=this.Ta;if(e!==t){e!==null&&e.fC(this),this.Ta=t,t!==null&&t.uC(this);let i=this.containingGroupChanged;if(i!==null){let s=!0,n=this.diagram;n!==null&&(s=n.G,n.G=!0),i(this,e,t),n!==null&&(n.G=s)}this.Fi&&(this.bC===e||this.kC===e)&&this.$t()}}Sa(){let t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.Sa()}getOtherNode(t){let e=this.fromNode;return t===e?this.toNode:e}getOtherPort(t){let e=this.fromPort;return t===e?this.toPort:e}get isLabeledLink(){return this.on===null?!1:this.on.count>0}get labelNodes(){return this.on===null?J.instance:this.on.iterator}JD(t){this.on===null&&(this.on=new I),this.on.add(t),this.c()}$D(t){this.on!==null&&(this.on.delete(t),this.c())}_m(t){if(super._m(t),this.Zh()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){let e=this.po,i=null;e!==null&&(i=this.fromPort,e.fk(this,i));let s=this.wo,n=null;s!==null&&(n=this.toPort,(s!==e||n!==i)&&s.fk(this,n)),this.Zy()}}tp(t){if(super.tp(t),this.Zh()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){let e=this.po,i=null;e!==null&&(i=this.fromPort,e.uk(this,i));let s=this.wo,n=null;s!==null&&(n=this.toPort,(s!==e||n!==i)&&s.uk(this,n)),this.$y()}}rf(){if(this.Fi=!0,this.on!==null){let t=this.diagram;if(t!==null){let e=this.on.copy().iterator;for(;e.next();){let i=e.value;t.remove(i)}}}if(this.data!==null){let t=this.diagram;t!==null&&t.partManager.AC(this)}}updateRelationshipsFromData(){if(this.data===null)return;let t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}move(t,e){let i=e?this.location:this.position,s=i.x;isNaN(s)&&(s=0);let n=i.y;isNaN(n)&&(n=0);let o=t.x-s,r=t.y-n;if(e===!0)super.move(t,!1);else{let h=P.z(i.x+o,i.y+r);super.move(h,!1),P.i(h)}this.Pr(o,r);let a=this.labelNodes;for(;a.next();){let h=a.value,l=h.position;h.moveTo(l.x+o,l.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){let e=(this.Nt&1)!==0;e!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",e,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){let e=(this.Nt&2)!==0;e!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",e,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;let e=t.diagram;return!(e!==null&&!e.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;let e=t.diagram;return!(e!==null&&!e.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){let e=(this.Nt&4)!==0;e!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",e,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){let e=(this.Nt&8)!==0;e!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",e,t),this.fromNode!==null&&this.fromNode.Dp(),this.toNode!==null&&this.toNode.Dp())}get path(){let t=this.findMainElement();return t instanceof at?t:null}get routeBounds(){return this.updateRoute(),this.ME(this.Gf)}ME(t){let e=1/0,i=1/0,s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){let n=this.getPoint(0);e=Math.min(n.x,e),i=Math.min(n.y,i),t.e(n.x,n.y,0,0)}else if(s===2){let n=this.getPoint(0),o=this.getPoint(1);e=Math.min(n.x,o.x),i=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(e=n.x,i=n.y,t.e(e,i,0,0),s===3){let o=this.getPoint(1);e=Math.min(o.x,e),i=Math.min(o.y,i);let r=this.getPoint(2);e=Math.min(r.x,e),i=Math.min(r.y,i),A.Nu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o<s;o+=3){let r=this.getPoint(o-2);o+3>=s&&(o=s-1);let a=this.getPoint(o-1),h=this.getPoint(o);A.Nu(n.x,n.y,r.x,r.y,a.x,a.y,h.x,h.y,.5,t),e=Math.min(h.x,e),i=Math.min(h.y,i),n=h}}else{let n=this.getPoint(0),o=this.getPoint(1);e=Math.min(n.x,o.x),i=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r<s;r++){let a=this.getPoint(r);e=Math.min(a.x,e),i=Math.min(a.y,i),t.unionPoint(a)}}return this.dk.e(e-t.x,i-t.y),t}get midPoint(){return this.HN(new P)}HN(t){return this.updateRoute(),this.computeMidPoint(t)}computeMidPoint(t){let e=this.pointsCount;if(e===0)return t.h(P.mn),t;if(e===1)return t.h(this.getPoint(0)),t;if(e===2){let l=this.getPoint(0),c=this.getPoint(1);return t.e((l.x+c.x)/2,(l.y+c.y)/2),t}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9)){this.ut.getPointAlongPath(.5,t),t.add(this.getPoint(0));let l=this.ut.figures.first();return t.offset(-l.startX,-l.startY),t}if(this.computeCurve()===9){if(e===3){let u=this.getPoint(0),d=this.getPoint(1),f=this.getPoint(2);return A.YL(u.x,u.y,d.x,d.y,d.x,d.y,f.x,f.y,t),t}let l=(e-1)/3|0,c=(l/2|0)*3;if(l%2===1){let u=this.getPoint(c),d=this.getPoint(c+1),f=this.getPoint(c+2),p=this.getPoint(c+3);return A.YL(u.x,u.y,d.x,d.y,f.x,f.y,p.x,p.y,t),t}else return t.h(this.getPoint(c)),t}let i=this.flattenedLengths,s=this.flattenedTotalLength,n=0,o=0,r=0;for(;n<s/2&&o<e&&(r=i[o],!(n+r>s/2));)n+=r,o++;let a=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(a.x-h.x)<1)a.y>h.y?t.e(a.x,a.y-(s/2-n)):t.e(a.x,a.y+(s/2-n));else if(Math.abs(a.y-h.y)<1)a.x>h.x?t.e(a.x-(s/2-n),a.y):t.e(a.x+(s/2-n),a.y);else{let l=(s/2-n)/r,c=l*(h.x-a.x),u=l*(h.y-a.y);t.e(a.x+c,a.y+u)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){let t=this.pointsCount;if(t<2)return NaN;if(t===2){let h=this.getPoint(0),l=this.getPoint(1);return h.directionPoint(l)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ut.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){let h=(t-1)/3|0,l=(h/2|0)*3;if(h%2===1){l=Math.floor(l);let c=this.getPoint(l),u=this.getPoint(l+1),d=this.getPoint(l+2),f=this.getPoint(l+3);return A.HF(c.x,c.y,u.x,u.y,d.x,d.y,f.x,f.y)}else if(l>0&&l+1<t){let c=this.getPoint(l-1),u=this.getPoint(l+1);return c.directionPoint(u)}}let e=this.flattenedLengths,i=this.flattenedTotalLength,s=0,n=0,o=0;for(;s<i/2&&n<t&&(o=e[n],!(s+o>i/2));)s+=o,n++;let r=this.getPoint(n),a=this.getPoint(n+1);if(Math.abs(r.x-a.x)<.5&&Math.abs(r.y-a.y)<q.NC){if(n>0&&n<t-2){let h=this.getPoint(n-1),l=this.getPoint(n+2);return h.x<l.x?0:h.x>l.x?180:h.y<l.y?90:270}}else if(Math.abs(r.y-a.y)<.5&&Math.abs(r.x-a.x)<q.NC&&n>0&&n<t-2){let h=this.getPoint(n-1),l=this.getPoint(n+2);return h.y<l.y?90:h.y>l.y?270:h.x<l.x?0:180}return r.directionPoint(a)}get flattenedLengths(){return this.Wh!==null?this.Wh:(this.Fi||this.mk(),this.NE())}get flattenedTotalLength(){let t=this.gk;if(isNaN(t)){let e=this.flattenedLengths,i=e.length;t=0;for(let s=0;s<i;s++)t+=e[s];this.gk=t}return t}NE(){this.Wh===null?this.Wh=[]:this.Wh.length=0;let t=this.Wh,e=this.pointsCount;for(let i=0;i<e-1;i++){let s=0,n=this.getPoint(i),o=this.getPoint(i+1);A.X(n.x,o.x)?(s=o.y-n.y,s<0&&(s=-s),t.push(s)):A.X(n.y,o.y)?(s=o.x-n.x,s<0&&(s=-s),t.push(s)):(s=Math.sqrt(n.distanceSquaredPoint(o)),t.push(s))}return t}get points(){return this.Me}set points(t){let e=this.Me;if(e===t)return;let i=null;if(Array.isArray(t))i=this.convertPointsArrayToList(t);else if(t instanceof U){i=t.copy();let n=i.iterator;for(;n.next();)n.value.b()}else g.o("Link.points value is not an instance of List or Array: "+t);if(i===null)return;i.b(),this.Me=i,this.Ze(),this.mk();let s=this.diagram;s!==null&&(!s.$a&&!s.undoManager.isUndoingRedoing&&s.sb.add(this),s.animationManager.ke&&s.animationManager.LM(this,i)),this.t("points",e,i)}convertPointsArrayToList(t){let e=null,i=t.length%2===0;if(i){for(let s=0;s<t.length;s++)if(typeof t[s]!="number"||isNaN(t[s])){i=!1;break}}if(i){e=new U;for(let s=0;s<t.length/2;s++)e.add(new P(t[s*2],t[s*2+1]).b())}else{let s=!0;for(let n=0;n<t.length;n++){let o=t[n];if(!g.$(o)||typeof o.x!="number"||isNaN(o.x)||typeof o.y!="number"||isNaN(o.y)){s=!1;break}}if(s){e=new U;for(let n=0;n<t.length;n++){let o=t[n];e.add(new P(o.x,o.y).b())}}}return e}get pointsCount(){return this.Me.count}getPoint(t){return this.Me.r[t]}setPoint(t,e){this.Me.setElt(t,e)}setPointAt(t,e,i){this.Me.setElt(t,new P(e,i))}insertPoint(t,e){this.Me.insertAt(t,e)}insertPointAt(t,e,i){this.Me.insertAt(t,new P(e,i))}addPoint(t){this.Me.add(t)}addPointAt(t,e){this.Me.add(new P(t,e))}removePoint(t){this.Me.removeAt(t)}clearPoints(){this.Me.clear()}Pr(t,e){if(t===0&&e===0)return;if(this.pointsCount===0){this.defaultFromPoint.isReal()&&this.defaultFromPoint.offset(t,e),this.defaultToPoint.isReal()&&this.defaultToPoint.offset(t,e);return}let i=this.Fi,s=new U,n=this.Me.iterator;for(;n.next();){let a=n.value;s.add(new P(a.x+t,a.y+e).b())}s.b();let o=this.Me;this.Me=s;let r=this.diagram;isNaN(t)||isNaN(e)||r!==null&&r.animationManager.ke?this.c():(this.nn.e(this.nn.x+t,this.nn.y+e),this.ct.e(this.ct.x+t,this.ct.y+e),this.kf()),i?this.mk():(this.defaultFromPoint.isReal()&&(this.defaultFromPoint=this.getPoint(0)),this.defaultToPoint.isReal()&&(this.defaultToPoint=this.getPoint(this.pointsCount-1))),r!==null&&r.animationManager.ke&&r.animationManager.LM(this,s),this.t("points",o,s)}startRoute(){this.xl===null&&(this.xl=this.Me,this.Me=this.Me.copy())}commitRoute(){if(this.xl===null)return;let t=this.xl,e=this.Me,i=1/0,s=1/0,n=t.r,o=n.length;for(let u=0;u<o;u++){let d=n[u];i=Math.min(d.x,i),s=Math.min(d.y,s)}let r=1/0,a=1/0,h=e.r,l=h.length;for(let u=0;u<l;u++){let d=h[u];r=Math.min(d.x,r),a=Math.min(d.y,a),d.b()}if(e.b(),l===o)for(let u=0;u<l;u++){let d=n[u],f=h[u];if(d.x-i!==f.x-r||d.y-s!==f.y-a){this.Ze();break}}else this.Ze();this.xl=null;let c=this.diagram;c!==null&&c.animationManager.ke&&c.animationManager.LM(this,e),this.mk(),this.t("points",t,e)}rollbackRoute(){this.xl!==null&&(this.Me=this.xl,this.xl=null)}DR(){this.vr!==null&&(this.points=this.vr,this.vr=null)}mk(){if(this.Me.count===0){this.Fi=!1;return}this.Fi=!0,this.Wh=null,this.gk=NaN,this.defaultFromPoint=this.getPoint(0),this.defaultToPoint=this.getPoint(this.pointsCount-1),this.pk(!1)}invalidateRoute(){this.$t()}$t(){if(this.suspendsRouting)return;let t=this.path;if(t===null)return;let e=this.diagram;if(e){if(e.sb.has(this)||e.undoManager.isUndoingRedoing)return;let i=e.animationManager;if(i.isTicking&&!i.isAnimating)return;this.vr!==null&&!i.isTicking&&(this.vr=null)}this.Fi=!1,this.c(),t.c()}get Fi(){return(this.Nt&16)!==0}set Fi(t){(this.Nt&16)!==0!==t&&(this.Nt=this.Nt^16)}get suspendsRouting(){return(this.Nt&32)!==0}set suspendsRouting(t){(this.Nt&32)!==0!==t&&(this.Nt=this.Nt^32)}get Qy(){return(this.Nt&64)!==0}set Qy(t){(this.Nt&64)!==0!==t&&(this.Nt=this.Nt^64)}get TC(){return(this.Nt&512)!==0}set TC(t){(this.Nt&512)!==0!==t&&(this.Nt=this.Nt^512)}get defaultFromPoint(){return this.wC}set defaultFromPoint(t){this.wC=t&&t.isReal()?t.copy():P.mn}get defaultToPoint(){return this.xC}set defaultToPoint(t){this.xC=t&&t.isReal()?t.copy():P.mn}updateRoute(){if(this.Fi||this.Qy)return;let t=!0;try{this.Qy=!0,this.startRoute(),t=this.computePoints()}catch{this.Qy=!1,this.rollbackRoute()}finally{this.Qy=!1,t?this.commitRoute():this.rollbackRoute()}}computePoints(){let t=this.diagram;if(t===null)return!1;let e=this.fromNode,i=null;if(e===null?(q.Jh||(q.Jh=new it,q.Jh.desiredSize=_.xc,q.Jh.ensureBounds()),this.defaultFromPoint.isReal()&&(q.Jh.location=this.defaultFromPoint,q.Jh.ensureBounds(),e=q.Jh,i=q.Jh)):i=this.fromPort,i!==null&&!e.isVisible()){let p=e.findVisibleNode();p!==null&&p!==e?(e=p,i=p.port):e=p}if(this.bC=e,e===null||!e.location.isReal()||i===null||(i=e.findVisiblePort(i),i===null))return!1;let s=this.toNode,n=null;if(s===null?(q.$h||(q.$h=new it,q.$h.desiredSize=_.xc,q.$h.ensureBounds()),this.defaultToPoint.isReal()&&(q.$h.location=this.defaultToPoint,q.$h.ensureBounds(),s=q.$h,n=q.$h)):n=this.toPort,n!==null&&!s.isVisible()){let p=s.findVisibleNode();p!==null&&p!==s?(s=p,n=p.port):s=p}if(this.kC=s,s===null||!s.location.isReal()||n===null||(n=s.findVisiblePort(n),n===null))return!1;let o=this.pointsCount,r=this.computeSpot(!0,i),a=this.computeSpot(!1,n),h=this.Qh(r),l=this.Qh(a),c=i===n&&i!==null,u=this.isOrthogonal,d=this.curve===9;c&&!u?(d=!0,this.ir=!0):this.ir=!1;let f=this.computeAdjusting()===0||c;if(!u&&!c&&h&&l){let p=!1;if(!f&&o>=3){let m=this.getLinkPoint(e,i,r,!0,!1,s,n),y=this.getLinkPoint(s,n,a,!1,!1,e,i);p=this.adjustPoints(0,m,o-1,y),p&&(m=this.getLinkPoint(e,i,r,!0,!1,s,n),y=this.getLinkPoint(s,n,a,!1,!1,e,i),this.adjustPoints(0,m,o-1,y))}p||(this.clearPoints(),d?this.CE(e,i,r,s,n,a):this.LE(e,i,r,s,n,a))}else{let p=c?this.computeCurviness():0;f&&(u&&this.isAvoiding||c)&&this.clearPoints();let m=this.getLinkPoint(e,i,r,!0,u,s,n),y=this.getLinkPoint(s,n,a,!1,u,e,i),b=0,v=0,w=0;if(u||!h||c){w=this.getLinkDirection(e,i,m,r,!0,u,s,n);let N=this.yk(e,i,r,!0,w);if(c&&(h||r.equals(a)||!u&&r.x+a.x===1&&r.y+a.y===1)&&(w-=u?90:q.rv,p<0&&(w-=180)),w=A.Ee(w),c&&(N+=Math.abs(p)*(u?1:2)),w===0?b=N:w===90?v=N:w===180?b=-N:w===270?v=-N:(b=N*Math.cos(w*Math.PI/180),v=N*Math.sin(w*Math.PI/180)),r.isNoSpot()&&c){let L=i.getDocumentPoint(T.Center,P.l()),R=P.z(L.x+b*q.Yf,L.y+v*q.Yf);this.getLinkPointFromPoint(e,i,L,R,!0,m),P.i(L),P.i(R)}}let k=0,S=0,M=0;if(u||!l||c){M=this.getLinkDirection(s,n,y,a,!1,u,e,i);let N=this.yk(s,n,a,!1,M);if(c&&(l||r.equals(a)||!u&&r.x+a.x===1&&r.y+a.y===1)&&(M+=u?0:q.lv,p<0&&(M+=180)),M=A.Ee(M),c&&(N+=Math.abs(p)*(u?1:2)),M===0?k=N:M===90?S=N:M===180?k=-N:M===270?S=-N:(k=N*Math.cos(M*Math.PI/180),S=N*Math.sin(M*Math.PI/180)),a.isNoSpot()&&c){let L=n.getDocumentPoint(T.Center,P.l()),R=P.z(L.x+k*q.Yf,L.y+S*q.Yf);this.getLinkPointFromPoint(s,n,L,R,!1,y),P.i(L),P.i(R)}}let F=m;(u||!h||c)&&(F=new P(m.x+b,m.y+v));let D=y;(u||!l||c)&&(D=new P(y.x+k,y.y+S)),!f&&!u&&h&&o>3&&this.adjustPoints(0,m,o-2,D)?this.setPoint(o-1,y):!f&&!u&&l&&o>3&&this.adjustPoints(1,F,o-1,y)?this.setPoint(0,m):!f&&(u?o>=6:o>4)&&this.adjustPoints(1,F,o-2,D)?(this.setPoint(0,m),this.setPoint(o-1,y)):(this.clearPoints(),this.addPoint(m),(u||!h||c)&&this.addPoint(F),u&&this.addOrthoPoints(F,w,D,M,e,s),(u||!l||c)&&this.addPoint(D),this.addPoint(y))}return t.addInvalidRoute(this),!0}DC(t,e){return Math.abs(e.x-t.x)>Math.abs(e.y-t.y)?(e.x>=t.x?e.x=t.x+9e9:e.x=t.x-9e9,e.y=t.y):(e.y>=t.y?e.y=t.y+9e9:e.y=t.y-9e9,e.x=t.x),e}getLinkPointFromPoint(t,e,i,s,n,o){if(o===void 0&&(o=new P),t===null||e===null)return o.h(i),o;if(!t.isVisible()){let d=t.findVisibleNode();d!==null&&d!==t&&(t=d,e=t.port)}let r=0,a=0,h=0,l=0,c=null,u=e.panel;if(u!==null&&!u.Nn()&&(u=u.panel),u===null)r=s.x,a=s.y,h=i.x,l=i.y;else{c=u.Js;let d=1/(c.m11*c.m22-c.m12*c.m21),f=c.m22*d,p=-c.m12*d,m=-c.m21*d,y=c.m11*d,b=d*(c.m21*c.dy-c.m22*c.dx),v=d*(c.m12*c.dx-c.m11*c.dy);r=s.x*f+s.y*m+b,a=s.x*p+s.y*y+v,h=i.x*f+i.y*m+b,l=i.x*p+i.y*y+v}return e.mf(r,a,h,l,o),c!==null&&o.v(c),o}AE(t,e){let i=t.pd;return i!==null?i.dv(e):null}wk(t){if(t===null)return null;let e=t.pd;return e===null&&(e=new Os(t.part,t),t.pd=e),e.dv(this)}getLinkPoint(t,e,i,s,n,o,r,a){if(a===void 0&&(a=new P),i.isSpot()&&!this.Qh(i))return e.getDocumentPoint(i,a),a;if(i.isSide()){let c=this.wk(e);if(c!==null){let u=c._h;if(a.h(u),n&&this.routing===7){let d=this.wk(r);if(d!==null&&c.Kf<d.Kf){let f=P.l(),p=P.l(),m=B.l();e.getDocumentPoint(T.TopLeft,f),e.getDocumentPoint(T.BottomRight,p);let y=f.x,b=f.y,v=p.x,w=p.y;m.x=Math.min(y,v),m.y=Math.min(b,w),m.width=Math.abs(y-v),m.height=Math.abs(b-w);let k=this.computeSpot(!s,r),S=this.getLinkPoint(o,r,k,!s,n,t,e,p);(i.includesSide(T.LeftSide)||i.includesSide(T.RightSide))&&S.y>=m.y&&S.y<=m.y+m.height?a.y=S.y:(i.includesSide(T.TopSide)||i.includesSide(T.BottomSide))&&S.x>=m.x&&S.x<=m.x+m.width&&(a.x=S.x),B.i(m),P.i(f),P.i(p)}}return a}}let h=e.getDocumentPoint(this.eg(i,s),P.l()),l=P.l();if(this.pointsCount>(n?6:2))l.h(s?this.getPoint(1):this.getPoint(this.pointsCount-2)),n&&this.DC(h,l);else if(t?.isMemberOf(o)||o?.isMemberOf(t)){let c=e.getDocumentBounds(B.l()),u=r.getDocumentBounds(B.l());c.isReal()&&u.isReal()?u.containsRect(c)?(l.h(h),this.vC(u,h.x,h.y,0,this.computeSpot(r===this.toPort,r),l)):c.containsRect(u)?(r.getDocumentPoint(T.Center,l),this.vC(c,l.x,l.y,0,this.computeSpot(e===this.toPort,e),l)):this.FC(r,h,s,n,l):this.FC(r,h,s,n,l),B.i(c),B.i(u)}else this.FC(r,h,s,n,l);return this.getLinkPointFromPoint(t,e,h,l,s,a),P.i(l),P.i(h),a}FC(t,e,i,s,n){let o=this.computeSpot(!i,t);t.getDocumentPoint(this.eg(o,!i),n),s&&this.DC(e,n)}getLinkDirection(t,e,i,s,n,o,r,a){let h=this.TE(t,e,i,s,n,o,r,a);if(t&&r){let c=B.l(),u=B.l();if(s.isNone()&&t.isMemberOf(r)&&e&&a){if(e.getDocumentBounds(c),a.getDocumentBounds(u),c.isReal()&&u.isReal()&&u.containsRect(c)){let d=this.computeSpot(a===this.toPort,a);d.equals(T.Left)||d.equals(T.LeftSide)?h=180:d.equals(T.Right)||d.equals(T.RightSide)?h=0:d.equals(T.Top)||d.equals(T.TopSide)?h=270:d.equals(T.Bottom)||d.equals(T.BottomSide)?h=90:h=A.Ee(h+180)}}else r?.isMemberOf(t)&&e&&a&&(e.getDocumentBounds(c),a.getDocumentBounds(u),c.isReal()&&u.isReal()&&c.containsRect(u)&&(h=A.Ee(h+180)));B.i(c),B.i(u)}if(this.Qh(s)||e===null)return h;let l=e.getDocumentAngle();return l===0?h:(45<=l&&l<135?h+=90:135<=l&&l<225?h+=180:225<=l&&l<315&&(h+=270),A.Ee(h))}TE(t,e,i,s,n,o,r,a){if(s.isSpot())return A.Qw(null,s.x,s.y);if(s.isSide()){let u=this.wk(e);if(u!==null)switch(u.ci){case 1:return 270;case 8:return 90;case 2:return 180;default:return 0}else return s.includesSide(T.TopSide)?270:s.includesSide(T.BottomSide)?90:s.includesSide(T.LeftSide)?180:0}if(e===null||a===null)return 0;let h=e.getDocumentPoint(T.Center,P.l()),l=P.l();this.pointsCount>(o?6:2)?o?(l.h(n?this.getPoint(1):this.getPoint(this.pointsCount-2)),this.DC(h,l)):l.h(i):a.getDocumentPoint(T.Center,l);let c=0;return Math.abs(l.x-h.x)>Math.abs(l.y-h.y)?l.x>=h.x?c=0:c=180:l.y>=h.y?c=90:c=270,P.i(l),P.i(h),c}computeEndSegmentLength(t,e,i,s){return this.yk(t,e,i,s,NaN)}yk(t,e,i,s,n){if(e!==null&&i.isSide()){let r=this.wk(e);if(r!==null)return r.xk}let o=NaN;if(s?o=this.fromEndSegmentLength:o=this.toEndSegmentLength,e!==null&&isNaN(o))if(n===void 0&&(n=NaN),q.CC>0&&this.computeCurve()===9&&!isNaN(n)&&i.isSpot()){let r=this.getOtherPort(e);if(r){let a=P.l(),h=P.l(),l=e.getDocumentPoint(i,a),c=r.getDocumentPoint(i.opposite(),h),u=n>=315||n<=45||n>=135&&n<=225,d=Math.abs(u?l.x-c.x:l.y-c.y)/q.CC;return d=Math.max(d,q.LC),P.i(a),P.i(h),d}}else s?o=e.fromEndSegmentLength:o=e.toEndSegmentLength;return isNaN(o)&&(o=q.LC),o}computeSpot(t,e){return e===void 0&&(e=null),t?this.DE(e||this.fromPort):this.vE(e||this.toPort)}DE(t){if(t===null)return T.Center;let e=this.fromSpot;return e.isDefault()&&(e=t.fromSpot),e===T.Default?T.None:e}vE(t){if(t===null)return T.Center;let e=this.toSpot;return e.isDefault()&&(e=t.toSpot),e===T.Default?T.None:e}Qh(t){return t===T.None||t.x===.5&&t.y===.5}eg(t,e){return t.x===.5&&t.y===.5?t:T.Center}computeOtherPoint(t,e){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new P);{let i=this.AE(e,this);if(i!==null)return i._h;if(t instanceof ft){let s=this.fromNode,n=this.fromPort;n===e&&(s=this.toNode,n=this.toPort);let o=B.l(),r=B.l();if(n&&s?.isMemberOf(t)){let a=this.computeSpot(n===e,e);if(e.getDocumentBounds(o),n.getDocumentBounds(r),o.isReal()&&r.isReal()&&o.containsRect(r)){let h=n.getDocumentPoint(T.Center);return this.vC(o,h.x,h.y,0,a,h),B.i(o),B.i(r),h}}B.i(o),B.i(r)}return e.getDocumentPoint(T.Center)}}computeShortLength(t){if(t){let e=this.fromShortLength;if(isNaN(e)){let i=this.fromPort;i!==null&&(e=i.fromShortLength)}return isNaN(e)?0:e}else{let e=this.toShortLength;if(isNaN(e)){let i=this.toPort;i!==null&&(e=i.toShortLength)}return isNaN(e)?0:e}}$m(t,e,i,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let r;if(o===void 0?(r=Pt.l(),r.Ue()):r=o,r.bc(this.v),this.containedInRect(t,r))return this.JN(e,i,n),o===void 0&&Pt.i(r),!0;if(this.intersectsRect(t,r)){let a=!1;if(!this.Af){let h=this.D.r,l=h.length;for(let c=l;c--;){let u=h[c];if(!u.visible&&u!==this.locationObject)continue;let d=u.actualBounds,f=this.naturalBounds;if(d.x>f.width||d.y>f.height||d.x+d.width<0||d.y+d.height<0)continue;let p=u,m=Pt.l();if(m.set(r),p instanceof H?a=p.$m(t,e,i,s,n,m):this.path===p?p instanceof at&&(a=p.sE(t,s,m)):a=p.JT(t,s,m),a){let y=p;e!==null&&(y=e(p)),y&&(i===null||i(y))&&n.add(y)}Pt.i(m)}}return o===void 0&&Pt.i(r),a||this.background!==null}return o===void 0&&Pt.i(r),!1}get isOrthogonal(){return(this.qh&2)===2}static MC(t){return(t&2)===2}get isAvoiding(){return(this.qh&4)===4}computeCurve(){if(this.ir===null){let t=this.fromPort,e=t!==null&&t===this.toPort,i=this.isOrthogonal;this.ir=e&&!i}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=q.av),t}findMidLabel(){let t=this.path,e=this.D.r,i=e.length;for(let n=0;n<i;n++){let o=e[n];if(!(o===t||o.isPanelMain)&&(o.segmentIndex===-1/0||isNaN(o.segmentIndex)))return o}let s=this.labelNodes;for(;s.next();){let n=s.value;if(n.segmentIndex===-1/0||isNaN(n.segmentIndex))return n}return null}computeSpacing(){if(!this.isVisible())return 0;let t=q.hv;t=Math.max(t,this.computeThickness());let e=this.fromPort,i=this.toPort;if(e!==null&&i!==null){let s=this.findMidLabel();if(s!==null){let n=s.naturalBounds,o=s.margin,r=isNaN(n.width)?q.cv:n.width*s.scale+o.left+o.right,a=isNaN(n.height)?q.fv:n.height*s.scale+o.top+o.bottom,h=s.segmentOrientation;if(h===21||h===25||h===24)t=Math.max(t,a);else if(h===23||h===27||h===22||h===26)t=Math.max(t,r);else{let l=e.getDocumentPoint(T.Center).directionPoint(i.getDocumentPoint(T.Center))/180*Math.PI;t=Math.max(t,Math.abs(Math.sin(l)*r)+Math.abs(Math.cos(l)*a)+1)}this.curve===9&&(t*=q.nv)}}return t}arrangeBundledLinks(t,e){if(e)for(let i=0;i<t.length;i++){let s=t[i];s.computeAdjusting()===0&&s.$t()}}computeCurviness(){let t=this.curviness;if(isNaN(t)){t=q.iv;let e=this.sr;if(e!==null){let i=g.ot(),s=0,n=e.rn;for(let r=0;r<n.length;r++){let a=n[r].computeSpacing();i.push(a),s+=a}let o=-s/2;for(let r=0;r<n.length;r++){if(n[r]===this){t=o+i[r]/2;break}o+=i[r]}e.Xy===this.fromNode&&(t=-t),g.Z(i)}}return t}computeThickness(){if(!this.isVisible())return 0;let t=this.path;return t!==null?Math.max(t.strokeWidth,1):1}hasCurviness(){return!isNaN(this.curviness)||this.sr!==null}LE(t,e,i,s,n,o){let r=this.getLinkPoint(t,e,i,!0,!1,s,n),a=this.getLinkPoint(s,n,o,!1,!1,t,e);if(this.gv(t,e,i,r,s,n,o,a),this.addPoint(r),this.addPoint(a),this.hasCurviness()){let h=a.x-r.x,l=a.y-r.y,c=this.computeCurviness(),u=c,d=r.x+h/2,f=r.y+l/2,p=d,m=f;if(A.u(l,0))h>0?m-=u:m+=u;else{let y=-h/l,b=Math.sqrt(u*u/(y*y+1));c<0&&(b=-b),p=(l<0?-1:1)*b+d,m=y*(p-d)+f}this.insertPointAt(1,p,m)}}gv(t,e,i,s,n,o,r,a){let h=o.getDocumentBounds(B.l()),l=e.getDocumentBounds(B.l());if(h.intersectsRect(l)&&!h.containsRect(l)&&!l.containsRect(h)){let c=P.l();e.getDocumentPoint(this.eg(i,!0),c);let u=P.l();o.getDocumentPoint(this.eg(r,!1),u);let d=l.width*l.height,f=h.width*h.height;d>f?(s.h(c),this.getLinkPointFromPoint(n,o,u,c,!1,u),a.h(u)):d<f?(this.getLinkPointFromPoint(t,e,c,u,!0,c),s.h(c),a.h(u)):(s.h(c),a.h(u)),P.i(c),P.i(u)}else if(h.containsPoint(s)){let c=P.l();e.getDocumentPoint(this.eg(i,!0),c),a.h(c),this.RC(h,c.x,c.y,q.Yf,a),this.getLinkPointFromPoint(n,o,h.containsPoint(c)?c:s,a,!1,a),this.getLinkPointFromPoint(t,e,c,a,!0,s),P.i(c)}else if(l.containsPoint(a)){let c=P.l();o.getDocumentPoint(this.eg(r,!1),c),s.h(c),this.RC(l,c.x,c.y,q.Yf,s),this.getLinkPointFromPoint(t,e,l.containsPoint(c)?c:a,s,!0,s),this.getLinkPointFromPoint(n,o,c,s,!1,a),P.i(c)}B.i(l),B.i(h)}vC(t,e,i,s,n,o){let r=-1;return n.equals(T.Left)||n.equals(T.LeftSide)?r=180:n.equals(T.Right)||n.equals(T.RightSide)?r=0:n.equals(T.Top)||n.equals(T.TopSide)?r=270:(n.equals(T.Bottom)||n.equals(T.BottomSide))&&(r=90),r===-1?this.RC(t,e,i,0,o):this.mv(t,e,i,0,r,o)}RC(t,e,i,s,n){let o=A.Qw(t,e,i);return this.mv(t,e,i,s,o,n)}mv(t,e,i,s,n,o){return n===0?o.x=t.right+s:n===90?o.y=t.bottom+s:n===180?o.x=t.x-s:n===270?o.y=t.y-s:n===45?(o.x=t.right+s,o.y=t.bottom+s):n===135?(o.x=t.x-s,o.y=t.bottom+s):n===225?(o.x=t.x-s,o.y=t.y-s):n===315&&(o.x=t.right+s,o.y=t.y-s),o}CE(t,e,i,s,n,o){let r=this.getLinkPoint(t,e,i,!0,!1,s,n),a=this.getLinkPoint(s,n,o,!1,!1,t,e);this.gv(t,e,i,r,s,n,o,a),this.addPoint(r),this.addPoint(a);let h=a.x-r.x,l=a.y-r.y,c=this.computeCurviness(),u=0,d=0,f=r.x+h/3,p=r.y+l/3,m=f,y=p;A.u(l,0)?h>0?y-=c:y+=c:(u=-h/l,d=Math.sqrt(c*c/(u*u+1)),c<0&&(d=-d),m=(l<0?-1:1)*d+f,y=u*(m-f)+p),f=r.x+2*h/3,p=r.y+2*l/3;let b=f,v=p;A.u(l,0)?h>0?v-=c:v+=c:(b=(l<0?-1:1)*d+f,v=u*(b-f)+p),this.insertPointAt(1,m,y),this.insertPointAt(2,b,v),this.setPoint(0,this.getLinkPoint(t,e,i,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,e))}adjustPoints(t,e,i,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.FE(t,e,i,s);case 19:return this.RE(t,e,i,s);case 17:return this.OE(t,e,i,s);default:return!1}}FE(t,e,i,s){let n=this.getPoint(t),o=this.getPoint(i);if(n.equalsApprox(e)&&o.equalsApprox(s))return!0;let r=n.x,a=n.y,h=o.x,l=o.y,c=h-r,u=l-a,d=Math.sqrt(c*c+u*u);if(A.X(d,0))return!0;let f=0;A.X(c,0)?u<0?f=-Math.PI/2:f=Math.PI/2:(f=Math.atan(u/Math.abs(c)),c<0&&(f=Math.PI-f));let p=e.x,m=e.y,y=s.x,b=s.y,v=y-p,w=b-m,k=Math.sqrt(v*v+w*w),S=0;A.X(v,0)?w<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(w/Math.abs(v)),v<0&&(S=Math.PI-S));let M=k/d,F=S-f;this.setPoint(t,e);for(let D=t+1;D<i;D++){let N=this.getPoint(D);c=N.x-r,u=N.y-a;let L=Math.sqrt(c*c+u*u);if(A.X(L,0))continue;let R=0;A.X(c,0)?u<0?R=-Math.PI/2:R=Math.PI/2:(R=Math.atan(u/Math.abs(c)),c<0&&(R=Math.PI-R));let O=R+F,V=L*M,K=p+V*Math.cos(O),Y=m+V*Math.sin(O);this.setPointAt(D,K,Y)}return this.setPoint(i,s),!0}RE(t,e,i,s){let n=this.getPoint(t),o=this.getPoint(i);if(n.equalsApprox(e)&&o.equalsApprox(s))return!0;let r=n.x,a=n.y,h=o.x,l=o.y,c=(h-r)**2+(l-a)**2,u=e.x,d=e.y,f=s.x,p=s.y,m=0,y=1;f-u!==0?(m=(p-d)/(f-u),y=Math.sqrt(1+1/(m*m))):m=9e9,this.setPoint(t,e);for(let b=t+1;b<i;b++){let v=this.getPoint(b),w=v.x,k=v.y,S=.5;c!==0&&(S=((r-w)*(r-h)+(a-k)*(a-l))/c);let M=r+S*(h-r),F=a+S*(l-a),D=Math.sqrt((w-M)**2+(k-F)**2);k<m*(w-M)+F&&(D=-D),m>0&&(D=-D);let N=u+S*(f-u),L=d+S*(p-d);if(m!==0){let R=N+D/y,O=L-(R-N)/m;this.setPointAt(b,R,O)}else this.setPointAt(b,N,L+D)}return this.setPoint(i,s),!0}OE(t,e,i,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),a=o.x,h=o.y,l=a,c=h;A.u(n.y,o.y)?A.u(o.x,r.x)?h=e.y:A.u(o.y,r.y)&&(a=e.x):A.u(n.x,o.x)&&(A.u(o.y,r.y)?a=e.x:A.u(o.x,r.x)&&(h=e.y)),this.setPointAt(t+1,a,h),n=this.getPoint(i),o=this.getPoint(i-1),r=this.getPoint(i-2);let u=o.x,d=o.y,f=u,p=d;if(A.u(n.y,o.y)?A.u(o.x,r.x)?d=s.y:A.u(o.y,r.y)&&(u=s.x):A.u(n.x,o.x)&&(A.u(o.y,r.y)?u=s.x:A.u(o.x,r.x)&&(d=s.y)),this.setPointAt(i-1,u,d),this.yT())return this.setPointAt(t+1,l,c),this.setPointAt(i-1,f,p),!1}return this.setPoint(t,e),this.setPoint(i,s),!0}addOrthoPoints(t,e,i,s,n,o){e=A.Ee(e),s=A.Ee(s);let r=s;e>=315||e<45?e=0:45<=e&&e<135?e=90:135<=e&&e<225?e=180:e=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;let a=t,h=i,l=B.bs(n.actualBounds),c=B.bs(o.actualBounds);l.inflate(q.va,q.va),c.inflate(q.va,q.va),l.unionPoint(t),c.unionPoint(i);let u=P.l(),d=P.l();e===0?h.x>a.x||s===270&&h.y<a.y&&c.right>a.x||s===90&&h.y>a.y&&c.right>a.x?(u.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),s===180?(u.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1),d.x=u.x,d.y=h.y):s===270&&h.y<a.y||s===90&&h.y>a.y?(a.x<c.left?u.x=this.computeMidOrthoPosition(a.x,a.y,c.left,h.y,!1):a.x<c.right&&(s===270&&a.y<c.top||s===90&&a.y>c.bottom)?u.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):u.x=c.right,d.x=u.x,d.y=h.y):s===0&&a.x<c.left&&a.y>c.top&&a.y<c.bottom&&(u.x=a.x,a.y<h.y?u.y=Math.min(h.y,c.top):u.y=Math.max(h.y,c.bottom),d.y=u.y)):(u.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),(s===180||s===90&&h.y<l.top||s===270&&h.y>l.bottom)&&(s===180&&(c.containsPoint(a)||l.containsPoint(h))?u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):h.y<a.y&&(s===180||s===90)?u.y=this.computeMidOrthoPosition(a.x,l.top,h.x,Math.min(h.y,c.bottom),!0):h.y>a.y&&(s===180||s===270)&&(u.y=this.computeMidOrthoPosition(a.x,l.bottom,h.x,Math.max(h.y,c.top),!0)),d.x=h.x,d.y=u.y),u.y>l.top&&u.y<l.bottom&&(h.x>=l.left&&h.x<=a.x||a.x<=c.right&&a.x>=h.x?(s===90||s===270)&&(u.e(Math.max((a.x+h.x)/2,a.x),a.y),d.e(u.x,h.y)):(s===270||(s===0||s===180)&&h.y<a.y?u.y=Math.min(h.y,s===0?l.top:Math.min(l.top,c.top)):u.y=Math.max(h.y,s===0?l.bottom:Math.max(l.bottom,c.bottom)),d.x=h.x,d.y=u.y))):e===180?h.x<a.x||s===270&&h.y<a.y&&c.left<a.x||s===90&&h.y>a.y&&c.left<a.x?(u.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),s===0?(u.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1),d.x=u.x,d.y=h.y):s===270&&h.y<a.y||s===90&&h.y>a.y?(a.x>c.right?u.x=this.computeMidOrthoPosition(a.x,a.y,c.right,h.y,!1):a.x>c.left&&(s===270&&a.y<c.top||s===90&&a.y>c.bottom)?u.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):u.x=c.left,d.x=u.x,d.y=h.y):s===180&&a.x>c.right&&a.y>c.top&&a.y<c.bottom&&(u.x=a.x,a.y<h.y?u.y=Math.min(h.y,c.top):u.y=Math.max(h.y,c.bottom),d.y=u.y)):(u.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),(s===0||s===90&&h.y<l.top||s===270&&h.y>l.bottom)&&(s===0&&(c.containsPoint(a)||l.containsPoint(h))?u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):h.y<a.y&&(s===0||s===90)?u.y=this.computeMidOrthoPosition(a.x,l.top,h.x,Math.min(h.y,c.bottom),!0):h.y>a.y&&(s===0||s===270)&&(u.y=this.computeMidOrthoPosition(a.x,l.bottom,h.x,Math.max(h.y,c.top),!0)),d.x=h.x,d.y=u.y),u.y>l.top&&u.y<l.bottom&&(h.x<=l.right&&h.x>=a.x||a.x>=c.left&&a.x<=h.x?(s===90||s===270)&&(u.e(Math.min((a.x+h.x)/2,a.x),a.y),d.e(u.x,h.y)):(s===270||(s===0||s===180)&&h.y<a.y?u.y=Math.min(h.y,s===180?l.top:Math.min(l.top,c.top)):u.y=Math.max(h.y,s===180?l.bottom:Math.max(l.bottom,c.bottom)),d.x=h.x,d.y=u.y))):e===90?h.y>a.y||s===180&&h.x<a.x&&c.bottom>a.y||s===0&&h.x>a.x&&c.bottom>a.y?(u.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),s===270?(u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0),d.x=h.x,d.y=u.y):s===180&&h.x<a.x||s===0&&h.x>a.x?(a.y<c.top?u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,c.top,!0):a.y<c.bottom&&(s===180&&a.x<c.left||s===0&&a.x>c.right)?u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):u.y=c.bottom,d.x=h.x,d.y=u.y):s===90&&a.y<c.top&&a.x>c.left&&a.x<c.right&&(a.x<h.x?u.x=Math.min(h.x,c.left):u.x=Math.max(h.x,c.right),u.y=a.y,d.x=u.x)):(u.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),(s===270||s===0&&h.x<l.left||s===180&&h.x>l.right)&&(s===270&&(c.containsPoint(a)||l.containsPoint(h))?u.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):h.x<a.x&&(s===270||s===0)?u.x=this.computeMidOrthoPosition(l.left,a.y,Math.min(h.x,c.right),h.y,!1):h.x>a.x&&(s===270||s===180)&&(u.x=this.computeMidOrthoPosition(l.right,a.y,Math.max(h.x,c.left),h.y,!1)),d.x=u.x,d.y=h.y),u.x>l.left&&u.x<l.right&&(h.y>=l.top&&h.y<=a.y||a.y<=c.bottom&&a.y>=h.y?(s===0||s===180)&&(u.e(a.x,Math.max((a.y+h.y)/2,a.y)),d.e(h.x,u.y)):(s===180||(s===90||s===270)&&h.x<a.x?u.x=Math.min(h.x,s===90?l.left:Math.min(l.left,c.left)):u.x=Math.max(h.x,s===90?l.right:Math.max(l.right,c.right)),d.x=u.x,d.y=h.y))):h.y<a.y||s===180&&h.x<a.x&&c.top<a.y||s===0&&h.x>a.x&&c.top<a.y?(u.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),s===90?(u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0),d.x=h.x,d.y=u.y):s===180&&h.x<a.x||s===0&&h.x>=a.x?(a.y>c.bottom?u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,c.bottom,!0):a.y>c.top&&(s===180&&a.x<c.left||s===0&&a.x>c.right)?u.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):u.y=c.top,d.x=h.x,d.y=u.y):s===270&&a.y>c.bottom&&a.x>c.left&&a.x<c.right&&(a.x<h.x?u.x=Math.min(h.x,c.left):u.x=Math.max(h.x,c.right),u.y=a.y,d.x=u.x)):(u.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),(s===90||s===0&&h.x<l.left||s===180&&h.x>l.right)&&(s===90&&(c.containsPoint(a)||l.containsPoint(h))?u.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):h.x<a.x&&(s===90||s===0)?u.x=this.computeMidOrthoPosition(l.left,a.y,Math.min(h.x,c.right),h.y,!1):h.x>a.x&&(s===90||s===180)&&(u.x=this.computeMidOrthoPosition(l.right,a.y,Math.max(h.x,c.left),h.y,!1)),d.x=u.x,d.y=h.y),u.x>l.left&&u.x<l.right&&(h.y<=l.bottom&&h.y>=a.y||a.y>=c.top&&a.y<=h.y?(s===0||s===180)&&(u.e(a.x,Math.min((a.y+h.y)/2,a.y)),d.e(h.x,u.y)):(s===180||(s===90||s===270)&&h.x<a.x?u.x=Math.min(h.x,s===270?l.left:Math.min(l.left,c.left)):u.x=Math.max(h.x,s===270?l.right:Math.max(l.right,c.right)),d.x=u.x,d.y=h.y))),this.TC=s!==r,this.PC=e,this.SC=s,this.addPoint(u.copy()),this.addPoint(d.copy()),P.i(u),P.i(d),B.i(l),B.i(c)}computeMidOrthoPosition(t,e,i,s,n){let o=0;return this.hasCurviness()&&!this.computeSpot(!0,this.fromPort).isSide()&&!this.computeSpot(!1,this.toPort).isSide()&&(o=this.computeCurviness()),n?(e+s)/2+o:(t+i)/2+o}yT(){if(this.diagram===null||!this.isAvoiding||this.diagram.animationManager.isTicking)return!1;let t=this.points.r,e=t.length;if(e<4)return!1;let i=this.diagram.getPositions(!1,this.containingGroup,null);for(let s=1;s<e-2;s++){let n=t[s],o=t[s+1];if(!i.isUnoccupied(Math.min(n.x,o.x),Math.min(n.y,o.y),Math.abs(n.x-o.x),Math.abs(n.y-o.y)))return!0}return!1}findClosestSegment(t){let e=t.x,i=t.y,s=this.getPoint(0),n=this.getPoint(1),o=P.distanceLineSegmentSquared(e,i,s.x,s.y,n.x,n.y),r=0;for(let a=1;a<this.pointsCount-1;a++){s=this.getPoint(a+1);let h=P.distanceLineSegmentSquared(e,i,n.x,n.y,s.x,s.y);n=s,h<o&&(r=a,o=h)}return r}invalidateGeometry(){this.Ze()}Ze(){this.bl&&(this.bl=!1,this.c())}get bl(){return(this.Nt&128)!==0}set bl(t){(this.Nt&128)!==0!==t&&(this.Nt=this.Nt^128)}get geometry(){if(!this.bl){if(this.updateRoute(),this.pointsCount<2)return this.bl=!0,this.ut;this.ut=this.makeGeometry()}return this.ut}Ad(t){if(!t){if(this.Fi===!1)return;let n=this.findMainElement();if(this.bl&&(n===null||n.geometry!==null))return}this.pointsCount<2?this.bl=!0:this.ut=this.makeGeometry();let e=this.path;if(e===null)return;e.ut=this.ut;let i=this.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];o!==e&&o.isPanelMain&&o instanceof at&&(o.ut=this.ut)}}IE(t){return this.Zh()&&t.ra.has(this)&&(this.Gf.width!==0||this.Gf.height!==0)&&(t.animationManager.isAnimating||t.currentTool!==t.toolManager)}makeGeometry(){let t=this.ut,e=this.pointsCount,i=!1,s=this.diagram;s!==null&&this.IE(s)&&(i=!0);let n=0,o=0,r=P.bs(this.getPoint(0)),a=P.bs(r),h=this.Me.r,l=this.computeCurve();if(l===9&&e>=3&&!A.X(this.smoothness,0))if(e===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c<e;c++){let u=h[c];a.x=Math.min(u.x,a.x),a.y=Math.min(u.y,a.y)}n=a.x,o=a.y}else{for(let c=3;c<e;c+=3){c+3>=e&&(c=e-1);let u=this.getPoint(c);a.x=Math.min(u.x,a.x),a.y=Math.min(u.y,a.y)}n=a.x,o=a.y}else{for(let c=0;c<e;c++){let u=h[c];a.x=Math.min(u.x,a.x),a.y=Math.min(u.y,a.y)}n=a.x,o=a.y}if(n-=this.dk.x,o-=this.dk.y,r.x-=n,r.y-=o,this.computeShortLength(!0)!==0&&(r=this.tc(r,!0,a)),e===2&&!this.Zh()){let c=P.bs(this.getPoint(1));return c.x-=n,c.y-=o,this.computeShortLength(!1)!==0&&(c=this.tc(c,!1,a)),t.type=1,t.startX=r.x,t.startY=r.y,t.endX=c.x,t.endY=c.y,this.bl=!0,P.i(c),P.i(r),P.i(a),t}else{t.type=4;let c=Ye.qL(t);if(c.Au(r.x,r.y,!1,!1),l===9&&e>=3&&!A.X(this.smoothness,0))if(e===3){let u=this.getPoint(1),d=u.x-n,f=u.y-o,p=P.bs(this.getPoint(2));p.x-=n,p.y-=o,this.computeShortLength(!1)!==0&&this.tc(p,!1,a),c.xr(d,f,d,f,p.x,p.y),P.i(p)}else if(this.isOrthogonal){let u=P.z(n,o),d=P.bs(this.getPoint(1)),f=P.z(n,o),p=P.z(n,o),m=this.getPoint(0),y,b=this.smoothness/3;for(let S=1;S<this.pointsCount-1;S++){y=this.getPoint(S);let M=m,F=y,D=this.getPoint(this.OC(y,S,!1));A.X(M.x,F.x)&&A.X(F.x,D.x)||A.X(M.y,F.y)&&A.X(F.y,D.y)||(this.EE(M,F,D,b,f,p),(S===1||S===2&&A.X(m.x,this.getPoint(0).x)&&A.X(m.y,this.getPoint(0).y))&&(d.x=(m.x+y.x)*.5,d.y=(m.y+y.y)*.5),c.xr(d.x-n,d.y-o,f.x-n,f.y-o,y.x-n,y.y-o),u.h(f),d.h(p),m=y)}let v=m.x,w=m.y,k=P.bs(this.getPoint(this.pointsCount-1));this.computeShortLength(!1)!==0&&this.tc(k,!1,P.gn),v=.5*(v+k.x),w=.5*(w+k.y),c.xr(p.x-n,p.y-o,v-n,w-o,k.x-n,k.y-o),P.i(k),P.i(u),P.i(d),P.i(f),P.i(p)}else for(let u=3;u<e;u+=3){let d=this.getPoint(u-2);u+3>=e&&(u=e-1);let f=this.getPoint(u-1),p=P.bs(this.getPoint(u));u===e-1&&this.computeShortLength(!1)!==0&&this.tc(p,!1,P.gn),c.xr(d.x-n,d.y-o,f.x-n,f.y-o,p.x-n,p.y-o),P.i(p)}else if(this.isOrthogonal||e===2){let u=P.bs(this.getPoint(0)),d=P.l(),f=P.bs(u),p=this.computeCorner(),m=1,y=0;for(;m<e;){if(m=this.OC(u,m,m>1),d.h(this.getPoint(m)),m>=e-1){if(!u.equals(d))this.computeShortLength(!1)!==0&&this.tc(d,!1,P.gn),this.On(c,-n,-o,u,d,i);else if(y===0)for(m=1;m<e;)f.h(u),d.h(this.getPoint(m++)),this.On(c,-n,-o,u,d,i),u.h(d);break}y=this.OC(d,m+1,m<e-3);let b=this.getPoint(y);this.UE(c,-n,-o,u,d,b,u,f,p,i),f.h(d),m=y}P.i(u),P.i(d),P.i(f)}else{let u=this.computeCorner();if(e>2&&u>=.5){let d=P.bs(h[e-1]);this.computeShortLength(!1)!==0&&this.tc(d,!1,P.gn),r.x+=n,r.y+=o;for(let f=1;f<e;f++){let p=f===1?r:h[f-1],m=f===e-1?d:h[f],y=Math.sqrt(p.distanceSquaredPoint(m)),b=u/y;if(b<.5){if(f>1){let v=p.x+(m.x-p.x)*b,w=p.y+(m.y-p.y)*b;c.Tu(p.x-n,p.y-o,v-n,w-o)}c.Ks(m.x+(p.x-m.x)*b-n,m.y+(p.y-m.y)*b-o)}else f>1&&c.Tu(p.x-n,p.y-o,(p.x+m.x)/2-n,(p.y+m.y)/2-o);f===e-1&&c.Ks(d.x-n,d.y-o)}P.i(d)}else if(e>=2){let d=P.bs(h[e-1]);this.computeShortLength(!1)!==0&&this.tc(d,!1,P.gn);for(let f=1;f<e-1;f++)c.Ks(h[f].x-n,h[f].y-o);c.Ks(d.x-n,d.y-o),P.i(d)}}return Ye.WL(c),this.bl=!0,P.i(r),P.i(a),t}}bk(t,e,i,s){let n=i-t;if(isNaN(n)||n===1/0||n===-1/0)return NaN;n<0&&(n=-n);let o=s-e;return isNaN(o)||o===1/0||o===-1/0?NaN:(o<0&&(o=-o),A.X(n,0)?o:A.X(o,0)?n:Math.sqrt(n*n+o*o))}EE(t,e,i,s,n,o){isNaN(s)&&(s=this.smoothness/3);let r=t.x,a=t.y,h=e.x,l=e.y,c=i.x,u=i.y,d=s*this.bk(r,a,h,l),f=s*this.bk(h,l,c,u);if(A.X(a,l)&&A.X(h,c)&&(h>r?u>l?(n.x=h-d,n.y=l-d,o.x=h+f,o.y=l+f):(n.x=h-d,n.y=l+d,o.x=h+f,o.y=l-f):u>l?(n.x=h+d,n.y=l-d,o.x=h-f,o.y=l+f):(n.x=h+d,n.y=l+d,o.x=h-f,o.y=l-f)),A.X(r,h)&&A.X(l,u)&&(l>a?c>h?(n.x=h-d,n.y=l-d,o.x=h+f,o.y=l+f):(n.x=h+d,n.y=l-d,o.x=h-f,o.y=l+f):c>h?(n.x=h-d,n.y=l+d,o.x=h+f,o.y=l-f):(n.x=h+d,n.y=l+d,o.x=h-f,o.y=l-f)),A.X(r,h)&&A.X(h,c)||A.X(a,l)&&A.X(l,u)){let p=.5*(r+c),m=.5*(a+u);n.x=p,n.y=m,o.x=p,o.y=m}}tc(t,e,i){let s=this.pointsCount;if(s<2)return t;if(e){let n=this.getPoint(1),o=n.x-i.x,r=n.y-i.y,a=this.bk(t.x,t.y,o,r);if(a===0)return t;let h=s===2?a*.5:a,l=this.computeShortLength(!0);l>h&&(l=h);let c=l*(o-t.x)/a,u=l*(r-t.y)/a;t.x+=c,t.y+=u}else{let n=this.getPoint(s-2),o=n.x-i.x,r=n.y-i.y,a=this.bk(t.x,t.y,o,r);if(a===0)return t;let h=s===2?a*.5:a,l=this.computeShortLength(!1);l>h&&(l=h);let c=l*(t.x-o)/a,u=l*(t.y-r)/a;t.x-=c,t.y-=u}return t}OC(t,e,i){let s=this.pointsCount,n=t;for(;A.X(t.x,n.x)&&A.X(t.y,n.y);){if(e>=s)return s-1;n=this.getPoint(e++)}if(!A.X(t.x,n.x)&&!A.X(t.y,n.y))return e-1;let o=n;for(;A.X(t.x,n.x)&&A.X(n.x,o.x)&&(!i||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||A.X(t.y,n.y)&&A.X(n.y,o.y)&&(!i||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(e>=s)return s-1;o=this.getPoint(e++)}return e-2}UE(t,e,i,s,n,o,r,a,h,l){if(A.u(s.y,n.y)&&A.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-a.x)/2),u=Math.min(c,Math.abs(o.y-n.y)/2);if(c=u,A.u(c,0)){this.On(t,e,i,s,n,l),r.h(n);return}let d=n.x,f=n.y,p=d,m=f;n.x>s.x?(d=n.x-c,o.y>n.y?m=n.y+u:m=n.y-u):(d=n.x+c,o.y>n.y?m=n.y+u:m=n.y-u);let y=P.z(d,f);this.On(t,e,i,s,y,l),P.i(y),t.Tu(n.x+e,n.y+i,p+e,m+i),r.e(p,m)}else if(A.u(s.x,n.x)&&A.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-a.y)/2),u=Math.min(c,Math.abs(o.x-n.x)/2);if(c=u,A.u(u,0)){this.On(t,e,i,s,n,l),r.h(n);return}let d=n.x,f=n.y,p=d,m=f;n.y>s.y?(f=n.y-c,o.x>n.x?p=n.x+u:p=n.x-u):(f=n.y+c,o.x>n.x?p=n.x+u:p=n.x-u);let y=P.z(d,f);this.On(t,e,i,s,y,l),P.i(y),t.Tu(n.x+e,n.y+i,p+e,m+i),r.e(p,m)}else this.On(t,e,i,s,n,l),r.h(n)}On(t,e,i,s,n,o){if(o||!this.Zh())t.Ks(n.x+e,n.y+i);else{let r=q.ov,a=r/2,h=[],l=0;this.isVisible()&&(l=this.VE(s,n,h));let c=s.x,u=s.y;if(l>0){if(A.u(s.y,n.y))if(s.x<n.x){let d=0;for(;d<l;){let f=Math.max(s.x,Math.min(h[d++]-a,n.x-r));t.Ks(f+e,n.y+i),c=f+e,u=n.y+i;let p=Math.min(f+r,n.x);for(;d<l;){let v=h[d];if(v<p+r)d++,p=Math.min(v+a,n.x);else break}let m=n.y-r+i,y=p+e,b=n.y+i;this.curve===10?t.Au(y,b,!1,!1):t.xr(c,m,y,m,y,b),c=y,u=b}}else{let d=l-1;for(;d>=0;){let f=Math.min(s.x,Math.max(h[d--]+a,n.x+r));t.Ks(f+e,n.y+i),c=f+e,u=n.y+i;let p=Math.max(f-r,n.x);for(;d>=0;){let v=h[d];if(v>p-r)d--,p=Math.max(v-a,n.x);else break}let m=n.y-r+i,y=p+e,b=n.y+i;this.curve===10?t.Au(y,b,!1,!1):t.xr(c,m,y,m,y,b),c=y,u=b}}else if(A.u(s.x,n.x))if(s.y<n.y){let d=0;for(;d<l;){let f=Math.max(s.y,Math.min(h[d++]-a,n.y-r));t.Ks(n.x+e,f+i),c=n.x+e,u=f+i;let p=Math.min(f+r,n.y);for(;d<l;){let v=h[d];if(v<p+r)d++,p=Math.min(v+a,n.y);else break}let m=n.x-r+e,y=n.x+e,b=p+i;this.curve===10?t.Au(y,b,!1,!1):t.xr(m,u,m,b,y,b),c=y,u=b}}else{let d=l-1;for(;d>=0;){let f=Math.min(s.y,Math.max(h[d--]+a,n.y+r));t.Ks(n.x+e,f+i),c=n.x+e,u=f+i;let p=Math.max(f-r,n.y);for(;d>=0;){let v=h[d];if(v>p-r)d--,p=Math.max(v-a,n.y);else break}let m=n.x-r+e,y=n.x+e,b=p+i;this.curve===10?t.Au(y,b,!1,!1):t.xr(m,u,m,b,y,b),c=y,u=b}}}t.Ks(n.x+e,n.y+i)}}VE(t,e,i){let s=this.diagram;if(s===null||t.equals(e))return 0;let n=s.layers;for(;n.next();){let o=n.value;if(o!==null&&o.visible){let r=o.IM(),a=r.length;for(let h=0;h<a;h++){let l=r[h];if(!(l instanceof q))continue;if(l===this)return i.length>0&&i.sort((d,f)=>d-f),i.length;if(!l.isVisible()||!l.Zh())continue;let c=l.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(l))continue;let u=l.path;u!==null&&u.isVisibleObject()&&this.BE(t,e,i,l)}}}return i.length>0&&i.sort((o,r)=>o-r),i.length}BE(t,e,i,s){let n=A.u(t.y,e.y),o=s.pointsCount,r=s.getPoint(0),a=P.l();for(let h=1;h<o;h++){let l=s.getPoint(h);if(h<o-1){let c=s.getPoint(h+1);if(r.y===l.y&&l.y===c.y){if(l.x>r.x&&c.x>=l.x||l.x<r.x&&c.x<=l.x)continue}else if(r.x===l.x&&l.x===c.x&&(l.y>r.y&&c.y>=l.y||l.y<r.y&&c.y<=l.y))continue}this.zE(t,e,r,l,a)&&(n?i.push(a.x):i.push(a.y)),r=l}P.i(a)}zE(t,e,i,s,n){let o=t.x,r=t.y,a=e.x,h=e.y,l=i.x,c=i.y,u=s.x,d=s.y;if(A.u(o,a)){if(!A.u(r,h)&&A.u(c,d)&&Math.min(r,h)<c&&Math.max(r,h)>c&&Math.min(l,u)<o&&Math.max(l,u)>o&&!A.u(l,u))return n.x=o,n.y=c,!0}else if(A.u(r,h)&&A.u(l,u)&&Math.min(o,a)<l&&Math.max(o,a)>l&&Math.min(c,d)<r&&Math.max(c,d)>r&&!A.u(c,d))return n.x=l,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Qh(this.computeSpot(!0))?1:0}get lastPickIndex(){let t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Qh(this.computeSpot(!1))?t-2:t-1}Zh(){let t=this.curve;return t===11||t===10}pk(t){if(t||this.Zh()){let e=this.diagram;e!==null&&!e.animationManager.isTicking&&!e.ra.has(this)&&(this.Gf.width!==0||this.Gf.height!==0)&&e.ra.set(this,this.Gf.copy())}}invalidateOtherJumpOvers(t){let e=this.layer;if(e===null||!e.visible||e.isTemporary)return;let i=e.diagram;if(i===null||i.animationManager.isTicking)return;let s=!1,n=i.layers;for(;n.next();){let o=n.value;if(o.visible){if(o===e){s=!0;let r=!1,a=o.IM(),h=a.length;for(let l=0;l<h;l++){let c=a[l];c instanceof q&&(c===this?r=!0:r&&this.pv(c,t))}}else if(s){let r=o.IM(),a=r.length;for(let h=0;h<a;h++){let l=r[h];l instanceof q&&this.pv(l,t)}}}}}pv(t,e){if(t===null||!t.bl||!t.Fi||!t.Zh())return;let i=t.routeBounds;i.isReal()&&(!this.routeBounds.intersectsRect(i)&&!e.intersectsRect(i)||this.usesSamePort(t)||t.Ze())}usesSamePort(t){let e=this.pointsCount,i=t.pointsCount;if(e>0&&i>0){let s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;let o=this.getPoint(e-1),r=t.getPoint(i-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;let t=this.containingGroup,e=!0,i=this.diagram;i!==null&&(e=i.isTreePathToChildren);let s=this.fromNode;if(s!==null){if(this.isTreeLink&&e&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}let r=s.findVisibleNode();if(r===null||r===t)return!1}let n=this.toNode;if(n!==null){if(this.isTreeLink&&!e&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}let r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Xe(t){if(super.Xe(t),t&&this.pk(!1),this.sr!==null&&this.sr.Wd(),this.on!==null){let e=this.on.iterator;for(;e.next();)e.value.Xe(t)}}get adjusting(){return this.Xf}set adjusting(t){let e=this.Xf;e!==t&&(this.Xf=t,this.t("adjusting",e,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Xf}get corner(){return this.Zd}set corner(t){let e=this.Zd;e!==t&&(this.Zd=t,this.Ze(),this.t("corner",e,t))}get curve(){return this.Qd}set curve(t){let e=this.Qd;e!==t&&(this.Qd=t,this.$t(),this.Ze(),this.pk(e===10||e===11||t===10||t===11),this.t("curve",e,t))}get curviness(){return this._d}set curviness(t){let e=this._d;e!==t&&(this._d=t,this.$t(),this.Ze(),this.t("curviness",e,t))}get routing(){return this.qh}set routing(t){let e=this.qh;e!==t&&(this.qh=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.rp=!0),this.ir=null,this.$t(),this.pk(q.MC(e)||q.MC(t)),this.t("routing",e,t))}get smoothness(){return this.tg}set smoothness(t){let e=this.tg;e!==t&&(this.tg=t,this.Ze(),this.t("smoothness",e,t))}Zy(){let t=this.po;if(t===null)return;let e=this.wo;if(e===null||!isNaN(this.curviness))return;let i=this.yo,s=this.xo,n=null,o=null,r=t.ee.r,a=r.length;for(let h=0;h<a;h++){let l=r[h];!(l.po===t&&l.yo===i&&l.wo===e&&l.xo===s)&&!(l.po===e&&l.yo===s&&l.wo===t&&l.xo===i)||(o===null?o=l:(n===null&&(n=[],n.push(o)),n.push(l)))}if(n!==null){let h=t.HD(e,i,s);h===null&&(h=new pr(t,i,e,s),t.YD(h),e.YD(h)),h.rn=n;for(let l=0;l<n.length;l++){let c=n[l];c.sr=h}h.Wd()}}$y(){let t=this.sr;if(t!==null){if(!isNaN(this.curviness))return;this.sr=null;let e=t.rn.indexOf(this);e>=0&&(t.rn.splice(e,1),t.Wd())}}Ar(){return!0}get key(){let t=this.diagram;if(!(t===null||!t.model.jh()))return t.model.getKeyForLinkData(this.data)}}class pr{Ko;qs;Xy;pC;ck;yC;rn;constructor(t,e,i,s){I.Je(this),this.Ko=!1,this.qs=!1,this.Xy=t,this.pC=e,this.ck=i,this.yC=s,this.rn=[]}Wd(){if(!this.Ko){let t=this.rn;if(t.length>0){let e=t[0].diagram;e!==null&&(e.s2.add(this),this.qs=e.undoManager.isUndoingRedoing)}}this.Ko=!0}k2(){if(this.Ko){this.Ko=!1;let t=this.rn;if(t.length>0){let e=t[0],i=e.diagram,s=i===null||i.$a&&!this.qs;this.qs=!1,e.arrangeBundledLinks(t,s),t.length===1&&(e.sr=null,t.length=0)}t.length===0&&(this.Xy.KD(this),this.ck.KD(this))}}}class Et{fi;ui;ec;ic;we;xe;Vt;Fa;Ra;Ch;O2;Ko;_y;af;I2;E2;constructor(t){I.Je(this),this.Ch=null,this.O2=null,this.Ko=!0,this._y=!1,this.fi=1,this.ui=1,this.ec=-1,this.ic=-1,this.we=t.width,this.xe=t.height,this.Vt=[],this.Fa=0,this.Ra=0,this.af=q.uv,this.I2=this.af*2,this.E2=this.af*2}static ln=0;static sc=1;static ig=999999;static IC=Et.ig+1;static EC=Et.ig+2;c1(t){if(t.width<=0||t.height<=0)return;let e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;this.fi=Math.floor((e-this.we)/this.we)*this.we,this.ui=Math.floor((i-this.xe)/this.xe)*this.xe,this.ec=Math.ceil((s+2*this.we)/this.we)*this.we,this.ic=Math.ceil((n+2*this.xe)/this.xe)*this.xe;let o=1+(Math.ceil((this.ec-this.fi)/this.we)|0),r=1+(Math.ceil((this.ic-this.ui)/this.xe)|0);if(this.Vt.length===0||this.Fa<o-1||this.Ra<r-1){let a=[];for(let h=0;h<=o;h++)a[h]=new Uint32Array(r);this.Vt=a,this.Fa=o-1,this.Ra=r-1}this.XE(Et.IC)}get bounds(){return new B(this.fi,this.ui,this.ec-this.fi,this.ic-this.ui)}get cellWidth(){return this.we}set cellWidth(t){t>0&&t!==this.we&&(this.we=t,this.c1(this.bounds))}get cellHeight(){return this.xe}set cellHeight(t){t>0&&t!==this.xe&&(this.xe=t,this.c1(this.bounds))}sg(t,e){return this.fi<=t&&t<=this.ec&&this.ui<=e&&e<=this.ic}bo(t,e){if(!this.sg(t,e))return Et.IC;t-=this.fi,t/=this.we,e-=this.ui,e/=this.xe;let i=t|0,s=e|0;return this.Vt[i][s]}vO(t,e,i,s){if(!this.sg(t,e))return;let n=(t-this.fi)/this.we|0,o=(e-this.ui)/this.xe|0,r=(t+i-this.fi)/this.we|0,a=(e+s-this.ui)/this.xe|0,h=Math.min(r,this.Fa),l=Math.min(a,this.Ra);for(let c=n;c<=h;c++){let u=this.Vt[c];if(u.fill)u.fill(Et.ln,o,l+1);else for(let d=o;d<=l;d++)u[d]=Et.ln}}XE(t){for(let e=0;e<=this.Fa;e++){let i=this.Vt[e];if(i.fill)i.fill(t);else for(let s=0;s<=this.Ra;s++)i[s]=t}}TT(){for(let t=0;t<=this.Fa;t++){let e=this.Vt[t];for(let i=0;i<=this.Ra;i++)e[i]>=Et.sc&&(e[i]=Et.IC)}}GE(t,e){return this.bo(t,e)===Et.ln}isUnoccupied(t,e,i,s){if(t>this.ec||t+i<this.fi||e>this.ic||e+s<this.ui)return!0;let n=(t-this.fi)/this.we|0,o=(e-this.ui)/this.xe|0,r=Math.max(0,i)/this.we+1|0,a=Math.max(0,s)/this.xe+1|0;if(n<0&&(r+=n,n=0),o<0&&(a+=o,o=0),r<0||a<0)return!0;let h=Math.min(n+r-1,this.Fa)|0,l=Math.min(o+a-1,this.Ra)|0;for(let c=n;c<=h;c++){let u=this.Vt[c];for(let d=o;d<=l;d++)if(u[d]===Et.ln)return!1}return!0}maxAvoidsLinksSpaceH(t,e,i,s){if(t>this.ec||e<this.fi||i>this.ic||i<this.ui)return 0;let n=(t-this.fi)/this.we|0,o=(e-this.fi)/this.we|0,r=(i-this.ui)/this.xe|0,a=s/this.xe+1|0,h;for(h=0;h<a/2;h++){let l=!1;for(let c=n;c<=o;c++)if(this.Vt[c][r+h]===Et.ln||this.Vt[c][r-h]===Et.ln){l=!0;break}if(l)return Math.max(0,(2*h-1)*this.xe)}return s}maxAvoidsLinksSpaceV(t,e,i,s){if(t>this.ic||e<this.ui||i>this.ec||i<this.fi)return 0;let n=(t-this.ui)/this.xe|0,o=(e-this.ui)/this.xe|0,r=(i-this.fi)/this.we|0,a=s/this.we+1|0,h;for(h=0;h<a/2;h++){let l=!1;for(let c=n;c<=o;c++)if(this.Vt[r+h][c]===Et.ln||this.Vt[r-h][c]===Et.ln){l=!0;break}if(l)return Math.max(0,(2*h-1)*this.we)}return s}YE(t,e,i,s,n,o,r,a){t=t|0,e=e|0;let h=this.Vt[t][e];if(h>=Et.sc&&h<Et.ig)for(s?e+=i:t+=i,h+=1;n<=t&&t<=o&&r<=e&&e<=a;){let l=this.Vt[t][e];if(h>=l)break;this.Vt[t][e]=h,h+=1,s?e+=i:t+=i}return s?e:t}ko(t,e,i,s,n,o,r,a){if(t<n||t>o||e<r||e>a)return;let h=this.YE(t,e,i,s,n,o,r,a);if(s)if(i>0)for(let l=e+i;l<h;l+=i)this.ko(t,l,1,!s,n,o,r,a),this.ko(t,l,-1,!s,n,o,r,a);else for(let l=e+i;l>h;l+=i)this.ko(t,l,1,!s,n,o,r,a),this.ko(t,l,-1,!s,n,o,r,a);else if(i>0)for(let l=t+i;l<h;l+=i)this.ko(l,e,1,!s,n,o,r,a),this.ko(l,e,-1,!s,n,o,r,a);else for(let l=t+i;l>h;l+=i)this.ko(l,e,1,!s,n,o,r,a),this.ko(l,e,-1,!s,n,o,r,a)}kk(t,e,i,s,n,o,r,a,h,l){let c=t|0,u=e|0,d=Et.ln,f=Et.sc;for(this.Vt[c][u]=f;d===Et.ln&&c>r&&c<a&&u>h&&u<l;)f+=1,this.Vt[c][u]=f,o?u+=n:c+=n,d=this.Vt[c][u];return o?u:c}Pk(t,e,i,s,n,o,r,a,h,l){let c=i|0,u=s|0,d=Et.ln,f=Et.ig;for(this.Vt[c][u]=f;d===Et.ln&&c>r&&c<a&&u>h&&u<l;)this.Vt[c][u]=f,o?u+=n:c+=n,d=this.Vt[c][u]}yv(t,e,i,s,n,o){this._y=!1;let r=t.x,a=t.y;if(!this.sg(r,a))return;r-=this.fi,r/=this.we,a-=this.ui,a/=this.xe;let h=i.x,l=i.y;if(!this.sg(h,l))return;if(h-=this.fi,h/=this.we,l-=this.ui,l/=this.xe,Math.abs(r-h)<=1&&Math.abs(a-l)<=1){this._y=!0;return}let c=n.x,u=n.y,d=n.x+n.width,f=n.y+n.height;c-=this.fi,c/=this.we,u-=this.ui,u/=this.xe,d-=this.fi,d/=this.we,f-=this.ui,f/=this.xe;let p=Math.max(0,Math.min(this.Fa,c|0)),m=Math.min(this.Fa,Math.max(0,d|0)),y=Math.max(0,Math.min(this.Ra,u|0)),b=Math.min(this.Ra,Math.max(0,f|0)),v=0,w=90,k=270,S=this.Vt,M=r|0,F=a|0,D=h|0,N=l|0,L=e===v||e===w?1:-1,R=e===w||e===k;S[M][F]===Et.ln?(this.kk(M,F,D,N,L,R,p,m,y,b),this.kk(M,F,D,N,1,!R,p,m,y,b),this.kk(M,F,D,N,-1,!R,p,m,y,b)):this.kk(M,F,D,N,L,R,M,F,M,F),S[D][N]===Et.ln?(this.Pk(M,F,D,N,s===v||s===w?1:-1,s===w||s===k,p,m,y,b),this.Pk(M,F,D,N,1,!(s===w||s===k),p,m,y,b),this.Pk(M,F,D,N,-1,!(s===w||s===k),p,m,y,b)):this.Pk(M,F,D,N,L,R,D,N,D,N);let O=g.ot();if(o&&this.wv(D,N,s,M,F,O)){(O[0]!==D||O[1]!==N)&&(O.unshift(N),O.unshift(D)),(O[O.length-2]!==M||O[O.length-1]!==F)&&(O.push(M),O.push(F));let V=Et.sc,K=O[O.length-2],Y=O[O.length-1];S[K][Y]=V++;for(let X=O.length-4;X>=0;X-=2){K=O[X+2],Y=O[X+3];let G=O[X],rt=O[X+1];for(;G>K?K++:G<K?K--:rt>Y?Y++:rt<Y&&Y--,S[K][Y]=V++,!(K===G&&Y===rt););}}else this.ko(M,F,1,!1,p,m,y,b),this.ko(M,F,-1,!1,p,m,y,b),this.ko(M,F,1,!0,p,m,y,b),this.ko(M,F,-1,!0,p,m,y,b);g.Z(O)}wv(t,e,i,s,n,o){let r=this.Vt,a=t,h=e;for(;;){if(a===s&&h===n)return!0;let l=a,c=h;if(i===0)if(l<s)l++;else break;else if(i===90)if(c<n)c++;else break;else if(i===180)if(l>s)l--;else break;else if(c>n)c--;else break;let u=r[l][c];if(u===0||u===Et.EC)break;a=l,h=c}for(;;){let l=i,c=a,u=h;i===0?u<n?(l=90,u++):u>n&&(l=270,u--):i===90?c<s?(l=0,c++):c>s&&(l=180,c--):i===180?u<n?(l=90,u++):u>n&&(l=270,u--):c<s?(l=0,c++):c>s&&(l=180,c--);let d=r[c][u];if(l!==i&&d!==0&&d!==Et.EC){if(o.push(a),o.push(h),this.wv(a,h,l,s,n,o))return!0;o.pop(),o.pop()}if(r[a][h]=Et.EC,i===0){if(a===t)return!1;a--}else if(i===90){if(h===e)return!1;h--}else if(i===180){if(a===t)return!1;a++}else{if(h===e)return!1;h++}}}}class Os{Ri;kl;Ei;ng;constructor(t,e){I.Je(this),this.Ri=t,this.kl=e,this.Ei=[],this.ng=!1}toString(){let t=this.Ei,e=this.Ri.toString()+" "+t.length.toString()+":";for(let i=0;i<t.length;i++){let s=t[i];s!==null&&(e+=`
15
+ `+s.toString())}return e}KE(t,e,i,s){let n=e.offsetY;switch(n){case 8:return 90;case 2:return 180;case 1:return 270;case 4:return 0}let o=i;switch(n){case 9:return o>180?270:90;case 6:return o>90&&o<=270?180:0}let r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Wd(){this.Ei.length=0}dv(t){let e=this.Ei;e.length===0&&(this.HE(),e=this.Ei);for(let i=0;i<e.length;i++){let s=e[i];if(s!==null&&s.es===t)return s}return null}HE(){if(!this.ng){let t=this.ng;this.ng=!0;let e,i=null,s=this.Ri,n=s instanceof ft?s:null;if(n!==null&&!n.isSubGraphExpanded){if(!n.actualBounds.isReal())return this.ng=t,this.Ei;i=n,e=i.findExternalLinksConnected()}else s.isTreeExpanded?e=s.findLinksConnected(this.kl.portId):e=s.findExternalTreeLinksConnected();this.Ei.length=0;let o=0,r=this.kl.getDocumentPoint(T.TopLeft,P.l()),a=this.kl.getDocumentPoint(T.BottomRight,P.l()),h=B.z(r.x,r.y,0,0);h.unionPoint(a),P.i(r),P.i(a);let l=P.z(h.x+h.width/2,h.y+h.height/2),c=this.kl.getDocumentAngle(),u=e.iterator;for(;u.next();){let m=u.value;if(!m.isVisible()||m.fromPort===m.toPort)continue;let y=m.fromPort===this.kl||i!==null&&m.fromNode!==null&&m.fromNode.isMemberOf(i),b=m.computeSpot(y,this.kl);if(!b.isSide())continue;let v;if(y?v=m.toPort:v=m.fromPort,v===null)continue;let w=v.part;if(w===null)continue;let k=w.findVisibleNode();k!==null&&k!==w&&(w=k,v=w.port);let S=m.computeOtherPoint(w,v),M=l.directionPoint(S);c!==0&&(M=A.Ee(M-c));let F=this.KE(h,b,M,m.isOrthogonal),D=0;F===0?(D=4,M>180&&(M-=360)):F===90?(D=8,M>270&&(M-=360)):F===180?D=2:(D=1,M<90&&(M+=360));let N=this.Ei[o];N===void 0?(N=new yr(m,M,D),this.Ei[o]=N):(N.es=m,N.Xt=M,N.ci=D),N.Sk.h(S),o++}P.i(l),this.jE();let d=this.Ei.length,f=-1,p=0;for(o=0;o<d;o++){let m=this.Ei[o];m!==void 0&&(m.ci!==f&&(f=m.ci,p=0),m.og=p,p++)}for(f=-1,p=0,o=d-1;o>=0;o--){let m=this.Ei[o];m!==void 0&&(m.ci!==f&&(f=m.ci,p=m.og+1),m.Kf=p)}this.qE(this.Ei),this.WE(this.Ei),this.ng=t,B.i(h)}return this.Ei}JE(t,e){return t===e?0:t===null?-1:e===null?1:t.ci<e.ci?-1:t.ci>e.ci?1:t.Xt<e.Xt?-1:t.Xt>e.Xt?1:0}jE(){this.Ei.sort(Os.prototype.JE)}qE(t){let e=this.kl,i=this.Ri.portSpreading,s=P.l(),n=P.l(),o=P.l(),r=P.l();e.getDocumentPoint(T.TopLeft,s),e.getDocumentPoint(T.TopRight,n),e.getDocumentPoint(T.BottomRight,o),e.getDocumentPoint(T.BottomLeft,r);let a=0,h=0,l=0,c=0;if(i===2)for(let v=0;v<t.length;v++){let w=t[v];if(w===null)continue;let k=w.es.computeThickness();switch(w.ci){case 8:l+=k;break;case 2:c+=k;break;case 1:a+=k;break;default:case 4:h+=k;break}}let u=0,d=0,f=1,p=n,m=o,y=0,b=0;for(let v=0;v<t.length;v++){let w=t[v];if(w===null)continue;if(u!==w.ci){switch(u=w.ci,u){case 8:p=o,m=r;break;case 2:p=r,m=s;break;case 1:p=s,m=n;break;default:case 4:p=n,m=o;break}switch(y=m.x-p.x,b=m.y-p.y,u){case 8:l>Math.abs(y)?(f=Math.abs(y)/l,l=Math.abs(y)):f=1;break;case 2:c>Math.abs(b)?(f=Math.abs(b)/c,c=Math.abs(b)):f=1;break;case 1:a>Math.abs(y)?(f=Math.abs(y)/a,a=Math.abs(y)):f=1;break;default:case 4:h>Math.abs(b)?(f=Math.abs(b)/h,h=Math.abs(b)):f=1;break}d=0}let k=w._h;if(i===2){let S=w.es.computeThickness();switch(S*=f,k.h(p),u){case 8:k.x=p.x+y/2+l/2-d-S/2;break;case 2:k.y=p.y+b/2+c/2-d-S/2;break;case 1:k.x=p.x+y/2-a/2+d+S/2;break;default:case 4:k.y=p.y+b/2-h/2+d+S/2;break}d+=S}else{let S=.5;i===1&&(S=(w.og+1)/(w.Kf+1)),k.x=p.x+y*S,k.y=p.y+b*S}}P.i(s),P.i(n),P.i(o),P.i(r)}WE(t){for(let e=0;e<t.length;e++){let i=t[e];i!==null&&(i.xk=this.$E(i,e))}}$E(t,e){let i=t.es,s=i.fromPort===this.kl,n=0;switch(t.ci){case 1:n=270;break;case 2:n=180;break;case 4:n=0;break;case 8:n=90;break}let o=i.yk(this.Ri,this.kl,T.None,s,n),r=t.og;if(r<0)return o;let a=t.Kf;if(a<=1||!i.isOrthogonal)return o;let h=t.Sk,l=t._h,c=t.ci===2||t.ci===8;c&&(r=a-1-r);let u=q.ev,d=t.ci===2||t.ci===4,f=r<=0?l:this.Ei[c?e+1:e-1]._h,p=r>=a-1?l:this.Ei[c?e-1:e+1]._h;return(d?h.y>=f.y&&h.y<=p.y:h.x>=f.x&&h.x<=p.x)?o:(d?h.y<l.y:h.x<l.x)?o+r*u:o+(a-1-r)*u}}class yr{es;Xt;ci;Sk;og;Kf;_h;xk;constructor(t,e,i){this.es=t,this.Xt=e,this.ci=i,this.Sk=new P,this.og=0,this.Kf=0,this._h=new P,this.xk=0}toString(){return this.es.toString()+" "+this.Xt.toString()+" "+this.ci.toString()+":"+this.og.toString()+"/"+this.Kf.toString()+" "+this._h.toString()+" "+this.xk.toString()+" "+this.Sk.toString()}}class ns{Ah;Th;Dh;vh;Fh;Rh;h0;l0;c0;a0;constructor(){this.Ah=T.Default,this.Th=T.Default,this.Dh=NaN,this.vh=NaN,this.Fh=NaN,this.Rh=NaN,this.h0=null,this.l0=null,this.c0=1/0,this.a0=1/0}copy(){let t=new ns;return t.Ah=this.Ah.N(),t.Th=this.Th.N(),t.Dh=this.Dh,t.vh=this.vh,t.Fh=this.Fh,t.Rh=this.Rh,t.h0=this.h0,t.l0=this.l0,t.c0=this.c0,t.a0=this.a0,t}}class $e{_p;t0;e0;Qp;H0;j0;constructor(){this._p=-1/0,this.t0=0,this.e0=P.gn,this.Qp=0,this.H0="None",this.j0="None"}copy(){let t=new $e;return t._p=this._p,t.t0=this.t0,t.e0=this.e0.N(),t.Qp=this.Qp,t.H0=this.H0,t.j0=this.j0,t}}class ft extends it{rg;Dt;Mh;vp;he;li;constructor(t,e){let i;t===void 0||t instanceof Ft||typeof t=="string"?i=t:t&&(e=t),super(i),this.E=this.E|4608,this.rg=new I,this.Dt=null,this.li=new oe,this.li.group=this,this.Mh=new I,this.vp=null,this.he=null,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),this.E=this.E&-32769;let e=t.findInVisualTree(i=>i instanceof we);e instanceof we?t.Dt=e:t.Dt=null,this.li!==null?(t.li=this.li.copy(),t.li.group=t):(t.li!==null&&(t.li.group=null),t.li=null),this.he!==null&&(t.he=this.he.copy())}jo(t){super.jo(t);let e=t.findSubGraphParts(),i=t.memberParts;for(;i.next();){let s=i.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof it)s.invalidateConnectedLinks(e);else if(s instanceof q){let n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(e)}}}df(t,e,i,s,n,o,r){if(t===3&&e==="elements"){if(n instanceof we)this.Dt===null?this.Dt=n:this.Dt!==n&&g.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof H){let a=n.findInVisualTree(h=>h instanceof we);a instanceof we&&(this.Dt===null?this.Dt=a:this.Dt!==a&&g.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&e==="elements"&&this.Dt!==null&&(s===this.Dt?this.Dt=null:s instanceof H&&this.Dt.isContainedBy(s)&&(this.Dt=null));super.df(t,e,i,s,n,o,r)}bd(t,e){if(super.bd(t,e),this.isClipping&&this.type!==H.Spot&&this.isSubGraphExpanded){let i=this.resizeObject;i instanceof H&&(i=i.findMainElement()),this.he===null&&(this.he=new B),i.getDocumentBounds(this.he),i instanceof at&&this.he.inflate(-i.strokeWidth,-i.strokeWidth)}}Pa(t,e,i,s){this.hasPlaceholder()&&(this.er=this.placeholder),super.Pa(t,e,i,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(t=>{t.ensureBounds()}),super.ensureBounds()}_r(){if(!super._r())return!1;let t=this.memberParts;for(;t.next();){let e=t.value;if(e instanceof it){if(!e.isVisible())continue;if(e.as())return!1}else if(e instanceof q){if(!e.isVisible())continue;if(e.as()&&e.fromNode!==this&&e.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Dt!==null&&this.Dt.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Dt}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){let e=(this.E&2048)!==0;e!==t&&(this.E=this.E^2048,this.t("computesBoundsAfterDrag",e,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){let e=(this.E&4096)!==0;e!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",e,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){let e=(this.E&8192)!==0;e!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",e,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){let e=(this.E&16384)!==0;e!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",e,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){let e=(this.E&131072)!==0;e!==t&&(this.E=this.E^131072,this.t("avoidableMembers",e,t))}get memberParts(){return this.rg.iterator}uC(t){if(this.rg.add(t)){t instanceof ft&&this.Mh.add(t);let i=this.memberAdded;if(i!==null){let s=!0,n=this.diagram;n!==null&&(s=n.G,n.G=!0),i(this,t),n!==null&&(n.G=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Xe(!1)}if(t instanceof q&&!this.computesBoundsIncludingLinks)return;let e=this.Dt;e===null&&(e=this),e.c()}fC(t){if(this.rg.delete(t)){t instanceof ft&&this.Mh.delete(t);let i=this.memberRemoved;if(i!==null){let s=!0,n=this.diagram;n!==null&&(s=n.G,n.G=!0),i(this,t),n!==null&&(n.G=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Xe(!0)}if(t instanceof q&&!this.computesBoundsIncludingLinks)return;let e=this.Dt;e===null&&(e=this),e.c()}rf(){if(this.rg.count>0){let t=this.diagram;if(t!==null){let e=this.rg.copy().iterator;for(;e.next();){let i=e.value;t.remove(i)}}}super.rf()}get layout(){return this.li}set layout(t){let e=this.li;if(e!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&g.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),e!==null&&(e.diagram=null,e.group=null),this.li=t;let i=this.diagram;t!==null&&(t.diagram=i,t.group=this),i!==null&&(i.$r=!0),this.t("layout",e,t),i!==null&&i.requestUpdate()}}get memberAdded(){return this.vt!==null?this.vt.qy:null}set memberAdded(t){let e=this.memberAdded;e!==t&&(t!==null&&g.S(t,ft,"memberAdded"),this.wl().qy=t,this.t("memberAdded",e,t))}get memberRemoved(){return this.vt!==null?this.vt.Wy:null}set memberRemoved(t){let e=this.memberRemoved;e!==t&&(t!==null&&g.S(t,ft,"memberRemoved"),this.wl().Wy=t,this.t("memberRemoved",e,t))}get memberValidation(){return this.vt!==null?this.vt.da:null}set memberValidation(t){let e=this.memberValidation;e!==t&&(t!==null&&g.S(t,ft,"memberValidation"),this.wl().da=t,this.t("memberValidation",e,t))}canAddMembers(t){let e=this.diagram;if(e===null)return!1;let i=e.commandHandler,s=i.wN(t).iterator;for(;s.next();){let n=s.value;if(!i.isValidMember(this,n))return!1}return!0}addMembers(t,e){let i=this.diagram;if(i===null)return!1;let s=i.commandHandler,n=s.wN(t),o=!0,r=n.iterator;for(;r.next();){let a=r.value;!e||s.isValidMember(this,a)?a.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){let e=(this.E&256)!==0;e!==t&&(this.E=this.E^256,this.t("ungroupable",e,t))}canUngroup(){if(!this.ungroupable)return!1;let t=this.layer;if(t===null||!t.allowUngroup)return!1;let e=t.diagram;return!(e!==null&&!e.allowUngroup)}invalidateConnectedLinks(t){let e=this.ZE();if(super.invalidateConnectedLinks(t),e)return;this.cT(!0);let i=this.findExternalLinksConnected();for(;i.next();){let s=i.value;if(t!==void 0&&t.has(s))continue;let n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.Pi(s.fromPort),n.Pi(s.toPort),s.$t();else{let o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.Pi(s.fromPort),o.Pi(s.toPort),s.$t())}}}findExternalLinksConnected(){let t=this.diagram!==null&&this.diagram.f2;if(t&&this.vp!==null)return this.vp.iterator;let e=this.findSubGraphParts();e.add(this);let i=new I,s=e.iterator;for(;s.next();){let n=s.value;if(!(n instanceof it))continue;let o=n.linksConnected;for(;o.next();){let r=o.value;e.has(r)||i.add(r)}}return t&&(this.vp=i),i.iterator}findExternalNodesConnected(){let t=this.findSubGraphParts();t.add(this);let e=new I,i=t.iterator;for(;i.next();){let s=i.value;if(!(s instanceof it))continue;let n=s.linksConnected;for(;n.next();){let o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&e.add(r);let a=o.toNode;a!==null&&(!t.has(a)||a===this)&&e.add(a)}}return e.iterator}XU(){function t(i,s){i!==null&&(s.add(i),t(i.containingGroup,s))}let e=new I;return t(this,e),e}findSubGraphParts(){let t=new I;return bt.ga(t,this,!0,0,!0),t.delete(this),t}Xe(t){super.Xe(t);let e=this.memberParts;for(;e.next();)e.value.Xe(t)}collapseSubGraph(){let t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;let e=this.findSubGraphParts();this.xv(e,t,this),t.isCollapsingExpanding=!1}xv(t,e,i){let s=this.memberParts;for(;s.next();){let n=s.value;if(n.Xe(!1),n instanceof ft&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.xv(t,e,i)),n instanceof it)n.invalidateConnectedLinks(t),e.Yc(n,i);else if(n instanceof q){let o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){let t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;let e=this.findSubGraphParts();this.bv(e,t,this),t.isCollapsingExpanding=!1}bv(t,e,i){let s=this.memberParts;for(;s.next();){let n=s.value;if(n.Xe(!0),n instanceof ft&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.bv(t,e,i)),n instanceof it)n.invalidateConnectedLinks(t);else if(n instanceof q){let o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){let e=(this.E&512)!==0;if(e!==t){this.E=this.E^512;let i=this.diagram;this.t("isSubGraphExpanded",e,t);let s=this.subGraphExpandedChanged;if(s!==null){let n=!0;i!==null&&(n=i.G,i.G=!0),s(this),i!==null&&(i.G=n)}if(i!==null&&i.undoManager.isUndoingRedoing){this.Dt!==null&&this.Dt.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){let e=(this.E&1024)!==0;e!==t&&(this.E=this.E^1024,this.t("wasSubGraphExpanded",e,t))}get subGraphExpandedChanged(){return this.vt!==null?this.vt.Jy:null}set subGraphExpandedChanged(t){let e=this.subGraphExpandedChanged;e!==t&&(t!==null&&g.S(t,ft,"subGraphExpandedChanged"),this.wl().Jy=t,this.t("subGraphExpandedChanged",e,t))}move(t,e){e===void 0&&(e=!1);let i=e?this.location:this.position,s=i.x,n=i.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;let a=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),l=P.l();super.move(t,e);let c=new I,u=this.findSubGraphParts().iterator;for(;u.next();){let d=u.value;d instanceof q&&(d.suspendsRouting&&c.add(d),!(!d.Fi&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){let d=u.value;if(d.Ar()||d instanceof it&&d.isLinkLabel)continue;let f=d.position,p=d.location;f.isReal()?(l.x=f.x+a,l.y=f.y+h,d.position=l):p.isReal()&&(l.x=p.x+a,l.y=p.y+h,d.location=l)}for(u.reset();u.next();){let d=u.value;if(!(d instanceof q)||(d.suspendsRouting=c.has(d),!d.Fi&&(d.fromNode===this||d.toNode===this)))continue;let f=d.position;l.x=f.x+a,l.y=f.y+h,l.isReal()?d.move(l):d.$t()}P.i(l)}ZE(){return(this.E&65536)!==0}cT(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Nh(){return(this.E&32768)!==0}set Nh(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class we extends tt{Qt;lg;constructor(t){super(),this.Qt=Dt.em,this.lg=new B(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Qt=this.Qt.N(),t.lg=this.lg.copy()}ka(t){if(this.background===null)return!1;let e=this.naturalBounds;return B.contains(0,0,e.width,e.height,t.x,t.y)}xd(t,e,i,s){let n=this.part;if((n===null||!(n instanceof ft)&&!(n instanceof Mt))&&g.o("Placeholder is not inside a Group or Adornment."),n instanceof ft){let o=this.computeBorder(this.lg),r=this.minSize,a=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,l=this.Ke;l.jn(a||0,h||0),this.lo(0,0,l.width,l.height);let c=n.memberParts,u=!1;for(;c.next();)if(c.value.isVisible()){u=!0;break}let d=n.diagram;if(u&&d!==null&&!d.animationManager.NM(n)&&!isNaN(o.x)&&!isNaN(o.y)){let f=P.l();f.setRectSpot(o,n.locationSpot),n.location=f,P.i(f)}}else{let o=n,r=this.Ke,a=this.Qt,h=a.left+a.right,l=a.top+a.bottom,c=o.adornedObject,u=c.getDocumentAngle();o.angle=u;let d=0;c instanceof at&&(d=c.strokeWidth);let f=c.getDocumentScale(),p=c.naturalBounds,m=(p.width+d)*f,y=(p.height+d)*f;if(o.type!==H.Link){let b=o.category==="Selection"?T.TopLeft:o.locationSpot,v=c.getDocumentPoint(b,P.l());o.location=v,P.i(v)}if(!isNaN(m)&&!isNaN(y))r.jn(m+h||0,y+l||0),this.lo(-a.left,-a.top,r.width,r.height);else{let b=c.getDocumentPoint(T.TopLeft,P.l()),v=B.z(b.x,b.y,0,0);v.unionPoint(c.getDocumentPoint(T.BottomRight,b)),v.unionPoint(c.getDocumentPoint(T.TopRight,b)),v.unionPoint(c.getDocumentPoint(T.BottomLeft,b)),r.jn(v.width+h||0,v.height+l||0),this.lo(-a.left,-a.top,r.width,r.height),P.i(b),B.i(v)}}}Pa(t,e,i,s){this.actualBounds.e(t,e,i,s)}computeBorder(t){let e=this.part,i=e.diagram;if(i===null||i.animationManager.isAnimating)return t;if(e instanceof ft&&!e.layer.isTemporary&&e.computesBoundsAfterDrag&&this.lg.isReal()){let r=i.toolManager.findTool("Dragging");if(r===i.currentTool&&r.mR(e,this.lg,t))return t}let s=B.l(),n=this.computeMemberBounds(s),o=this.Qt;return e instanceof ft&&!e.isSubGraphExpanded?t.e(n.x-o.left,n.y-o.top,0,0):t.e(n.x-o.left,n.y-o.top,Math.max(n.width+o.left+o.right,0),Math.max(n.height+o.top+o.bottom,0)),B.i(s),e instanceof ft&&e.computesBoundsIncludingLocation&&e.location.isReal()&&t.unionPoint(e.location),t}computeMemberBounds(t){if(!(this.part instanceof ft))return t.e(0,0,0,0),t;let e=this.part,i=1/0,s=1/0,n=-1/0,o=-1/0,r=e.memberParts;for(;r.next();){let a=r.value;if(!a.isVisible()||a instanceof q&&(!e.computesBoundsIncludingLinks||a.Go()||a.fromNode===e||a.toNode===e))continue;let h=a.actualBounds;h.left<i&&(i=h.left),h.top<s&&(s=h.top),h.right>n&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(i)||!isFinite(s)){let a=e.location;t.e(a.x,a.y,0,0)}else t.e(i,s,n-i,o-s);return t}get padding(){return this.Qt}set padding(t){typeof t=="number"&&(t=new Dt(t));let e=this.Qt;e.equals(t)||(t=t.N(),this.Qt=t,this.t("padding",e,t),this.c())}}class oe{a;Ch;ag;Tr;hg;cg;Vo;Pl;fg;ug;Po;constructor(t){I.Je(this),this.a=null,this.Ch=null,this.ag=!0,this.Tr=!0,this.hg=!1,this.cg=new P(0,0),this.Vo=!0,this.Pl=null,this.fg=null,this.ug=!1,this.Po=null,t&&Object.assign(this,t)}cloneProtected(t){t.ag=this.ag,t.Tr=this.Tr,t.hg=this.hg,t.cg.h(this.cg),t.Vo=this.Vo,t.Pl=this.Pl,t.fg=this.fg,t.ug=!0}copy(){let t=new this.constructor;return this.cloneProtected(t),t}fe(t){g.dr(this,t)}toString(){let t=g.Hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.a}set diagram(t){this.a=t}get group(){return this.Ch}set group(t){this.Ch!==t&&(this.Ch=t,t!==null&&(this.a=t.diagram))}get isOngoing(){return this.ag}set isOngoing(t){this.ag!==t&&(g.s(t,"boolean",oe,"isOngoing"),this.ag=t)}get isInitial(){return this.Tr}set isInitial(t){g.s(t,"boolean",oe,"isInitial"),this.Tr=t,t||(this.ug=!0)}get isViewportSized(){return this.hg}set isViewportSized(t){this.hg!==t&&(g.s(t,"boolean",oe,"isViewportSized"),this.hg=t,t&&this.p())}get isRouting(){return this.Vo}set isRouting(t){this.Vo!==t&&(g.s(t,"boolean",oe,"isRouting"),this.Vo=t)}get isRealtime(){return this.Pl}set isRealtime(t){this.Pl!==t&&(t!==null&&g.s(t,"boolean",oe,"isRealtime"),this.Pl=t)}get isValidLayout(){return this.ug}set isValidLayout(t){if(this.ug!==t&&(g.s(t,"boolean",oe,"isValidLayout"),this.ug=t,!t)){let e=this.diagram;e!==null&&(e.$r=!0)}}invalidateLayout(){if(!this.isValidLayout)return;let t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;let e=t.animationManager;e.isTicking||(e.defaultAnimation.isAnimating&&e.stopAnimation(),(this.isOngoing&&t.$a||this.isInitial&&!t.$a)&&(this.isValidLayout=!1,t.requestUpdate()))}p(){this.invalidateLayout()}get network(){return this.Po}set network(t){this.Po!==t&&(this.Po=t,t!==null&&(t.layout=this))}createNetwork(){return new Je(this)}makeNetwork(t){let e=this.createNetwork();return t instanceof j?(e.addParts(t.nodes,!0),e.addParts(t.links,!0)):t instanceof ft?e.addParts(t.memberParts):e.addParts(t.iterator),e}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){let e=this.network.vertexes.iterator;for(;e.next();){let i=e.value.node;if(i!==null&&(t=i.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;let t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){let e=this.network.edges.iterator;for(;e.next();)e.value.commit()}}doLayout(t){let e=new I;if(t instanceof j?(this.Oa(e,t.nodes,!0,this.Nh,!0,!1,!0),this.Oa(e,t.parts,!0,this.Nh,!0,!1,!0)):t instanceof ft?this.Oa(e,t.memberParts,!1,this.Nh,!0,!1,!0):e.addAll(t.iterator),e.count>0){let i=this.diagram;i!==null&&i.startTransaction("Layout"),this.doMinimalNoNetworkLayout(e),i!==null&&i.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){let e=t.count,i=Math.ceil(Math.sqrt(e));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);let s=this.arrangementOrigin.x,n=this.arrangementOrigin.y,o=s,r=n,a=0,h=0,l=t.iterator;for(;l.next();){let c=l.value;c.ensureBounds();let u=c.measuredBounds,d=u.width,f=u.height;c.moveTo(o,r),c instanceof ft&&(c.Nh=!1),o+=Math.max(d,50)+20,h=Math.max(h,Math.max(f,50)),a>=i-1?(a=0,o=s,r+=h+20,h=0):a++}}Nh(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof ft&&t.Nh)}Oa(t,e,i,s,n,o,r){let a=e.iterator;for(;a.next();){let h=a.value;if(!(i&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof it){if(h.isLinkLabel)continue;h instanceof ft&&h.layout===null?this.Oa(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof q?t.add(h):r&&h.Di()&&!(h instanceof it)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,e){let i=this.boundsComputation;return i!==null?(e||(e=new B),i(t,this,e)):!e&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(e||(e=new B),e.set(t.actualBounds),e.addMargin(t.margin),e)}get boundsComputation(){return this.fg}set boundsComputation(t){this.fg!==t&&(t!==null&&g.S(t,oe,"boundsComputation"),this.fg=t,this.p())}collectParts(t){let e=new I;return t instanceof j?(this.Oa(e,t.nodes,!0,null,!0,!0,!0),this.Oa(e,t.links,!0,null,!0,!0,!0),this.Oa(e,t.parts,!0,null,!0,!0,!0)):t instanceof ft?this.Oa(e,t.memberParts,!1,null,!0,!0,!0):this.Oa(e,t.iterator,!1,null,!0,!0,!0),e}get arrangementOrigin(){return this.cg}set arrangementOrigin(t){this.cg.equals(t)||(this.cg.h(t),this.p())}initialOrigin(t){let e=this.group;if(e!==null)if(e.hasPlaceholder()){let i=e.placeholder,s=i.getDocumentPoint(T.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);let n=i.padding;return s.x+=n.left,s.y+=n.top,s}else{let i=e.position.copy();return(isNaN(i.x)||isNaN(i.y))&&i.set(t),i}return t}}class Je{li;So;In;tw;ew;constructor(t){I.Je(this),this.li=t,this.So=new I,this.In=new I,this.tw=new wt,this.ew=new wt}clear(){if(this.So){let t=this.So.iterator;for(;t.next();)t.value.clear()}if(this.In){let t=this.In.iterator;for(;t.next();)t.value.clear()}this.So=new I,this.In=new I,this.tw=new wt,this.ew=new wt}toString(t){t===void 0&&(t=0);let e="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return e;if(e+=" vertexes: "+this.So.count+" edges: "+this.In.count,t>1){let i=this.So.iterator;for(;i.next();){let n=i.value;e+=`
16
+ `+n.toString(t-1)}let s=this.In.iterator;for(;s.next();){let n=s.value;e+=`
17
+ `+n.toString(t-1)}}return e}get layout(){return this.li}set layout(t){t!==null&&(this.li=t)}get vertexes(){return this.So}get edges(){return this.In}createVertex(){return new Ze(this)}createEdge(){return new xi(this)}addParts(t,e,i){if(t===null)return;e===void 0&&(e=!1),g.s(e,"boolean",Je,"addParts:toplevelonly"),i===void 0&&(i=null),i===null&&(i=n=>{if(n instanceof it)return!n.isLinkLabel;if(n instanceof q){let o=n.fromNode;if(o===null||o.isLinkLabel)return!1;let r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});let s=t.iterator;for(;s.next();){let n=s.value;if(n instanceof it&&!(e&&!n.isTopLevel)&&n.canLayout()&&i(n))if(n instanceof ft&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;let o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){let n=s.value;if(!(n instanceof q)||e&&!n.isTopLevel||!n.canLayout()||!i(n)||this.findEdge(n)!==null)continue;let o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;let a=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(a,h,n)}}findGroupVertex(t){let e=t.findVisibleNode();if(e===null)return null;let i=this.findVertex(e);if(i!==null)return i;let s=e.containingGroup;for(;s!==null;){if(i=this.findVertex(s),i!==null)return i;s=s.containingGroup}return null}addVertex(t){this.So.add(t);let e=t.node;e!==null&&this.tw.set(e,t),t.network=this}addNode(t){let e=this.findVertex(t);return e===null&&(e=this.createVertex(),e.node=t,this.addVertex(e)),e}deleteVertex(t){if(this.kv(t)){let e=t.nr;for(let i=e.count-1;i>=0;i--){let s=e.elt(i);this.deleteEdge(s)}e=t.or;for(let i=e.count-1;i>=0;i--){let s=e.elt(i);this.deleteEdge(s)}}}kv(t){let e=this.So.delete(t);if(e){let i=t.node;i!==null&&this.tw.delete(i)}return e}deleteNode(t){let e=this.findVertex(t);e!==null&&this.deleteVertex(e)}findVertex(t){return this.tw.get(t)}addEdge(t){this.UC(t);let e=t.toVertex;e!==null&&e.addSourceEdge(t);let i=t.fromVertex;i!==null&&i.addDestinationEdge(t)}UC(t){this.In.add(t);let e=t.link;e!==null&&this.findEdge(e)===null&&this.ew.set(e,t),t.network=this}addLink(t){let e=t.fromNode,i=t.toNode,s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,e!==null&&(s.fromVertex=this.addNode(e)),i!==null&&(s.toVertex=this.addNode(i)),this.addEdge(s)):(e!==null?s.fromVertex=this.addNode(e):s.fromVertex=null,i!==null?s.toVertex=this.addNode(i):s.toVertex=null),s}deleteEdge(t){let e=t.toVertex;e!==null&&e.deleteSourceEdge(t);let i=t.fromVertex;i!==null&&i.deleteDestinationEdge(t),this.VC(t)}VC(t){let e=this.In.delete(t);if(e){let i=t.link;i!==null&&this.ew.delete(i)}return e}deleteLink(t){let e=this.findEdge(t);e!==null&&this.deleteEdge(e)}findEdge(t){return this.ew.get(t)}linkVertexes(t,e,i){if(t===null||e===null)return null;if(t.network===this&&e.network===this){let s=this.createEdge();return s.link=i,s.fromVertex=t,s.toVertex=e,this.addEdge(s),s}return null}reverseEdge(t){let e=t.fromVertex,i=t.toVertex;e===null||i===null||(e.deleteDestinationEdge(t),i.deleteSourceEdge(t),t.reverseEdge(),e.addSourceEdge(t),i.addDestinationEdge(t))}deleteSelfEdges(){let t=g.ot(),e=this.In.iterator;for(;e.next();){let s=e.value;s.fromVertex===s.toVertex&&t.push(s)}let i=t.length;for(let s=0;s<i;s++)this.deleteEdge(t[s]);g.Z(t)}deleteArtificialVertexes(){let t=g.ot(),e=this.So.iterator;for(;e.next();){let o=e.value;o.node===null&&o.data===null&&t.push(o)}let i=t.length;for(let o=0;o<i;o++)this.deleteVertex(t[o]);let s=g.ot(),n=this.In.iterator;for(;n.next();){let o=n.value;o.link===null&&o.data===null&&s.push(o)}i=s.length;for(let o=0;o<i;o++)this.deleteEdge(s[o]);g.Z(t),g.Z(s)}deleteUselessEdges(){let t=g.ot(),e=this.In.iterator;for(;e.next();){let s=e.value;(s.fromVertex===null||s.toVertex===null)&&t.push(s)}let i=t.length;for(let s=0;s<i;s++)this.deleteEdge(t[s]);g.Z(t)}isSingleton(t){return!(t.nr.count>0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());let e=new U,i=!0;for(;i;){i=!1;let s=this.So.iterator;for(;s.next();){let n=s.value;if(this.isSingleton(n))continue;let o=this.layout.createNetwork();e.add(o),this.QE(o,n),i=!0;break}}return e.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),e}QE(t,e){if(e===null)return;let i=new U;for(i.add(e);i.count>0;){let s=i.first();if(i.removeAt(0),!s||s.network===t)continue;this.kv(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){let o=n.value;o.network!==t&&(this.VC(o),t.UC(o),o.fromVertex&&i.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){let o=n.value;o.network!==t&&(this.VC(o),t.UC(o),o.toVertex&&i.add(o.toVertex))}}}findAllParts(){let t=new I,e=this.So.iterator;for(;e.next();){let s=e.value;s.node&&t.add(s.node)}let i=this.In.iterator;for(;i.next();){let s=i.value;s.link&&t.add(s.link)}return t}}class Ze{Po;te;Ri;Ui;is;nr;or;constructor(t){I.Je(this),this.Po=t,this.Ui=new B(0,0,10,10),this.is=new P(5,5),this.te=null,this.Ri=null,this.nr=new U,this.or=new U}clear(){this.te=null,this.Ri=null,this.nr=new U,this.or=new U}toString(t){t===void 0&&(t=0);let e="LayoutVertex#"+I.xs(this);if(t>0&&(e+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let i="",s=!0,n=this.nr.iterator;for(;n.next();){let r=n.value;s?s=!1:i+=",",i+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){let r=n.value;s?s=!1:o+=",",o+=r.toString(0)}e+=" sources: "+i+" destinations: "+o}return e}get Mo(){return this.nr.AL}get rr(){return this.or.AL}get data(){return this.te}set data(t){if(this.te=t,t!==null&&t.bounds){let e=t.bounds,i=e.x,s=e.y,n=e.width,o=e.height;this.is.e(n/2,o/2),this.Ui.e(i,s,n,o)}}get node(){return this.Ri}set node(t){if(this.Ri!==t){if(this.Ri=t,t===null)return;t.ensureBounds();let e=this.network.layout,i=B.l(),s=e.getLayoutBounds(t,i),n=s.x,o=s.y,r=s.width,a=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ui.e(n,o,r,a),B.i(i),!(t instanceof ft)){let h=t.locationObject.getDocumentPoint(T.Center);if(h.isReal()){this.is.e(h.x-n,h.y-o);return}}this.is.e(r/2,a/2)}}get bounds(){return this.Ui}set bounds(t){this.Ui.equals(t)||this.Ui.h(t)}get focus(){return this.is}set focus(t){this.is.equals(t)||this.is.h(t)}get centerX(){return this.Ui.x+this.is.x}set centerX(t){let e=this.Ui;e.x+this.is.x!==t&&(e.x=t-this.is.x)}get centerY(){return this.Ui.y+this.is.y}set centerY(t){let e=this.Ui;e.y+this.is.y!==t&&(e.y=t-this.is.y)}get focusX(){return this.is.x}set focusX(t){let e=this.is;e.x!==t&&(e.x=t)}get focusY(){return this.is.y}set focusY(t){let e=this.is;e.y!==t&&(e.y=t)}get x(){return this.Ui.x}set x(t){let e=this.Ui;e.x!==t&&(e.x=t)}get y(){return this.Ui.y}set y(t){let e=this.Ui;e.y!==t&&(e.y=t)}get width(){return this.Ui.width}set width(t){let e=this.Ui;e.width!==t&&(e.width=t)}get height(){return this.Ui.height}set height(t){let e=this.Ui;e.height!==t&&(e.height=t)}commit(){let t=this.te;if(t!==null){let i=this.bounds,s=t.bounds;g.$(s)?(s.x=i.x,s.y=i.y,s.width=i.width,s.height=i.height):t.bounds=i.copy();return}let e=this.node;if(e!==null){let i=this.bounds;if(!(e instanceof ft)){let s=B.l();e.ensureBounds();let n=this.network.layout.getLayoutBounds(e,s),o=e.locationObject.getDocumentPoint(T.Center);if(n.isReal()&&o.isReal()){e.moveTo(i.x+this.focusX-(o.x-n.x)+e.margin.left,i.y+this.focusY-(o.y-n.y+e.margin.top)),B.i(s);return}B.i(s)}e.moveTo(i.x+e.margin.left,i.y+e.margin.top)}}addSourceEdge(t){t!==null&&(this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&this.nr.delete(t)}addDestinationEdge(t){t!==null&&(this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&this.or.delete(t)}get network(){return this.Po}set network(t){this.Po=t}get sourceVertexes(){let t=new I,e=this.sourceEdges;for(;e.next();){let i=e.value;i.fromVertex&&t.add(i.fromVertex)}return t.iterator}get destinationVertexes(){let t=new I,e=this.destinationEdges;for(;e.next();){let i=e.value;i.toVertex&&t.add(i.toVertex)}return t.iterator}get vertexes(){let t=new I,e=this.sourceEdges;for(;e.next();){let i=e.value;i.fromVertex&&t.add(i.fromVertex)}for(e=this.destinationEdges;e.next();){let i=e.value;i.toVertex&&t.add(i.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){let t=new U,e=this.sourceEdges;for(;e.next();){let i=e.value;t.add(i)}for(e=this.destinationEdges;e.next();){let i=e.value;t.add(i)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,e){let i=t.Ri,s=e.Ri;if(i)if(s){let n=i.text,o=s.text;return n<o?-1:n>o?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,e){if(t!==null)if(e!==null){let i=t.Ri,s=e.Ri;if(i!==null)if(s!==null){let n=i.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),a=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),h=0;for(;h<r.length;h++)if(a[h]!==""&&a[h]!==void 0){let l=parseFloat(r[h]),c=parseFloat(a[h]);if(isNaN(l))if(isNaN(c)){if(r[h].localeCompare(a[h])!==0)return r[h].localeCompare(a[h]);continue}else return 1;else{if(isNaN(c))return-1;if(l-c!==0)return l-c;continue}}else{if(r[h]==="")continue;return 1}return a[h]!==""&&a[h]!==void 0?-1:0}else return 1;else return s!==null?-1:0}else return 1;else return e!==null?-1:0}}class xi{Po;te;es;ss;ns;constructor(t){I.Je(this),this.Po=t,this.te=null,this.es=null,this.ss=null,this.ns=null}clear(){this.te=null,this.es=null,this.ss=null,this.ns=null}toString(t){t===void 0&&(t=0);let e="LayoutEdge#"+I.xs(this);return t>0&&(e+=this.es!==null?"("+this.es.toString()+")":"",t>1&&(e+=" "+(this.ss?this.ss.toString():"null")+" --> "+(this.ns?this.ns.toString():"null"))),e}reverseEdge(){let t=this.ss;this.ss=this.ns,this.ns=t}commit(){}getOtherVertex(t){return this.ns===t?this.ss:this.ss===t?this.ns:null}get network(){return this.Po}set network(t){this.Po=t}get data(){return this.te}set data(t){this.te!==t&&(this.te=t)}get link(){return this.es}set link(t){this.es!==t&&(this.es=t)}get fromVertex(){return this.ss}set fromVertex(t){this.ss!==t&&(this.ss=t)}get toVertex(){return this.ns}set toVertex(t){this.ns!==t&&(this.ns=t)}}var Rs=(x=>(x[x.Position=0]="Position",x[x.Location=1]="Location",x))(Rs||{}),Es=(x=>(x[x.LeftToRight=10]="LeftToRight",x[x.RightToLeft=11]="RightToLeft",x))(Es||{}),Is=(x=>(x[x.Forwards=20]="Forwards",x[x.Reverse=21]="Reverse",x[x.Ascending=22]="Ascending",x[x.Descending=23]="Descending",x))(Is||{});class ri extends oe{dg;gg;Oo;En;de;He;Si;Mi;constructor(t){super(),this.isViewportSized=!0,this.dg=NaN,this.gg=NaN,this.Oo=new _(NaN,NaN).b(),this.En=new _(10,10).b(),this.de=1,this.He=10,this.Si=22,this.Mi=ri.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.dg=this.dg,t.gg=this.gg,t.Oo.h(this.Oo),t.En.h(this.En),t.de=this.de,t.He=this.He,t.Si=this.Si,t.Mi=this.Mi}fe(t){t in Is?this.sorting=t:t in Es?this.arrangement=t:t in Rs?this.alignment=t:super.fe(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);let e=this.collectParts(t),i=this.diagram,s=e.copy().iterator;for(;s.next();){let f=s.value;if(f.Ar()&&(f.fromNode!==null||f.toNode!==null)){e.delete(f);continue}if(f.ensureBounds(),f instanceof ft){let p=f.memberParts;for(;p.next();){let m=p.value;e.delete(m)}}}let n=e.toArray();if(n.length===0)return;switch(this.sorting){case 20:break;case 21:n.reverse();break;case 22:n.sort(this.comparer);break;case 23:n.sort(this.comparer),n.reverse();break}let o=this.wrappingColumn;isNaN(o)&&(o=0);let r=this.wrappingWidth;if(isNaN(r)&&i!==null){let f=i.viewportBounds,p=i.padding;r=Math.max(f.width-p.left-p.right,0)}else r=Math.max(this.wrappingWidth,0);o<=0&&r<=0&&(o=1);let a=this.spacing.width;isFinite(a)||(a=0);let h=this.spacing.height;isFinite(h)||(h=0),i!==null&&i.startTransaction("Layout");let l=[];switch(this.alignment){case 0:this._E(n,r,o,a,h,l);break;case 1:this.t3(n,r,o,a,h,l);break}let c=0,u=0,d=0;for(let f=0;f<l.length;f++){let p=l[f];c=Math.min(c,p.x),u=Math.min(u,p.y),d=Math.max(d,p.x+p.width)}this.arrangement===11?this.commitLayers(l,new P(c+a/2-(d+c),u-h/2)):this.commitLayers(l,new P(c-a/2,u-h/2)),i!==null&&i.commitTransaction("Layout"),this.isValidLayout=!0}_E(t,e,i,s,n,o){let r=B.l(),a=Math.max(this.cellSize.width,1);if(!isFinite(a)){a=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r);a=Math.max(a,v.width)}}a+=s,a=Math.max(a,1);let h=Math.max(this.cellSize.height,1);if(!isFinite(h)){h=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r);h=Math.max(h,v.height)}}h+=n,h=Math.max(h,1);let l=this.arrangement,c=this.arrangementOrigin.x,u=this.arrangementOrigin.y,d=c,f=u,p=0,m=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r),w=Math.ceil((v.width+s)/a),k=Math.ceil((v.height+n)/h),S=w*a,M=k*h,F=0;switch(l){case 11:F=Math.abs(d-v.width);break;default:F=d+v.width;break}(i>0&&p>i-1||e>0&&p>0&&F-c>e)&&(o.push(new B(0,f,e+s,m)),p=0,d=c,f+=m,m=0),m=Math.max(m,M);let D=0;switch(l){case 11:D=-v.width;break;default:D=0;break}switch(b.moveTo(d+D+b.margin.left,f+b.margin.top),l){case 11:d-=S;break;default:d+=S;break}p++}o.push(new B(0,f,e+s,m)),B.i(r)}t3(t,e,i,s,n,o){let r=B.l(),a=Math.max(this.cellSize.width,1),h=0,l=0,c=0,u=P.l();for(let D=0;D<t.length;D++){let N=t[D],L=this.getLayoutBounds(N,r),R=N.getRelativePoint(N.locationObject,N.locationSpot,u);h=Math.max(h,R.x),l=Math.max(l,L.width-R.x),c=Math.max(c,R.y)}let d=this.arrangement;switch(d){case 11:h+=s;break;default:l+=s;break}isFinite(a)?a=Math.max(a+s,1):a=Math.max(h+l,1);let f=this.arrangementOrigin.x,p=this.arrangementOrigin.y,m=f,y=p,b=0;e>=h&&(e-=h);let v=0,w=0,k=Math.max(this.cellSize.height,1);c=0;let S=0,M=!0,F=P.l();for(let D=0;D<t.length;D++){let N=t[D],L=this.getLayoutBounds(N,r),R=N.getRelativePoint(N.locationObject,N.locationSpot,u);if(b>0)switch(d){case 11:{let V=(m-f-(L.width-R.x))/a;A.X(Math.round(V),V)?V=Math.round(V):V=Math.floor(V),m=V*a+f;break}default:{let V=(m-f+R.x)/a;A.X(Math.round(V),V)?V=Math.round(V):V=Math.ceil(V),m=V*a+f;break}}else switch(d){case 11:v=m+R.x+L.width;break;default:v=m-R.x;break}let O=0;switch(d){case 11:O=-(m+R.x)+v;break;default:O=m+L.width-R.x-v;break}if(i>0&&b>i-1||e>0&&b>0&&O>e){o.push(new B(0,M?y-c:y,e+s,S+c+n));for(let V=0;V<b&&D!==b;V++){let K=t[D-b+V],Y=K.getRelativePoint(K.locationObject,K.locationSpot,F);K.moveTo(K.position.x,K.position.y+c-Y.y)}S+=n,M?y+=S:y+=S+c,c=0,S=0,b=0,m=f,M=!1}switch(m===f&&(d===11?w=Math.max(w,L.width-R.x):w=Math.min(w,-R.x)),c=Math.max(c,R.y),S=Math.max(S,L.height-R.y),isFinite(k)&&(S=Math.max(S,Math.max(L.height,k)-R.y)),M?N.moveTo(m-R.x,y-R.y):N.moveTo(m-R.x,y),d){case 11:m-=R.x+s;break;default:m+=L.width-R.x+s;break}b++}if(o.push(new B(0,y,e+s,(M?S:S+c)+n)),t.length!==b)for(let D=0;D<b;D++){let N=t[t.length-b+D],L=N.getRelativePoint(N.locationObject,N.locationSpot,u);N.moveTo(N.position.x,N.position.y+c-L.y)}if(P.i(u),P.i(F),d===11)for(let D=0;D<o.length;D++){let N=o[D];N.width+=w,N.x-=w}else for(let D=0;D<o.length;D++){let N=o[D];N.x>w&&(N.width+=N.x-w,N.x=w)}B.i(r)}commitLayers(t,e){}get wrappingWidth(){return this.dg}set wrappingWidth(t){this.dg!==t&&(g.s(t,"number",ri,"wrappingWidth"),(t>0||isNaN(t))&&(this.dg=t,this.isViewportSized=isNaN(t),this.p()))}get wrappingColumn(){return this.gg}set wrappingColumn(t){this.gg!==t&&(g.s(t,"number",ri,"wrappingColumn"),(t>0||isNaN(t))&&(this.gg=t,this.p()))}get cellSize(){return this.Oo}set cellSize(t){this.Oo.equals(t)||(this.Oo.h(t),this.p())}get spacing(){return this.En}set spacing(t){this.En.equals(t)||(this.En.h(t),this.p())}get alignment(){return this.de}set alignment(t){this.de!==t&&(t===1||t===0)&&(this.de=t,this.p())}get arrangement(){return this.He}set arrangement(t){this.He!==t&&(t===10||t===11)&&(this.He=t,this.p())}get sorting(){return this.Si}set sorting(t){this.Si!==t&&(t===20||t===21||t===22||t===23)&&(this.Si=t,this.p())}get comparer(){return this.Mi}set comparer(t){this.Mi!==t&&(g.S(t,ri,"comparer"),this.Mi=t,this.p())}static standardComparer(t,e){let i=t.text,s=e.text;return i<s?-1:i>s?1:0}static smartComparer(t,e){if(t!==null)if(e!==null){let i=t.text.toLocaleLowerCase(),s=e.text.toLocaleLowerCase(),n=i.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),r=0;for(;r<n.length;r++)if(o[r]!==""&&o[r]!==void 0){let a=parseFloat(n[r]),h=parseFloat(o[r]);if(isNaN(a))if(isNaN(h)){if(n[r].localeCompare(o[r])!==0)return n[r].localeCompare(o[r]);continue}else return 1;else{if(isNaN(h))return-1;if(a-h!==0)return a-h;continue}}else{if(n[r]==="")continue;return 1}return o[r]!==""&&o[r]!==void 0?-1:0}else return 1;else return e!==null?-1:0}static Position=0;static Location=1;static LeftToRight=10;static RightToLeft=11;static Forward=20;static Reverse=21;static Ascending=22;static Descending=23}class Ne{mg;rn;Ct;No;pg;yg;a;BC;constructor(){this.mg=new I,this.rn=new I,this.Ct=new I,this.No=new wt,this.pg=new wt,this.yg=new wt,this.a=null,this.BC=!1}clear(){this.mg.clear(),this.rn.clear(),this.Ct.clear(),this.No.clear(),this.pg.clear(),this.yg.clear()}Eo(t){this.a=t}ah(t){if(t instanceof it){if(this.mg.add(t),t instanceof ft){let i=t.containingGroup;i===null?this.diagram.Zr.add(t):i.Mh.add(t);let s=t.layout;s!==null&&(s.diagram=this.diagram)}}else t instanceof q?(this.rn.add(t),t.isAvoiding&&(this.diagram.rp=!0)):t instanceof Mt||this.Ct.add(t);let e=t.data;e!==null&&(t instanceof Mt||(t instanceof q?this.Pv(e,t):this.No.set(e,t)))}ri(t){if(t.clearAdornments(),t instanceof it){if(this.mg.delete(t),t instanceof ft){let i=t.containingGroup;i===null?this.diagram.Zr.delete(t):i.Mh.delete(t);let s=t.layout;s!==null&&(s.diagram=null)}}else t instanceof q?this.rn.delete(t):t instanceof Mt||this.Ct.delete(t);let e=t.data;e!==null&&(t instanceof Mt||(t instanceof q?this.Sv(e,t):this.No.delete(e)))}Pv(t,e){this.pg.set(t,e)}Sv(t,e){this.pg.delete(t)}rebuildParts(){let t=this.diagram;if(t===null)return;let e=t.nodeTemplateMap.iterator;for(;e.next();){let d=e.value,f=e.key;(!d.Di()||d instanceof ft)&&g.o(`Invalid node template in Diagram.nodeTemplateMap: template for "${f}" must be a Node or a simple Part, not a Group or Link: ${d}`)}let i=t.groupTemplateMap.iterator;for(;i.next();){let d=i.value,f=i.key;d instanceof ft||g.o(`Invalid group template in Diagram.groupTemplateMap: template for "${f}" must be a Group, not a normal Node or Link: ${d}`)}let s=t.linkTemplateMap.iterator;for(;s.next();){let d=s.value,f=s.key;d instanceof q||g.o(`Invalid link template in Diagram.linkTemplateMap: template for "${f}" must be a Link, not a normal Node or simple Part: ${d}`)}let n=g.ot(),o=t.selection.iterator;for(;o.next();){let d=o.value.data;d&&n.push(d)}let r=g.ot(),a=t.highlighteds.iterator;for(;a.next();){let d=a.value.data;d&&r.push(d)}let h=g.ot(),l=this.nodes.iterator;for(;l.next();){let d=l.value;d.data!==null&&(h.push(d.data),h.push(d.location))}let c=this.links.iterator;for(;c.next();){let d=c.value;d.data!==null&&(h.push(d.data),h.push(d.location))}let u=this.parts.iterator;for(;u.next();){let d=u.value;d.data!==null&&(h.push(d.data),h.push(d.location))}this.Mv(),this.T2();for(let d=0;d<n.length;d++){let f=this.findPartForData(n[d]);f!==null&&(f.isSelected=!0)}for(let d=0;d<r.length;d++){let f=this.findPartForData(r[d]);f!==null&&(f.isHighlighted=!0)}for(let d=0;d<h.length;d+=2){let f=this.findPartForData(h[d]);f!==null&&(f.location=h[d+1])}g.Z(n),g.Z(r),g.Z(h)}T2(){let t=this.diagram.model;this.iw(t.nodeDataArray)}iw(t,e){let i=this.diagram.model;t.forEach(s=>{i.containsNodeData(s)&&this.Nv(s,!1)}),t.forEach(s=>{i.containsNodeData(s)&&this.Mk(s)}),e!==!1&&this.diagram.h1(!1)}Nv(t,e){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.No.has(t))return null;e===void 0&&(e=!0);let i=this.e3(t);return i!==null&&e&&this.Mk(t),i}e3(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.No.has(t))return null;let e=this.i3(t),i=this.findTemplateForNodeData(t,e);if(i!==null){i.It();let s=i.copy();if(s!==null){let n=this.diagram.yi;return this.diagram.yi=!0,s._o=e,s.te=t,this.addsToTemporaryLayer&&(s.dl="Tool"),this.diagram.add(s),s.te=null,s.data=t,this.diagram.yi=n,s}}return null}insertLink(t,e,i,s){return null}Mk(t){}i3(t){return this.diagram.model.getCategoryForNodeData(t)}static Cv=!1;static Lv=!1;findTemplateForNodeData(t,e){let i=this.diagram,s=i.model,n=s.ff()&&s.isGroupForData(t),o=null;return n?(o=i.groupTemplateMap.get(e),o===null&&(o=i.groupTemplateMap.get(""),o===null&&(Ne.Lv||(Ne.Lv=!0,g.ne('No Group template found for category "'+e+'"'),g.ne(" Using default group template")),o=i.i2))):(o=i.nodeTemplateMap.get(e),o===null&&(o=i.nodeTemplateMap.get(""),o===null&&(Ne.Cv||(Ne.Cv=!0,g.ne('No Node template found for category "'+e+'"'),g.ne(" Using default node template")),o=i._M))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,e){}setFromNodeForLink(t,e,i){}setToNodeForLink(t,e,i){}static Av=!1;findLinkTemplateForCategory(t){let e=this.diagram,i=e.linkTemplateMap.get(t);return i===null&&(i=e.linkTemplateMap.get(""),i===null&&(Ne.Av||(Ne.Av=!0,g.ne('No Link template found for category "'+t+'"'),g.ne(" Using default link template")),i=e.t2)),i}qI(t,e,i){t instanceof q?(e!==null&&this.Sv(e,t),i!==null&&this.Pv(i,t)):t instanceof bt&&(e!==null&&this.No.delete(e),i!==null&&this.No.set(i,t))}Mv(){let t=this.diagram.model;this.zC(t.nodeDataArray)}zC(t){t.forEach(e=>{this.Nk(e)})}Nk(t){let e=this.findPartForData(t);e!==null&&(this.diagram.C2(e,!1),this.XC(e))}XC(t){}AC(t){}findPartForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.No.get(e):null}findNodeForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);if(e===null)return null;let i=this.No.get(e);return i instanceof it?i:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let e=this.No.get(t);return e!==null||(e=this.pg.get(t)),e}findNodeForData(t){if(t===null)return null;let e=this.No.get(t);return e instanceof it?e:null}findLinkForData(t,e){return t===null?null:this.pg.get(t)}findNodesByExample(...t){let e=new I,i=this.mg.iterator;for(;i.next();){let s=i.value,n=s.data;if(n!==null)for(let o=0;o<arguments.length;o++){let r=arguments[o];if(g.$(r)&&this.GC(n,r)){e.add(s);break}}}return e.iterator}findLinksByExample(...t){let e=new I,i=this.rn.iterator;for(;i.next();){let s=i.value,n=s.data;if(n!==null)for(let o=0;o<arguments.length;o++){let r=arguments[o];if(g.$(r)&&this.GC(n,r)){e.add(s);break}}}return e.iterator}GC(t,e){for(let i in e){let s=t[i],n=e[i];if(Array.isArray(n)){if(!Array.isArray(s))return!1;let o=s,r=n;if(o.length<r.length)return!1;for(let a=0;a<o.length;a++){let h=o[a],l=r[a];if(l!==void 0&&!this.Tv(h,l))return!1}}else if(!this.Tv(s,n))return!1}return!0}Tv(t,e){if(g.nt(e)){if(!e(t))return!1}else if(e instanceof RegExp){if(!t||!e.test(t.toString()))return!1}else if(g.$(t)&&g.$(e)){if(!this.GC(t,e))return!1}else if(t!==e)return!1;return!0}doModelDataChanged(t){if(t.model===this.diagram.model&&this.diagram.G){this.diagram.G=!1;try{let e=t.change;t.modelChange===""&&t.object!==null&&e===2&&this.nw(t.object,t.propertyName)}finally{this.diagram.G=!0}}}doModelChanged(t){let e=this.diagram;if(!e||t.model!==e.model)return;let i=t.change;if(e.LO(t),!!e.G){e.G=!1;try{let s=t.modelChange;if(s!=="")if(i===2){if(s==="nodeCategory"){let n=t.object;if(n!==null){let o=this.findPartForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}}else if(s==="nodeDataArray"){let n=t.oldValue;this.zC(n);let o=t.newValue;this.iw(o)}e.isModified=!0}else if(i===3){let n=t.newValue;s==="nodeDataArray"&&g.$(n)&&this.Nv(n),e.isModified=!0}else if(i===4){let n=t.oldValue;s==="nodeDataArray"&&g.$(n)&&this.Nk(n),e.isModified=!0}else i===1&&(s==="SourceChanged"?t.object!==null?this.nw(t.object,t.propertyName):(this.updateAllRelationshipsFromData(),this.updateAllTargetBindings()):s==="ModelDisplaced"&&this.rebuildParts());else if(i===2){let n=t.propertyName,o=t.object,r=e.model;o===r?(n==="nodeKeyProperty"||n==="nodeCategoryProperty")&&(e.undoManager.isUndoingRedoing||this.rebuildParts()):o!==null&&this.nw(o,n),e.isModified=!0}else(i===3||i===4)&&(this.s3(t,e.model),e.isModified=!0)}finally{e.G=!0}}}updateAllTargetBindings(t){t===void 0&&(t="");let e=this.parts.iterator;for(;e.next();)e.value.updateTargetBindings(t);for(e=this.nodes.iterator;e.next();)e.value.updateTargetBindings(t);for(e=this.links.iterator;e.next();)e.value.updateTargetBindings(t)}updateAllThemeBindings(){let t=this.parts.iterator;for(;t.next();)t.value.Yo();for(t=this.nodes.iterator;t.next();)t.value.Yo();for(t=this.links.iterator;t.next();)t.value.Yo()}updateAllRelationshipsFromData(){let t=this.diagram.model,e=new I,i=t.nodeDataArray;for(let o=0;o<i.length;o++){let r=i[o];e.add(r)}let s=[];this.nodes.each(o=>{o.data!==null&&!e.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!e.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.Dv(o,!1));for(let o=0;o<i.length;o++){let r=i[o];this.findPartForData(r)===null&&t.vv(r,!1)}this.Fv();let n=this.parts.iterator;for(;n.next();)n.value.updateRelationshipsFromData();for(n=this.nodes.iterator;n.next();)n.value.updateRelationshipsFromData();for(n=this.links.iterator;n.next();)n.value.updateRelationshipsFromData()}Fv(){}updateRelationshipsFromData(t){}nw(t,e){if(typeof e=="string"){let i=this.findPartForData(t);if(i!==null)i.updateTargetBindings(e);else{let s=this.o3(t);if(s!==null&&s.length>0){for(let o=0;o<s.length;o++)s[o].updateTargetBindings(e);let n=s[0].part;if(n!==null){let o=n.adornments;for(;o.next();)o.value.updateTargetBindings(e)}g.Z(s)}}t===this.diagram.model.modelData&&this.updateAllTargetBindings(e)}}o3(t){let e=null,i=this.yg.iterator;for(;i.next();){let s=i.value;for(let n=0;n<s.length;n++){let o=s[n].findItemPanelForData(t);o!==null&&(e===null&&(e=g.ot()),e.push(o))}if(e!==null)break}return e}YC(t){return this.yg.get(t)}s3(t,e){let i=t.object;if(!Array.isArray(i))return;let s=t.change===3,n=s?t.newParam:t.oldParam,o=s?t.newValue:t.oldValue,r=this.YC(i);if(Array.isArray(r))for(let a=0;a<r.length;a++){let h=r[a];s?h.Z1(o,n,!0):h.$I(n)}}M2(t,e){e!==null&&t.Sn(s=>e.uT(s));let i=t.Aa;if(Array.isArray(i)){let s=this.YC(i);if(s===null)this.yg.set(i,[t]);else{for(let n=0;n<s.length;n++)if(s[n]===t)return;s.push(t)}}}N2(t,e){t.Sn(s=>e.TO(s));let i=t.Aa;if(Array.isArray(i)){let s=this.YC(i);if(s!==null){for(let n=0;n<s.length;n++)if(s[n]===t){s.splice(n,1),s.length===0&&this.yg.delete(i);return}}}}copyParts(t,e,i){i===void 0&&(i=!1);let s=new wt;if(Array.isArray(t))for(let o=0;o<t.length;o++)this.Ck(t[o],e,s,i);else{let o=t.iterator;for(;o.next();)this.Ck(o.value,e,s,i)}if(e!==null){let o=e.model,r=e.Ap().dragsLink,a=new I,h=new wt,l=s.iterator;for(;l.next();){let c=l.value;if(c instanceof q)!r&&(c.fromNode===null||c.toNode===null)&&a.add(c);else if(c instanceof it&&c.data!==null){if(o.Um()){let u=c,d=l.key,f=d.findTreeParentNode();if(f!==null){let p=s.get(f);if(p!==null){o.setParentKeyForNodeData(u.data,o.getKeyForNodeData(p.data));let m=e.findLinkForData(u.data),y=d.findTreeParentLink();y!==null&&m!==null&&h.set(y,m)}}}else if(o.l1()){let u=c,d=l.key,f=o.isRelatedKeysPathTo?d.findNodesOutOf():d.findNodesInto();for(;f.next();){let p=f.value,m=s.get(p);if(m!==null){o.addRelatedKeyForNodeData(u.data,m.key);let y=e.partManager.findLinkForData(u.data,m.key),b=this.findLinkForData(d.data,p.key);b!==null&&y!==null&&h.set(b,y)}else o.removeRelatedKeyForNodeData(u.data,p.key)}}}}if(a.count>0&&e.removeParts(a,!1),h.count>0){let c=h.iterator;for(;c.next();){let u=c.key,d=c.value;s.set(u,d)}}}if(e!==null&&this.diagram!==null){let o=e.model,r=o.afterCopyFunction;if(r!==null){let a=new wt;s.each(l=>{l.key.data!==null&&a.set(l.key.data,l.value.data)});let h=this.diagram.model;r(a,o,h)}}let n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ck(t,e,i,s){if(t===null||s&&!t.canCopy())return null;if(i.has(t))return i.get(t);let n=this.KC(t,e);if(!(n instanceof bt))return null;if(n.isSelected=!1,n.isHighlighted=!1,i.set(t,n),t instanceof it){let o=t.linksConnected;for(;o.next();){let r=o.value;if(r.fromNode===t){let a=i.get(r);a!==null&&(a.fromNode=n)}if(r.toNode===t){let a=i.get(r);a!==null&&(a.toNode=n)}}if(t instanceof ft&&n instanceof ft){let r=t.memberParts;for(;r.next();){let a=r.value,h=this.Ck(a,e,i,s);h instanceof q||h!==null&&(h.containingGroup=n)}}}else if(t instanceof q&&n instanceof q){let o=t.fromNode;if(o!==null){let h=i.get(o);h!==null&&(n.fromNode=h)}let r=t.toNode;if(r!==null){let h=i.get(r);h!==null&&(n.toNode=h)}let a=t.labelNodes;for(;a.next();){let h=a.value,l=this.Ck(h,e,i,s);l!==null&&l instanceof it&&(l.labeledLink=n)}}return n}KC(t,e){let i=null,s=t.data;if(s!==null&&e!==null){let n=e.model;if(!(t instanceof q)){let o=n.copyNodeData(s);n.addNodeData(o),i=e.findPartForData(o)}}else if(t.It(),i=t.copy(),i!==null){let n=this.diagram;if(e!==null)e.add(i);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){let o=n.model,r=null;i instanceof q||(r=o.copyNodeData(s)),i.data=r}}return i}get nodes(){return this.mg}get links(){return this.rn}get parts(){return this.Ct}get diagram(){return this.a}get addsToTemporaryLayer(){return this.BC}set addsToTemporaryLayer(t){this.BC=t}}class xr extends Ne{T2(){let t=this.diagram.model;this.iw(t.nodeDataArray),this.Rv(t.linkDataArray)}iw(t){super.iw(t,!1);let e=this.links.iterator;for(;e.next();)e.value.qd();this.diagram.h1(!1)}Rv(t){t.forEach(e=>{this.Ov(e)}),this.diagram.h1(!1)}Ov(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.findLinkForData(t))return null;let e=this.getLinkCategoryForData(t),i=this.findLinkTemplateForCategory(e);if(i!==null){i.It();let s=i.copy();if(s!==null){let n=this.diagram.yi;this.diagram.yi=!0,s._o=e,s.te=t;let o=this.diagram.model,r=o.Lk(t,!0);r!==""&&(s.fromPortId=r);let a=o.Vi(t,!0);if(a!==void 0){let u=this.findNodeForKey(a);u instanceof it&&(s.fromNode=u)}let h=o.Lk(t,!1);h!==""&&(s.toPortId=h);let l=o.Vi(t,!1);if(l!==void 0){let u=this.findNodeForKey(l);u instanceof it&&(s.toNode=u)}let c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(u=>{let d=this.findNodeForKey(u);d!==null&&(d.labeledLink=s)}),this.addsToTemporaryLayer&&(s.dl="Tool"),this.diagram.add(s),s.te=null,s.data=t,this.diagram.yi=n,s}}return null}Mv(){let t=this.diagram.model;this.Iv(t.linkDataArray),this.zC(t.nodeDataArray)}Iv(t){t.forEach(e=>{this.Nk(e)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,e){return this.diagram.model.setCategoryForLinkData(t,e)}setFromNodeForLink(t,e,i){let s=this.diagram.model,n=e!==null?e.data:null;s.setFromKeyForLinkData(t.data,s.getKeyForNodeData(n))}setToNodeForLink(t,e,i){let s=this.diagram.model,n=e!==null?e.data:null;s.setToKeyForLinkData(t.data,s.getKeyForNodeData(n))}AC(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){let e=super.findPartForKey(t);if(e===null){let i=this.diagram.model.findLinkDataForKey(t);if(i!==null)return this.findLinkForData(i)}return e}findLinkForKey(t){if(t==null)return null;let e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.findLinkForData(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;let e=this.diagram;if(t.model!==e.model)return;let i=t.change;if(e.G){e.G=!1;try{let s=t.modelChange;if(s!==""){if(i===2){if(s==="linkFromKey"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue,a=this.findNodeForKey(r);o.fromNode=a}}else if(s==="linkToKey"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue,a=this.findNodeForKey(r);o.toNode=a}}else if(s==="linkFromPortId"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){let n=t.object,o=this.findPartForData(n);if(o!==null){let r=t.newValue;if(r!==void 0){let a=this.findNodeForKey(r);a instanceof ft?o.containingGroup=a:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.oldValue,a=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(a.indexOf(h)>=0)return;let l=this.findNodeForKey(h);l!==null&&(l.labeledLink=null)}),Array.isArray(a)&&a.forEach(h=>{let l=this.findNodeForKey(h);l!==null&&(l.labeledLink=o)})}}else if(s==="linkCategory"){let n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){let n=t.oldValue;this.Iv(n);let o=t.newValue;this.Rv(o)}e.isModified=!0}else if(i===3){let n=t.newValue;if(s==="linkDataArray"&&g.$(n))this.Ov(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){let o=t.object,r=this.findLinkForData(o),a=this.findNodeForKey(n);r!==null&&a!==null&&(a.labeledLink=r)}e.isModified=!0}else if(i===4){let n=t.oldValue;if(s==="linkDataArray"&&g.$(n))this.Nk(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){let o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}e.isModified=!0}}else if(i===2){let n=t.propertyName,o=t.object,r=e.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(e.undoManager.isUndoingRedoing||this.rebuildParts()),e.isModified=!0}}finally{e.G=!0}}}Fv(){let t=this.diagram.model,e=new Set,i=t.linkDataArray;i.forEach(n=>{e.add(n)});let s=[];this.links.each(n=>{n.data!==null&&!e.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.Ev(n,!1)}),i.forEach(n=>{this.findLinkForData(n)===null&&t.Uv(n,!1)})}updateRelationshipsFromData(t){let e=t.data;if(e===null)return;let i=t.diagram;if(i===null)return;let s=i.model;if(t instanceof q){let n=s.Vi(e,!0),o=i.findNodeForKey(n);t.fromNode=o,n=s.Vi(e,!1),o=i.findNodeForKey(n),t.toNode=o;let r=s.getLabelKeysForLinkData(e);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){let u=r[0],d=t.labelNodes.first();if(d!==null&&s.getKeyForNodeData(d.data)===u)return}let a=new I().addAll(r),h=new I;t.labelNodes.each(u=>{if(u.data!==null){let d=s.getKeyForNodeData(u.data);d!==void 0&&h.add(d)}});let l=h.copy();l.removeAll(a);let c=a.copy();if(c.removeAll(h),l.count>0||c.count>0){let u=t;l.each(d=>{let f=i.findNodeForKey(d);f!==null&&f.labeledLink===u&&(f.labeledLink=null)}),c.each(d=>{let f=i.findNodeForKey(d);f!==null&&f.labeledLink!==u&&(f.labeledLink=u)})}}}else if(!(t instanceof Mt)){let n=s.getGroupKeyForNodeData(e),o=i.findPartForKey(n);(o===null||o instanceof ft)&&(t.containingGroup=o)}}Mk(t){let e=this.diagram.model,i=e.getKeyForNodeData(t);if(i!==void 0){let s=e.ow(i),n=this.findPartForData(t);if(s!==null&&n!==null){let r=s.iterator;for(;r.next();){let a=r.value;if(e.containsNodeData(a)){if(n instanceof ft&&e.getGroupKeyForNodeData(a)===i){let h=this.findPartForData(a);h!==null&&(h.containingGroup=n)}}else{let h=this.findLinkForData(a);if(h!==null&&n instanceof it){e.Vi(a,!0)===i&&(h.fromNode=n),e.Vi(a,!1)===i&&(h.toNode=n);let l=e.getLabelKeysForLinkData(a);Array.isArray(l)&&l.some(c=>c===i?(n.labeledLink=h,!0):!1)}}}e.an(i)}let o=e.getGroupKeyForNodeData(t);if(o!==void 0){let r=this.findNodeForKey(o);n!==null&&r instanceof ft&&(n.containingGroup=r)}}}XC(t){let e=this.diagram.model;if(t instanceof it){let i=e.getKeyForNodeData(t.data);if(i!==void 0){let s=t.linksConnected;for(;s.next();){let n=s.value;e.hn(i,n.data)}if(t.isLinkLabel){let n=t.labeledLink;n!==null&&e.hn(i,n.data)}if(t instanceof ft){let n=t.memberParts;for(;n.next();){let o=n.value.data;e.containsNodeData(o)&&e.hn(i,o)}}}}}KC(t,e){let i=super.KC(t,e);if(t instanceof q){let s=t.data;if(s!==null&&e!==null){let n=e.model,o=n.copyLinkData(s);n.addLinkData(o),i=e.findLinkForData(o)}else if(i!==null){let n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){let o=n.model.copyLinkData(s);i.data=o}}}return i}insertLink(t,e,i,s){let n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking"),a="";t!==null&&(e===null&&(e=t),a=e.portId,a===null&&(a=""));let h="";i!==null&&(s===null&&(s=i),h=s.portId,h===null&&(h=""));let l=r.archetypeLinkData;if(l instanceof q){l.It();let c=l.copy();if(c!==null){c.fromNode=t,c.fromPortId=a,c.toNode=i,c.toPortId=h,n.add(c);let u=r.archetypeLabelNodeData;if(u instanceof it){u.It();let d=u.copy();d!==null&&(d.labeledLink=c,n.add(d))}return c}}else if(l!==null){let c=o.copyLinkData(l);if(g.$(c)){t!==null&&o.wg(c,o.getKeyForNodeData(t.data),!0),o.xg(c,a,!0),i!==null&&o.wg(c,o.getKeyForNodeData(i.data),!1),o.xg(c,h,!1),o.addLinkData(c);let u=r.archetypeLabelNodeData;if(u!==null&&!(u instanceof it)){let d=o.copyNodeData(u);o.addNodeData(d);let f=o.getKeyForNodeData(d);f!==void 0&&o.addLabelKeyForLinkData(c,f)}return n.findLinkForData(c)}}return null}}class br extends Ne{Ia=null;Ak(t,e){if(t===null||e===null||e.findTreeParentLink()!==null)return;let i=this.diagram.toolManager.findTool("Linking"),s=t,n=e;if(this.diagram.isTreePathToChildren){if(i!==null&&i.Vu(s,n,null,!0))return}else if(s=e,n=t,i!==null&&i.Vu(s,n,null,!0))return;let o=this.getLinkCategoryForData(e.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.It();let a=r.copy();if(a!==null){let h=this.diagram.yi;this.diagram.yi=!0,a._o=o,a.te=e.data,a.fromNode=s,a.toNode=n,this.diagram.add(a),a.te=null,a.data=e.data,this.diagram.yi=h}}}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,e){this.diagram.model.setParentLinkCategoryForNodeData(t,e)}setFromNodeForLink(t,e,i){let s=this.diagram.model;i===void 0&&(i=null);let n=e!==null?e.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{let o=this.Ia;this.Ia=t,i!==null&&s.setParentKeyForNodeData(i.data,void 0);let r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ia=o}}setToNodeForLink(t,e,i){let s=this.diagram.model;i===void 0&&(i=null);let n=e!==null?e.data:null;if(this.diagram.isTreePathToChildren){let o=this.Ia;this.Ia=t,i!==null&&s.setParentKeyForNodeData(i.data,void 0);let r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ia=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}AC(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.findLinkForData(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;let e=this.diagram;if(t.model!==e.model)return;let i=t.change;if(e.G){e.G=!1;try{let s=t.modelChange;if(s!==""){if(i===2){if(s==="nodeParentKey"){let n=t.object,o=n?this.findNodeForData(n):null,r=t.newValue,a=this.findNodeForKey(r);if(n&&this.Ia!==null)a!==null&&(this.Ia.data=n,this.Ia.category=this.getLinkCategoryForData(n));else if(o!==null){let h=o.findTreeParentLink();h!==null?a===null?e.remove(h):e.isTreePathToChildren?h.fromNode=a:h.toNode=a:this.Ak(a,o)}}else if(s==="parentLinkCategory"){let n=t.object,o=n?this.findNodeForData(n):null,r=t.newValue;if(o!==null&&typeof r=="string"){let a=o.findTreeParentLink();a!==null&&(a.category=r)}}e.isModified=!0}}else i===2&&(t.object===e.model&&t.propertyName==="nodeParentKeyProperty"&&(e.undoManager.isUndoingRedoing||this.rebuildParts()),e.isModified=!0)}finally{e.G=!0}}}updateRelationshipsFromData(t){let e=t.data;if(e===null)return;let i=t.diagram;if(i===null)return;let s=i.model;if(t instanceof it){let n=s.getParentKeyForNodeData(e),o=i.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){let a=t.findTreeParentLink();o!==null?a!==null?i.isTreePathToChildren?a.fromNode=o:a.toNode=o:this.Ak(o,t):a!==null&&i.C2(a,!1)}}}nw(t,e){if(super.nw(t,e),typeof e=="string"&&this.findPartForData(t)!==null){let i=this.findLinkForData(t);i!==null&&i.updateTargetBindings(e)}}Mk(t){let e=this.diagram.model,i=e.getKeyForNodeData(t);if(i!==void 0){let s=e.ow(i),n=this.findPartForData(t);if(s!==null&&n!==null){let r=s.iterator;for(;r.next();){let a=r.value;if(e.containsNodeData(a)&&n instanceof it&&e.getParentKeyForNodeData(a)===i){let h=this.findNodeForData(a);this.Ak(n,h)}}e.an(i)}let o=e.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof it){let r=this.findNodeForKey(o);this.Ak(r,n)}}}XC(t){let e=this.diagram.model;if(t instanceof it){let i=e.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;let r=s.layer;if(r!==null){let a=r.ri(-1,s,!1);a>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,a,null);let h=s.layerChanged;h!==null&&h(s,r,null)}}let n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){let r=o.value,a=n?r.toNode:r.fromNode;if(a!==null){let h=a.data;e.containsNodeData(h)&&e.hn(i,h)}}}}insertLink(t,e,i,s){let n=this.diagram.model,o=t,r=i;if(this.diagram.isTreePathToChildren||(o=i,r=t),o!==null&&r!==null){let a=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(a)),r.findTreeParentLink()}return null}}var os=(x=>(x[x.OneWay=1]="OneWay",x[x.TwoWay=2]="TwoWay",x))(os||{});class re{n;HC;nc;Hf;Ea;jf;qf;Wf;Tk;Ti;Od;Df;constructor(t,e,i,s){I.Je(this),t===void 0?t="":g.s(t,"string",re,"constructor:targetprop"),e===void 0?e=t:g.s(e,"string",re,"constructor:sourceprop"),i===void 0?i=null:i!==null&&g.S(i,re,"constructor:conv"),this.HC=-1,this.Ti=null,this.nc=t,this.Od=0,this.Df=0,this.Hf=null,this.Ea=e,this.jf=i,s===void 0?(this.qf=1,this.Wf=null):(this.qf=2,this.Wf=s),this.Tk=new I,this.n=2}copy(){let t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.nc=this.nc,t.Od=this.Od,t.Df=this.Df,t.Hf=this.Hf,t.Ea=this.Ea,t.jf=this.jf,t.qf=this.qf,t.Wf=this.Wf,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,e){return g.S(t,re,"parseEnum:ctor"),i=>{let s=parseInt(i);return isNaN(s)&&(s=g.Wa(t,i),s===null)?e:s}}fe(t){t in os?this.mode=t:g.dr(this,t)}static toString(t){return g.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+os[this.mode]+")"}b(){return this.n=this.n|1,this}get targetId(){return this.HC}set targetId(t){this.f&&g.L(this),this.HC=t}get targetProperty(){return this.nc}set targetProperty(t){this.f&&g.L(this),g.s(t,"string",re,"targetProperty"),this.nc=t}get sourceProperty(){return this.Ea}set sourceProperty(t){this.f&&g.L(this),g.s(t,"string",re,"sourceProperty"),this.Ea=t}get f(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get jC(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}wd(){return!1}get sourceName(){return this.Hf}set sourceName(t){this.f&&g.L(this),t!==null&&g.s(t,"string",re,"sourceName"),this.Hf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.jf}set converter(t){this.f&&g.L(this),t!==null&&g.S(t,re,"converter"),this.jf=t}get backConverter(){return this.Wf}set backConverter(t){this.f&&g.L(this),t!==null&&g.S(t,re,"backConverter"),this.Wf=t}get mode(){return this.qf}set mode(t){this.f&&g.L(this),this.isToTheme&&t===2&&g.o("Theme Bindings cannot be TwoWay."),this.qf=t}makeTwoWay(t){return this.isToTheme&&g.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(g.S(t,re,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&g.L(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.f&&g.L(this),this.n=this.n&-3&-5|8,this.Hf=null,this}WT(t,e){let i=this.sourceName,s=null;return i===null||i===""?s=t:i==="/"?s=e.part:i==="."?s=e:i===".."?s=e.panel:s=t.findObject(i),s}check(t){let e=this.nc,i=this.Ea,s=this.jf;(this.wd()&&s===null&&this.Ua===null&&e===""||s===null&&e==="")&&g.ne("Binding error: target property is the empty string: "+this.toString()),this.wd()&&this.jC&&i===""&&s===null&&this.Ua===null&&g.ne("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof e=="string"&&(!g.nt(["setAttribute"])&&e.length>0&&e[0]!=="_"&&!g.Hw(t,e)?g.ne("Binding error: undefined target property: "+e+" on "+t.toString()):e==="name"&&t instanceof tt&&g.ne("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,e,i,s){let n=this.Ea;if(i!==void 0&&n!==""&&n!==i||this.isToTheme&&t.diagram===null)return;let o=this.nc,r=this.jf,a=e;if(n!==""&&!this.jC&&(a=mt.Mt(e,n)),a!==void 0)if(r===null){if(o!==""){if(this.wd()){let h=t.diagram?.themeManager;if(a=this.Vv(h,a,t,o),a===void 0)return}s?s.et(t,o,a):(e instanceof tt||e instanceof Gt)&&mt.et(t,o,a)}}else try{if(o!==""){let h=r(a,t);if(this.wd()){let l=t.diagram?.themeManager;if(h=this.Vv(l,h,t,o),h===void 0)return}s?s.et(t,o,h):(e instanceof tt||e instanceof Gt)&&mt.et(t,o,h)}else r(a,t)}catch{}}updateSource(t,e,i,s){if(this.qf!==2)return;let n=this.nc;if(i!==void 0&&n!==i)return;let o=this.Ea,r=this.Wf,a=s!==null?s.diagram:null,h=a!==null?a.model:null,l=t;if(n!==""&&(l=mt.Mt(t,n)),l!==void 0&&!this.Tk.has(t))try{if(this.Tk.add(t),r===null){if(o!=="")h!==null?h.setDataProperty(e,o,l):(e instanceof tt||e instanceof Gt)&&(e[o]=l);else if(h!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){let c=s.itemIndex,u=s.panel.itemArray;h.removeArrayItem(u,c),h.insertArrayItem(u,c,l)}}else try{if(o!==""){let c=r(l,e,h);h!==null?h.setDataProperty(e,o,c):(e instanceof tt||e instanceof Gt)&&(e[o]=c)}else{let c=r(l,e,h);if(c!==void 0&&h!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){let u=s.itemIndex,d=s.panel.itemArray;h.removeArrayItem(d,u),h.insertArrayItem(d,u,c)}}}catch{}}finally{this.Tk.delete(t)}}}class bi extends re{lw;Ua;oc;constructor(t,e,i,s,n){super(t,e,s),i==null&&(i=""),n===void 0&&(n=null),this.lw=i,this.Ua=n,this.oc=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.lw=this.lw,t.Ua=this.Ua,t.oc=this.oc}wd(){return!0}get themeSource(){return this.lw}set themeSource(t){this.f&&g.L(this),t!==null&&g.s(t,"string",bi,"themeSource"),this.lw=t,this.oc=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Ua}set themeConverter(t){this.f&&g.L(this),t!==null&&g.S(t,bi,"themeConverter"),this.Ua=t}ofData(){return this.f&&g.L(this),this.n=this.n|2,this.Hf=null,this}Vv(t,e,i,s){if(!t||(this.jC&&(e=this.Ea),!e&&e!==0))return;let n=this.themeSource;this.oc!==null?n=this.oc:typeof n=="string"&&n.includes(".")&&(this.oc=n.split("."),n=this.oc);let o=t.findValue(e,n,s);if(o===void 0&&g.ne(`Theme warning: ${e} could not be found when setting target property ${s}.`),t.readsCssVariables&&typeof o=="string"&&o.startsWith("var(")){let r=o.match(this.r3);r&&(o=getComputedStyle(C.document.documentElement).getPropertyValue(r[1]))}return g.nt(this.Ua)&&(o=this.Ua(o,i)),o}r3=/var\((.*)\)/}class mt{Pt;bg;zo;qC;Bi;be;Va;Jf;$f;kg;Pg;Sg;Mg;aw;rc;lr;hw;Bo;Dk;constructor(t,e){if(I.Je(this),this.Pt="",this.bg="",this.zo=!1,this.qC={},this.Bi=[],this.be=new wt,this.Va="key",this.Jf=null,this.$f=null,this.kg=!1,this.Pg=!1,this.Sg=!1,this.Mg=null,this.aw=100,this.rc="category",this.lr=new wt,this.hw=[],this.Bo=!1,this.Dk=null,this.undoManager=new _i,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:e=t),e){Object.assign(this,e);let i=e.Changed;i&&(delete this.Changed,this.addChangedListener(i))}}cloneProtected(t){t.Pt=this.Pt,t.bg=this.bg,t.zo=this.zo,t.Va=this.Va,t.Jf=this.Jf,t.$f=this.$f,t.kg=this.kg,t.Pg=this.Pg,t.Sg=this.Sg,t.Mg=this.Mg,t.aw=this.aw,t.rc=this.rc}copy(){let t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Bi=[],this.be.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let e=(this.name!==""?this.name:"")+" Model";if(t>0){e+=`
18
+ node data:`;let i=this.nodeDataArray,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+this.getKeyForNodeData(o)+":"+g.toString(o)}}return e}}toIncrementalData(t){t.change!==1&&g.o("Model.toIncrementalData argument is not a Transaction ChangedEvent:"+t.toString());let e=t.object;if(!t.isTransactionFinished||!(e instanceof Fi))return null;let i=this.Bv(e);return this.WC(e,t.propertyName==="FinishedUndo",i)}WC(t,e,i){let s=this,n=!1,o=new I,r=new I,a=new I;t.changes.each(d=>{if(d.model===s){if(d.modelChange==="nodeDataArray")d.change===3?o.add(d.newValue):d.change===4&&a.add(d.oldValue);else if(s.containsNodeData(d.object))d.object!==null&&r.add(d.object);else if(d.change===2&&(s.modelData===d.object||d.propertyName==="modelData"))n=!0;else if(d.object!==null)if(i.has(d.object)){let f=i.get(d.object);f&&f.each(p=>{s.containsNodeData(p)&&r.add(p)})}else{if(d.object instanceof mt||s.jh()&&s.containsLinkData(d.object))return;s.zv(d.object).each(f=>{r.add(f)})}}});let h=new I;o.each(d=>{let f=s.getKeyForNodeData(d);f!==void 0&&h.add(f),e||r.add(d)});let l=new I;a.each(d=>{let f=s.getKeyForNodeData(d);f!==void 0&&l.add(f),e&&r.add(d)});let c=s.cloneDeep(r.toArray()),u=null;return n&&(u===null&&(u={}),u.modelData=this.cloneDeep(this.modelData)),h.count>0&&(u===null&&(u={}),e?u.removedNodeKeys=h.toArray():u.insertedNodeKeys=h.toArray()),c.length>0&&(u===null&&(u={}),u.modifiedNodeData=c),l.count>0&&(u===null&&(u={}),e?u.insertedNodeKeys=l.toArray():u.removedNodeKeys=l.toArray()),u}cloneDeep(t){return this.Ng(t,!0)}Ng(t,e,i,s){if(!g.$(t))return t;i||(i=new wt);let n=i.get(t);if(n)return n;let o;if(Array.isArray(t)){o=[],i.set(t,o);for(let r=0;r<t.length;r++){let a=t[r];o.push(this.Ng(a,!1,i,s))}}else if(t instanceof P||t instanceof _||t instanceof B||t instanceof Dt||t instanceof T)o=t.copy(),i.set(t,o);else{if(t instanceof E||t instanceof St)return t;if(t instanceof U)o=new U().addAll(this.Ng(t.toArray(),!1,i,s)),i.set(t,o);else if(t instanceof I)o=new I().addAll(this.Ng(t.toArray(),!1,i,s)),i.set(t,o);else if(t instanceof wt)o=new wt().addAll(this.Ng(t.toArray(),!1,i,s)),i.set(t,o);else if(t instanceof Date)o=new Date(t),i.set(t,o);else if(t instanceof RegExp)o=new RegExp(t),i.set(t,o),o.lastIndex=t.lastIndex;else if(mt.JC(null,"",t))o=t;else if(g.nt(t.copy))o=t.copy(),i.set(t,o);else{o={},i.set(t,o);for(let r in t){if(r==="__gohashid")continue;let a=t[r];o[r]=this.Ng(a,!1,i,s)}}}return o}zi(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{let i="0000"+e.charCodeAt(0).toString(16);return"\\u"+i.substring(i.length-4)})}Cg(){let t="";return this.name!==""&&(t+=`,
19
+ "name": `+this.zi(this.name)),this.dataFormat!==""&&(t+=`,
20
+ "dataFormat": `+this.zi(this.dataFormat)),this.isReadOnly&&(t+=`,
21
+ "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`,
22
+ "nodeKeyProperty": `+this.zi(this.nodeKeyProperty)),this.copiesArrays&&(t+=`,
23
+ "copiesArrays": true`),this.copiesArrayObjects&&(t+=`,
24
+ "copiesArrayObjects": true`),this.copiesKey&&(t+=`,
25
+ "copiesKey": true`),this.pointsDigits!==100&&(t+=`,
26
+ "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`,
27
+ "nodeCategoryProperty": `+this.zi(this.nodeCategoryProperty)),t}cw(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}Xv(){let t=this.modelData;return`,
28
+ "modelData": `+this.Gv(t)}Yv(t){let e=t.modelData;g.$(e)&&(this.replaceJsonObjects(e),this.modelData=e)}$C(){let t=this.modelData,e=!1;for(let s in t)if(!this.vk(t,s,t[s])){e=!0;break}let i="";return e&&(i=this.Xv()),i+`,
29
+ "nodeDataArray": `+this.Ba(this.nodeDataArray,!0)}ZC(t){this.Yv(t);let e=t.nodeDataArray;Array.isArray(e)&&(this.replaceJsonObjects(e),this.nodeDataArray=e)}QC(t,e,i){if(t===e)return!0;if(typeof t!=typeof e||g.nt(t)||g.nt(e))return!1;if(Array.isArray(t)&&Array.isArray(e)){if(i.get(t)===e)return!0;if(i.set(t,e),t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!this.QC(t[s],e[s],i))return!1;return!0}else if(g.$(t)&&g.$(e)){if(i.get(t)===e)return!0;i.set(t,e);for(let s in t){let n=t[s];if(this.vk(t,s,n))continue;let o=e[s];if(o===void 0||!this.QC(n,o,i))return!1}for(let s in e){let n=e[s];if(this.vk(e,s,n))continue;let o=t[s];if(o===void 0||!this.QC(o,n,i))return!1}return!0}return!1}static Kv=`,
30
+ "insertedNodeKeys": `;static l3=`,
31
+ "modifiedNodeData": `;static Hv=`,
32
+ "removedNodeKeys": `;Bv(t){let e=new wt,i=(s,n)=>{let o=n.part;if(!o)return;let r=o.data;if(s===r)return;let a=e.get(s);a===null?(a=new I,a.add(r),e.set(s,a)):a.add(r)};return t.changes.each(s=>{if(s.diagram!==null){let n=s.change;if(n===2){if(s.object!==null){let o=s.object.panel;if(o){let r=o.data;r&&i(r,o)}}}else if(n===3||n===4){let o=s.object,r=o.itemArray;r&&i(r,o)}}}),e}zv(t){let e=new I;for(let i=0;i<this.nodeDataArray.length;i++){let s=this.nodeDataArray[i];this.Fk(t,s,s,e)}return e}Fk(t,e,i,s){if(Array.isArray(e))for(let n=0;n<e.length;n++){let o=e[n];if(o===t)return s.add(i),!0;if(this.Fk(t,o,i,s))return!0}else if(g.$(e)&&Object.getPrototypeOf(e)===Object.prototype)for(let n in e){let o=e[n];if(o===t)return s.add(i),!0;if(this.Fk(t,o,i,s))return!0}return!1}_C(t,e,i){let s=this,n=!1,o=new I,r=new I,a=new I;t.changes.each(u=>{if(u.model===s){if(u.modelChange==="nodeDataArray")u.change===3?o.add(u.newValue):u.change===4&&a.add(u.oldValue);else if(s.containsNodeData(u.object))u.object!==null&&r.add(u.object);else if(u.change===2&&(s.modelData===u.object||u.propertyName==="modelData"))n=!0;else if(u.object!==null)if(i.has(u.object)){let d=i.get(u.object);d&&d.each(f=>{s.containsNodeData(f)&&r.add(f)})}else{if(u.object instanceof mt||s.jh()&&s.containsLinkData(u.object))return;s.zv(u.object).each(d=>{r.add(d)})}}});let h=new I;o.each(u=>{let d=s.getKeyForNodeData(u);d!==void 0&&h.add(d),e||r.add(u)});let l=new I;a.each(u=>{let d=s.getKeyForNodeData(u);d!==void 0&&l.add(d),e&&r.add(u)});let c="";return n&&(c+=this.Xv()),h.count>0&&(c+=(e?mt.Hv:mt.Kv)+this.Ba(h.toArray(),!0)),r.count>0&&(c+=mt.l3+this.Ba(r.toArray(),!0)),l.count>0&&(c+=(e?mt.Kv:mt.Hv)+this.Ba(l.toArray(),!0)),c}fw(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&g.o("applyIncrementalJson cannot change Model properties"),this.Yv(t);let e=t.insertedNodeKeys,i=t.modifiedNodeData,s=new wt;if(Array.isArray(i))for(let o=0;o<i.length;o++){let r=i[o],a=this.getKeyForNodeData(r);a!=null&&s.set(a,r)}if(Array.isArray(e)){let o=e.length;for(let r=0;r<o;r++){let a=e[r],h=this.findNodeDataForKey(a);h===null&&(h=s.get(a)||this.copyNodeData({}),h!==null&&(this.setKeyForNodeData(h,a),this.addNodeData(h)))}}if(Array.isArray(i)){let o=i.length;for(let r=0;r<o;r++){let a=i[r],h=this.getKeyForNodeData(a),l=this.findNodeDataForKey(h);if(l!==null){for(let c in a)c==="__gohashid"||c===this.nodeKeyProperty||(this.Em()||this.l1())&&c===this.nodeIsGroupProperty||this.setDataProperty(l,c,a[c]);this.Lg(a,l)}}}let n=t.removedNodeKeys;if(Array.isArray(n)){let o=n.length;for(let r=0;r<o;r++){let a=n[r],h=this.findNodeDataForKey(a);h!==null&&this.removeNodeData(h)}}}toIncrementalJson(t,e){t.change!==1&&g.o("Model.toIncrementalJson argument is not a Transaction ChangedEvent:"+t.toString());let i=t.object;if(!t.isTransactionFinished||!(i instanceof Fi))return'{ "incremental": 0 }';e===void 0&&(e=g.Hn(this));let s=this.Bv(i),n=this._C(i,t.propertyName==="FinishedUndo",s);return'{ "class": '+this.zi(e)+', "incremental": 1'+this.Cg()+n+"}"}toIncrementalJSON(t,e){return this.toIncrementalJson(t,e)}toJson(t){return t===void 0&&(t=g.Hn(this)),'{ "class": '+this.zi(t)+this.Cg()+this.$C()+"}"}toJSON(t){return this.toJson(t)}applyIncrementalJson(t){let e=null;if(typeof t=="string")try{e=C.JSON.parse(t)}catch{}else g.$(t)?e=t:g.o("Unable to modify a Model from: "+t);let i=e.incremental;typeof i!="number"&&g.o("Unable to apply non-incremental changes to Model: "+t),i!==0&&(this.startTransaction("applyIncrementalJson"),this.fw(e),this.commitTransaction("applyIncrementalJson"))}applyIncrementalJSON(t){return this.applyIncrementalJson(t)}static fromJson(t,e){e===void 0&&(e=null),e!==null&&g.se(e,mt,mt,"fromJson:model");let i=null;if(typeof t=="string")try{i=C.JSON.parse(t)}catch{}else g.$(t)?i=t:g.o("Unable to construct a Model from: "+t);if(e===null){let s=mt.a3(i);s===null||s instanceof mt?e=s:g.o("Unable to construct a Model of declared class: "+i.class)}return e===null&&(e=mt.jv()),e.cw(i),e.ZC(i),e}static fromJSON(t,e){return this.fromJson(t,e)}static jv(){return new mt}static a3(t){let e=null,i=t.class;if(typeof i=="string")try{let s=null;i.indexOf("go.")===0?s=mt.tL(i.substring(3)):(s=mt.tL(i),s===null&&(s=C[i])),g.nt(s)&&(e=new s)}catch{}return e}replaceJsonObjects(t){if(Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++){let s=t[i];g.$(s)&&this.qv(t,i,this.replaceJsonObjects(s))}}else if(g.$(t)){for(let e in t){let i=t[e];if(g.$(i)){let s=this.replaceJsonObjects(i);t[e]=s,this.replaceJsonPropertyValue(t,e,s)}}return this.h3(t)}return t}replaceJsonPropertyValue(t,e,i){if(e==="points"&&Array.isArray(i)){let s=i.length%2===0;for(let n=0;n<i.length;n++)if(typeof i[n]!="number"){s=!1;break}if(s){let n=new U;for(let o=0;o<i.length/2;o++)n.add(new P(i[o*2],i[o*2+1]));t[e]=n}}}writeJsonValue(t){return t===void 0?"undefined":t===null?"null":t===!0?"true":t===!1?"false":typeof t=="string"?this.zi(t):typeof t=="number"?t===1/0?"9e9999":t===-1/0?"-9e9999":isNaN(t)?'{"class":"NaN"}':t.toString():t instanceof Boolean?this.writeJsonValue(t.valueOf()):t instanceof String?this.writeJsonValue(t.valueOf()):t instanceof Number?this.writeJsonValue(t.valueOf()):t instanceof Date?'{"class":"Date", "value":"'+t.toJSON()+'"}':Array.isArray(t)?this.Ba(t):g.$(t)?this.Gv(t):g.nt(t)?"null":'"'+t.toString()+'"'}Ba(t,e){e===void 0&&(e=!1);let i=t.length;if(i<=0)return"[]";let s=new z;s.add("["),e&&i>1&&s.add(`
33
+ `);for(let n=0;n<i;n++){let o=t[n];o!==void 0&&(n>0&&(s.add(","),e&&s.add(`
34
+ `)),s.add(this.writeJsonValue(o)))}return e&&i>1&&s.add(`
35
+ `),s.add("]"),s.toString()}vk(t,e,i){return!!(i===void 0||e==="__gohashid"||e[0]==="_"||g.nt(i))}je(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}Gv(t){let e=t;if(e instanceof P)t={class:"go.Point",x:this.je(e.x),y:this.je(e.y)};else if(e instanceof _)t={class:"go.Size",width:this.je(e.width),height:this.je(e.height)};else if(e instanceof B)t={class:"go.Rect",x:this.je(e.x),y:this.je(e.y),width:this.je(e.width),height:this.je(e.height)};else if(e instanceof Dt)t={class:"go.Margin",top:this.je(e.top),right:this.je(e.right),bottom:this.je(e.bottom),left:this.je(e.left)};else if(e instanceof T)e.isSpot()?t={class:"go.Spot",x:this.je(e.x),y:this.je(e.y),offsetX:this.je(e.offsetX),offsetY:this.je(e.offsetY)}:t={class:"go.Spot",enum:e.toString()};else if(e instanceof E){if(t={class:"go.Brush",type:We[e.type]},e.type===1?t.color=e.color:(e.type===2||e.type===3)&&(t.start=e.start,t.end=e.end,e.type===3&&(e.startRadius!==0&&(t.startRadius=this.je(e.startRadius)),isNaN(e.endRadius)||(t.endRadius=this.je(e.endRadius)))),e.colorStops!==null){let n={},o=e.colorStops.iterator;for(;o.next();){let r=o.key,a=o.value;n[r]=a}t.colorStops=n}}else if(e instanceof St)t={class:"go.Geometry",type:ii[e.type]},e.startX!==0&&(t.startX=this.je(e.startX)),e.startY!==0&&(t.startY=this.je(e.startY)),e.endX!==0&&(t.endX=this.je(e.endX)),e.endY!==0&&(t.endY=this.je(e.endY)),e.spot1.equals(T.TopLeft)||(t.spot1=e.spot1),e.spot2.equals(T.BottomRight)||(t.spot2=e.spot2),e.type===4&&(t.path=St.stringify(e));else if(mt.JC(null,"",e))return"{}";let i="{",s=!0;for(let n in t){let o=this.Mt(t,n);this.vk(t,n,o)||(s?s=!1:i+=",",i+=this.zi(n)+":"+this.writeJsonPropertyValue(n,o))}return i+="}",i}writeJsonPropertyValue(t,e){if(t==="points"&&e instanceof U){let i=e,s="[",n=i.iterator;for(;n.next();){let o=n.value;s.length>1&&(s+=","),s+=this.Wv(o.x),s+=",",s+=this.Wv(o.y)}return s+="]",s}else return this.writeJsonValue(e)}Wv(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";let e=this.pointsDigits;return e>16?t.toString():t.toFixed(e)}get pointsDigits(){return this.aw}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.aw=t}qe(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}h3(t){if(!g.$(t))return t;let e=t.class||"";if(typeof e!="string"||e==="")return t;if(e==="NaN")return NaN;if(e==="Date")return new Date(t.value);if(e.indexOf("go.")!==0)return t;e=e.substring(3);let i=t;if(e==="Point")i=new P(this.qe(t.x),this.qe(t.y));else if(e==="Size")i=new _(this.qe(t.width),this.qe(t.height));else if(e==="Rect")i=new B(this.qe(t.x),this.qe(t.y),this.qe(t.width),this.qe(t.height));else if(e==="Margin")i=new Dt(this.qe(t.top),this.qe(t.right),this.qe(t.bottom),this.qe(t.left));else if(e==="Spot")typeof t.enum=="string"?i=T.parse(t.enum):i=new T(this.qe(t.x),this.qe(t.y),this.qe(t.offsetX),this.qe(t.offsetY));else if(e==="Brush"){let s=new E;s.type=g.Wa(We,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof T&&(s.start=t.start),t.end instanceof T&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.qe(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.qe(t.endRadius));let n=t.colorStops;if(g.$(n))for(let o in n){let r=parseFloat(o);s.addColorStop(r,n[o])}i=s}else if(e==="Geometry"){let s=null;typeof t.path=="string"?s=St.parse(t.path):s=new St,s.type=g.Wa(ii,t.type)??1,typeof t.startX=="number"&&(s.startX=this.qe(t.startX)),typeof t.startY=="number"&&(s.startY=this.qe(t.startY)),typeof t.endX=="number"&&(s.endX=this.qe(t.endX)),typeof t.endY=="number"&&(s.endY=this.qe(t.endY)),t.spot1 instanceof T&&(s.spot1=t.spot1),t.spot2 instanceof T&&(s.spot2=t.spot2),i=s}else if(e==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));let n=mt.tL(s);g.nt(n)&&(i=g.Wa(n,t.name))}return i}get name(){return this.Pt}set name(t){let e=this.Pt;e!==t&&(g.s(t,"string",mt,"name"),this.Pt=t,this.t("name",e,t))}get dataFormat(){return this.bg}set dataFormat(t){let e=this.bg;e!==t&&(g.s(t,"string",mt,"dataFormat"),this.bg=t,this.t("dataFormat",e,t))}get isReadOnly(){return this.zo}set isReadOnly(t){let e=this.zo;e!==t&&(g.s(t,"boolean",mt,"isReadOnly"),this.zo=t,this.t("isReadOnly",e,t))}get modelData(){return this.qC}set modelData(t){let e=this.modelData;e!==t&&(g.wc(t,mt,"modelData"),this.containsNodeData(t)&&g.o("Model.modelData Object must not be used by the rest of the model: "+t),this.qC=t,this.t("modelData",e,t),this.updateTargetBindings(t))}addChangedListener(t){return g.S(t,mt,"addChangedListener:listener"),this.hw.push(t),this}removeChangedListener(t){g.S(t,mt,"removeChangedListener:listener");let e=this.hw.indexOf(t);e>=0&&this.hw.splice(e,1)}A2(t){this.skipsUndoManager||this.undoManager.handleChanged(t),this.Jv(t)}Jv(t){this.hw.forEach(e=>e(t))}rR(t){this.Jv(t)}raiseChangedEvent(t,e,i,s,n,o,r){this.Ft("",t,e,i,s,n,o,r)}raiseChanged(t,e,i,s,n){this.Ft("",2,t,this,e,i,s,n)}t(t,e,i,s,n){this.Ft("",2,t,this,e,i,s,n)}raiseDataChanged(t,e,i,s,n,o){this.Ft("",2,e,t,i,s,n,o)}Ft(t,e,i,s,n,o,r,a){r===void 0&&(r=null),a===void 0&&(a=null);let h=new si;h.model=this,h.change=e,h.modelChange=t,h.propertyName=i,h.object=s,h.oldValue=n,h.oldParam=r,h.newValue=o,h.newParam=a,this.A2(h)}get undoManager(){return this.Dk}set undoManager(t){let e=this.Dk;e!==t&&(e&&e.removeModel(this),this.Dk=t,t.addModel(this))}get skipsUndoManager(){return this.Bo}set skipsUndoManager(t){g.s(t,"boolean",mt,"skipsUndoManager"),this.Bo=t}changeState(t,e){if(t!==null&&t.model===this)if(t.change===2){let i=t.object,s=t.propertyName,n=t.getValue(e);if(i!==null&&s===this.nodeKeyProperty&&this.containsNodeData(i)){let o=t.getValue(!e);o!==void 0&&this.be.delete(o),n!==void 0&&this.be.set(n,i)}this.et(i,s,n)}else if(t.change===3){let i=t.newParam;if(t.modelChange==="nodeDataArray"){let s=t.newValue;if(g.$(s)&&typeof i=="number"){let n=this.getKeyForNodeData(s);e?(this.Bi[i]===s&&this.Co(this.Bi,i),n!==void 0&&this.be.delete(n)):(this.Bi[i]!==s&&this.ar(this.Bi,i,s),n!==void 0&&this.be.set(n,s))}}else if(t.modelChange===""){let s=t.object;if(s&&!Array.isArray(s)&&t.propertyName&&(s=this.Mt(s,t.propertyName)),Array.isArray(s)&&typeof i=="number"){let n=t.newValue;e?this.Co(s,i):this.ar(s,i,n)}}else g.o("unknown ChangeType.Insert modelChange: "+t.toString())}else if(t.change===4){let i=t.oldParam;if(t.modelChange==="nodeDataArray"){let s=t.oldValue;if(g.$(s)&&typeof i=="number"){let n=this.getKeyForNodeData(s);e?(this.Bi[i]!==s&&this.ar(this.Bi,i,s),n!==void 0&&this.be.set(n,s)):(this.Bi[i]===s&&this.Co(this.Bi,i),n!==void 0&&this.be.delete(n))}}else if(t.modelChange===""){let s=t.object;if(s&&!Array.isArray(s)&&t.propertyName&&(s=this.Mt(s,t.propertyName)),Array.isArray(s)&&typeof i=="number"){let n=t.oldValue;e?this.ar(s,i,n):this.Co(s,i)}}else g.o("unknown ChangeType.Remove modelChange: "+t.toString())}else t.change===1||g.o("unknown ChangedEvent: "+t.toString())}startTransaction(t){return this.undoManager.startTransaction(t)}commitTransaction(t){return this.undoManager.commitTransaction(t)}rollbackTransaction(){return this.undoManager.rollbackTransaction()}commit(t,e){let i=e;i===void 0&&(i="");let s=this.skipsUndoManager;i===null&&(this.skipsUndoManager=!0,i=""),this.undoManager.startTransaction(i);let n=!1;try{t(this),n=!0}finally{n?this.undoManager.commitTransaction(i):this.undoManager.rollbackTransaction(),this.skipsUndoManager=s}}updateTargetBindings(t,e){e===void 0&&(e=""),this.Ft("SourceChanged",1,e,t,null,null)}get nodeKeyProperty(){return this.Va}set nodeKeyProperty(t){let e=this.Va;e!==t&&(this.Un(t,mt,"nodeKeyProperty"),t===""&&g.o("Model.nodeKeyProperty may not be the empty string"),this.be.count>0&&g.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Va=t,this.t("nodeKeyProperty",e,t))}Un(t,e,i){typeof t!="string"&&!g.nt(t)&&g.si(t,"string or function",e,i)}getKeyForNodeData(t){if(t===null)return;let e=this.Va;if(e==="")return;let i=this.Mt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;g.o("Key value for node data "+t+" is not a number or a string: "+i)}}setKeyForNodeData(t,e){if((e==null||!this.isKeyType(e))&&g.si(e,"number or string",mt,"setKeyForNodeData:key"),t===null)return;let i=this.Va;if(i==="")return;if(!this.containsNodeData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);if(s!==e){if(this.findNodeDataForKey(e)!==null)return;this.et(t,i,e),s!==void 0&&this.be.delete(s),this.be.set(e,t),this.Ft("nodeKey",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i),this.uw(s,e)}}get makeUniqueKeyFunction(){return this.Jf}set makeUniqueKeyFunction(t){let e=this.Jf;e!==t&&(t!==null&&g.S(t,mt,"makeUniqueKeyFunction"),this.Jf=t,this.t("makeUniqueKeyFunction",e,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;let e=this.getKeyForNodeData(t);return e===void 0?!1:this.be.get(e)===t}findNodeDataForKey(t){return t===null&&g.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.be.get(t)}get nodeDataArray(){return this.Bi}set nodeDataArray(t){let e=this.Bi;if(e!==t){this.eL(t,mt,"nodeDataArray"),this.be.clear(),this.iL();let i=t.length;for(let o=0;o<i;o++){let r=t[o];g.$(r)||g.o("Model.nodeDataArray must only contain Objects, not: "+r),r===this.modelData&&g.o("nodeDataArray Objects must not be the shared Model.modelData")}this.Bi=t;let s=new U;for(let o=0;o<i;o++){let r=t[o],a=this.getKeyForNodeData(r);a===void 0||this.be.get(a)!==null?s.add(r):this.be.set(a,r)}let n=s.iterator;for(;n.next();){let o=n.value;this.makeNodeDataKeyUnique(o);let r=this.getKeyForNodeData(o);r!==void 0&&this.be.set(r,o)}this.Ft("nodeDataArray",2,"nodeDataArray",this,e,t);for(let o=0;o<i;o++){let r=t[o];this.Ag(r),this.Tg(r)}}}Rk(t){return t===void 0?!1:this.be.has(t)}makeNodeDataKeyUnique(t){if(t===null)return;let e=this.Va;if(e==="")return;let i=this.getKeyForNodeData(t);if(i!==void 0&&!this.Rk(i))return;let s=this.Jf;if(s!==null&&(i=s(this,t),i!=null&&!this.Rk(i))){this.et(t,e,i);return}if(typeof i=="string"){let n=2;for(;this.Rk(i+n);)n++;this.et(t,e,i+n)}else if(i===void 0||typeof i=="number"){let n=-this.be.count-1;for(;this.Rk(n);)n--;this.et(t,e,n)}}addNodeData(t){t!==null&&(t===this.modelData&&g.o("Model.addNodeData cannot add the shared Model.modelData Object"),this.containsNodeData(t)||this.vv(t,!0))}vv(t,e){let i=this.getKeyForNodeData(t);if(i===void 0)this.makeNodeDataKeyUnique(t),i=this.getKeyForNodeData(t);else{if(this.be.get(i)===t)return;this.makeNodeDataKeyUnique(t),i=this.getKeyForNodeData(t)}i===void 0&&g.o("Model.makeNodeDataKeyUnique failed on "+t+". Data not added to Model."),this.be.set(i,t);let s=null;e&&(s=this.Bi.length,this.ar(this.Bi,s,t)),this.Ft("nodeDataArray",3,"nodeDataArray",this,null,t,null,s),this.Ag(t),this.Tg(t)}addNodeDataCollection(t){if(Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++)this.addNodeData(t[i])}else{let e=t.iterator;for(;e.next();){let i=e.value;this.addNodeData(i)}}}removeNodeData(t){t!==null&&this.Dv(t,!0)}Dv(t,e){let i=this.getKeyForNodeData(t);i!==void 0&&this.be.delete(i);let s=null;if(e){if(s=this.Bi.indexOf(t),s<0)return;this.Co(this.Bi,s)}this.Ft("nodeDataArray",4,"nodeDataArray",this,t,null,s,null),this.dw(t)}removeNodeDataCollection(t){if(Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++)this.removeNodeData(t[i])}else{let e=t.iterator;for(;e.next();){let i=e.value;this.removeNodeData(i)}}}mergeNodeDataArray(t){if(t===this.nodeDataArray||!Array.isArray(t))return;let e=new I;e.addAll(this.be.iteratorKeys);let i=new I,s=t.length;for(let o=0;o<s;o++){let r=t[o],a=this.getKeyForNodeData(r);if(a!==void 0){i.add(a);let h=this.findNodeDataForKey(a);if(h===r)continue;if(h!==null)this.assignAllDataProperties(h,r),this.Lg(r,h);else{let l=this.cloneDeep(r);this.setKeyForNodeData(l,a),this.addNodeData(l)}}else{let h=this.cloneDeep(r);this.addNodeData(h);let l=this.getKeyForNodeData(h);l!==void 0&&i.add(l)}}let n=e.iterator;for(;n.next();){let o=n.value;if(!i.has(o)){let r=this.findNodeDataForKey(o);r&&this.removeNodeData(r)}}}uw(t,e){if(e===void 0)return;let i=this.ow(t);i instanceof I&&this.lr.set(e,i)}iL(){}Ag(t){}Tg(t){}dw(t){}hn(t,e){if(t===void 0)return;let i=this.lr.get(t);i===null&&(i=new I,this.lr.set(t,i)),i.add(e)}an(t,e){if(t===void 0)return;let i=this.lr.get(t);i instanceof I&&(e==null?this.lr.delete(t):(i.delete(e),i.count===0&&this.lr.delete(t)))}ow(t){if(t===void 0)return null;let e=this.lr.get(t);return e instanceof I?e:null}GU(t){t===void 0?this.lr.clear():this.lr.delete(t)}get copyNodeDataFunction(){return this.$f}set copyNodeDataFunction(t){let e=this.$f;e!==t&&(t!==null&&g.S(t,mt,"copyNodeDataFunction"),this.$f=t,this.t("copyNodeDataFunction",e,t))}get copiesArrays(){return this.kg}set copiesArrays(t){let e=this.kg;e!==t&&(t!==null&&g.s(t,"boolean",mt,"copiesArrays"),this.kg=t,this.t("copiesArrays",e,t))}get copiesArrayObjects(){return this.Pg}set copiesArrayObjects(t){let e=this.Pg;e!==t&&(t!==null&&g.s(t,"boolean",mt,"copiesArrayObjects"),this.Pg=t,this.t("copiesArrayObjects",e,t))}get copiesKey(){return this.Sg}set copiesKey(t){let e=this.Sg;e!==t&&(t!==null&&g.s(t,"boolean",mt,"copiesKey"),this.Sg=t,this.t("copiesKey",e,t))}copyNodeData(t){let e=null,i=this.$f;return i!==null?e=i(t,this):e=this.Ok(t,!0),e}Ok(t,e){if(g.$(t))if(Array.isArray(t))if(this.copiesArrays){let i=t,s=[];for(let n=0;n<i.length;n++){let o=i[n],r=this.Ok(o,this.copiesArrayObjects);s.push(r)}return s}else return t;else{if(t instanceof P||t instanceof _||t instanceof B||t instanceof Dt||t instanceof T)return t.copy();if(e){let i=t,s=i.constructor,n=s?new s:{},o=!this.copiesKey&&typeof this.nodeKeyProperty=="string"?this.nodeKeyProperty:null;for(let r in i){if(r==="__gohashid"){n.__gohashid=void 0;continue}if(r===o){n[o]=void 0;continue}let a=this.Mt(i,r);if(!g.$(a))n[r]=a;else if(mt.JC(i,r,a))this.et(n,r,a);else{let h=this.Ok(a,!1);this.et(n,r,h)}}return n}else return t}else return t}get afterCopyFunction(){return this.Mg}set afterCopyFunction(t){let e=this.Mg;e!==t&&(t!==null&&g.S(t,mt,"afterCopyFunction"),this.Mg=t,this.t("afterCopyFunction",e,t))}static JC(t,e,i){let s=g.Hn(i);return i instanceof mt||i instanceof _i||i instanceof Fi||i instanceof si||i instanceof tt||i instanceof Gt||i instanceof j||i instanceof EventTarget||s==="Layer"||s==="RowColumnDefinition"||s.indexOf("Animation")>=0||s.indexOf("Tool")>=0||s.indexOf("CommandHandler")>=0||s.indexOf("Layout")>=0}static $v=!1;setDataProperty(t,e,i){if(this.containsNodeData(t)){if(e===this.nodeKeyProperty){this.setKeyForNodeData(t,i);return}else if(e===this.nodeCategoryProperty){this.setCategoryForNodeData(t,i);return}}else!mt.$v&&t instanceof tt&&(mt.$v=!0,g.ne('Model.setDataProperty is modifying a GraphObject, "'+t.toString()+'"'),g.ne(" Is that really your intent?"));let s=this.Mt(t,e);s!==i&&(this.et(t,e,i),this.raiseDataChanged(t,e,s,i))}set(t,e,i){this.setDataProperty(t,e,i)}assignAllDataProperties(t,e){if(!e)return;let i=this.containsNodeData(t);for(let s in e)s!=="__gohashid"&&(i&&s===this.nodeKeyProperty||this.setDataProperty(t,s,e[s]))}addArrayItem(t,e){this.insertArrayItem(t,-1,e)}insertArrayItem(t,e,i){e<0&&(e=t.length),t=this.ar(t,e,i),this.Ft("",3,"",t,null,i,null,e)}removeArrayItem(t,e){e===void 0&&(e=-1),t===this.Bi&&g.o("Model.removeArrayItem should not be called on the Model.nodeDataArray"),e===-1&&(e=t.length-1);let i=t[e];t=this.Co(t,e),this.Ft("",4,"",t,i,null,e,null)}get nodeCategoryProperty(){return this.rc}set nodeCategoryProperty(t){let e=this.rc;e!==t&&(this.Un(t,mt,"nodeCategoryProperty"),this.rc=t,this.t("nodeCategoryProperty",e,t))}getCategoryForNodeData(t){if(t===null)return"";let e=this.rc;if(e==="")return"";let i=this.Mt(t,e);if(i===void 0)return"";if(typeof i=="string")return i;g.o("getCategoryForNodeData found a non-string category for "+t+": "+i)}setCategoryForNodeData(t,e){if(g.s(e,"string",mt,"setCategoryForNodeData:cat"),t===null)return;let i=this.rc;if(i==="")return;if(!this.containsNodeData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);s===void 0&&(s=""),s!==e&&(this.et(t,i,e),this.Ft("nodeCategory",2,i,t,s,e))}Lg(t,e){this.setCategoryForNodeData(e,this.getCategoryForNodeData(t))}get type(){return"Model"}Um(){return!1}Em(){return!1}l1(){return!1}jh(){return!1}Lx(){return!1}ff(){return!1}static g2(){return new mt}Mt(t,e){return mt.Mt(t,e)}static Mt(t,e){if(!t||!e)return null;let i;try{g.nt(e)?i=e(t):g.nt(t.getAttribute)?(i=t.getAttribute(e),i===null&&(i=void 0)):i=t[e]}catch{}return i}et(t,e,i){mt.et(t,e,i)}static et(t,e,i){if(!(!t||!e)){try{g.nt(e)?e(t,i):g.nt(t.setAttribute)?t.setAttribute(e,i):t[e]=i}catch{}return t}}eL(t,e,i){Array.isArray(t)||g.si(t,"Array",e,i)}qv(t,e,i){return t[e]=i,t}ar(t,e,i){return e>=t.length?t.push(i):t.splice(e,0,i),t}Co(t,e){return e>=t.length?t.pop():t.splice(e,1),t}static tL(t){return mt.sL[t]?mt.sL[t]:C.go!==void 0&&C.go[t]?C.go[t]:null}static Sl(t,e){mt.sL[e]=t}static sL={}}mt.fromJSON=mt.fromJson=mt.fromJson,mt.Sl(E,"Brush"),mt.Sl(St,"Geometry"),mt.Sl(Dt,"Margin"),mt.Sl(P,"Point"),mt.Sl(B,"Rect"),mt.Sl(_,"Size"),mt.Sl(T,"Spot"),mt.Sl(mt,"Model");class Yt extends mt{Is;hr;Oe;za;Zf;Qf;Vl;Lo;Ao;lc;ac;hc;cn;_f;Vn;Dg;constructor(t,e,i){if(super(),this.Is=[],this.hr=new I,this.Oe=new wt,this.za="",this.Zf=null,this.Qf=null,this.Vl=null,this.Lo="from",this.Ao="to",this.lc="",this.ac="",this.hc="category",this.cn="",this._f="isGroup",this.Vn="group",this.Dg=!1,e!==void 0&&(this.linkDataArray=e),t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);let s=i.Changed;s&&(delete this.Changed,this.addChangedListener(s))}}cloneProtected(t){super.cloneProtected(t),t.za=this.za,t.Zf=this.Zf,t.Qf=this.Qf,t.Lo=this.Lo,t.Ao=this.Ao,t.lc=this.lc,t.ac=this.ac,t.hc=this.hc,t.cn=this.cn,t._f=this._f,t.Vn=this.Vn,t.Dg=this.Dg}clear(){this.Is=[],this.Oe.clear(),this.hr.clear(),super.clear()}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let e=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){e+=`
36
+ node data:`;let i=this.nodeDataArray,s=i.length,n=0;for(n=0;n<s;n++){let o=i[n];e+=" "+this.getKeyForNodeData(o)+":"+re.toString(o)}for(e+=`
37
+ link data:`,i=this.linkDataArray,s=i.length,n=0;n<s;n++){let o=i[n];e+=" "+this.Vi(o,!0)+"-->"+this.Vi(o,!1)}}return e}}WC(t,e,i){if(this.linkKeyProperty===""){let u=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=u}let s=super.WC(t,e,i),n=this,o=new I,r=new I,a=new I;t.changes.each(u=>{if(u.model===n){if(u.modelChange==="linkDataArray")u.change===3?o.add(u.newValue):u.change===4&&a.add(u.oldValue);else if(n.containsLinkData(u.object))u.object!==null&&r.add(u.object);else if(u.object!==null)if(u.object!==null&&i.has(u.object)){let d=i.get(u.object);d&&d.each(f=>{n.containsLinkData(f)&&r.add(f)})}else{if(u.object instanceof mt||n.containsNodeData(u.object))return;n.Zv(u.object).each(d=>r.add(d))}}});let h=new I;o.each(u=>{let d=n.getKeyForLinkData(u);d!==void 0&&h.add(d),e||r.add(u)});let l=new I;a.each(u=>{let d=n.getKeyForLinkData(u);d!==void 0&&l.add(d),e&&r.add(u)});let c=n.cloneDeep(r.toArray());return h.count>0&&(s===null&&(s={}),e?s.removedLinkKeys=h.toArray():s.insertedLinkKeys=h.toArray()),c.length>0&&(s===null&&(s={}),s.modifiedLinkData=c),l.count>0&&(s===null&&(s={}),e?s.insertedLinkKeys=l.toArray():s.removedLinkKeys=l.toArray()),s}Cg(){let t=super.Cg(),e="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(e+=`,
38
+ "linkCategoryProperty": `+this.zi(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(e+=`,
39
+ "linkKeyProperty": `+this.zi(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(e+=`,
40
+ "linkFromKeyProperty": `+this.zi(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(e+=`,
41
+ "linkToKeyProperty": `+this.zi(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(e+=`,
42
+ "linkFromPortIdProperty": `+this.zi(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(e+=`,
43
+ "linkToPortIdProperty": `+this.zi(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(e+=`,
44
+ "linkLabelKeysProperty": `+this.zi(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(e+=`,
45
+ "nodeIsGroupProperty": `+this.zi(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(e+=`,
46
+ "nodeGroupKeyProperty": `+this.zi(this.nodeGroupKeyProperty)),t+e}cw(t){super.cw(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}$C(){let t=super.$C(),e=`,
47
+ "linkDataArray": `+this.Ba(this.linkDataArray,!0);return t+e}ZC(t){super.ZC(t);let e=t.linkDataArray;Array.isArray(e)&&(this.replaceJsonObjects(e),this.linkDataArray=e)}Qv=`,
48
+ "insertedLinkKeys": `;c3=`,
49
+ "modifiedLinkData": `;_v=`,
50
+ "removedLinkKeys": `;Zv(t){let e=new I;for(let i=0;i<this.linkDataArray.length;i++){let s=this.linkDataArray[i];this.Fk(t,s,s,e)}return e}_C(t,e,i){if(this.linkKeyProperty===""){let u=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=u}let s=super._C(t,e,i),n=this,o=new I,r=new I,a=new I;t.changes.each(u=>{if(u.model===n){if(u.modelChange==="linkDataArray")u.change===3?o.add(u.newValue):u.change===4&&a.add(u.oldValue);else if(n.containsLinkData(u.object))u.object!==null&&r.add(u.object);else if(u.object!==null)if(u.object!==null&&i.has(u.object)){let d=i.get(u.object);d&&d.each(f=>{n.containsLinkData(f)&&r.add(f)})}else{if(u.object instanceof mt||n.containsNodeData(u.object))return;n.Zv(u.object).each(d=>r.add(d))}}});let h=new I;o.each(u=>{let d=n.getKeyForLinkData(u);d!==void 0&&h.add(d),e||r.add(u)});let l=new I;a.each(u=>{let d=n.getKeyForLinkData(u);d!==void 0&&l.add(d),e&&r.add(u)});let c=s;return h.count>0&&(c+=(e?this._v:this.Qv)+this.Ba(h.toArray(),!0)),r.count>0&&(c+=this.c3+this.Ba(r.toArray(),!0)),l.count>0&&(c+=(e?this.Qv:this._v)+this.Ba(l.toArray(),!0)),c}fw(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&g.o("applyIncrementalJson cannot change Model properties"),super.fw(t);let e=t.insertedLinkKeys;if(Array.isArray(e)){let n=e.length;for(let o=0;o<n;o++){let r=e[o],a=this.findLinkDataForKey(r);a===null&&(a=this.copyLinkData({}),this.setKeyForLinkData(a,r),this.addLinkData(a))}}let i=t.modifiedLinkData;if(Array.isArray(i)){let n=i.length;for(let o=0;o<n;o++){let r=i[o],a=this.getKeyForLinkData(r),h=this.findLinkDataForKey(a);if(h!==null){for(let l in r)l==="__gohashid"||l===this.linkKeyProperty||this.setDataProperty(h,l,r[l]);this.tF(r,h)}}}let s=t.removedLinkKeys;if(Array.isArray(s)){let n=s.length;for(let o=0;o<n;o++){let r=s[o],a=this.findLinkDataForKey(r);a!==null&&this.removeLinkData(a)}}}changeState(t,e){if(!(t===null||t.model!==this)){if(t.change===2){let i=t.object,s=t.propertyName;if(i!==null&&s===this.linkKeyProperty&&this.containsLinkData(i)){let n=t.getValue(e),o=t.getValue(!e);o!==void 0&&this.Oe.delete(o),n!==void 0&&this.Oe.set(n,i),this.et(i,s,n);return}}else if(t.change===3){let i=t.newParam;if(t.modelChange==="linkDataArray"){let s=t.newValue;if(g.$(s)&&typeof i=="number"){let n=this.getKeyForLinkData(s);e?(this.hr.delete(s),this.Is[i]===s&&this.Co(this.linkDataArray,i),n!==void 0&&this.Oe.delete(n)):(this.hr.add(s),this.Is[i]!==s&&this.ar(this.Is,i,s),n!==void 0&&this.Oe.set(n,s))}return}else if(t.modelChange==="linkLabelKeys"){let s=t.object,n=s!==null?this.getLabelKeysForLinkData(s):null;Array.isArray(n)&&typeof i=="number"&&(e?(i=n.indexOf(t.newValue),i>=0&&this.Co(n,i)):n.indexOf(t.newValue)<0&&this.ar(n,i,t.newValue));return}}else if(t.change===4){let i=t.oldParam;if(t.modelChange==="linkDataArray"){let s=t.oldValue;if(g.$(s)&&typeof i=="number"){let n=this.getKeyForLinkData(s);e?(this.hr.add(s),this.Is[i]!==s&&this.ar(this.Is,i,s),n!==void 0&&this.Oe.set(n,s)):(this.hr.delete(s),this.Is[i]===s&&this.Co(this.linkDataArray,i),n!==void 0&&this.Oe.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){let s=t.object,n=s!==null?this.getLabelKeysForLinkData(s):null;Array.isArray(n)&&typeof i=="number"&&(e?n.indexOf(t.oldValue)<0&&this.ar(n,i,t.oldValue):(i=n.indexOf(t.oldValue),i>=0&&this.Co(n,i)));return}}super.changeState(t,e)}}get archetypeNodeData(){return this.Vl}set archetypeNodeData(t){let e=this.Vl;e!==t&&(t!==null&&g.wc(t,Yt,"archetypeNodeData"),this.Vl=t,this.t("archetypeNodeData",e,t))}nL(t){if(t===void 0)return;let e=this.Vl;if(e!==null){let i=this.findNodeDataForKey(t);i===null&&(i=this.copyNodeData(e),this.et(i,this.nodeKeyProperty,t),this.addNodeData(i))}return t}get linkFromKeyProperty(){return this.Lo}set linkFromKeyProperty(t){let e=this.Lo;e!==t&&(this.Un(t,Yt,"linkFromKeyProperty"),this.Lo=t,this.t("linkFromKeyProperty",e,t))}getFromKeyForLinkData(t){return this.Vi(t,!0)}setFromKeyForLinkData(t,e){this.wg(t,e,!0)}get linkToKeyProperty(){return this.Ao}set linkToKeyProperty(t){let e=this.Ao;e!==t&&(this.Un(t,Yt,"linkToKeyProperty"),this.Ao=t,this.t("linkToKeyProperty",e,t))}getToKeyForLinkData(t){return this.Vi(t,!1)}setToKeyForLinkData(t,e){this.wg(t,e,!1)}Vi(t,e){if(t===null)return;let i=e?this.Lo:this.Ao;if(i==="")return;let s=this.Mt(t,i);if(s!==void 0){if(this.isKeyType(s))return s;g.o((e?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}wg(t,e,i){if(e===null&&(e=void 0),e!==void 0&&!this.isKeyType(e)&&g.si(e,"number or string",Yt,i?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;let s=i?this.Lo:this.Ao;if(s==="")return;if(e=this.nL(e),!this.containsLinkData(t)){this.et(t,s,e);return}let n=this.Mt(t,s);n!==e&&(this.an(n,t),this.et(t,s,e),this.findNodeDataForKey(e)===null&&this.hn(e,t),this.Ft(i?"linkFromKey":"linkToKey",2,s,t,n,e),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.lc}set linkFromPortIdProperty(t){let e=this.lc;e!==t&&(this.Un(t,Yt,"linkFromPortIdProperty"),this.lc=t,this.t("linkFromPortIdProperty",e,t))}getFromPortIdForLinkData(t){return this.Lk(t,!0)}setFromPortIdForLinkData(t,e){this.xg(t,e,!0)}get linkToPortIdProperty(){return this.ac}set linkToPortIdProperty(t){let e=this.ac;e!==t&&(this.Un(t,Yt,"linkToPortIdProperty"),this.ac=t,this.t("linkToPortIdProperty",e,t))}getToPortIdForLinkData(t){return this.Lk(t,!1)}setToPortIdForLinkData(t,e){this.xg(t,e,!1)}Lk(t,e){if(t===null)return"";let i=e?this.lc:this.ac;if(i==="")return"";let s=this.Mt(t,i);return s===void 0?"":s}xg(t,e,i){if(g.s(e,"string",Yt,i?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;let s=i?this.lc:this.ac;if(s==="")return;if(!this.containsLinkData(t)){this.et(t,s,e);return}let n=this.Mt(t,s);n===void 0&&(n=""),n!==e&&(this.et(t,s,e),this.Ft(i?"linkFromPortId":"linkToPortId",2,s,t,n,e),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.cn}set linkLabelKeysProperty(t){let e=this.cn;e!==t&&(this.Un(t,Yt,"linkLabelKeysProperty"),this.cn=t,this.t("linkLabelKeysProperty",e,t))}getLabelKeysForLinkData(t){if(t===null)return Yt.EmptyArray;let e=this.cn;if(e==="")return Yt.EmptyArray;let i=this.Mt(t,e);return i===void 0?Yt.EmptyArray:i}setLabelKeysForLinkData(t,e){if(this.eL(e,Yt,"setLabelKeysForLinkData:arr"),t===null)return;let i=this.cn;if(i==="")return;if(!this.containsLinkData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);if(s===void 0&&(s=Yt.EmptyArray),s!==e){if(Array.isArray(s)){let o=s.length;for(let r=0;r<o;r++){let a=s[r];this.an(a,t)}}this.et(t,i,e);let n=e.length;for(let o=0;o<n;o++){let r=e[o];this.findNodeDataForKey(r)===null&&this.hn(r,t)}this.Ft("linkLabelKeys",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i)}}addLabelKeyForLinkData(t,e){if(e==null||(this.isKeyType(e)||g.si(e,"number or string",Yt,"addLabelKeyForLinkData:key"),t===null))return;let i=this.cn;if(i==="")return;let s=this.Mt(t,i);if(s===void 0){let n=[];n.push(e),this.setLabelKeysForLinkData(t,n)}else if(Array.isArray(s)){let n=s.indexOf(e);if(n>=0)return;n=s.length,s.push(e),this.containsLinkData(t)&&(this.findNodeDataForKey(e)===null&&this.hn(e,t),this.Ft("linkLabelKeys",3,i,t,null,e,null,n))}else g.o(i+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,e){if(e==null||(this.isKeyType(e)||g.si(e,"number or string",Yt,"removeLabelKeyForLinkData:key"),t===null))return;let i=this.cn;if(i==="")return;let s=this.Mt(t,i);if(Array.isArray(s)){let n=s.indexOf(e);if(n<0)return;this.Co(s,n),this.containsLinkData(t)&&(this.an(e,t),this.Ft("linkLabelKeys",4,i,t,e,null,n,null))}else s!==void 0&&g.o(i+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.Is}set linkDataArray(t){let e=this.Is;if(e!==t){this.eL(t,Yt,"linkDataArray"),this.Oe.clear();let i=t.length;for(let n=0;n<i;n++){let o=t[n];g.$(o)||g.o("GraphLinksModel.linkDataArray must only contain Objects, not: "+o)}if(this.Is=t,this.linkKeyProperty!==""){let n=new U;for(let r=0;r<i;r++){let a=t[r],h=this.getKeyForLinkData(a);h===void 0||this.Oe.get(h)!==null?n.add(a):this.Oe.set(h,a)}let o=n.iterator;for(;o.next();){let r=o.value;this.makeLinkDataKeyUnique(r);let a=this.getKeyForLinkData(r);a!==void 0&&this.Oe.set(a,r)}}let s=new I;for(let n=0;n<i;n++){let o=t[n];s.add(o)}this.hr=s,this.Ft("linkDataArray",2,"linkDataArray",this,e,t);for(let n=0;n<i;n++){let o=t[n];this.oL(o)}}}get linkKeyProperty(){return this.za}set linkKeyProperty(t){let e=this.za;if(e!==t){this.Un(t,Yt,"linkKeyProperty"),this.za=t,this.Oe.clear();let i=this.linkDataArray.length;for(let s=0;s<i;s++){let n=this.linkDataArray[s],o=this.getKeyForLinkData(n);o===void 0&&(this.makeLinkDataKeyUnique(n),o=this.getKeyForLinkData(n)),o!==void 0&&this.Oe.set(o,n)}this.t("linkKeyProperty",e,t)}}getKeyForLinkData(t){if(t===null)return;let e=this.za;if(e==="")return;let i=this.Mt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;g.o("Key value for link data "+t+" is not a number or a string: "+i)}}setKeyForLinkData(t,e){if((e==null||!this.isKeyType(e))&&g.si(e,"number or string",Yt,"setKeyForLinkData:key"),t===null)return;let i=this.za;if(i==="")return;if(!this.containsLinkData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);if(s!==e){if(this.findLinkDataForKey(e)!==null)return;this.et(t,i,e),s!==void 0&&this.Oe.delete(s),this.Oe.set(e,t),this.Ft("linkKey",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i)}}get makeUniqueLinkKeyFunction(){return this.Zf}set makeUniqueLinkKeyFunction(t){let e=this.Zf;e!==t&&(t!==null&&g.S(t,Yt,"makeUniqueLinkKeyFunction"),this.Zf=t,this.t("makeUniqueLinkKeyFunction",e,t))}findLinkDataForKey(t){return t===null&&g.o("GraphLinksModel.findLinkDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.Oe.get(t)}Ik(t){return t===void 0?!1:this.Oe.has(t)}makeLinkDataKeyUnique(t){if(t===null)return;let e=this.za;if(e==="")return;let i=this.getKeyForLinkData(t);if(i!==void 0&&!this.Ik(i))return;let s=this.Zf;if(s!==null&&(i=s(this,t),i!=null&&!this.Ik(i))){this.et(t,e,i);return}if(typeof i=="string"){let n=2;for(;this.Ik(i+n);)n++;this.et(t,e,i+n)}else if(i===void 0||typeof i=="number"){let n=-this.Oe.count-1;for(;this.Ik(n);)n--;this.et(t,e,n)}}containsLinkData(t){return t===null?!1:this.hr.has(t)}addLinkData(t){t!==null&&(this.containsLinkData(t)||this.Uv(t,!0))}Uv(t,e){if(this.linkKeyProperty!==""){let s=this.getKeyForLinkData(t);if(s===void 0)this.makeLinkDataKeyUnique(t),s=this.getKeyForLinkData(t);else{if(this.Oe.get(s)===t)return;this.makeLinkDataKeyUnique(t),s=this.getKeyForLinkData(t)}s===void 0&&g.o("GraphLinksModel.makeLinkDataKeyUnique failed on "+t+". Data not added to model."),this.Oe.set(s,t)}this.hr.add(t);let i=null;e&&(i=this.Is.length,this.ar(this.Is,i,t)),this.Ft("linkDataArray",3,"linkDataArray",this,null,t,null,i),this.oL(t)}addLinkDataCollection(t){if(Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++)this.addLinkData(t[i])}else{let e=t.iterator;for(;e.next();){let i=e.value;this.addLinkData(i)}}}removeLinkData(t){t!==null&&this.Ev(t,!0)}Ev(t,e){this.hr.delete(t);let i=this.getKeyForLinkData(t);i!==void 0&&this.Oe.delete(i);let s=null;if(e){if(s=this.Is.indexOf(t),s<0)return;this.Co(this.Is,s)}this.Ft("linkDataArray",4,"linkDataArray",this,t,null,s,null),this.f3(t)}removeLinkDataCollection(t){if(Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++)this.removeLinkData(t[i])}else{let e=t.iterator;for(;e.next();){let i=e.value;this.removeLinkData(i)}}}mergeLinkDataArray(t){if(this.linkKeyProperty===""&&g.o("GraphLinksModel.linkKeyProperty must not be an empty string for .mergeLinkDataArray() to succeed."),t===this.linkDataArray||!Array.isArray(t))return;let e=new I;e.addAll(this.Oe.iteratorKeys);let i=new I,s=t.length;for(let o=0;o<s;o++){let r=t[o],a=this.getKeyForLinkData(r);if(a!==void 0){i.add(a);let h=this.findLinkDataForKey(a);if(h===r)continue;if(h!==null)this.assignAllDataProperties(h,r),this.tF(r,h);else{let l=this.cloneDeep(r);this.setKeyForLinkData(l,a),this.addLinkData(l)}}else{let h=this.cloneDeep(r);this.addLinkData(h);let l=this.getKeyForLinkData(h);l!==void 0&&i.add(l)}}let n=e.iterator;for(;n.next();){let o=n.value;if(!i.has(o)){let r=this.findLinkDataForKey(o);r&&this.removeLinkData(r)}}}oL(t){let e=this.Vi(t,!0);e=this.nL(e),this.findNodeDataForKey(e)===null&&this.hn(e,t),e=this.Vi(t,!1),e=this.nL(e),this.findNodeDataForKey(e)===null&&this.hn(e,t);let i=this.getLabelKeysForLinkData(t);if(Array.isArray(i)){let s=i.length;for(let n=0;n<s;n++)e=i[n],this.findNodeDataForKey(e)===null&&this.hn(e,t)}}f3(t){let e=this.Vi(t,!0);this.an(e,t),e=this.Vi(t,!1),this.an(e,t);let i=this.getLabelKeysForLinkData(t);if(Array.isArray(i)){let s=i.length;for(let n=0;n<s;n++)e=i[n],this.an(e,t)}}get copyLinkDataFunction(){return this.Qf}set copyLinkDataFunction(t){let e=this.Qf;e!==t&&(t!==null&&g.S(t,Yt,"copyLinkDataFunction"),this.Qf=t,this.t("copyLinkDataFunction",e,t))}copyLinkData(t){let e=null,i=this.Qf;return i!==null?e=i(t,this):e=this.Ok(t,!0),g.$(e)&&(this.Lo!==""&&this.et(e,this.Lo,void 0),this.Ao!==""&&this.et(e,this.Ao,void 0),this.cn!==""&&this.et(e,this.cn,[])),e}get nodeIsGroupProperty(){return this._f}set nodeIsGroupProperty(t){let e=this._f;e!==t&&(this.Un(t,Yt,"nodeIsGroupProperty"),this._f=t,this.t("nodeIsGroupProperty",e,t))}isGroupForNodeData(t){if(t===null)return!1;let e=this._f;return e===""?!1:!!this.Mt(t,e)}isGroupForData(t){return this.isGroupForNodeData(t)}get nodeGroupKeyProperty(){return this.Vn}set nodeGroupKeyProperty(t){let e=this.Vn;e!==t&&(this.Un(t,Yt,"nodeGroupKeyProperty"),this.Vn=t,this.t("nodeGroupKeyProperty",e,t))}get copiesGroupKeyOfNodeData(){return this.Dg}set copiesGroupKeyOfNodeData(t){this.Dg!==t&&(g.s(t,"boolean",Yt,"copiesGroupKeyOfNodeData"),this.Dg=t)}getGroupKeyForNodeData(t){if(t===null)return;let e=this.Vn;if(e==="")return;let i=this.Mt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;g.o("GroupKey value for node data "+t+" is not a number or a string: "+i)}}getGroupForData(t){return this.getGroupKeyForNodeData(t)}setGroupKeyForNodeData(t,e){if(e===null&&(e=void 0),e!==void 0&&!this.isKeyType(e)&&g.si(e,"number or string",Yt,"setGroupKeyForNodeData:key"),t===null)return;let i=this.Vn;if(i==="")return;if(!this.containsNodeData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);s!==e&&(this.an(s,t),this.et(t,i,e),this.findNodeDataForKey(e)===null&&this.hn(e,t),this.Ft("nodeGroupKey",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i))}setGroupForData(t,e){this.setGroupKeyForNodeData(t,e)}copyNodeData(t){let e=super.copyNodeData(t);return!this.copiesGroupKeyOfNodeData&&this.Vn!==""&&this.Mt(e,this.Vn)!==void 0&&this.et(e,this.Vn,void 0),e}setDataProperty(t,e,i){if(this.containsNodeData(t)){if(e===this.nodeKeyProperty){this.setKeyForNodeData(t,i);return}else if(e===this.nodeCategoryProperty){this.setCategoryForNodeData(t,i);return}else if(e===this.nodeGroupKeyProperty){this.setGroupKeyForNodeData(t,i);return}}else if(this.containsLinkData(t)){if(e===this.linkFromKeyProperty){this.wg(t,i,!0);return}else if(e===this.linkToKeyProperty){this.wg(t,i,!1);return}else if(e===this.linkFromPortIdProperty){this.xg(t,i,!0);return}else if(e===this.linkToPortIdProperty){this.xg(t,i,!1);return}else if(e===this.linkKeyProperty){this.setKeyForLinkData(t,i);return}else if(e===this.linkCategoryProperty){this.setCategoryForLinkData(t,i);return}else if(e===this.linkLabelKeysProperty){this.setLabelKeysForLinkData(t,i);return}}let s=this.Mt(t,e);s!==i&&(this.et(t,e,i),this.raiseDataChanged(t,e,s,i))}assignAllDataProperties(t,e){if(!e)return;let i=this.containsNodeData(t),s=this.containsLinkData(t);for(let n in e)if(n!=="__gohashid"&&!(i&&n===this.nodeKeyProperty)){if(i&&n===this.nodeIsGroupProperty&&this.Mt(t,n)===e[n]||s&&n===this.linkKeyProperty)continue;this.setDataProperty(t,n,e[n])}}uw(t,e){super.uw(t,e);let i=this.be.iterator;for(;i.next();){let n=i.value;this.rL(n,t,e)}let s=this.hr.iterator;for(;s.next();){let n=s.value;this.u3(n,t,e)}}rL(t,e,i){if(this.getGroupKeyForNodeData(t)===e){let s=this.Vn;this.et(t,s,i),this.Ft("nodeGroupKey",2,s,t,e,i),typeof s=="string"&&this.updateTargetBindings(t,s)}}u3(t,e,i){if(this.Vi(t,!0)===e){let n=this.Lo;this.et(t,n,i),this.Ft("linkFromKey",2,n,t,e,i),typeof n=="string"&&this.updateTargetBindings(t,n)}if(this.Vi(t,!1)===e){let n=this.Ao;this.et(t,n,i),this.Ft("linkToKey",2,n,t,e,i),typeof n=="string"&&this.updateTargetBindings(t,n)}let s=this.getLabelKeysForLinkData(t);if(Array.isArray(s)){let n=s.length,o=this.cn;for(let r=0;r<n;r++)s[r]===e&&(this.qv(s,r,i),this.Ft("linkLabelKeys",3,o,t,e,i,r,r))}}iL(){super.iL();let t=this.linkDataArray,e=t.length;for(let i=0;i<e;i++){let s=t[i];this.oL(s)}}Ag(t){super.Ag(t);let e=this.getKeyForNodeData(t),i=this.ow(e);if(i!==null){let s=g.ot(),n=i.iterator;for(;n.next();){let o=n.value;if(this.containsNodeData(o)){if(this.getGroupKeyForNodeData(o)===e){let r=this.Vn;this.Ft("nodeGroupKey",2,r,o,e,e),typeof r=="string"&&this.updateTargetBindings(o,r),s.push(o)}}else{if(this.Vi(o,!0)===e){let a=this.Lo;this.Ft("linkFromKey",2,a,o,e,e),typeof a=="string"&&this.updateTargetBindings(o,a),s.push(o)}if(this.Vi(o,!1)===e){let a=this.Ao;this.Ft("linkToKey",2,a,o,e,e),typeof a=="string"&&this.updateTargetBindings(o,a),s.push(o)}let r=this.getLabelKeysForLinkData(o);if(Array.isArray(r)){let a=r.length,h=this.cn;for(let l=0;l<a;l++)r[l]===e&&(this.Ft("linkLabelKeys",3,h,o,e,e,l,l),s.push(o))}}}for(let o=0;o<s.length;o++)this.an(e,s[o]);g.Z(s)}}Tg(t){super.Tg(t);let e=this.getGroupKeyForNodeData(t);this.findNodeDataForKey(e)===null&&this.hn(e,t)}dw(t){super.dw(t);let e=this.getGroupKeyForNodeData(t);this.an(e,t)}get linkCategoryProperty(){return this.hc}set linkCategoryProperty(t){let e=this.hc;e!==t&&(this.Un(t,Yt,"linkCategoryProperty"),this.hc=t,this.t("linkCategoryProperty",e,t))}getCategoryForLinkData(t){if(t===null)return"";let e=this.hc;if(e==="")return"";let i=this.Mt(t,e);if(i===void 0)return"";if(typeof i=="string")return i;g.o("getCategoryForLinkData found a non-string category for "+t+": "+i)}getLinkCategoryForData(t){return this.getCategoryForLinkData(t)}setCategoryForLinkData(t,e){if(g.s(e,"string",Yt,"setCategoryForLinkData:cat"),t===null)return;let i=this.hc;if(i==="")return;if(!this.containsLinkData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);s===void 0&&(s=""),s!==e&&(this.et(t,i,e),this.Ft("linkCategory",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i))}setLinkCategoryForData(t,e){this.setCategoryForLinkData(t,e)}Lg(t,e){super.Lg(t,e),this.setGroupKeyForNodeData(e,this.getGroupKeyForNodeData(t))}tF(t,e){this.setCategoryForLinkData(e,this.getCategoryForLinkData(t)),this.setFromKeyForLinkData(e,this.getFromKeyForLinkData(t)),this.setToKeyForLinkData(e,this.getToKeyForLinkData(t)),this.setLabelKeysForLinkData(e,this.getLabelKeysForLinkData(t)),this.setFromPortIdForLinkData(e,this.getFromPortIdForLinkData(t)),this.setToPortIdForLinkData(e,this.getToPortIdForLinkData(t))}get type(){return"GraphLinksModel"}Em(){return!0}jh(){return!0}Lx(){return!0}ff(){return!0}static EmptyArray=Object.freeze([])}mt.Sl(Yt,"GraphLinksModel"),mt.jv=()=>new Yt,mt.g2=()=>new Yt;class Qe extends mt{Bn;vg;cc;constructor(t,e){if(super(),this.Bn="parent",this.vg=!1,this.cc="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:e=t),e){Object.assign(this,e);let i=e.Changed;i&&(delete this.Changed,this.addChangedListener(i))}}cloneProtected(t){super.cloneProtected(t),t.Bn=this.Bn,t.vg=this.vg,t.cc=this.cc}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let e=(this.name!==""?this.name:"")+" TreeModel";if(t>0){e+=`
51
+ node data:`;let i=this.nodeDataArray,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+this.getKeyForNodeData(o)+":"+re.toString(o)}}return e}}Cg(){let t=super.Cg(),e="";return this.nodeParentKeyProperty!=="parent"&&typeof this.nodeParentKeyProperty=="string"&&(e+=`,
52
+ "nodeParentKeyProperty": `+this.zi(this.nodeParentKeyProperty)),t+e}cw(t){super.cw(t),t.nodeParentKeyProperty&&(this.nodeParentKeyProperty=t.nodeParentKeyProperty)}fw(t){t.nodeParentKeyProperty!==void 0&&t.nodeParentKeyProperty!==this.nodeParentKeyProperty&&g.o("applyIncrementalJson cannot change Model properties"),super.fw(t)}maybeEnsureLinkReference(t){return t}get nodeParentKeyProperty(){return this.Bn}set nodeParentKeyProperty(t){let e=this.Bn;e!==t&&(this.Un(t,Qe,"nodeParentKeyProperty"),this.Bn=t,this.t("nodeParentKeyProperty",e,t))}get copiesParentKeyOfNodeData(){return this.vg}set copiesParentKeyOfNodeData(t){this.vg!==t&&(g.s(t,"boolean",Qe,"copiesParentKeyOfNodeData"),this.vg=t)}getParentKeyForNodeData(t){if(t===null)return;let e=this.Bn;if(e==="")return;let i=this.Mt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;g.o("ParentKey value for node data "+t+" is not a number or a string: "+i)}}setParentKeyForNodeData(t,e){if(e===null&&(e=void 0),e!==void 0&&!this.isKeyType(e)&&g.si(e,"number or string",Qe,"setParentKeyForNodeData:key"),t===null)return;let i=this.Bn;if(i==="")return;if(e=this.maybeEnsureLinkReference(e),!this.containsNodeData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);s!==e&&(this.an(s,t),this.et(t,i,e),this.findNodeDataForKey(e)===null&&this.hn(e,t),this.Ft("nodeParentKey",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i))}get parentLinkCategoryProperty(){return this.cc}set parentLinkCategoryProperty(t){let e=this.cc;e!==t&&(this.Un(t,Qe,"parentLinkCategoryProperty"),this.cc=t,this.t("parentLinkCategoryProperty",e,t))}get linkCategoryProperty(){return this.parentLinkCategoryProperty}set linkCategoryProperty(t){this.parentLinkCategoryProperty=t}getParentLinkCategoryForNodeData(t){if(t===null)return"";let e=this.cc;if(e==="")return"";let i=this.Mt(t,e);if(i===void 0)return"";if(typeof i=="string")return i;g.o("getParentLinkCategoryForNodeData found a non-string category for "+t+": "+i)}getLinkCategoryForData(t){return this.getParentLinkCategoryForNodeData(t)}setParentLinkCategoryForNodeData(t,e){if(g.s(e,"string",Qe,"setParentLinkCategoryForNodeData:cat"),t===null)return;let i=this.cc;if(i==="")return;if(!this.containsNodeData(t)){this.et(t,i,e);return}let s=this.Mt(t,i);s===void 0&&(s=""),s!==e&&(this.et(t,i,e),this.Ft("parentLinkCategory",2,i,t,s,e),typeof i=="string"&&this.updateTargetBindings(t,i))}setLinkCategoryForData(t,e){this.setParentLinkCategoryForNodeData(t,e)}copyNodeData(t){let e=super.copyNodeData(t);return!this.copiesParentKeyOfNodeData&&this.Bn!==""&&this.Mt(e,this.Bn)!==void 0&&this.et(e,this.Bn,void 0),e}setDataProperty(t,e,i){if(this.containsNodeData(t)){if(e===this.nodeKeyProperty){this.setKeyForNodeData(t,i);return}else if(e===this.nodeCategoryProperty){this.setCategoryForNodeData(t,i);return}else if(e===this.nodeParentKeyProperty){this.setParentKeyForNodeData(t,i);return}else if(e===this.parentLinkCategoryProperty){this.setParentLinkCategoryForNodeData(t,i);return}}let s=this.Mt(t,e);s!==i&&(this.et(t,e,i),this.raiseDataChanged(t,e,s,i))}uw(t,e){super.uw(t,e);let i=this.be.iterator;for(;i.next();){let s=i.value;this.rL(s,t,e)}}rL(t,e,i){if(this.getParentKeyForNodeData(t)===e){let s=this.Bn;this.et(t,s,i),this.Ft("nodeParentKey",2,s,t,e,i),typeof s=="string"&&this.updateTargetBindings(t,s)}}Ag(t){super.Ag(t);let e=this.getKeyForNodeData(t),i=this.ow(e);if(i!==null){let s=g.ot(),n=i.iterator;for(;n.next();){let o=n.value;if(this.containsNodeData(o)&&this.getParentKeyForNodeData(o)===e){let r=this.Bn;this.Ft("nodeParentKey",2,r,o,e,e),typeof r=="string"&&this.updateTargetBindings(o,r),s.push(o)}}for(let o=0;o<s.length;o++)this.an(e,s[o]);g.Z(s)}}Tg(t){super.Tg(t);let e=this.getParentKeyForNodeData(t);e=this.maybeEnsureLinkReference(e),this.findNodeDataForKey(e)===null&&this.hn(e,t)}dw(t){super.dw(t);let e=this.getParentKeyForNodeData(t);this.an(e,t)}Lg(t,e){super.Lg(t,e),this.setParentLinkCategoryForNodeData(e,this.getParentLinkCategoryForNodeData(t)),this.setParentKeyForNodeData(e,this.getParentKeyForNodeData(t))}get type(){return"TreeModel"}Um(){return!0}Lx(){return!0}}mt.Sl(Qe,"TreeModel");var Bs=(x=>(x[x.ConstantSpacing=0]="ConstantSpacing",x[x.ConstantDistance=1]="ConstantDistance",x[x.ConstantAngle=2]="ConstantAngle",x[x.Packed=3]="Packed",x))(Bs||{}),Vs=(x=>(x[x.Clockwise=10]="Clockwise",x[x.Counterclockwise=11]="Counterclockwise",x[x.BidirectionalLeft=12]="BidirectionalLeft",x[x.BidirectionalRight=13]="BidirectionalRight",x))(Vs||{}),zs=(x=>(x[x.Forwards=20]="Forwards",x[x.Reverse=21]="Reverse",x[x.Ascending=22]="Ascending",x[x.Descending=23]="Descending",x[x.Optimized=24]="Optimized",x))(zs||{}),Ks=(x=>(x[x.Pythagorean=30]="Pythagorean",x[x.Circular=31]="Circular",x))(Ks||{});class _e extends oe{di;tu;Ek;Fg;Uk;Xa;lL;aL;hL;Es;gw;mw;fc;pw;eF;Rg;Og;Ig;eu;He;P;Si;Mi;En;Eg;constructor(t){super(),this.di=0,this.tu=0,this.Ek=0,this.Fg=360,this.Uk=0,this.Xa=0,this.lL=new P,this.aL=30,this.hL=0,this.Es=0,this.gw=0,this.mw=new En,this.fc=0,this.pw=0,this.eF=600,this.Rg=NaN,this.Og=1,this.Ig=0,this.eu=360,this.He=0,this.P=10,this.Si=24,this.Mi=Ze.standardComparer,this.En=6,this.Eg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Rg=this.Rg,t.Og=this.Og,t.Ig=this.Ig,t.eu=this.eu,t.He=this.He,t.P=this.P,t.Si=this.Si,t.Mi=this.Mi,t.En=this.En,t.Eg=this.Eg}fe(t){t in zs?this.sorting=t:t in Vs?this.direction=t:t in Bs?this.arrangement=t:t in Ks?this.nodeDiameterFormula=t:super.fe(t)}createNetwork(){return new In(this)}d3(t,e,i){t=this.g3(t);let s=this.Uk,n=this.aL,o=this.di,r=this.tu,a=this.Ek,h=this.Fg,l=this.Xa,c=this.hL,u=this.Es,d=this.gw;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),a=this.startAngle,isFinite(a)||(a=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),l=this.spacing,isFinite(l)||(l=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let m=0;!(m>=t.length||(e.add(t.elt(m)),m+1>=t.length));m+=2)i.add(t.elt(m+1));this.direction===12?(this.arrangement===3&&e.reverse(),t=new U,t.addAll(e),t.addAll(i)):(this.arrangement===3&&i.reverse(),t=new U,t.addAll(i),t.addAll(e))}let f=t.length;c=0;let p=0;for(let m=0;m<t.length;m++){let y=a+h*p*(this.direction===10?1:-1)/f,b=t.elt(m).diameter;isNaN(b)&&(b=t.elt(m).Ga(y)),h<360&&(m===0||m===t.length-1)&&(b/=2),c+=b,p++}if(isNaN(o)||s===3){if(isNaN(l)&&(l=6),s!==0&&s!==3){let m=-1/0;for(let y=0;y<f;y++){let b=t.elt(y),v=t.elt(y===f-1?0:y+1);isNaN(b.diameter)&&b.Ga(0),isNaN(v.diameter)&&v.Ga(0),m=Math.max(m,(b.diameter+v.diameter)/2)}if(d=m+l,s===2){let y=2*Math.PI/f,b=(m+l)/y;r>1?(o=b,u=o*r):(u=b,o=u)}else o=this.Vk(d*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180)}else o=this.Vk(c+(h>=360?f:f-1)*(s!==3?l:l*1.6),r,a*Math.PI/180,h*Math.PI/180);u=o*r}else{u=o*r;let m=this.cL(o,u,a*Math.PI/180,h*Math.PI/180);if(isNaN(l))s===0&&(l=(m-c)/(h>=360?f:f-1));else if(s===0){let y=(m-c)/(h>=360?f:f-1);y<l?(o=this.Vk(c+l*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180),u=o*r):l=y}else{let y=-1/0;for(let w=0;w<f;w++){let k=t.elt(w),S=t.elt(w===f-1?0:w+1);isNaN(k.diameter)&&k.Ga(0),isNaN(S.diameter)&&S.Ga(0),y=Math.max(y,(k.diameter+S.diameter)/2)}let b=y+l,v=this.Vk(b*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180);v>o?(o=v,u=o*r,d=b):d=m/(h>=360?f:f-1)}}return this.Uk=s,this.aL=n,this.di=o,this.tu=r,this.Ek=a,this.Fg=h,this.Xa=l,this.hL=c,this.Es=u,this.gw=d,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);let e=this.network.vertexes;if(e.count<=1){if(e.count===1){let d=e.first();d.centerX=0,d.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let i=new U;i.addAll(e.iterator);let s=new U,n=new U;i=this.d3(i,s,n);let o=this.Uk,r=this.di,a=this.Ek,h=this.Fg,l=this.Xa,c=this.Es,u=this.gw;if((this.direction===12||this.direction===13)&&o===3)this.iF(i,h,a-h/2,10);else if(this.direction===12||this.direction===13){let d=0;switch(o){case 1:d=this.Bk(r,c,a,u)*180/Math.PI;break;case 0:{let f=0,p=0,m=s.first();m!==null&&(f=m.Ga(Math.PI/2));let y=n.first();y!==null&&(p=y.Ga(Math.PI/2)),d=this.Bk(r,c,a,l+(f+p)/2)*180/Math.PI;break}case 2:d=h/i.length;break}if(this.direction===12){switch(o){case 1:this.yw(s,h/2,a,11);break;case 0:this.ww(s,h/2,a,11);break;case 2:this.xw(s,h/2,a,11);break}switch(o){case 1:this.yw(n,h/2,a+d,10);break;case 0:this.ww(n,h/2,a+d,10);break;case 2:this.xw(n,h/2,a+d,10);break}}else{switch(o){case 1:this.yw(n,h/2,a,11);break;case 0:this.ww(n,h/2,a,11);break;case 2:this.xw(n,h/2,a,11);break}switch(o){case 1:this.yw(s,h/2,a+d,10);break;case 0:this.ww(s,h/2,a+d,10);break;case 2:this.xw(s,h/2,a+d,10);break}}}else switch(o){case 1:this.yw(i,h,a,this.direction);break;case 0:this.ww(i,h,a,this.direction);break;case 2:this.xw(i,h,a,this.direction);break;case 3:this.iF(i,h,a,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}xw(t,e,i,s){let n=this.Fg,o=this.di,r=this.Es,a=i*Math.PI/180,h=e*Math.PI/180,l=t.length;for(let c=0;c<l;c++){let u=a+(s===10?c*h/(n>=360?l:l-1):-(c*h)/l),d=t.elt(c),f=o*Math.tan(u)/r,p=Math.sqrt((o*o+r*r*f*f)/(1+f*f));d.centerX=p*Math.cos(u),d.centerY=p*Math.sin(u),d.actualAngle=u*180/Math.PI}}ww(t,e,i,s){let n=this.di,o=this.Es,r=this.Xa,a=i*Math.PI/180,h=t.length;for(let l=0;l<h;l++){let c=t.elt(l),u=t.elt(l===h-1?0:l+1),d=n*Math.cos(a),f=o*Math.sin(a);c.centerX=d,c.centerY=f,c.actualAngle=a*180/Math.PI,isNaN(c.diameter)&&c.Ga(0),isNaN(u.diameter)&&u.Ga(0);let p=(c.diameter+u.diameter)/2,m=this.Bk(n,o,s===10?a:-a,p+r);a+=s===10?m:-m}}yw(t,e,i,s){let n=this.di,o=this.Es,r=this.gw,a=i*Math.PI/180,h=t.length;for(let l=0;l<h;l++){let c=t.elt(l);c.centerX=n*Math.cos(a),c.centerY=o*Math.sin(a),c.actualAngle=a*180/Math.PI;let u=this.Bk(n,o,s===10?a:-a,r);a+=s===10?u:-u}}iF(t,e,i,s){let n=this.pw,o=this.Fg;if(this.fc=0,this.mw=new En,e<360){for(n=i+(s===10?o:-o);n<0;)n+=360;n%=360,n>180&&(n-=360),n*=Math.PI/180,this.pw=n,this.sF(t,e,i,s)}else this.nF(t,e,i,s);this.mw.commit(t)}nF(t,e,i,s){let n=this.di,o=this.Es,r=this.Xa,a=this.tu,h=n*Math.cos(i*Math.PI/180),l=o*Math.sin(i*Math.PI/180),c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}let u=P.l();for(let k=0;k<c.length&&(c[k].centerX=h,c[k].centerY=l,!(k>=c.length-1));k++)this.oF(h,l,c,k,s,u)||this.rF(h,l,c,k,s,u),h=u.x,l=u.y;if(P.i(u),this.fc++,this.fc>23)return;let d=c[0].centerX,f=c[0].centerY,p=c[c.length-1].centerX,m=c[c.length-1].centerY,y=Math.abs(d-p)-((c[0].width+c[c.length-1].width)/2+r),b=Math.abs(f-m)-((c[0].height+c[c.length-1].height)/2+r),v=0;if(Math.abs(b)<1){let k=Math.abs(d-p),S=(c[0].width+c[c.length-1].width)/2;k<S&&(v=0),y=k-S}else b>0?v=b:Math.abs(y)<1?v=0:v=y;let w=!1;Math.abs(p)>Math.abs(m)?w=p>0!=f>m:w=m>0!=d<p,w=s===10?w:!w,w&&(v=-Math.abs(v),v=Math.min(v,-c[c.length-1].width),v=Math.min(v,-c[c.length-1].height)),this.mw.m3(v,c),Math.abs(v)>1&&(this.fc<8?this.di-=v/(2*Math.PI):c.length<5&&v>10?this.di/=2:this.di-=v>0?1.7:-2.3,this.Es=this.di*a,this.nF(t,e,i,s))}sF(t,e,i,s){let n=this.di,o=this.Es,r=this.tu,a=n*Math.cos(i*Math.PI/180),h=o*Math.sin(i*Math.PI/180),l=P.l(),c=t.toArray();for(let p=0;p<c.length&&(c[p].centerX=a,c[p].centerY=h,!(p>=c.length-1));p++)this.oF(a,h,c,p,s,l)||this.rF(a,h,c,p,s,l),a=l.x,h=l.y;if(P.i(l),this.fc++,this.fc>23)return;let u=Math.atan2(h,a),d=s===10?this.pw-u:u-this.pw;d=Math.abs(d)<Math.abs(d-2*Math.PI)?d:d-2*Math.PI;let f=d*(n+o)/2;this.mw.p3(f,c),Math.abs(f)>1&&(this.fc<8?this.di-=f/(2*Math.PI):this.di-=f>0?1.7:-2.3,this.Es=this.di*r,this.sF(t,e,i,s))}oF(t,e,i,s,n,o){let r=this.Xa,a=this.di,h=this.Es,l=0,c=0,u=(i[s].width+i[s+1].width)/2+r,d=!1;if(e>=0!=(n===10)){if(l=t+u,l>a){if(l=t-u,l<-a)return o.x=l,o.y=c,!1;d=!0}}else if(l=t-u,l<-a){if(l=t+u,l>a)return o.x=l,o.y=c,!1;d=!0}return c=Math.sqrt(1-Math.min(1,l*l/(a*a)))*h,e<0!==d&&(c=-c),Math.abs(e-c)>(i[s].height+i[s+1].height)/2?(o.x=l,o.y=c,!1):(o.x=l,o.y=c,!0)}rF(t,e,i,s,n,o){let r=this.Xa,a=this.di,h=this.Es,l=0,c=0,u=(i[s].height+i[s+1].height)/2+r,d=!1;if(t>=0!=(n===10)){if(c=e-u,c<-h){if(c=e+u,c>h)return o.x=l,o.y=c,!1;d=!0}}else if(c=e+u,c>h){if(c=e-u,c<-h)return o.x=l,o.y=c,!1;d=!0}return l=Math.sqrt(1-Math.min(1,c*c/(h*h)))*a,t<0!==d&&(l=-l),Math.abs(t-l)>(i[s].width+i[s+1].width)/2?(o.x=l,o.y=c,!1):(o.x=l,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){let t=this.group!==null&&this.group.hasPlaceholder(),e=t?this.group.location.copy():null,i=this.actualCenter;if(t?i=new P(0,0):(i.x=this.arrangementOrigin.x+this.di,i.y=this.arrangementOrigin.y+this.Es),this.network!==null){let s=this.network.vertexes.iterator;for(;s.next();){let n=s.value;n.x+=i.x,n.y+=i.y,n.commit()}}if(t&&this.group&&e){this.group.ensureBounds();let s=this.group.position.copy(),n=this.group.location.copy(),o=e.subtract(n.subtract(s));this.group.move(o),this.lL=o.subtract(s)}}commitLinks(){if(this.network!==null){let t=this.network.edges.iterator;for(;t.next();)t.value.commit()}}cL(t,e,i,s){let n=this.eF;if(Math.abs(this.tu-1)<.001)return i!==void 0&&s!==void 0?s*t:2*Math.PI*t;let o=t>e?Math.sqrt(t*t-e*e)/t:Math.sqrt(e*e-t*t)/e,r=0,a=0;i!==void 0&&s!==void 0?a=s/(n+1):a=Math.PI/(2*(n+1));let h=0;for(let l=0;l<=n;l++){i!==void 0&&s!==void 0?h=i+l*s/n:h=l*Math.PI/(2*n);let c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*a}return i!==void 0&&s!==void 0?(t>e?t:e)*r:4*(t>e?t:e)*r}Vk(t,e,i,s){let n=0;return i!==void 0&&s!==void 0?n=this.cL(1,e,i,s):n=this.cL(1,e),t/n}Bk(t,e,i,s){if(Math.abs(this.tu-1)<.001)return s/t;let n=t>e?Math.sqrt(t*t-e*e)/t:Math.sqrt(e*e-t*t)/e,o=0,r=2*Math.PI/(this.network.vertexes.count*700);t>e&&(i+=Math.PI/2);for(let a=0;;a++){let h=i+a*r,l=Math.sin(h);if(o+=(t>e?t:e)*Math.sqrt(1-n*n*l*l)*r,o>=s)return a*r}}g3(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.y3(this.w3(t));default:g.o("Invalid sorting type.")}return t}w3(t){let e=[];for(let s=0;s<t.length;s++)e.push(0);let i=new U;for(let s=0;s<t.length;s++){let n=-1,o=-1;if(s===0)for(let c=0;c<t.length;c++){let u=t.elt(c).edgesCount;u>n&&(n=u,o=c)}else for(let c=0;c<t.length;c++){let u=e[c];u>n&&(n=u,o=c)}i.add(t.elt(o)),e[o]=-1;let r=t.elt(o),a=0,h=r.sourceEdges;for(;h.next();){let c=h.value.fromVertex;a=t.indexOf(c),!(a<0)&&e[a]>=0&&e[a]++}let l=r.destinationEdges;for(;l.next();){let c=l.value.toVertex;a=t.indexOf(c),!(a<0)&&e[a]>=0&&e[a]++}}return i}y3(t){let e=[];for(let u=0;u<t.length;u++){let d=t.elt(u);e[u]=[];let f=0,p=d.destinationEdges;for(;p.next();){let y=p.value.toVertex;f=t.indexOf(y),f!==u&&e[u].indexOf(f)<0&&e[u].push(f)}let m=d.sourceEdges;for(;m.next();){let y=m.value.fromVertex;f=t.indexOf(y),f!==u&&e[u].indexOf(f)<0&&e[u].push(f)}}let i=[];for(let u=0;u<e.length;u++)i[u]=0;let s=[],n=[],o=[],r=[],a=new U,h=0;for(let u=0;u<e.length;u++){let d=e[u].length;if(d===1){r.push(u);continue}if(d===0){a.add(t.elt(u));continue}if(h===0){s.push(u),h++;continue}let f=1/0,p=1/0,m=-1,y=[];for(let b=0;b<s.length;b++)e[s[b]].indexOf(s[b===s.length-1?0:b+1])<0&&y.push(b===s.length-1?0:b+1);if(y.length===0)for(let b=0;b<s.length;b++)y.push(b);for(let b=0;b<y.length;b++){let v=y[b],w=this.x3(e[u],n,o,i,v,s),k=0;for(let S=0;S<e[u].length;S++){let M=e[u][S],F=s.indexOf(M);if(F>=0){let D=Math.abs(v-(F>=v?F+1:F));k+=D<s.length+1-D?D:s.length+1-D}}for(let S=0;S<n.length;S++){let M=i[n[S]],F=i[o[S]];if(M>=v&&M++,F>=v&&F++,M>F){let D=F;F=M,M=D}F-M<(s.length+2)/2==(M<v&&v<=F)&&k++}(w<f||w===f&&k<p)&&(f=w,p=k,m=v)}s.splice(m,0,u);for(let b=0;b<s.length;b++)i[s[b]]=b;for(let b=0;b<e[u].length;b++){let v=e[u][b];s.indexOf(v)>=0&&(n.push(u),o.push(v))}h++}let l=!1,c=s.length;for(;;){l=!0;for(let u=0;u<r.length;u++){let d=r[u],f=e[d][0],p=s.indexOf(f);if(p>=0){let m=0;for(let y=0;y<e[f].length;y++){let b=e[f][y],v=s.indexOf(b);if(v<0||v===p)continue;let w=v>p?v-p:p-v,k=c-w;m+=v<p!=w>k?1:-1}s.splice(m<0?p:p+1,0,d),r.splice(u,1),u--}else l=!1}if(l)break;s.push(r[0]),r.splice(0,1)}for(let u=0;u<s.length;u++){let d=s[u];a.add(t.elt(d))}return a}x3(t,e,i,s,n,o){let r=0;for(let a=0;a<e.length;a++){let h=e[a],l=i[a],c=s[h],u=s[l],d=0,f=0;if(c<u?(d=c,f=u):(d=u,f=c),d<n&&n<=f)for(let p=0;p<t.length;p++){let m=t[p];o.indexOf(m)<0||d<s[m]&&s[m]<f||d===s[m]||f===s[m]||r++}else for(let p=0;p<t.length;p++){let m=t[p];o.indexOf(m)<0||!(d<s[m]&&s[m]<f)||d===s[m]||f===s[m]||r++}}return r}get radius(){return this.Rg}set radius(t){this.Rg!==t&&(g.s(t,"number",_e,"radius"),(t>0||isNaN(t))&&(this.Rg=t,this.p()))}get aspectRatio(){return this.Og}set aspectRatio(t){this.Og!==t&&(g.s(t,"number",_e,"aspectRatio"),t>0&&(this.Og=t,this.p()))}get startAngle(){return this.Ig}set startAngle(t){this.Ig!==t&&(g.s(t,"number",_e,"startAngle"),this.Ig=t,this.p())}get sweepAngle(){return this.eu}set sweepAngle(t){this.eu!==t&&(g.s(t,"number",_e,"sweepAngle"),t>0&&t<=360?this.eu=t:this.eu=360,this.p())}get arrangement(){return this.He}set arrangement(t){this.He!==t&&(t===3||t===0||t===1||t===2)&&(this.He=t,this.p())}get direction(){return this.P}set direction(t){this.P!==t&&(t===10||t===11||t===12||t===13)&&(this.P=t,this.p())}get sorting(){return this.Si}set sorting(t){this.Si!==t&&(this.Si=t,this.p())}get comparer(){return this.Mi}set comparer(t){this.Mi!==t&&(g.S(t,_e,"comparer"),this.Mi=t,this.p())}get spacing(){return this.En}set spacing(t){this.En!==t&&(g.s(t,"number",_e,"spacing"),this.En=t,this.p())}get nodeDiameterFormula(){return this.Eg}set nodeDiameterFormula(t){this.Eg!==t&&(t===30||t===31)&&(this.Eg=t,this.p())}get actualXRadius(){return this.di}get actualYRadius(){return this.Es}get actualSpacing(){return this.Xa}get actualCenter(){return this.lL}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class En{iu;uc;su;constructor(){this.iu=-1/0,this.uc=null,this.su=null}m3(t,e){if(t>0&&this.iu<0||Math.abs(t)<Math.abs(this.iu)&&!(t<0&&this.iu>0)){this.iu=t,this.uc=[],this.su=[];for(let i=0;i<e.length;i++)this.uc[i]=e[i].bounds.x,this.su[i]=e[i].bounds.y}}p3(t,e){if(Math.abs(t)<Math.abs(this.iu)){this.iu=t,this.uc=[],this.su=[];for(let i=0;i<e.length;i++)this.uc[i]=e[i].bounds.x,this.su[i]=e[i].bounds.y}}commit(t){if(!(this.uc===null||this.su===null))for(let e=0;e<this.uc.length;e++){let i=t.elt(e);i.x=this.uc[e],i.y=this.su[e]}}}class In extends Je{constructor(t){super(t)}createVertex(){return new zi(this)}createEdge(){return new Bn(this)}}class zi extends Ze{To;zk;constructor(t){super(t),this.To=NaN,this.zk=NaN}Ga(t){let e=this.network;if(e===null)return NaN;let i=e.layout;if(i===null)return NaN;if(i.arrangement===3){if(i.nodeDiameterFormula===31)return this.To=Math.max(this.width,this.height),this.To;{let s=Math.abs(Math.sin(t)),n=Math.abs(Math.cos(t));return s===0?this.width:n===0?this.height:(this.To=Math.min(this.height/s,this.width/n),this.To)}}else return i.nodeDiameterFormula===31?(this.To=Math.max(this.width,this.height),this.To):(this.To=Math.sqrt(this.width*this.width+this.height*this.height),this.To)}get diameter(){return this.To}set diameter(t){this.To!==t&&(g.s(t,"number",zi,"diameter"),this.To=t)}get actualAngle(){return this.zk}set actualAngle(t){this.zk!==t&&(g.s(t,"number",zi,"actualAngle"),this.zk=t)}}class Bn extends xi{constructor(t){super(t)}}class ae extends oe{bw;Ya;Us;Ug;zn;Xi;Vg;Bg;zg;nu;Xg;Gg;ou;ru;lu;au;Yg;Kg;hu;dc;constructor(t){super(),this.bw=0,this.Ya=0,this.Us=new _(100,100).b(),this.Ug=!1,this.zn=!0,this.Xi=!1,this.Vg=100,this.Bg=300,this.zg=1,this.nu=1e3,this.Xg=10,this.Gg=Math,this.ou=.05,this.ru=50,this.lu=150,this.au=0,this.Yg=10,this.Kg=5,this.hu=NaN,this.dc=10,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Us.h(this.Us),t.Ug=this.Ug,t.zn=this.zn,t.Xi=this.Xi,t.Vg=this.Vg,t.Bg=this.Bg,t.zg=this.zg,t.nu=this.nu,t.Xg=this.Xg,t.Gg=this.Gg,t.ou=this.ou,t.ru=this.ru,t.lu=this.lu,t.au=this.au,t.Yg=this.Yg,t.Kg=this.Kg,t.hu=this.hu,t.dc=this.dc}createNetwork(){return new Vn(this)}doLayout(t){this.network=this.makeNetwork(t);let e=this.network.vertexes.iterator,i=this.maxIterations;if(this.network.vertexes.count>0){for(this.network.deleteSelfEdges(),e=this.network.vertexes.iterator;e.next();){let n=e.value;n.charge=this.electricalCharge(n),n.mass=this.gravitationalMass(n)}let s=this.network.edges.iterator;for(;s.next();){let n=s.value;n.stiffness=this.springStiffness(n),n.length=this.springLength(n)}if(this.fL(),this.Ya=0,this.needsPrelayout()){let n=this.network,o=n.splitIntoSubNetworks(!1),r=o.iterator;for(;r.next();){let a=r.value;this.doConnectedSubnetLayout(a)}for(r=o.iterator,this.b3(r,n),r=o.iterator;r.next();){let a=r.value,h=a.vertexes.iterator;for(;h.next();){let c=h.value;n.addVertex(c)}let l=a.edges.iterator;for(;l.next();){let c=l.value;n.addEdge(c)}}}else this.lF(this.network,this.maxIterations);this.updateParts()}this.maxIterations=i,this.isValidLayout=!0}needsPrelayout(){if(this.network===null||this.network.vertexes.count<3)return!1;let t=0,e=0,i=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){let n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(i)&&(t++,t>2))return!0;if(e>10)return!1;e++}return!1}doConnectedSubnetLayout(t){let e=t.vertexes.iterator;for(;e.next();){let a=e.value;a.hierarchicalVertexes.add(a)}let i=t,s=this.hu;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),s<t.vertexes.count)for(;i.vertexes.count>Math.max(100,Math.sqrt(s*t.vertexes.count));)i=this.coarsenNetwork(i);let n=0;e=i.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new zn(0));e.next();){e.value.idInCluster=n++;let a=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(e.value)||(e.value.x=a,e.value.y=h);let l=e.value.hierarchicalVertexes.iterator;for(;l.next();)this.isFixed(l.value)||(l.value.x=a,l.value.y=h)}let r=this.computePairwiseDistances(i);this.k3(i,r,this.maxPrelayoutIterations,t.vertexes.count),this.lF(t,this.maxIterations)}computePairwiseDistances(t){let e=t.vertexes.count,i=new Array(e);for(let r=0;r<e;r++)i[r]=new Array(e).fill(-1),i[r][r]=0;let s=t.vertexes.iterator,n=new Map,o=[];for(;s.next();){let r=s.value;for(o=[r],n=new Map,n.set(r.idInCluster,0);o.length>0;){let a=o.shift(),h=a.vertexes.iterator;for(;h.next();){let l=h.value;n.has(l.idInCluster)||(n.set(l.idInCluster,n.get(a.idInCluster)+1),o.push(l))}}for(let a=0;a<e;a++){let h=Math.min(i[r.idInCluster][a],i[a][r.idInCluster]),l=n.get(a);(h<0||l<h)&&(i[r.idInCluster][a]=l,i[a][r.idInCluster]=l)}}return i}coarsenNetwork(t){let e=this.createNetwork(),i=new Map,s=0,n=t.vertexes.iterator;for(;n.next();)n.value.idInCluster=s++;for(n=t.vertexes.iterator;n.next();){let r=n.value;if(i.has(r.idInCluster))continue;let a=Number.MAX_SAFE_INTEGER,h=null,l=r.vertexes.iterator;for(;l.next();){let u=l.value;i.has(u.idInCluster)||u.hierarchicalVertexes.length<a&&(a=u.hierarchicalVertexes.length,h=u)}let c=e.createVertex();c.hierarchicalVertexes.addAll(r.hierarchicalVertexes),h!=null&&c.hierarchicalVertexes.addAll(h.hierarchicalVertexes),i.set(r.idInCluster,c),h!=null&&i.set(h.idInCluster,c),e.addVertex(c)}let o=t.edges.iterator;for(;o.next();){let r=o.value,a=i.get(r.fromVertex.idInCluster),h=i.get(r.toVertex.idInCluster);if(a===h)continue;let l=e.createEdge();l.fromVertex=a||null,l.toVertex=h||null,e.addEdge(l)}return e}hx(t,e){let i=!0,s=t.vertexes.iterator;for(;s.next();){let n=s.value;i?(i=!1,e.set(n.bounds)):e.unionRect(n.bounds)}return e}b3(t,e){let i=this.arrangementSpacing,s=t.count,n=!0,o=0,r=0,a=g.ot();for(let u=0;u<s+e.vertexes.count+2;u++)a[u]=null;let h=0;t.reset();let l=B.l(),c;for(;t.next();){let u=t.value;if(this.hx(u,l),n)n=!1,o=l.x+l.width/2,r=l.y+l.height/2,a[0]=new P(l.x+l.width+i.width,l.y),a[1]=new P(l.x,l.y+l.height+i.height),h=2;else{let d=this.aF(a,h,o,r,l.width,l.height,i),f=a[d],p=new P(f.x+l.width+i.width,f.y),m=new P(f.x,f.y+l.height+i.height);d+1<h&&a.splice(d+1,0,null),a[d]=p,a[d+1]=m,h++;let y=f.x-l.x,b=f.y-l.y;for(c=u.vertexes.iterator;c.next();){let v=c.value;this.isFixed(v)||(v.centerX+=y,v.centerY+=b)}}}for(B.i(l),c=e.vertexes.iterator;c.next();){let u=c.value,d=u.bounds;if(h<2){o=d.x+d.width/2,r=d.y+d.height/2,a[0]=new P(d.x+d.width+i.width,d.y),a[1]=new P(d.x,d.y+d.height+i.height),h=2;continue}let f=this.aF(a,h,o,r,d.width,d.height,i),p=a[f],m=new P(p.x+d.width+i.width,p.y),y=new P(p.x,p.y+d.height+i.height);f+1<h&&a.splice(f+1,0,null),a[f]=m,a[f+1]=y,h++,this.isFixed(u)||(u.centerX=p.x+u.width/2,u.centerY=p.y+u.height/2)}g.Z(a)}aF(t,e,i,s,n,o,r){let a=9e19,h=-1;t:for(let l=0;l<e;l++){let c=t[l],u=c.x-i,d=c.y-s,f=u*u+d*d;if(f<a){for(let p=l-1;p>=0;p--)if(t[p].y>c.y&&t[p].x-c.x<n+r.width)continue t;for(let p=l+1;p<e;p++)if(t[p].x>c.x&&t[p].y-c.y<o+r.height)continue t;h=l,a=f}}return h}fL(){if(this.network===null||!this.comments)return;let t=this.network.vertexes.iterator;for(;t.next();){let e=t.value;this.addComments(e)}}addComments(t){if(this.network===null)return;let e=t.node;if(e!==null){let i=e.findNodesConnected();for(;i.next();){let s=i.value;if(s.category!=="Comment"||!s.isVisible())continue;let n=this.network.findVertex(s);n===null&&(n=this.network.addNode(s)),n.charge=this.defaultCommentElectricalCharge;let o=null,r=n.destinationEdges;for(;r.next();){let a=r.value;if(a.toVertex===t){o=a;break}}if(o===null){let a=n.sourceEdges;for(;a.next();){let h=a.value;if(h.fromVertex===t){o=h;break}}}o===null&&(o=this.network.linkVertexes(t,n,null)),o.length=this.defaultCommentSpringLength}}}hF(t,e){let i=t.bounds,s=i.x,n=i.y,o=i.width,r=i.height,a=e.bounds,h=a.x,l=a.y,c=a.width,u=a.height;if(s+o<h)if(n>l+u){let d=s+o-h,f=n-l-u;return A.ex(d*d+f*f)}else if(n+r<l){let d=s+o-h,f=n+r-l;return A.ex(d*d+f*f)}else return h-(s+o);else if(s>h+c)if(n>l+u){let d=s-h-c,f=n-l-u;return A.ex(d*d+f*f)}else if(n+r<l){let d=s-h-c,f=n+r-l;return A.ex(d*d+f*f)}else return s-(h+c);else return n>l+u?n-(l+u):n+r<l?l-(n+r):.1}lF(t,e){let i=this.Ya+e;for(;this.Ya<i&&(this.Ya++,!!this.P3(t)););}P3(t){let e=t.vertexes.toArray();if(e.length<=0)return!1;let i=e[0];i.forceX=0,i.forceY=0;let s=i.centerX,n=s,o=i.centerY,r=o;for(let p=1;p<e.length;p++){let m=e[p];m.forceX=0,m.forceY=0;let y=m.centerX,b=m.centerY;s=Math.min(s,y),n=Math.max(n,y),o=Math.min(o,b),r=Math.max(r,b)}let a=n-s>r-o;a?e.sort((p,m)=>p===null||m===null||p===m?0:p.centerX-m.centerX):e.sort((p,m)=>p===null||m===null||p===m?0:p.centerY-m.centerY);let h=this.nu,l=0,c=0,u=0;for(let p=0;p<e.length;p++){let m=e[p],y=m.bounds,b=m.focus,v=y.x+b.x,w=y.y+b.y;c=m.charge*this.electricalFieldX(v,w),u=m.charge*this.electricalFieldY(v,w),c+=m.mass*this.gravitationalFieldX(v,w),u+=m.mass*this.gravitationalFieldY(v,w),m.forceX+=c,m.forceY+=u;for(let k=p+1;k<e.length;k++){let S=e[k];if(!this.shouldInteract(m,S)||k===p)continue;let M=S.bounds,F=S.focus,D=M.x+F.x,N=M.y+F.y;if(v-D>h||D-v>h){if(a)break;continue}if(w-N>h||N-w>h){if(!a)break;continue}let L=this.hF(m,S),R=2*m.charge,O=2*S.charge;if(L>1)l=R*O/(L*L),c=l*(v-D)/L,u=l*(w-N)/L;else{let V=this.randomNumberGenerator;V===null&&(this.randomNumberGenerator=V=new zn(0));let K=V.random(),Y=V.random();if(v>D)c=Math.abs(S.bounds.right-m.bounds.x),c=R*O*(1+c)*K;else if(v<D)c=Math.abs(S.bounds.x-m.bounds.right),c=-(R*O)*(1+c)*K;else{let X=Math.max(S.width,m.width);c=R*O*((1+X)*K-X/2)}if(w>N)u=Math.abs(S.bounds.bottom-m.bounds.y),u=R*O*(1+u)*Y;else if(v<D)u=Math.abs(S.bounds.y-m.bounds.bottom),u=-(R*O)*(1+u)*Y;else{let X=Math.max(S.height,m.height);u=R*O*((1+X)*Y-X/2)}}m.forceX+=c,m.forceY+=u,S.forceX-=c,S.forceY-=u}}let d=t.edges.iterator;for(;d.next();){let p=d.value,m=p.fromVertex,y=p.toVertex,b=m.bounds,v=m.focus,w=b.x+v.x,k=b.y+v.y,S=y.bounds,M=y.focus,F=S.x+M.x,D=S.y+M.y,N=this.hF(m,y);N>1&&(l=.1*p.stiffness*(N-p.length),c=l*.5*(m.width+y.height)*(w-F)/N,u=l*.5*(m.width+y.height)*(k-D)/N),m.forceX-=c,m.forceY-=u,y.forceX+=c,y.forceY+=u}let f=0;for(let p=0;p<e.length;p++){let m=e[p];this.isFixed(m)?this.moveFixedVertex(m):f=Math.max(f,this.moveVertex(m)||0)}return f>this.epsilonDistance*this.epsilonDistance}k3(t,e,i,s){let n=this.Ya+i,o=Math.sqrt(s);this.bw=this.dc*t.vertexes.count;let r=t.vertexes.toArray(),a=0,h=0,l=0;for(;this.Ya<n;){this.Ya++,h=a,a=0;for(let c=0;c<r.length;c++){r[c].forceX=0,r[c].forceY=0;for(let d=0;d<r.length;d++){if(c===d)continue;let f=Math.sqrt((r[c].centerX-r[d].centerX)**2+(r[c].centerY-r[d].centerY)**2),p=e[r[c].idInCluster][r[d].idInCluster],m=(f-this.dc*o*p)/f;r[c].forceX+=m*(r[d].x-r[c].x),r[c].forceY+=m*(r[d].y-r[c].y)}let u=Math.sqrt(r[c].forceX*r[c].forceX+r[c].forceY*r[c].forceY);if(u>0){r[c].forceX=this.bw*r[c].forceX/u,r[c].forceY=this.bw*r[c].forceY/u,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);let d=r[c].hierarchicalVertexes.iterator;for(;d.next();){let f=d.value;this.isFixed(f)||(f.centerX+=r[c].forceX,f.centerY+=r[c].forceY)}}a+=u*u}if(a>=h){if(l++,l>=5)break}else l=0;this.bw*=.95}}moveVertex(t){let e=t.forceX,i=t.forceY,s=this.moveLimit;return e<-s?e=-s:e>s&&(e=s),i<-s?i=-s:i>s&&(i=s),t.centerX+=e,t.centerY+=i,e*e+i*i}shouldInteract(t,e){return!0}moveFixedVertex(t){}commitLayout(){this.kw(),this.commitNodes(),this.isRouting&&this.commitLinks()}kw(){if(this.network===null||!this.setsPortSpots)return;let t=this.network.edges.iterator;for(;t.next();){let e=t.value.link;e!==null&&(e.fromSpot=T.Default,e.toSpot=T.Default)}}commitNodes(){if(!this.network)return;let t=0,e=0;if(this.arrangesToOrigin){let n=B.l();this.hx(this.network,n);let o=this.arrangementOrigin;t=o.x-n.x,e=o.y-n.y,B.i(n)}let i=B.l(),s=this.network.vertexes.iterator;for(;s.next();){let n=s.value;(t!==0||e!==0)&&(i.h(n.bounds),i.x+=t,i.y+=e,n.bounds=i),n.commit()}B.i(i)}commitLinks(){if(!this.network)return;let t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){let e=t.stiffness;return isNaN(e)?this.ou:e}springLength(t){let e=t.length;return isNaN(e)?this.ru:e}electricalCharge(t){let e=t.charge;return isNaN(e)?this.lu:e}electricalFieldX(t,e){return 0}electricalFieldY(t,e){return 0}gravitationalMass(t){let e=t.mass;return isNaN(e)?this.au:e}gravitationalFieldX(t,e){return 0}gravitationalFieldY(t,e){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Ya}get arrangementSpacing(){return this.Us}set arrangementSpacing(t){this.Us.equals(t)||(this.Us.h(t),this.p())}get arrangesToOrigin(){return this.Ug}set arrangesToOrigin(t){this.Ug!==t&&(g.s(t,"boolean",ae,"arrangesToOrigin"),this.Ug=t,this.p())}get setsPortSpots(){return this.zn}set setsPortSpots(t){this.zn!==t&&(g.s(t,"boolean",ae,"setsPortSpots"),this.zn=t,this.p())}get comments(){return this.Xi}set comments(t){this.Xi!==t&&(g.s(t,"boolean",ae,"comments"),this.Xi=t,this.p())}get maxPrelayoutIterations(){return this.Vg}set maxPrelayoutIterations(t){this.Vg!==t&&(g.s(t,"number",ae,"maxPrelayoutIterations"),t>=0&&(this.Vg=t,this.p()))}get maxIterations(){return this.Bg}set maxIterations(t){this.Bg!==t&&(g.s(t,"number",ae,"maxIterations"),t>=0&&(this.Bg=t,this.p()))}get epsilonDistance(){return this.zg}set epsilonDistance(t){this.zg!==t&&(g.s(t,"number",ae,"epsilonDistance"),t>0&&(this.zg=t,this.p()))}get infinityDistance(){return this.nu}set infinityDistance(t){this.nu!==t&&(g.s(t,"number",ae,"infinityDistance"),t>1&&(this.nu=t,this.p()))}get moveLimit(){return this.Xg}set moveLimit(t){this.Xg!==t&&(g.s(t,"number",ae,"moveLimit"),this.Xg=t,this.p())}get randomNumberGenerator(){return this.Gg}set randomNumberGenerator(t){this.Gg!==t&&(t!==null&&!g.nt(t.random)&&g.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Gg=t)}get defaultSpringStiffness(){return this.ou}set defaultSpringStiffness(t){this.ou!==t&&(g.s(t,"number",ae,"defaultSpringStiffness"),this.ou=t,this.p())}get defaultSpringLength(){return this.ru}set defaultSpringLength(t){this.ru!==t&&(g.s(t,"number",ae,"defaultSpringLength"),this.ru=t,this.p())}get defaultElectricalCharge(){return this.lu}set defaultElectricalCharge(t){this.lu!==t&&(g.s(t,"number",ae,"defaultElectricalCharge"),this.lu=t,this.p())}get defaultGravitationalMass(){return this.au}set defaultGravitationalMass(t){this.au!==t&&(g.s(t,"number",ae,"defaultGravitationalMass"),this.au=t,this.p())}get defaultCommentSpringLength(){return this.Yg}set defaultCommentSpringLength(t){this.Yg!==t&&(g.s(t,"number",ae,"defaultCommentSpringLength"),this.Yg=t,this.p())}get defaultCommentElectricalCharge(){return this.Kg}set defaultCommentElectricalCharge(t){this.Kg!==t&&(g.s(t,"number",ae,"defaultCommentElectricalCharge"),this.Kg=t,this.p())}get prelayoutQuality(){return this.hu}set prelayoutQuality(t){this.hu!==t&&(g.s(t,"number",ae,"prelayoutQuality"),this.hu=t,this.p())}get prelayoutSpread(){return this.dc}set prelayoutSpread(t){this.dc!==t&&(g.s(t,"number",ae,"prelayoutSpread"),this.dc=t,this.p())}}class Vn extends Je{constructor(t){super(t)}createVertex(){return new ti(this)}createEdge(){return new Ki(this)}}class ti extends Ze{Xk;Gk;Yk;Kk;Hk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Xk=!1,this.Gk=NaN,this.Yk=NaN,this.Kk=0,this.Hk=0,this.hierarchicalVertexes=new U,this.idInCluster=-1}get isFixed(){return this.Xk}set isFixed(t){this.Xk!==t&&(g.s(t,"boolean",ti,"isFixed"),this.Xk=t)}get charge(){return this.Gk}set charge(t){this.Gk!==t&&(g.s(t,"number",ti,"charge"),this.Gk=t)}get mass(){return this.Yk}set mass(t){this.Yk!==t&&(g.s(t,"number",ti,"mass"),this.Yk=t)}get forceX(){return this.Kk}set forceX(t){this.Kk!==t&&(g.s(t,"number",ti,"forceX"),this.Kk=t)}get forceY(){return this.Hk}set forceY(t){this.Hk!==t&&(g.s(t,"number",ti,"forceY"),this.Hk=t)}}class Ki extends xi{jk;qk;constructor(t){super(t),this.jk=NaN,this.qk=NaN}get stiffness(){return this.jk}set stiffness(t){this.jk!==t&&(g.s(t,"number",Ki,"stiffness"),this.jk=t)}get length(){return this.qk}set length(t){this.qk!==t&&(g.s(t,"number",Ki,"length"),this.qk=t)}}class zn{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){let t=this.seed/this.Q,e=this.seed%this.Q,i=this.A*e-this.R*t;return i>0?this.seed=i:this.seed=i+this.M,this.seed*this.I}}var Xs=(x=>(x[x.DepthFirst=0]="DepthFirst",x[x.Greedy=1]="Greedy",x[x.FromLayers=2]="FromLayers",x))(Xs||{}),Ys=(x=>(x[x.OptimalLinkLength=10]="OptimalLinkLength",x[x.LongestPathSink=11]="LongestPathSink",x[x.LongestPathSource=12]="LongestPathSource",x))(Ys||{}),Us=(x=>(x[x.DepthFirstOut=20]="DepthFirstOut",x[x.DepthFirstIn=21]="DepthFirstIn",x[x.Naive=22]="Naive",x))(Us||{}),js=(x=>(x[x.None=30]="None",x[x.Less=31]="Less",x[x.More=32]="More",x))(js||{}),Kn=(x=>(x[x.None=0]="None",x[x.Expand=1]="Expand",x[x.Straighten=2]="Straighten",x[x.Median=4]="Median",x[x.MaybeExpand=8]="MaybeExpand",x[x.All=15]="All",x))(Kn||{}),Xn=(x=>(x[x.None=0]="None",x[x.UpperLeft=1]="UpperLeft",x[x.UpperRight=2]="UpperRight",x[x.LowerLeft=4]="LowerLeft",x[x.LowerRight=8]="LowerRight",x[x.All=15]="All",x))(Xn||{});class Ue extends oe{Vs;ti;P;cu;fu;uu;gc;du;cr;gu;zn;_;Pw;Bt;Hg;Bs;ie;zs;ms;ps;Rt;jg;qg;Wk;fn;mu;fr;Xn;Gn;uL;Ka;constructor(t){super(),this.Vs=25,this.ti=25,this.P=0,this.cu=0,this.fu=10,this.uu=20,this.gc=4,this.du=31,this.cr=15,this.gu=10,this.zn=!0,this._=-1,this.Pw=-1,this.Bt=-1,this.Hg=0,this.Bs=0,this.ie=new Int16Array(0),this.zs=new Float32Array(0),this.ms=new Float32Array(0),this.ps=new Float32Array(0),this.Rt=new Float32Array(0),this.jg=0,this.qg=new Int16Array(0),this.Wk=new Int16Array(0),this.fn=0,this.mu=null,this.fr=new P,this.Xn=[],this.Xn.length=100,this.Gn=15,this.uL=0,this.Ka=!0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Vs=this.Vs,t.ti=this.ti,t.P=this.P,t.cu=this.cu,t.fu=this.fu,t.uu=this.uu,t.gc=this.gc,t.du=this.du,t.cr=this.cr,t.gu=this.gu,t.zn=this.zn,t.Gn=this.Gn,t.Ka=this.Ka}fe(t){t in js?this.aggressiveOption=t:t in Xs?this.cycleRemoveOption=t:t in Us?this.initializeOption=t:t in Ys?this.layeringOption=t:super.fe(t)}createNetwork(){return new Yn(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.S3(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.M3(),this.cycleRemoveOption===2&&this.removeCycles(),this.N3(),this.C3(),this.L3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){let e=t.fromVertex.node||t.fromVertex.data,i=t.toVertex.node||t.toVertex.data;return e===null&&i===null?8:e===null||i===null?4:1}nodeMinLayerSpace(t,e){return t.node===null&&t.data===null?0:this.P===90||this.P===270?e?t.focus.y+10:t.bounds.height-t.focus.y+10:e?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,e){if(t.node===null&&t.data===null)return 0;let i=e?t.Jk:t.$k;if(i!==null)return i;let s=this.P;return s===90||s===270?e?t.Jk=t.focus.x/this.ti+1|0:t.$k=(t.bounds.width-t.focus.x)/this.ti+1|0:e?t.Jk=t.focus.y/this.ti+1|0:t.$k=(t.bounds.height-t.focus.y)/this.ti+1|0}ei(){let t=this.network.vertexes.count;this.qg.length<t*2&&(this.qg=new Int16Array(t*2));let e=0,i=this.network.vertexes.iterator;for(;i.next();){let s=i.value;this.qg[e]=s.column,e++,this.qg[e]=s.index,e++}return this.qg}os(t){let e=0,i=this.network.vertexes.iterator;for(;i.next();){let s=i.value;s.column=t[e],e++,s.index=t[e],e++}}cF(t,e){let i=this.Ha(t),s=this.ie[t];this.Wk.length<s*s&&(this.Wk=new Int16Array(s*s));let n=this.Wk;for(let o=0;o<s;o++){let r=0,a=i[o],h=a.near,l=0;h!==null&&h!==a&&h.layer===a.layer&&(r+=Math.max(0,Math.abs(h.index-a.index)-1));let c,u=0,d,f=0,p=0,m=0,y,b=0,v,w=0,k=0,S=0,M;if(e>=0){for(c=i[o].Mo,u=0;u<c.length;u++)if(d=c[u],d.valid&&d.fromVertex.layer!==t)for(f=d.fromVertex.index,p=d.portToPos,m=d.portFromPos,b=u+1;b<c.length;b++)v=c[b],v.valid&&v.fromVertex.layer!==t&&(w=v.fromVertex.index,k=v.portToPos,S=v.portFromPos,p<k&&(f>w||f===w&&m>S)&&r++,k<p&&(w>f||w===f&&S>m)&&r++)}if(e<=0){for(c=i[o].rr,u=0;u<c.length;u++)if(d=c[u],d.valid&&d.toVertex.layer!==t)for(f=d.toVertex.index,p=d.portToPos,m=d.portFromPos,b=u+1;b<c.length;b++)v=c[b],v.valid&&v.toVertex.layer!==t&&(w=v.toVertex.index,k=v.portToPos,S=v.portFromPos,m<S&&(f>w||f===w&&p>k)&&r++,S<m&&(w>f||w===f&&k>p)&&r++)}for(n[o*s+o]=r,l=o+1;l<s;l++){let F=0,D=0;if(e>=0){for(y=i[o].Mo,M=i[l].Mo,u=0;u<y.length;u++)if(d=y[u],d.valid&&d.fromVertex.layer!==t)for(f=d.fromVertex.index,p=d.portToPos,m=d.portFromPos,b=0;b<M.length;b++)v=M[b],v.valid&&v.fromVertex.layer!==t&&(w=v.fromVertex.index,k=v.portToPos,S=v.portFromPos,(f<w||f===w&&m<S)&&D++,(w<f||w===f&&S<m)&&F++)}if(e<=0){for(y=i[o].rr,M=i[l].rr,u=0;u<y.length;u++)if(d=y[u],d.valid&&d.toVertex.layer!==t)for(f=d.toVertex.index,p=d.portToPos,m=d.portFromPos,b=0;b<M.length;b++)v=M[b],v.valid&&v.toVertex.layer!==t&&(w=v.toVertex.index,k=v.portToPos,S=v.portFromPos,(f<w||f===w&&p<k)&&D++,(w<f||w===f&&k<p)&&F++)}n[o*s+l]=F,n[l*s+o]=D}}return this.ja(t,i),n}countCrossings(){let t=0;for(let e=0;e<=this._;e++){let i=this.cF(e,1),s=this.ie[e];for(let n=0;n<s;n++)for(let o=n;o<s;o++)t+=i[n*s+o]}return t}A3(t,e,i){let s=this.Ha(t),n=this.ie[t],o=0;for(let r=0;r<n;r++){let a=null;e<=0&&(a=s[r].Mo);let h=null;e>=0&&(h=s[r].rr);let l,c=0,u=0;if(a!==null)for(let d=0;d<a.length;d++)l=a[d],l.valid&&l.fromVertex.layer!==t&&(c=l.fromVertex.column+l.portFromColOffset,u=l.toVertex.column+l.portToColOffset,i?o+=Math.abs(c-u)*this.linkStraightenWeight(l):o+=Math.abs(c-u));if(h!==null)for(let d=0;d<h.length;d++)l=h[d],l.valid&&l.toVertex.layer!==t&&(c=l.fromVertex.column+l.portFromColOffset,u=l.toVertex.column+l.portToColOffset,i?o+=(Math.abs(c-u)+1)*this.linkStraightenWeight(l):o+=Math.abs(c-u))}return this.ja(t,s),o}Zk(t){let e=0;for(let i=0;i<=this._;i++)e+=this.A3(i,1,t);return e}Sw(){let t=1/0;this.Bt=-1;let e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;t=Math.min(t,i.column-this.nodeMinColumnSpace(i,!0)),this.Bt=Math.max(this.Bt,i.column+this.nodeMinColumnSpace(i,!1))}for(e.reset();e.next();){let i=e.value;i.column-=t}this.Bt-=t}Mw(t,e){let i=this.Ha(t),s=this.ie[t],n=new Float32Array(s);for(let o=0;o<s;o++){let r=i[o],a=null;e<=0&&(a=r.Mo);let h=null;e>=0&&(h=r.rr);let l=0,c=0,u=r.near;u!==null&&u.layer===r.layer&&(l+=u.column-1,c++);let d;if(a!==null)for(let f=0;f<a.length;f++){d=a[f];let p=d.fromVertex;d.valid&&!d.rev&&p.layer!==t&&(l+=p.column,c++)}if(h!==null)for(let f=0;f<h.length;f++){d=h[f];let p=d.toVertex;d.valid&&!d.rev&&p.layer!==t&&(l+=p.column,c++)}c===0?n[o]=-1:n[o]=l/c}return this.ja(t,i),n}fF(t,e){let i=this.Ha(t),s=this.ie[t],n=new Int16Array(s);for(let o=0;o<s;o++){let r=i[o],a=null;e<=0&&(a=r.Mo);let h=null;e>=0&&(h=r.rr);let l=0,c=[],u=r.near;u!==null&&u.layer===r.layer&&(c[l]=u.column-1,l++);let d;if(a!==null)for(let f=0;f<a.length;f++){d=a[f];let p=d.fromVertex;d.valid&&!d.rev&&p.layer!==t&&(c[l]=p.column+d.portFromColOffset,l++)}if(h!==null)for(let f=0;f<h.length;f++){d=h[f];let p=d.toVertex;d.valid&&!d.rev&&p.layer!==t&&(c[l]=p.column+d.portToColOffset,l++)}if(l===0)n[o]=-1;else{c.sort((p,m)=>p-m);let f=l>>1;(l&1)!==0?n[o]=c[f]:n[o]=c[f-1]+c[f]>>1}}return this.ja(t,i),n}Nw(t,e,i,s,n){if(t.component===i){t.component=e;let o=0,r=0;if(s){let a=t.destinationEdges;for(;a.next();){let h=a.value,l=h.toVertex;o=t.layer-l.layer,r=this.linkMinLength(h),o===r&&this.Nw(l,e,i,s,n)}}if(n){let a=t.sourceEdges;for(;a.next();){let h=a.value,l=h.fromVertex;o=l.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Nw(l,e,i,s,n)}}}}dL(t,e,i,s,n){if(t.component===i){if(t.component=e,s){let o=t.destinationEdges;for(;o.next();){let r=o.value.toVertex;this.dL(r,e,i,s,n)}}if(n){let o=t.sourceEdges;for(;o.next();){let r=o.value.fromVertex;this.dL(r,e,i,s,n)}}}}removeCycles(){let t=this.network.edges.iterator;for(;t.next();){let e=t.value;e.rev=!1}switch(this.cu){default:case 1:this.T3();break;case 0:this.D3();break;case 2:this.v3();break}}v3(){let t=this.network,e=t.vertexes.iterator,i=1/0;for(;e.next();){let s=e.value;i=Math.min(i,s.layer)}if(i<1/0){if(i<0)for(e.reset();e.next();){let r=e.value;r.layer-=i}let s=[];for(e.reset();e.next();){let r=e.value,a=s[r.layer];a===void 0?s[r.layer]=[r]:a.push(r)}let n=0;for(let r=0;r<s.length;r++){let a=s[r];if(!a||a.length===0)n++;else if(r>0)for(let h=0;h<a.length;h++){let l=a[h];l.layer-=n}}let o=t.edges.iterator;for(;o.next();){let r=o.value,a=r.fromVertex,h=r.toVertex;a.layer<h.layer&&(t.reverseEdge(r),r.rev=!0)}}}T3(){let t=this.network,e=0,i=t.vertexes.count-1,s=[];s.length=i+1;let n=t.vertexes.iterator;for(;n.next();){let r=n.value;r.ii=!0}for(;this.F3(t)!==null;){let r;for(r=this.uF(t);r!==null;)s[i]=r,i--,r.ii=!1,r=this.uF(t);for(r=this.dF(t);r!==null;)s[e]=r,e++,r.ii=!1,r=this.dF(t);r=this.R3(t),r!==null&&(s[e]=r,e++,r.ii=!1)}for(let r=0;r<t.vertexes.count;r++)s[r].index=r;let o=t.edges.iterator;for(;o.next();){let r=o.value,a=r.fromVertex,h=r.toVertex;a.index>h.index&&(t.reverseEdge(r),r.rev=!0)}}F3(t){let e=t.vertexes.iterator;for(;e.next();){let i=e.value;if(i.ii)return i}return null}uF(t){let e=t.vertexes.iterator;for(;e.next();){let i=e.value;if(i.ii){let s=!0,n=i.destinationEdges;for(;n.next();)if(n.value.toVertex.ii){s=!1;break}if(s)return i}}return null}dF(t){let e=t.vertexes.iterator;for(;e.next();){let i=e.value;if(i.ii){let s=!0,n=i.sourceEdges;for(;n.next();)if(n.value.fromVertex.ii){s=!1;break}if(s)return i}}return null}R3(t){let e=null,i=0,s=this.network.vertexes.iterator;for(;s.next();){let n=s.value;if(n.ii){let o=0,r=n.destinationEdges;for(;r.next();)r.value.toVertex.ii&&o++;let a=0,h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ii&&a++;(e===null||i<o-a)&&(e=n,i=o-a)}}return e}D3(){let t=this.network.vertexes.iterator;for(;t.next();){let i=t.value;i.pu=-1,i.to=-1}let e=this.network.edges.iterator;for(;e.next();){let i=e.value;i.forest=!1}for(this.jg=0,t.reset();t.next();){let i=t.value;i.sourceEdges.count===0&&this.gL(i)}for(t.reset();t.next();){let i=t.value;i.pu===-1&&this.gL(i)}for(e.reset();e.next();){let i=e.value;if(!i.forest){let s=i.fromVertex,n=s.pu,o=s.to,r=i.toVertex,a=r.pu,h=r.to;a<n&&o<h&&(this.network.reverseEdge(i),i.rev=!0)}}}gL(t){t.pu=this.jg,this.jg++;let e=t.destinationEdges;for(;e.next();){let i=e.value,s=i.toVertex;s.pu===-1&&(i.forest=!0,this.gL(s))}t.to=this.jg,this.jg++}M3(){let t=this.network.vertexes.iterator;for(;t.next();){let s=t.value;s.layer=-1}for(this._=-1,this.assignLayers(),t.reset();t.next();){let s=t.value;this._=Math.max(this._,s.layer)}this._>=9999&&g.o("LayeredDigraphLayout, too many layers: "+this._);let e=this.direction==0||this.direction==180,i=[];for(let s=this.network.vertexes.iterator;s.next();){let n=s.value;if(n.node===null||n.centered)continue;let o=n.layer,r=i[o];r===void 0&&(r=0);let a=e?n.width:n.height;a>r&&(i[o]=a)}for(let s=this.network.vertexes.iterator;s.next();){let n=s.value;if(n.node===null||n.centered)continue;let o=i[n.layer];e?(n.focusX=o/2,n.focusY=n.focus.y,n.width=o):(n.focusX=n.focus.x,n.focusY=o/2,n.height=o)}}assignLayers(){switch(this.fu){case 11:this.gF();break;case 12:this.O3();break;default:case 10:this.I3();break}}gF(){let t=this.network.vertexes.iterator;for(;t.next();){let e=t.value,i=this.mF(e);this._=Math.max(i,this._)}}mF(t){let e=0;if(t.layer===-1){let i=t.destinationEdges;for(;i.next();){let s=i.value,n=s.toVertex,o=this.linkMinLength(s);e=Math.max(e,this.mF(n)+o)}t.layer=e}else e=t.layer;return e}O3(){let t=0,e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;t=this.pF(i),this._=Math.max(t,this._)}for(e.reset();e.next();){let i=e.value;i.layer=this._-i.layer}}pF(t){let e=0;if(t.layer===-1){let i=t.sourceEdges;for(;i.next();){let s=i.value,n=s.fromVertex,o=this.linkMinLength(s);e=Math.max(e,this.pF(n)+o)}t.layer=e}else e=t.layer;return e}I3(){this.gF();let t=this.network.vertexes.iterator;for(;t.next();){let i=t.value;i.ii=!1}for(t.reset();t.next();){let i=t.value;i.sourceEdges.count===0&&this.yF(i)}let e=1/0;for(t.reset();t.next();){let i=t.value;e=Math.min(e,i.layer)}for(this._=-1,t.reset();t.next();){let i=t.value;i.layer-=e,this._=Math.max(this._,i.layer)}}yF(t){if(!t.ii){t.ii=!0;let e=t.destinationEdges;for(;e.next();){let i=e.value.toVertex;this.yF(i)}this.E3(t),this.U3(t)}}E3(t){let e=this.network.vertexes.iterator;for(;e.next();){let r=e.value;r.component=-1}let i=0,s=1,n=t.Mo,o=n.length;for(let r=0;r<o;r++){let a=n[r],h=a.fromVertex,l=a.toVertex,c=this.linkMinLength(a);h.layer-l.layer>c&&this.Nw(h,i,-1,!0,!1)}for(this.Nw(t,s,-1,!0,!0);t.component!==i;){let r=0,a=1/0,h=0,l=null,c=this.network.vertexes.iterator;for(;c.next();){let u=c.value;if(u.component===s){let d=0,f=!1,p=u.Mo;o=p.length;for(let y=0;y<o;y++){let b=p[y],v=b.fromVertex;if(d+=this.linkLengthWeight(b),v.component!==s){r+=this.linkLengthWeight(b);let w=v.layer-u.layer,k=this.linkMinLength(b);a=Math.min(a,w-k)}}let m=u.rr;o=m.length;for(let y=0;y<o;y++){let b=m[y],v=b.toVertex;d-=this.linkLengthWeight(b),v.component!==s?r-=this.linkLengthWeight(b):f=!0}(l===null||d<h)&&!f&&(l=u,h=d)}}if(r>0){for(e.reset();e.next();){let u=e.value;u.component===s&&(u.layer+=a)}t.component=i}else l.component=i}}U3(t){let e=this.network.vertexes.iterator;for(;e.next();){let n=e.value;n.component=-1}let i=0,s=1;for(this.Nw(t,s,-1,!0,!1);t.component!==i;){let n=0,o=1/0,r=0,a=null,h=this.network.vertexes.iterator;for(;h.next();){let l=h.value;if(l.component===s){let c=0,u=!1,d=l.Mo,f=d.length;for(let m=0;m<f;m++){let y=d[m],b=y.fromVertex;c+=this.linkLengthWeight(y),b.component!==s?n+=this.linkLengthWeight(y):u=!0}let p=l.rr;f=p.length;for(let m=0;m<f;m++){let y=p[m],b=y.toVertex;if(c-=this.linkLengthWeight(y),b.component!==s){n-=this.linkLengthWeight(y);let v=l.layer-b.layer,w=this.linkMinLength(y);o=Math.min(o,v-w)}}(a===null||c>r)&&!u&&(a=l,r=c)}}if(n<0){for(e.reset();e.next();){let l=e.value;l.component===s&&(l.layer-=o)}t.component=i}else a.component=i}}N3(){let t=this.network,e=[],i=t.edges.iterator;for(;i.next();){let s=i.value;s.valid=!1,e.push(s)}for(let s=0;s<e.length;s++){let n=e[s],o=n.fromVertex,r=n.toVertex;if(n.valid||(o.node===null&&o.data===null||r.node===null&&r.data===null)&&o.layer===r.layer)continue;let a=0,h=0,l=0,c=0;if(n.link!==null){let S=n.link;if(S===null)continue;let M=o.node,F=r.node;if(M===null||F===null)continue;let D=S.fromNode,N=S.toNode,L=S.fromPort;for(;L!==null&&!L.isVisibleObject();)L=L.panel;let R=S.toPort;for(;R!==null&&!R.isVisibleObject();)R=R.panel;if(n.rev){let rt=D,lt=L;D=N,L=R,N=rt,R=lt}let O=o.focus,V=r.focus,K=n.rev?r.bounds:o.bounds,Y=P.l();M!==D?K.isReal()&&D.isVisible()?D.actualBounds.isReal()?(D.getRelativePoint(L,T.Center,Y),Y.x+=D.actualBounds.x-K.x,Y.y+=D.actualBounds.y-K.y):(D.getRelativePoint(L,T.Center,Y),Y.isReal()||Y.h(O)):Y.h(O):K.isReal()?(D.getRelativePoint(L,T.Center,Y),Y.isReal()||Y.h(O)):Y.h(O);let X=n.rev?o.bounds:r.bounds,G=P.l();F!==N?X.isReal()&&N.isVisible()?N.actualBounds.isReal()?(N.getRelativePoint(R,T.Center,G),G.x+=N.actualBounds.x-X.x,G.y+=N.actualBounds.y-X.y):(N.getRelativePoint(R,T.Center,G),G.isReal()||G.h(V)):G.h(V):X.isReal()?(N.getRelativePoint(R,T.Center,G),G.isReal()||G.h(V)):G.h(V),this.P===90||this.P===270?(a=Math.round((Y.x-O.x)/this.ti),l=Y.x,h=Math.round((G.x-V.x)/this.ti),c=G.x):(a=Math.round((Y.y-O.y)/this.ti),l=Y.y,h=Math.round((G.y-V.y)/this.ti),c=G.y),P.i(Y),P.i(G),n.portFromColOffset=a,n.portFromPos=l,n.portToColOffset=h,n.portToPos=c}else n.portFromColOffset=0,n.portFromPos=0,n.portToColOffset=0,n.portToPos=0;let u=o.layer,d=r.layer,f=this.V3(n),p=f===1||f===3,m=f===2||f===3,y,b,v=null,w;m&&(v=this.B3(o,r),w=1,b=t.createVertex(),b.node=null,b.Qk=1,b.layer=u,b.near=o,t.addVertex(b),y=t.linkVertexes(o,b,n.link),y.valid=!1,y.rev=n.rev,y.portFromColOffset=a,y.portToColOffset=0,y.portFromPos=l,y.portToPos=0,o=b);let k=1;if(p&&k--,u-d>k&&u>0){for(n.valid=!1,b=t.createVertex(),b.node=null,b.Qk=2,b.layer=u-1,v&&w<v.length&&b.layer===v[w].layer&&(b.near=v[w++]),t.addVertex(b),y=t.linkVertexes(o,b,n.link),y.valid=!0,y.rev=n.rev,y.portFromColOffset=m?0:a,y.portToColOffset=0,y.portFromPos=m?0:l,y.portToPos=0,o=b,u--;u-d>k&&u>0;)b=t.createVertex(),b.node=null,b.Qk=3,b.layer=u-1,v&&w<v.length&&b.layer===v[w].layer&&(b.near=v[w++]),t.addVertex(b),y=t.linkVertexes(o,b,n.link),y.valid=!0,y.rev=n.rev,y.portFromColOffset=0,y.portToColOffset=0,y.portFromPos=0,y.portToPos=0,o=b,u--;y=t.linkVertexes(b,r,n.link),y.valid=!p,p&&(b.near=r),y.rev=n.rev,y.portFromColOffset=0,y.portToColOffset=h,y.portFromPos=0,y.portToPos=c}else n.valid=!0}}V3(t){let e=0,i=t.link;if(i!==null){let s=i.fromPort,n=i.toPort;if(s!==null&&n!==null){let o=i.fromNode,r=i.toNode;if(o!==null&&r!==null){let a=this._k(!0),h=this._k(!1),l=this.setsPortSpots?a:i.computeSpot(!0,s),c=this.setsPortSpots?h:i.computeSpot(!1,n),u=i.isOrthogonal;if(l.isSide()&&l.includesSide(h)&&c.isSide()&&c.includesSide(a))return 0;let d=i.getLinkPoint(o,s,l,!0,u,r,n,P.l()),f=i.getLinkDirection(o,s,d,l,!0,u,r,n);P.i(d),(!l.isNone()&&f===this.wF(t,!0)||this.setsPortSpots&&o!==null&&o.ports.count===1&&t.rev)&&(e+=1);let p=i.getLinkPoint(r,n,c,!1,u,o,s,P.l()),m=i.getLinkDirection(r,n,p,c,!1,u,o,s);P.i(p),(!c.isNone()&&m===this.wF(t,!1)||this.setsPortSpots&&r!==null&&r.ports.count===1&&t.rev)&&(e+=2)}}}return e}wF(t,e){return this.P===90?e&&!t.rev||!e&&t.rev?270:90:this.P===180?e&&!t.rev||!e&&t.rev?0:180:this.P===270?e&&!t.rev||!e&&t.rev?90:270:e&&!t.rev||!e&&t.rev?180:0}B3(t,e){let i=[];return i.push(e),this.xF(t,i)?i.reverse():[]}xF(t,e){let i=e[e.length-1].sourceEdges.iterator;for(;i.next();){let s=i.value;if(s.rev||!s.valid)continue;let n=s.fromVertex;if(e.push(n),n===t||this.xF(t,e))return!0;e.pop()}return!1}C3(){this.ie.length!==this._+1&&(this.ie=new Int16Array(this._+1));let t=this.ie;for(let i=0;i<=this._;i++)t[i]=0;let e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;i.index=-1}this.initializeIndices(),this.Pw=-1,this.Hg=0,this.Bs=0;for(let i=0;i<=this._;i++)t[i]>t[this.Bs]&&(this.Pw=t[i]-1,this.Bs=i),t[i]<t[this.Hg]&&(this.Hg=i);this.mu=[];for(let i=0;i<t.length;i++)this.mu[i]=[];for(e.reset();e.next();){let i=e.value,s=i.layer,n=this.mu[s];n[i.index]=i}}initializeIndices(){switch(this.uu){default:case 22:this.z3();break;case 20:this.X3();break;case 21:this.G3();break}}z3(){let t=null,e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;if(i.near&&(t===null&&(t=new Map),i.layer===i.near.layer)){let s=t.get(i.near)||[];s.push(i),t.set(i.near,s)}}for(e.reset();e.next();){let i=e.value;if(i.near)continue;let s=i.layer;if(i.index=this.ie[s],this.ie[s]++,!t)continue;let n=t.get(i);Array.isArray(n)&&n.forEach(o=>{o.index=this.ie[s],this.ie[s]++})}}X3(){let t=null,e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;if(i.near&&(t===null&&(t=new Map),i.layer===i.near.layer)){let s=t.get(i.near)||[];s.push(i),t.set(i.near,s)}}for(let i=this._;i>=0;i--)for(e.reset();e.next();){let s=e.value;s.layer===i&&s.index===-1&&this.bF(s,t)}}bF(t,e){if(t.near)return;let i=t.layer;if(t.index=this.ie[i],this.ie[i]++,e){let o=e.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ie[i],this.ie[i]++})}let s=t.rr,n=!0;for(;n;){n=!1;for(let o=0;o<s.length-1;o++){let r=s[o],a=s[o+1];r.portFromColOffset>a.portFromColOffset&&(n=!0,s[o]=a,s[o+1]=r)}}for(let o=0;o<s.length;o++){let r=s[o];if(r.valid){let a=r.toVertex;a.index===-1&&this.bF(a,e)}}}G3(){let t=null,e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;if(i.near&&(t===null&&(t=new Map),i.layer===i.near.layer)){let s=t.get(i.near)||[];s.push(i),t.set(i.near,s)}}for(let i=0;i<=this._;i++)for(e.reset();e.next();){let s=e.value;s.layer===i&&s.index===-1&&this.kF(s,t)}}kF(t,e){if(t.near)return;let i=t.layer;if(t.index=this.ie[i],this.ie[i]++,e){let h=e.get(t);Array.isArray(h)&&h.forEach(l=>{l.index=this.ie[i],this.ie[i]++})}let s=t.Mo,n=!0,o=0;for(;n;)for(n=!1,o=0;o<s.length-1;o++){let h=s[o],l=s[o+1];h.portToColOffset>l.portToColOffset&&(n=!0,s[o]=l,s[o+1]=h)}let r,a;for(o=0;o<s.length;o++)a=s[o],a.valid&&(r=a.fromVertex,r.index===-1&&this.kF(r,e))}L3(){this.Bt=-1;for(let t=0;t<=this._;t++){let e=this.Ha(t),i=0,s=this.ie[t];for(let n=0;n<s;n++){let o=e[n];i+=this.nodeMinColumnSpace(o,!0),o.column=i,i+=1,i+=this.nodeMinColumnSpace(o,!1)}this.Bt=Math.max(this.Bt,i-1),this.ja(t,e)}}reduceCrossings(){let t=this.countCrossings(),e=this.ei(),i=0,s=0,n=0;for(i=0;i<this.gc;i++){for(s=0;s<=this._;s++)this.tP(s,1),this.ys(s,1,!1,1);for(n=this.countCrossings(),n<t&&(t=n,e=this.ei()),s=this._;s>=0;s--)this.tP(s,-1),this.ys(s,-1,!1,-1);n=this.countCrossings(),n<t&&(t=n,e=this.ei())}for(this.os(e),i=0;i<this.gc;i++){for(s=0;s<=this._;s++)this.tP(s,0),this.ys(s,0,!1,0);for(n=this.countCrossings(),n<t&&(t=n,e=this.ei()),s=this._;s>=0;s--)this.tP(s,0),this.ys(s,0,!1,0);n=this.countCrossings(),n<t&&(t=n,e=this.ei())}this.os(e);let o=!1,r=0,a=0,h=0,l=0;switch(this.du){case 30:break;case 32:for(h=t+1;(l=this.countCrossings())<h;)for(h=l,r=this._;r>=0;r--)for(a=0;a<=r;a++){for(o=!0;o;)for(o=!1,s=r;s>=a;s--)o=this.ys(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=r;s>=a;s--)o=this.ys(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=a;s<=r;s++)o=this.ys(s,1,!1,1)||o;for(n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=a;s<=r;s++)o=this.ys(s,-1,!1,-1)||o;for(n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=r;s>=a;s--)o=this.ys(s,0,!1,0)||o;for(n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=a;s<=r;s++)o=this.ys(s,0,!1,0)||o;n>=t?this.os(e):(t=n,e=this.ei())}break;default:case 31:for(r=this._,a=0,h=t+1;(l=this.countCrossings())<h;){for(h=l,o=!0;o;)for(o=!1,s=r;s>=a;s--)o=this.ys(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=r;s>=a;s--)o=this.ys(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=a;s<=r;s++)o=this.ys(s,1,!1,1)||o;for(n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=a;s<=r;s++)o=this.ys(s,-1,!1,-1)||o;for(n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=r;s>=a;s--)o=this.ys(s,0,!1,0)||o;for(n>=t?this.os(e):(t=n,e=this.ei()),o=!0;o;)for(o=!1,s=a;s<=r;s++)o=this.ys(s,0,!1,0)||o;n>=t?this.os(e):(t=n,e=this.ei())}break}this.os(e)}tP(t,e){let i=0,s=!1,n=this.Ha(t),o=this.ie[t],r=this.fF(t,e),a=this.Mw(t,e);for(i=0;i<o;i++)a[i]===-1&&(a[i]=n[i].column),r[i]===-1&&(r[i]=n[i].column);let h=!0,l;for(;h;)for(h=!1,i=0;i<o-1;i++)if(r[i+1]<r[i]||r[i+1]===r[i]&&a[i+1]<a[i]){s=!0,h=!0;let u=r[i];r[i]=r[i+1],r[i+1]=u;let d=a[i];a[i]=a[i+1],a[i+1]=d,l=n[i],n[i]=n[i+1],n[i+1]=l}let c=0;for(i=0;i<o;i++)l=n[i],l.index=i,c+=this.nodeMinColumnSpace(l,!0),l.column=c,c+=1,c+=this.nodeMinColumnSpace(l,!1);return this.ja(t,n),s}ys(t,e,i,s){let n=this.Ha(t),o=this.ie[t],r=this.cF(t,e),a=0,h;if(!i||s>0)for(h=new Float32Array(o),a=0;a<o;a++)h[a]=-1;else h=this.Mw(t,-1);let l;if(!i||s<0)for(l=new Float32Array(o),a=0;a<o;a++)l[a]=-1;else l=this.Mw(t,1);let c=!1,u=!0;for(;u;)for(u=!1,a=0;a<o-1;a++){let d=r[n[a].index*o+n[a+1].index],f=r[n[a+1].index*o+n[a].index],p=0,m=0,y=n[a].column,b=n[a+1].column,v=this.nodeMinColumnSpace(n[a],!0),w=this.nodeMinColumnSpace(n[a],!1),k=this.nodeMinColumnSpace(n[a+1],!0),S=this.nodeMinColumnSpace(n[a+1],!1),M=y-v+k,F=b-w+S,D=0,N=0,L=0,R=0,O=0,V=0,K=0,Y,X=0,G,rt=0,lt=n[a].sourceEdges.iterator;if(i&&s<=0)for(;lt.next();){let kt=lt.value;Y=kt.fromVertex,kt.valid&&Y.layer!==t&&(L=this.linkStraightenWeight(kt),R=kt.portFromColOffset,O=kt.portToColOffset,V=Y.column,D+=(Math.abs(y+O-(V+R))+1)*L,N+=(Math.abs(F+O-(V+R))+1)*L)}for(lt.reset();lt.next();){let kt=lt.value;if(Y=kt.fromVertex,kt.valid&&Y.layer===t){for(X=0;X<n.length&&n[X]!==Y;)X++;X<a&&(p+=2*(a-X),m+=2*(a+1-X)),X===a+1&&(p+=1),X>a+1&&(p+=4*(X-a),m+=4*(X-(a+1)))}}let st=n[a].destinationEdges.iterator;if(i&&s>=0)for(;st.next();){let kt=st.value;G=kt.toVertex,kt.valid&&G.layer!==t&&(L=this.linkStraightenWeight(kt),R=kt.portFromColOffset,O=kt.portToColOffset,K=G.column,D+=(Math.abs(y+R-(K+O))+1)*L,N+=(Math.abs(F+R-(K+O))+1)*L)}for(st.reset();st.next();){let kt=st.value;if(G=kt.toVertex,kt.valid&&G.layer===t){for(rt=0;rt<n.length&&n[rt]!==G;)rt++;rt===a+1&&(m+=1)}}let ht=n[a+1].sourceEdges.iterator;if(i&&s<=0)for(;ht.next();){let kt=ht.value;Y=kt.fromVertex,kt.valid&&Y.layer!==t&&(L=this.linkStraightenWeight(kt),R=kt.portFromColOffset,O=kt.portToColOffset,V=Y.column,D+=(Math.abs(b+O-(V+R))+1)*L,N+=(Math.abs(M+O-(V+R))+1)*L)}for(ht.reset();ht.next();){let kt=ht.value;if(Y=kt.fromVertex,kt.valid&&Y.layer===t){for(X=0;X<n.length&&n[X]!==Y;)X++;X<a&&(p+=2*(a+1-X),m+=2*(a-X)),X===a&&(m+=1),X>a+1&&(p+=4*(X-(a+1)),m+=4*(X-a))}}let ot=n[a+1].destinationEdges.iterator;if(i&&s>=0)for(;ot.next();){let kt=ot.value;G=kt.toVertex,kt.valid&&G.layer!==t&&(L=this.linkStraightenWeight(kt),R=kt.portFromColOffset,O=kt.portToColOffset,K=G.column,D+=(Math.abs(b+R-(K+O))+1)*L,N+=(Math.abs(M+R-(K+O))+1)*L)}for(ot.reset();ot.next();){let kt=ot.value;if(G=kt.toVertex,kt.valid&&G.layer===t){for(rt=0;rt<n.length&&n[rt]!==G;)rt++;rt===a&&(p+=1)}}let dt=0,pt=0,vt=h[n[a].index],Ct=l[n[a].index],nt=h[n[a+1].index],Nt=l[n[a+1].index];if(vt!==-1&&(dt+=Math.abs(vt-y),pt+=Math.abs(vt-F)),Ct!==-1&&(dt+=Math.abs(Ct-y),pt+=Math.abs(Ct-F)),nt!==-1&&(dt+=Math.abs(nt-b),pt+=Math.abs(nt-M)),Nt!==-1&&(dt+=Math.abs(Nt-b),pt+=Math.abs(Nt-M)),m<p-.5||m===p&&f<d-.5||m===p&&f===d&&N<D-.5||m===p&&f===d&&N===D&&pt<dt-.5){c=!0,u=!0,n[a].column=F,n[a+1].column=M;let kt=n[a];n[a]=n[a+1],n[a+1]=kt}}for(a=0;a<o;a++)n[a].index=a;return this.ja(t,n),c}straightenAndPack(){if(this.Gn!==0){this.Y3();return}let t=0,e=!1,i=(this.cr&1)!==0,s=(this.cr&8)!==0;if(this.network.edges.count>1e3&&s&&(i=!1),i){let n=[],o=0;for(o=0;o<=this._;o++)n[o]=0;let r=0,a=this.network.vertexes.iterator;for(;a.next();){let l=a.value;t=l.layer,r=l.column;let c=this.nodeMinColumnSpace(l,!1);n[t]=Math.max(n[t],r+c)}let h=8;for(a.reset();a.next();){let l=a.value;t=l.layer,r=l.column,l.column=((this.Bt-n[t])*h>>1)+r*h}this.Bt*=h}if((this.cr&2)!==0){e=!0;let n=0;for(;e&&n<this.gu;){for(e=!1,t=this.Bs+1;t<=this._;t++)e=this.Wg(t,1)||e;for(t=this.Bs-1;t>=0;t--)e=this.Wg(t,-1)||e;e=this.Wg(this.Bs,0)||e,n++}}if((this.cr&4)!==0){for(t=this.Bs+1;t<=this._;t++)this.mL(t,1);for(t=this.Bs-1;t>=0;t--)this.mL(t,-1);this.mL(this.Bs,0)}if(i&&(this.PF(-1),this.PF(1)),(this.cr&2)!==0){e=!0;let n=0;for(;e&&n<this.gu;){for(e=!1,e=this.Wg(this.Bs,0)||e,t=this.Bs+1;t<=this._;t++)e=this.Wg(t,0)||e;for(t=this.Bs-1;t>=0;t--)e=this.Wg(t,0)||e;n++}}}Wg(t,e){let i=!1;for(;this.K3(t,e);)i=!0;return i}K3(t,e){let i=0,s=this.Ha(t),n=this.ie[t],o=this.Mw(t,-1);if(e>0)for(i=0;i<n;i++)o[i]=-1;let r=this.Mw(t,1);if(e<0)for(i=0;i<n;i++)r[i]=-1;let a=!1,h=!0;for(;h;)for(h=!1,i=0;i<n;i++){let l=s[i].column,c=this.nodeMinColumnSpace(s[i],!0),u=this.nodeMinColumnSpace(s[i],!1),d=0;i-1<0||l-s[i-1].column-1>c+this.nodeMinColumnSpace(s[i-1],!1)?d=l-1:d=l;let f=0;i+1>=n||s[i+1].column-l-1>u+this.nodeMinColumnSpace(s[i+1],!0)?f=l+1:f=l;let p=0,m=0,y=0,b=0,v=0,w=0;if(e<=0){let N=s[i].sourceEdges.iterator;for(;N.next();){let L=N.value,R=L.fromVertex;if(L.valid&&R.layer!==t){b=this.linkStraightenWeight(L),v=L.portFromColOffset,w=L.portToColOffset;let O=R.column;p+=(Math.abs(l+w-(O+v))+1)*b,m+=(Math.abs(d+w-(O+v))+1)*b,y+=(Math.abs(f+w-(O+v))+1)*b}}}if(e>=0){let N=s[i].destinationEdges.iterator;for(;N.next();){let L=N.value,R=L.toVertex;if(L.valid&&R.layer!==t){b=this.linkStraightenWeight(L),v=L.portFromColOffset,w=L.portToColOffset;let O=R.column;p+=(Math.abs(l+v-(O+w))+1)*b,m+=(Math.abs(d+v-(O+w))+1)*b,y+=(Math.abs(f+v-(O+w))+1)*b}}}let k=0,S=0,M=0,F=o[s[i].index],D=r[s[i].index];F!==-1&&(k+=Math.abs(F-l),S+=Math.abs(F-d),M+=Math.abs(F-f)),D!==-1&&(k+=Math.abs(D-l),S+=Math.abs(D-d),M+=Math.abs(D-f)),m<p||m===p&&S<k?(a=!0,h=!0,s[i].column=d):(y<p||y===p&&M<k)&&(a=!0,h=!0,s[i].column=f)}return this.ja(t,s),this.Sw(),a}mL(t,e){let i=0,s=this.Ha(t),n=this.ie[t],o=this.fF(t,e),r=new Int16Array(o),a=!1,h=!0;for(;h;)for(h=!1,i=0;i<n;i++){let l=s[i].column,c=this.nodeMinColumnSpace(s[i],!0),u=this.nodeMinColumnSpace(s[i],!1),d=0,f=0,p=0,m=0,y=0;r[i]===-1?i===0&&i===n-1?d=l:i===0?(f=s[i+1].column,f-l===u+this.nodeMinColumnSpace(s[i+1],!0)?d=l-1:d=l):i===n-1?(p=s[i-1].column,l-p===c+this.nodeMinColumnSpace(s[i-1],!1)?d=l+1:d=l):(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+c+1,f=s[i+1].column,m=f-this.nodeMinColumnSpace(s[i+1],!0)-u-1,d=(y+m)/2|0):i===0&&i===n-1?d=r[i]:i===0?(f=s[i+1].column,m=f-this.nodeMinColumnSpace(s[i+1],!0)-u-1,d=Math.min(r[i],m)):i===n-1?(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+c+1,d=Math.max(r[i],y)):(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+c+1,f=s[i+1].column,m=f-this.nodeMinColumnSpace(s[i+1],!0)-u-1,y<r[i]&&r[i]<m?d=r[i]:y>=r[i]?d=y:m<=r[i]&&(d=m)),d!==l&&(a=!0,h=!0,s[i].column=d)}return this.ja(t,s),this.Sw(),a}H3(){for(let t=0;t<=this.Bt;t++)for(;this.j3(t,1););this.Sw()}j3(t,e){let i=!0,s=this.network.vertexes.iterator;for(;s.next();){let o=s.value,r=this.nodeMinColumnSpace(o,!0),a=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+a>=t){i=!1;break}}let n=!1;if(i){if(e>0)for(s.reset();s.next();){let o=s.value;o.column>t&&(o.column-=1,n=!0)}if(e<0)for(s.reset();s.next();){let o=s.value;o.column<t&&(o.column+=1,n=!0)}}return n}q3(){this.H3();for(let t=0;t<this.Bt;t++)for(;this.W3(t,1););this.Sw()}W3(t,e){let i=t;e>0&&(i=t+1),e<0&&(i=t-1);let s=0,n=[],o=[];for(s=0;s<=this._;s++)n[s]=!1,o[s]=!1;let r=this.network.vertexes.iterator;for(;r.next();){let l=r.value,c=l.column-this.nodeMinColumnSpace(l,!0),u=l.column+this.nodeMinColumnSpace(l,!1);c<=t&&u>=t&&(n[l.layer]=!0),c<=i&&u>=i&&(o[l.layer]=!0)}let a=!0,h=!1;for(s=0;s<=this._;s++)a=a&&!(n[s]&&o[s]);if(a){if(e>0)for(r.reset();r.next();){let l=r.value;l.column>t&&(l.column-=1,h=!0)}if(e<0)for(r.reset();r.next();){let l=r.value;l.column<t&&(l.column+=1,h=!0)}}return h}PF(t){this.q3();let e=0,i,s=0,n=0,o=0;if(t>0)for(e=0;e<=this.Bt;e++)for(i=this.ei(),s=this.Zk(!0),n=s+1;s<n;)n=s,this.SF(e,1),o=this.Zk(!0),o>s?this.os(i):o<s&&(s=o,i=this.ei());if(t<0)for(e=this.Bt;e>=0;e--)for(i=this.ei(),s=this.Zk(!0),n=s+1;s<n;)n=s,this.SF(e,-1),o=this.Zk(!0),o>s?this.os(i):o<s&&(s=o,i=this.ei());this.Sw()}SF(t,e){this.fn=0;let i=this.network.vertexes.iterator;for(;i.next();){let c=i.value;c.component=-1}if(e>0)for(i.reset();i.next();){let c=i.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this.fn)}if(e<0)for(i.reset();i.next();){let c=i.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this.fn)}for(this.fn++,i.reset();i.next();){let c=i.value;c.component===-1&&(this.dL(c,this.fn,-1,!0,!0),this.fn++)}let s=0,n=[];for(s=0;s<this.fn*this.fn;s++)n[s]=!1;let o=[];for(s=0;s<(this._+1)*(this.Bt+1);s++)o[s]=-1;for(i.reset();i.next();){let c=i.value,u=c.layer,d=Math.max(0,c.column-this.nodeMinColumnSpace(c,!0)),f=Math.min(this.Bt,c.column+this.nodeMinColumnSpace(c,!1));for(let p=d;p<=f;p++)o[u*(this.Bt+1)+p]=c.component}for(let c=0;c<=this._;c++){if(e>0)for(let u=0;u<this.Bt;u++)o[c*(this.Bt+1)+u]!==-1&&o[c*(this.Bt+1)+u+1]!==-1&&o[c*(this.Bt+1)+u]!==o[c*(this.Bt+1)+u+1]&&(n[o[c*(this.Bt+1)+u]*this.fn+o[c*(this.Bt+1)+u+1]]=!0);if(e<0)for(let u=this.Bt;u>0;u--)o[c*(this.Bt+1)+u]!==-1&&o[c*(this.Bt+1)+u-1]!==-1&&o[c*(this.Bt+1)+u]!==o[c*(this.Bt+1)+u-1]&&(n[o[c*(this.Bt+1)+u]*this.fn+o[c*(this.Bt+1)+u-1]]=!0)}let r=[];for(s=0;s<this.fn;s++)r[s]=!0;let a=[];a.push(0);let h=0;for(;a.length!==0;)if(h=a[a.length-1],a.pop(),r[h])for(r[h]=!1,s=0;s<this.fn;s++)n[h*this.fn+s]&&a.splice(0,0,s);let l=!1;if(e>0)for(i.reset();i.next();){let c=i.value;r[c.component]&&(c.column-=1,l=!0)}if(e<0)for(i.reset();i.next();){let c=i.value;r[c.component]&&(c.column+=1,l=!0)}return l}Y3(){let t=g.ot(),e=this.mu.length;for(let d=0;d<=e;d++)t[d]=[];let i=this.network.vertexes.iterator;for(;i.next();){let d=i.value,f=e-d.layer,p=t[f];p[d.index]=d}let s=new I;this.J3(t,s);let n=null,o=null,r=null,a=null,h=(this.Gn&1)!==0,l=(this.Gn&2)!==0,c=(this.Gn&4)!==0,u=(this.Gn&8)!==0;h&&(this.hl(t,s,!0),n=this.eP(t,!0,!1)),t.reverse(),c&&(this.hl(t,s,!1),r=this.eP(t,!1,!1));for(let d of t)d.reverse();u&&(this.hl(t,s,!1),a=this.eP(t,!1,!0)),t.reverse(),l&&(this.hl(t,s,!0),o=this.eP(t,!0,!0)),g.Z(t),this.$3(n,o,r,a),this.network.vertexes.each(d=>{let f=d,p=g.ot();h&&p.push(n.get(f)),l&&p.push(o.get(f)),c&&p.push(r.get(f)),u&&p.push(a.get(f)),p.sort((w,k)=>w-k);let m=p.length,y=Math.floor((m-1)/2),b=Math.ceil((m-1)/2),v=(p[y]+p[b])/2;g.Z(p),f.gi=v})}J3(t,e){let i=t.length;for(let s=1;s<i-1;s++){let n=0,o=0,r=t[s],a=t[s+1];for(let h=0;o<a.length;h++){let l=a[h],c=this.Z3(l);if(h===a.length-1||c){let u=r.length-1;for(c&&(u=l.getProperSourceVertexes()[0].index);o<=h;){let d=a[o].getProperSourceEdges();for(let f of d){let p=f.fromVertex.index;(p<n||p>u)&&e.add(f)}o++}n=u}}}}Z3(t){if(t.node===null){let e=t.getProperSourceVertexes();if(e.length>0)return e[0].node===null}return!1}hl(t,e,i){this.Q3(t);for(let s of t){let n=-1;for(let o of s){let r=i?o.getProperSourceVertexes():o.getProperDestinationVertexes(),a=r.length;if(a>0){r.sort((l,c)=>l.qa-c.qa);let h=(a-1)/2;for(let l=Math.floor(h),c=Math.ceil(h);l<=c;l++)if(o.Yn===o){let u=r[l],d;i?d=u.getDestinationEdge(o):d=o.getDestinationEdge(u),!e.has(d)&&n<u.qa&&(u.Yn=o,o.mc=u.mc,o.Yn=u.mc,n=u.qa)}}}}}Q3(t){for(let e=0;e<t.length;e++){let i=t[e];for(let s=0;s<i.length;s++){let n=i[s];n.mc=n,n.Yn=n,n.MF=e,n.qa=s}}}eP(t,e,i){let s=this.P===90||this.P===270;for(let o of t)for(let r of o)r.rs=r,r.yu=1/0,r.gi=NaN,r.Kn=0;this._3(t,e,i);for(let o of t)for(let r of o)r.mc===r&&this.NF(r,t);for(let o=0;o<t.length;o++){if(t[o].length<=0)continue;let r=t[o][0];if(r.rs===r){r.rs.yu===1/0&&(r.rs.yu=0);let a=o,h=0,l;do{for(l=t[a][h];l.Yn!==l.mc;)if(l=l.Yn,a++,l.qa>0){let c=this.CF(l,t),u=s?c.width:c.height,d=l.rs.yu+l.gi+l.Kn-(c.gi+c.Kn+u+this.columnSpacing);c.rs.yu=Math.min(c.rs.yu,d)}h=l.qa+1}while(a<t.length&&h<t[a].length&&l.rs===t[a][h].rs)}}let n=new wt;for(let o of t)for(let r of o){r.gi=r.gi+r.rs.yu+r.Kn;let a=s?r.width:r.height;n.set(r,i?-r.gi-a:r.gi)}return n}_3(t,e,i){let s=this.P===90||this.P===270;for(let n of t)for(let o of n)if(o.mc===o){let r=0,a=o;for(;a.Yn!==o;){let h=a.Yn,l=s?a.width:a.height,c=s?h.width:h.height,u,d,f,p;e?(f=a.getDestinationEdge(h),u=f.portFromPos,d=f.portToPos,f.link!==null&&(a.node&&a.node!==f.link.fromNode&&(u=s?a.focusX:a.focusY),h.node&&h.node!==f.link.toNode&&(d=s?h.focusX:h.focusY)),i?p=a.Kn+(l-u)-(c-d):p=a.Kn+u-d):(f=h.getDestinationEdge(a),u=f.portToPos,d=f.portFromPos,f.link!==null&&(a.node&&a.node!==f.link.toNode&&(u=s?a.focusX:a.focusY),h.node&&h.node!==f.link.fromNode&&(d=s?h.focusX:h.focusY)),i?p=a.Kn+(l-u)-(c-d):p=a.Kn+u-d),h.Kn=p,r=Math.min(r,p),a=a.Yn}a=o;do a.Kn=a.Kn-r,a=a.Yn;while(a!==o)}}NF(t,e){if(!isNaN(t.gi))return;t.gi=0;let i=t;do{if(i.qa>0){let s=this.CF(i,e),n=s.mc;this.NF(n,e),t.rs===t&&(t.rs=n.rs);let o=this.P===90||this.P===270?s.width:s.height;if(t.rs===n.rs){let r=n.gi+s.Kn+o-i.Kn+this.columnSpacing;t.gi=Math.max(t.gi,r)}}i=i.Yn}while(i!==t);for(;i.Yn!==t;)i=i.Yn,i.gi=t.gi,i.rs=t.rs}CF(t,e){let i=t.MF,s=t.qa;return s<1&&g.o("Could not determine previous vertex in layer"),e[i][s-1]}$3(...t){let e=-1,i=g.ot(),s=g.ot(),n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;let r=this.tU(t[o],i,s,o);r<n&&(e=o,n=r)}for(let o=0;o<4;o++){let r=t[o];if(!r)continue;let a=o===0||o===2?i[e]-i[o]:s[e]-s[o];a!==0&&r.each(h=>{r.set(h.key,h.value+a)})}g.Z(i),g.Z(s)}tU(t,e,i,s){if(!t||t.count===0)return e[s]=0,i[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{let a=r.key,h=r.value,l=this.P===90||this.P===270?a.width:a.height;h<n&&(n=h),h+l>o&&(o=h+l)}),e[s]=n,i[s]=o,o-n}commitLayout(){this.kw(),this.commitNodes(),this.pL(),this.isRouting&&this.commitLinks()}kw(){if(!this.setsPortSpots)return;let t=this._k(!0),e=this._k(!1),i=this.network.edges.iterator;for(;i.next();){let s=i.value.link;s!==null&&(s.fromSpot=t,s.toSpot=e)}}_k(t){return this.P===270?t?T.MiddleTop:T.MiddleBottom:this.P===90?t?T.MiddleBottom:T.MiddleTop:this.P===180?t?T.MiddleLeft:T.MiddleRight:t?T.MiddleRight:T.MiddleLeft}commitNodes(){this.zs.length!==this._+1&&(this.zs=new Float32Array(this._+1)),this.ms.length!==this._+1&&(this.ms=new Float32Array(this._+1)),this.ps.length!==this._+1&&(this.ps=new Float32Array(this._+1)),this.Rt.length!==this._+1&&(this.Rt=new Float32Array(this._+1));for(let f=0;f<=this._;f++)this.zs[f]=0,this.ms[f]=0,this.ps[f]=0,this.Rt[f]=0;let t=this.network.vertexes.iterator;for(;t.next();){let f=t.value,p=f.layer;this.zs[p]=Math.max(this.zs[p],this.nodeMinLayerSpace(f,!0)),this.ms[p]=Math.max(this.ms[p],this.nodeMinLayerSpace(f,!1))}let e=0,i=this.Vs;for(let f=0;f<=this._;f++){let p=i;this.zs[f]+this.ms[f]<=0&&(p=0),f>0&&(e+=p/2),this.P===90||this.P===0?(e+=this.ms[f],this.ps[f]=e,e+=this.zs[f]):(e+=this.zs[f],this.ps[f]=e,e+=this.ms[f]),f<this._&&(e+=p/2),this.Rt[f]=e}let s=e,n=this.arrangementOrigin;for(let f=0;f<=this._;f++)this.P===270?this.ps[f]=n.y+this.ps[f]:this.P===90?(this.ps[f]=n.y+s-this.ps[f],this.Rt[f]=s-this.Rt[f]):this.P===180?this.ps[f]=n.x+this.ps[f]:(this.ps[f]=n.x+s-this.ps[f],this.Rt[f]=s-this.Rt[f]);let o=this.Gn!==0;t.reset();let r=this.P===270||this.P===90,a=1/0,h=1/0,l=1/0,c=-1/0;for(;t.next();){let f=t.value,p=f.layer,m=f.column|0,y=0,b=0;r?(y=n.x+this.ti*m,b=this.ps[p]):(y=this.ps[p],b=n.y+this.ti*m),f.centerX=y,f.centerY=b,o&&isFinite(f.gi)&&(r?f.node?f.x=n.x+f.gi:f.centerX=n.x+f.gi:f.node?f.y=n.y+f.gi:f.centerY=n.y+f.gi),a=Math.min(f.x,a),h=Math.min(f.y,h),r?(l=a,c=Math.max(c,f.bounds.right)):(l=h,c=Math.max(c,f.bounds.bottom))}this.uL=c-l;let u=n.x-a,d=n.y-h;for(this.fr=new P(o&&r?0:u,o&&!r?0:d),t.reset();t.next();){let f=t.value;f.x+=u,f.y+=d,f.commit()}}pL(){let t=0,e=this.Vs;for(let n=0;n<=this._;n++)t+=this.zs[n],t+=this.ms[n];t+=this._*e;let i=[],s=this.Gn!==0?this.uL:this.ti*this.Bt;for(let n=this.maxLayer;n>=0;n--)this.P===270?n===0?i.push(new B(0,0,s,Math.abs(this.Rt[0]))):i.push(new B(0,this.Rt[n-1],s,Math.abs(this.Rt[n-1]-this.Rt[n]))):this.P===90?n===0?i.push(new B(0,this.Rt[0],s,Math.abs(this.Rt[0]-t))):i.push(new B(0,this.Rt[n],s,Math.abs(this.Rt[n-1]-this.Rt[n]))):this.P===180?n===0?i.push(new B(0,0,Math.abs(this.Rt[0]),s)):i.push(new B(this.Rt[n-1],0,Math.abs(this.Rt[n-1]-this.Rt[n]),s)):n===0?i.push(new B(this.Rt[0],0,Math.abs(this.Rt[0]-t),s)):i.push(new B(this.Rt[n],0,Math.abs(this.Rt[n-1]-this.Rt[n]),s));this.commitLayers(i,this.fr)}commitLayers(t,e){}commitLinks(){let t=this.network.edges.iterator,e=null;for(;t.next();)e=t.value.link,e!==null&&e.pointsCount>0&&(e.startRoute(),e.clearPoints(),e.commitRoute());for(t.reset();t.next();)e=t.value.link,e!==null&&e.updateRoute();for(t.reset();t.next();){let i=t.value;if(e=i.link,e===null||e.pointsCount===0)continue;e.startRoute();let s=e,n=s.fromNode,o=s.toNode,r=s.fromPort,a=s.toPort;if(n!==null){let L=n.findVisibleNode();L!==null&&L!==n&&(n=L,r=L.port)}if(o!==null){let L=o.findVisibleNode();L!==null&&L!==o&&(o=L,a=L.port)}let h=e.computeSpot(!0,r),l=e.computeSpot(!1,a),c=i.fromVertex,u=i.toVertex;if(i.valid){if(e.curve===9&&e.pointsCount===4)if(c.column===u.column&&this.alignOption===0){let L=e.getLinkPoint(n,r,h,!0,!1,o,a),R=e.getLinkPoint(o,a,l,!1,!1,n,r);L.isReal()||L.set(n.actualBounds.center),R.isReal()||R.set(o.actualBounds.center),e.clearPoints(),e.addPointAt(L.x,L.y),e.addPointAt((2*L.x+R.x)/3,(2*L.y+R.y)/3),e.addPointAt((L.x+2*R.x)/3,(L.y+2*R.y)/3),e.addPointAt(R.x,R.y)}else{let L=!1,R=!1;if(r!==null&&h===T.None&&(L=!0),a!==null&&l===T.None&&(R=!0),L||R){let O=null;L&&(O=e.getLinkPointFromPoint(n,r,r.getDocumentPoint(T.Center),e.getPoint(3),!0),O.isReal()||O.set(n.actualBounds.center),e.setPointAt(0,O.x,O.y));let V=null;if(R&&(V=e.getLinkPointFromPoint(o,a,a.getDocumentPoint(T.Center),e.getPoint(0),!1),V.isReal()||V.set(o.actualBounds.center),e.setPointAt(3,V.x,V.y)),O){let K=e.getPoint(2);e.setPointAt(1,(O.x*2+K.x)/3,(O.y*2+K.y)/3)}if(V){let K=e.getPoint(1);e.setPointAt(2,(V.x*2+K.x)/3,(V.y*2+K.y)/3)}}}e.commitRoute();continue}if(c.layer===u.layer){e.commitRoute();continue}let d=!1,f=!1,p=this.Vs,m=0,y=e.firstPickIndex+1;if(e.isOrthogonal)f=!0,m=e.pointsCount,m>4&&e.points.removeRange(2,m-3);else if(e.curve===9)d=!0,m=e.pointsCount,m>4&&e.points.removeRange(2,m-3),m===4&&(y=2);else{m=e.pointsCount;let L=h===T.None,R=l===T.None;m>2&&L&&R?e.points.removeRange(1,m-2):m>3&&L&&!R?e.points.removeRange(1,m-3):m>3&&!L&&R?e.points.removeRange(2,m-2):m>4&&!L&&!R&&e.points.removeRange(2,m-3)}let b,v,w=0,k=0,S=0,M=0,F=0,D=0,N=0;if(i.rev){let L=0;for(;u!==null&&c!==u;){b=null,v=null;let R=u.sourceEdges.iterator;for(;R.next();){let O=R.value;if(O.link===i.link&&(b=O.fromVertex,v=O.toVertex,b.node===null))break}if(b===null)break;if(b!==c)if(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=b.centerX,M=b.centerY,f)this.P===180||this.P===0?y===e.firstPickIndex+1?(e.insertPointAt(y++,w,k),e.insertPointAt(y++,w,M)):(v!==null?v.centerY:k)!==M&&(F=this.Rt[b.layer-1]+this.fr.x,e.insertPointAt(y++,F,k),e.insertPointAt(y++,F,M)):y===e.firstPickIndex+1?(e.insertPointAt(y++,w,k),e.insertPointAt(y++,S,k)):(v!==null?v.centerX:w)!==S&&(F=this.Rt[b.layer-1]+this.fr.y,e.insertPointAt(y++,w,F),e.insertPointAt(y++,S,F));else if(y===e.firstPickIndex+1)if(D=Math.max(10,this.zs[u.layer]),N=Math.max(10,this.ms[u.layer]),d)this.P===180?S<=u.bounds.x?(L=u.bounds.x,e.insertPointAt(y++,L-D,M),e.insertPointAt(y++,L,M),e.insertPointAt(y++,L+N,M)):(e.insertPointAt(y++,S-D,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S+N,M)):this.P===90?M>=u.bounds.bottom?(L=u.bounds.y+u.bounds.height,e.insertPointAt(y++,S,L+N),e.insertPointAt(y++,S,L),e.insertPointAt(y++,S,L-D)):(e.insertPointAt(y++,S,M+N),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M-D)):this.P===270?M<=u.bounds.y?(L=u.bounds.y,e.insertPointAt(y++,S,L-D),e.insertPointAt(y++,S,L),e.insertPointAt(y++,S,L+N)):(e.insertPointAt(y++,S,M-D),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M+N)):this.P===0&&(S>=u.bounds.right?(L=u.bounds.x+u.bounds.width,e.insertPointAt(y++,L+N,M),e.insertPointAt(y++,L,M),e.insertPointAt(y++,L-D,M)):(e.insertPointAt(y++,S+N,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S-D,M)));else{e.insertPointAt(y++,w,k);let O=0;this.P===180||this.P===0?((this.P===180?S>=u.bounds.right:S<=u.bounds.x)&&(O=(this.P===0?-D:N)/2),e.insertPointAt(y++,w+O,M)):((this.P===270?M>=u.bounds.bottom:M<=u.bounds.y)&&(O=(this.P===90?-D:N)/2),e.insertPointAt(y++,S,k+O)),e.insertPointAt(y++,S,M)}else D=Math.max(10,this.zs[b.layer]),N=Math.max(10,this.ms[b.layer]),d?this.P===180?(e.insertPointAt(y++,S-D-Math.max(10,p),M),e.insertPointAt(y++,Math.min(S-D+p/2,S),M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,Math.max(S+N-p/2,S),M),e.insertPointAt(y++,S+N+p,M)):this.P===90?(e.insertPointAt(y++,S,M+N+Math.max(10,p)),e.insertPointAt(y++,S,Math.max(M+N-p/2,M)),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,Math.min(M-D+p/2,M)),e.insertPointAt(y++,S,M-D-p)):this.P===270?(e.insertPointAt(y++,S,M-D-Math.max(10,p)),e.insertPointAt(y++,S,Math.min(M-D+p/2,M)),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,Math.max(M+N-p/2,M)),e.insertPointAt(y++,S,M+N+p)):(e.insertPointAt(y++,S+N+Math.max(10,p),M),e.insertPointAt(y++,Math.max(S+N-p/2,S),M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,Math.min(S-D+p/2,S),M),e.insertPointAt(y++,S-D-p,M)):(this.P===180||this.P===90||this.P,e.insertPointAt(y++,S,M));u=b}if(a===null||h!==T.None||f)if(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=e.getPoint(y).x,M=e.getPoint(y).y,f){let R=this.ms[c.layer],O=0;this.P===180||this.P===0?(O=k,O>=c.bounds.y&&O<=c.bounds.bottom&&(this.P===180?S>=c.bounds.x:S<=c.bounds.right)&&(L=c.centerX+(this.P===180?-R:R),O<c.bounds.y+c.bounds.height/2?O=c.bounds.y-this.ti/2:O=c.bounds.bottom+this.ti/2,e.insertPointAt(y++,L,k),e.insertPointAt(y++,L,O)),e.insertPointAt(y++,S,O),e.insertPointAt(y++,S,M)):(O=w,O>=c.bounds.x&&O<=c.bounds.right&&(this.P===270?M>=c.bounds.y:M<=c.bounds.bottom)&&(L=c.centerY+(this.P===270?-R:R),O<c.bounds.x+c.bounds.width/2?O=c.bounds.x-this.ti/2:O=c.bounds.right+this.ti/2,e.insertPointAt(y++,w,L),e.insertPointAt(y++,O,L)),e.insertPointAt(y++,O,M),e.insertPointAt(y++,S,M))}else if(d)D=Math.max(10,this.zs[c.layer]),N=Math.max(10,this.ms[c.layer]),this.P===180&&S>=c.bounds.x?(L=c.bounds.x+c.bounds.width,e.setPointAt(y-2,L,k),e.setPointAt(y-1,L+N,k)):this.P===90&&M<=c.bounds.bottom?(L=c.bounds.y,e.setPointAt(y-2,w,L),e.setPointAt(y-1,w,L-D)):this.P===270&&M>=c.bounds.y?(L=c.bounds.y+c.bounds.height,e.setPointAt(y-2,w,L),e.setPointAt(y-1,w,L+N)):this.P===0&&S<=c.bounds.right&&(L=c.bounds.x,e.setPointAt(y-2,L,k),e.setPointAt(y-1,L-D,k));else{D=Math.max(10,this.zs[c.layer]),N=Math.max(10,this.ms[c.layer]);let R=0;this.P===180||this.P===0?((this.P===180?S<=c.bounds.x:S>=c.bounds.right)&&(R=(this.P===0?N:-D)/2),e.insertPointAt(y++,S+R,k)):((this.P===270?M<=c.bounds.y:M>=c.bounds.bottom)&&(R=(this.P===90?N:-D)/2),e.insertPointAt(y++,w,M+R)),e.insertPointAt(y++,S,M)}}else{for(;c!==null&&c!==u;){b=null,v=null;let L=c.destinationEdges.iterator;for(;L.next();){let R=L.value;if(R.link===i.link&&(b=R.toVertex,v=R.fromVertex,v.node!==null&&(v=null),b.node===null))break}if(b===null)break;b!==u&&(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=b.centerX,M=b.centerY,f?this.P===180||this.P===0?(v!==null?v.centerY:k)!==M&&(F=this.Rt[b.layer]+this.fr.x,y===e.firstPickIndex+1&&(this.P===0?F=Math.max(F,w):F=Math.min(F,w)),e.insertPointAt(y++,F,k),e.insertPointAt(y++,F,M)):(v!==null?v.centerX:w)!==S&&(F=this.Rt[b.layer]+this.fr.y,y===e.firstPickIndex+1&&(this.P===90?F=Math.max(F,k):F=Math.min(F,k)),e.insertPointAt(y++,w,F),e.insertPointAt(y++,S,F)):(D=Math.max(10,this.zs[b.layer]),N=Math.max(10,this.ms[b.layer]),d?this.P===180?(e.insertPointAt(y++,S+N+Math.max(10,p),M),e.insertPointAt(y++,Math.max(S+N-p/2,S),M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,Math.min(S-D+p/2,S),M),e.insertPointAt(y++,S-D-p,M)):this.P===90?(e.insertPointAt(y++,S,M-D-Math.max(10,p)),e.insertPointAt(y++,S,Math.min(M-D+p/2,M)),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,Math.max(M+N-p/2,M)),e.insertPointAt(y++,S,M+N+p)):this.P===270?(e.insertPointAt(y++,S,M+N+Math.max(10,p)),e.insertPointAt(y++,S,Math.max(M+N-p/2,M)),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,Math.min(M-D+p/2,M)),e.insertPointAt(y++,S,M-D-p)):(e.insertPointAt(y++,S-D-Math.max(10,p),M),e.insertPointAt(y++,Math.min(S-D+p/2,S),M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,S,M),e.insertPointAt(y++,Math.max(S+N-p/2,S),M),e.insertPointAt(y++,S+N+p,M)):this.P===180?(e.insertPointAt(y++,S+N,M),e.insertPointAt(y++,S-D,M)):this.P===90?(e.insertPointAt(y++,S,M-D),e.insertPointAt(y++,S,M+N)):this.P===270?(e.insertPointAt(y++,S,M+N),e.insertPointAt(y++,S,M-D)):(e.insertPointAt(y++,S-D,M),e.insertPointAt(y++,S+N,M)))),c=b}f&&(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=e.getPoint(y).x,M=e.getPoint(y).y,this.P===180||this.P===0?k!==M&&(this.P===0?F=Math.min(Math.max((S+w)/2,this.Rt[u.layer]+this.fr.x),S):F=Math.max(Math.min((S+w)/2,this.Rt[u.layer]+this.fr.x),S),e.insertPointAt(y++,F,k),e.insertPointAt(y++,F,M)):w!==S&&(this.P===90?F=Math.min(Math.max((M+k)/2,this.Rt[u.layer]+this.fr.y),M):F=Math.max(Math.min((M+k)/2,this.Rt[u.layer]+this.fr.y),M),e.insertPointAt(y++,w,F),e.insertPointAt(y++,S,F)))}if(s!==null&&d&&e.pointsCount>=4){if(n!==null&&r!==null&&(h===T.None||s.Qh(h))){let L=r.getDocumentPoint(T.Center);L.isReal()||L.setTo(n.actualBounds.centerX,n.actualBounds.centerY);let R=e.getPoint(3),O=e.getLinkPointFromPoint(n,r,L,R,!0),V=e.getPoint(2);this.direction===90||this.direction===270?(e.setPointAt(1,(O.x+V.x)/2,V.y),e.setPointAt(2,R.x,(V.y+R.y)/2)):(e.setPointAt(1,V.x,(O.y+V.y)/2),e.setPointAt(2,(V.x+R.x)/2,R.y));let K=e.getLinkPointFromPoint(n,r,L,e.getPoint(1),!0);e.setPointAt(0,K.x,K.y)}if(o!==null&&a!==null&&(l===T.None||s.Qh(l))){let L=a.getDocumentPoint(T.Center);L.isReal()||L.setTo(o.actualBounds.centerX,o.actualBounds.centerY);let R=e.getPoint(e.pointsCount-4),O=e.getLinkPointFromPoint(o,a,L,R,!1),V=e.getPoint(e.pointsCount-3);this.direction===90||this.direction===270?(e.setPointAt(e.pointsCount-2,(O.x+V.x)/2,(V.y+O.y)/2),e.setPointAt(e.pointsCount-3,R.x,(V.y+O.y)/2)):(e.setPointAt(e.pointsCount-2,(V.x+O.x)/2,(O.y+V.y)/2),e.setPointAt(e.pointsCount-3,(V.x+O.x)/2,R.y));let K=e.getLinkPointFromPoint(o,a,L,e.getPoint(e.pointsCount-2),!1);e.setPointAt(e.pointsCount-1,K.x,K.y)}}e.commitRoute(),i.commit()}}S3(){this.Pw=-1,this.Hg=0,this.Bs=0,this.mu=null;for(let t=0;t<this.Xn.length;t++)this.Xn[t]=null}Ha(t){let e,i=this.ie[t];if(i>=this.Xn.length){let n=[];for(let o=0;o<this.Xn.length;o++)n[o]=this.Xn[o];this.Xn=n}this.Xn[i]===void 0||this.Xn[i]===null?e=[]:(e=this.Xn[i],this.Xn[i]=null);let s=this.mu[t];for(let n=0;n<s.length;n++){let o=s[n];e[o.index]=o}return e}ja(t,e){this.Xn[this.ie[t]]=e}get layerSpacing(){return this.Vs}set layerSpacing(t){this.Vs!==t&&(g.s(t,"number",Ue,"layerSpacing"),t>=0&&(this.Vs=t,this.p()))}get columnSpacing(){return this.ti}set columnSpacing(t){this.ti!==t&&(g.s(t,"number",Ue,"columnSpacing"),t>0&&(this.ti=t,this.p()))}get direction(){return this.P}set direction(t){this.P!==t&&(g.s(t,"number",Ue,"direction"),t===0||t===90||t===180||t===270?(this.P=t,this.p()):g.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.cu}set cycleRemoveOption(t){this.cu!==t&&(t===1||t===0||t===2)&&(this.cu=t,this.p())}get layeringOption(){return this.fu}set layeringOption(t){this.fu!==t&&(t===10||t===11||t===12)&&(this.fu=t,this.p())}get initializeOption(){return this.uu}set initializeOption(t){this.uu!==t&&(t===20||t===21||t===22)&&(this.uu=t,this.p())}get iterations(){return this.gc}set iterations(t){this.gc!==t&&t>=0&&(this.gc=t,this.p())}get aggressiveOption(){return this.du}set aggressiveOption(t){this.du!==t&&(t===30||t===31||t===32)&&(this.du=t,this.p())}get packOption(){return this.cr}set packOption(t){this.cr!==t&&(g.s(t,"number",Ue,"packOption"),t>=0&&t<8&&(this.cr=t,this.p()))}get packIterations(){return this.gu}set packIterations(t){this.gu=t}get alignOption(){return this.Gn}set alignOption(t){this.Gn!==t&&(g.s(t,"number",Ue,"align"),t>=0&&t<16&&(this.Gn=t,this.p()))}get centered(){return this.Ka}set centered(t){this.centered!==t&&(g.s(t,"boolean",Ue,"centered"),this.Ka=t,this.p())}get setsPortSpots(){return this.zn}set setsPortSpots(t){this.zn!==t&&(g.s(t,"boolean",Ue,"setsPortSpots"),this.zn=t,this.p())}get maxLayer(){return this._}get maxIndex(){return this.Pw}get maxColumn(){return this.Bt}get minIndexLayer(){return this.Hg}get maxIndexLayer(){return this.Bs}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class Yn extends Je{constructor(t){super(t)}createVertex(){let t=new wi(this);return t.centered=this.layout.centered,t}createEdge(){return new Be(this)}}class wi extends Ze{pl;pa;Tt;iP;sP;Ka;ii;pu;to;Qk;Jk;$k;mc;Yn;MF;qa;rs;yu;gi;Kn;Cw=null;Lw=null;Aw=null;Tw=null;constructor(t){super(t),this.pl=-1,this.pa=-1,this.Tt=-1,this.iP=NaN,this.sP=null,this.Ka=!0,this.ii=!1,this.pu=NaN,this.to=NaN,this.Qk=0,this.Jk=null,this.$k=null}static LF(t,e){return t.index-e.index}getProperSourceEdges(){if(!this.Aw){let t=[];for(let e of this.Mo){let i=e;i.valid&&t.push(i)}this.Aw=t}return this.Aw}getProperDestinationEdges(){if(!this.Tw){let t=[];for(let e of this.rr){let i=e;i.valid&&t.push(i)}this.Tw=t}return this.Tw}getDestinationEdge(t){let e=this.getProperDestinationEdges();for(let i of e)if(i.toVertex===t)return i;g.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.Cw){let t=[];for(let e of this.Mo){let i=e;!i.valid||i.fromVertex.layer<=i.toVertex.layer||t.push(i.fromVertex)}t.sort(wi.LF),this.Cw=t}return this.Cw}getProperDestinationVertexes(){if(!this.Lw){let t=[];for(let e of this.rr){let i=e;!i.valid||i.fromVertex.layer<=i.toVertex.layer||t.push(i.toVertex)}t.sort(wi.LF),this.Lw=t}return this.Lw}addSourceEdge(t){super.addSourceEdge(t),this.Cw=null,this.Aw=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.Cw=null,this.Aw=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Lw=null,this.Tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Lw=null,this.Tw=null}commit(){if(this.centered)super.commit();else{let t=this.node;if(t!==null){let e=this.network.layout;if(!e)return;e.direction===180||e.direction===270?t.moveTo(this.bounds.right-t.actualBounds.width,this.bounds.bottom-t.actualBounds.height):t.moveTo(this.bounds.x,this.bounds.y)}}}get layer(){return this.pl}set layer(t){this.pl=t}get column(){return this.pa}set column(t){this.pa=t}get index(){return this.Tt}set index(t){this.Tt=t}get component(){return this.iP}set component(t){this.iP!==t&&(g.s(t,"number",wi,"component"),this.iP=t)}get near(){return this.sP}set near(t){this.sP!==t&&(this.sP=t)}get centered(){return this.Ka}set centered(t){this.Ka=t}}class Be extends xi{ii;nP;oP;rP;lP;aP;hP;constructor(t){super(t),this.ii=!1,this.nP=!1,this.oP=!1,this.rP=NaN,this.lP=NaN,this.aP=0,this.hP=0}get fromVertex(){return this.ss}set fromVertex(t){this.ss!==t&&(this.ss=t)}get toVertex(){return this.ns}set toVertex(t){this.ns!==t&&(this.ns=t)}get valid(){return this.ii}set valid(t){this.ii!==t&&(g.s(t,"boolean",Be,"valid"),this.ii=t)}get rev(){return this.nP}set rev(t){this.nP!==t&&(g.s(t,"boolean",Be,"rev"),this.nP=t)}get forest(){return this.oP}set forest(t){this.oP!==t&&(g.s(t,"boolean",Be,"forest"),this.oP=t)}get portFromPos(){return this.rP}set portFromPos(t){this.rP!==t&&(g.s(t,"number",Be,"portFromPos"),this.rP=t)}get portToPos(){return this.lP}set portToPos(t){this.lP!==t&&(g.s(t,"number",Be,"portToPos"),this.lP=t)}get portFromColOffset(){return this.aP}set portFromColOffset(t){this.aP!==t&&(g.s(t,"number",Be,"portFromColOffset"),this.aP=t)}get portToColOffset(){return this.hP}set portToColOffset(t){this.hP!==t&&(g.s(t,"number",Be,"portToColOffset"),this.hP=t)}}var Gs=(x=>(x[x.Default=0]="Default",x[x.Destination=1]="Destination",x[x.Source=2]="Source",x))(Gs||{}),qs=(x=>(x[x.Forwards=10]="Forwards",x[x.Reverse=11]="Reverse",x[x.Ascending=12]="Ascending",x[x.Descending=13]="Descending",x))(qs||{}),Hs=(x=>(x[x.CenterSubtrees=20]="CenterSubtrees",x[x.CenterChildren=21]="CenterChildren",x[x.Start=22]="Start",x[x.End=23]="End",x[x.Bus=24]="Bus",x[x.BusBranching=25]="BusBranching",x[x.TopLeftBus=26]="TopLeftBus",x[x.BottomRightBus=27]="BottomRightBus",x[x.Custom=28]="Custom",x))(Hs||{}),Ws=(x=>(x[x.None=30]="None",x[x.Block=31]="Block",x))(Ws||{}),$s=(x=>(x[x.Layered=40]="Layered",x[x.LastParents=41]="LastParents",x[x.Alternating=42]="Alternating",x[x.RootOnly=43]="RootOnly",x))($s||{}),Js=(x=>(x[x.Vertical=50]="Vertical",x[x.Horizontal=51]="Horizontal",x[x.FixedRoots=52]="FixedRoots",x))(Js||{}),Un=(x=>(x[x.Individual=60]="Individual",x[x.Siblings=61]="Siblings",x[x.Uniform=62]="Uniform",x))(Un||{});class Ut extends oe{Ie;Fe;wu;Jg;yL;Xi;He;Us;V;B;cP;ws;constructor(t){super(),this.Ie=new I,this.Fe=0,this.ws=1,this.wu=40,this.Jg=60,this.yL=[],this.Xi=!0,this.He=50,this.Us=new _(10,10).b();let e=new Zs(this);this.V=new It(e),this.B=new It(e),this.cP=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Fe=this.Fe,t.wu=this.wu,t.Jg=this.Jg,t.Xi=this.Xi,t.He=this.He,t.Us.h(this.Us),t.V.copyInheritedPropertiesFrom(this.V),t.B.copyInheritedPropertiesFrom(this.B)}fe(t){t in Hs?this.alignment=t:t in Js?this.arrangement=t:t in Ws?this.compaction=t:t in Gs?this.path=t:t in qs?this.sorting=t:t in $s?this.treeStyle=t:super.fe(t)}createNetwork(){return new Zs(this)}makeNetwork(t){let e=this.createNetwork(),i=s=>{if(s instanceof it)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof q){let n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;let o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof j?(e.addParts(t.nodes,!0,i),e.addParts(t.links,!0,i)):t instanceof ft?e.addParts(t.memberParts,!1,i):e.addParts(t.iterator,!1,i),e}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let e=this.diagram;e===null&&t instanceof j&&(e=t),this.path===0&&e!==null?this.ws=e.isTreePathToChildren?1:2:this.ws=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.oU(),this.rU(),this.lU(),this.aU(),this.fL(),this.hU(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ie=new I,this.isValidLayout=!0}oU(){if(this.network===null)return;this.network.deleteSelfEdges();let t=this.network.vertexes.iterator;for(;t.next();){let n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ie.count>0){let n=new I,o=this.Ie.iterator;for(;o.next();){let r=o.value;if(r instanceof it){let a=this.network.findVertex(r);a!==null&&n.add(a)}else r instanceof It&&n.add(r)}this.Ie=n}this.Ie.count===0&&this.findRoots();let e=this.Ie.copy().iterator;for(;e.next();){let n=e.value;n.initialized||(n.initialized=!0,this.wL(n))}let i=this.network.vertexes,s=null;for(;s=this.cU(i),s.count>0;){let n=this.AF(s);n!==null&&(this.Ie.add(n),n.initialized=!0,this.wL(n)),i=s}}cU(t){let e=new I,i=t.iterator;for(;i.next();){let s=i.value;s.initialized||e.add(s)}return e}findRoots(){if(this.network===null)return;let t=this.network.vertexes,e=t.iterator;for(;e.next();){let i=e.value;switch(this.ws){case 1:i.sourceEdges.count===0&&this.Ie.add(i);break;case 2:i.destinationEdges.count===0&&this.Ie.add(i);break;default:g.o("Unhandled path value "+this.ws.toString())}}if(this.Ie.count===0){let i=this.AF(t);i!==null&&this.Ie.add(i)}}AF(t){let e=999999,i=null,s=t.iterator;for(;s.next();){let n=s.value;switch(this.ws){case 1:n.sourceEdges.count<e&&(e=n.sourceEdges.count,i=n);break;case 2:n.destinationEdges.count<e&&(e=n.destinationEdges.count,i=n);break;default:g.o("Unhandled path value "+this.ws.toString())}}return i}wL(t){if(t===null)return;switch(this.ws){case 1:if(t.destinationEdges.count>0){let s=new U,n=t.destinationVertexes;for(;n.next();){let o=n.value;this.TF(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){let s=new U,n=t.sourceVertexes;for(;n.next();){let o=n.value;this.TF(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:g.o("Unhandled path value"+this.ws.toString())}let e=t.children,i=e.length;for(let s=0;s<i;s++){let n=e[s];n.initialized=!0,n.level=t.level+1,n.parent=t,this.Ie.delete(n)}for(let s=0;s<i;s++){let n=e[s];this.wL(n)}}TF(t,e){return e.initialized?this.fU(e,t)||e.level>t.level?!1:(this.uU(e.parent,e),!0):!0}fU(t,e){if(e===null)return!1;let i=e.parent;for(;i!==null&&i!==t;)i=i.parent;return i===t}uU(t,e){if(t===null||e===null)return;let i=t.children,s=0;for(let n=0;n<i.length;n++)i[n]===e&&s++;if(s>0){let n=new Array(i.length-s),o=0;for(let r=0;r<i.length;r++)i[r]!==e&&(n[o++]=i[r]);t.children=n}}rU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof It&&this.DF(e)}}DF(t){if(t===null)return;this.initializeTreeVertexValues(t),t.alignment===25&&this.sortTreeVertexChildren(t);let e=0,i=t.childrenCount,s=0,n=t.children,o=n.length;for(let r=0;r<o;r++){let a=n[r];this.DF(a),e+=a.descendantCount+1,i=Math.max(i,a.maxChildrenCount),s=Math.max(s,a.maxGenerationCount)}t.descendantCount=e,t.maxChildrenCount=i,t.maxGenerationCount=i>0?s+1:0}dU(t){switch(this.wu){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.B:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.B:this.V;case 41:{let e=!0;if(t.childrenCount===0)e=!1;else{let i=t.children,s=i.length;for(let n=0;n<s;n++)if(i[n].childrenCount>0){e=!1;break}}return e&&t.parent!==null?this.B:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){let e=this.dU(t);if(t.copyInheritedPropertiesFrom(e),t.parent!==null&&t.parent.alignment===25){let i=t.angle,s=t.parent.children,n=0;for(;n<s.length&&t!==s[n];)n++;n%2===0?n!==s.length-1&&(i===90?i=180:i===180?i=270:i===270?i=180:i=270):i===90?i=0:i===180?i=90:i===270?i=0:i=90,t.angle=i}t.initialized=!0}lU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof It&&this.vF(e)}}vF(t){if(t===null)return;this.assignTreeVertexValues(t);let e=t.children,i=e.length;for(let s=0;s<i;s++){let n=e[s];this.vF(n)}}assignTreeVertexValues(t){}aU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof It&&this.FF(e)}}FF(t){if(t===null)return;t.alignment!==25&&this.sortTreeVertexChildren(t);let e=t.children,i=e.length;for(let s=0;s<i;s++){let n=e[s];this.FF(n)}}sortTreeVertexChildren(t){switch(t.sorting){default:case 10:break;case 11:t.children.reverse();break;case 12:t.children.sort(t.comparer);break;case 13:t.children.sort(t.comparer),t.children.reverse();break}}fL(){if(!this.comments||this.network===null)return;let t=this.network.vertexes.iterator;for(;t.next();){let e=t.value;this.addComments(e)}}addComments(t){let e=t.angle,i=t.parent,s=0,n=21,o=!1;i!==null&&(s=i.angle,n=i.alignment,o=this.isBusAlignment(n));let r=e===90||e===270,a=s===90||s===270,h=t.childrenCount===0,l=0,c=0,u=0,d=t.commentSpacing;if(t.node!==null){let f=t.node.findNodesConnected();for(;f.next();){let p=f.value;if(p.category!=="Comment"||!p.canLayout())continue;t.comments===null&&(t.comments=[]),t.comments.push(p),p.ensureBounds();let m=p.measuredBounds;r&&!h||!o&&!a&&h||o&&a&&h?(l=Math.max(l,m.width),c+=m.height+Math.abs(u)):(l+=m.width+Math.abs(u),c=Math.max(c,m.height)),u=d}}if(t.comments!==null){r&&!h||!o&&!a&&h||o&&a&&h?(l+=Math.abs(t.commentMargin),c=Math.max(0,c-t.height)):(c+=Math.abs(t.commentMargin),l=Math.max(0,l-t.width));let f=B.z(0,0,t.bounds.width+l,t.bounds.height+c);t.bounds=f,B.i(f)}}isBusAlignment(t){return t===24||t===25||t===26||t===27}Dw(t){return t===24||t===25}xL(t){let e=t.parent;if(e!==null){let i=e.alignment;if(this.isBusAlignment(i))if(this.Dw(i)){let s=e.children,n=0;for(;n<s.length&&t!==s[n];)n++;return n%2===0}else return i===26}return!1}layoutComments(t){if(t.comments!==null){let e=t.node.measuredBounds,i=t.parent,s=t.angle,n=0,o=21,r=!1;i!==null&&(n=i.angle,o=i.alignment,r=this.isBusAlignment(o));let a=s===90||s===270,h=n===90||n===270,l=t.childrenCount===0,c=this.xL(t),u=0,d=t.comments,f=d.length,p=P.l();for(let y=0;y<f;y++){let b=d[y],v=b.measuredBounds;if(a&&!l||!r&&!h&&l||r&&h&&l){if(n>135&&!r||h&&c)if(t.commentMargin>=0){p.e(t.bounds.x-t.commentMargin-v.width,t.bounds.y+u),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleLeft,k.toSpot=T.MiddleRight}}else{p.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleRight,k.toSpot=T.MiddleLeft}}else if(t.commentMargin>=0){p.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleRight,k.toSpot=T.MiddleLeft}}else{p.e(t.bounds.x+t.commentMargin-v.width,t.bounds.y+u),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleLeft,k.toSpot=T.MiddleRight}}t.commentSpacing>=0?u+=v.height+t.commentSpacing:u+=t.commentSpacing-v.height}else{if(n>135&&!r||!h&&c)if(t.commentMargin>=0){p.e(t.bounds.x+u,t.bounds.y-t.commentMargin-v.height),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleTop,k.toSpot=T.MiddleBottom}}else{p.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleBottom,k.toSpot=T.MiddleTop}}else if(t.commentMargin>=0){p.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleBottom,k.toSpot=T.MiddleTop}}else{p.e(t.bounds.x+u,t.bounds.y+t.commentMargin-v.height),b.move(p);let w=b.findLinksInto();for(;w.next();){let k=w.value;k.fromSpot=T.MiddleTop,k.toSpot=T.MiddleBottom}}t.commentSpacing>=0?u+=v.width+t.commentSpacing:u+=t.commentSpacing-v.width}}P.i(p);let m=u-t.commentSpacing-(a?e.height:e.width);if(this.ws===1){let y=t.destinationEdges;for(;y.next();){let b=y.value.link;b!==null&&!b.isAvoiding&&(b.fromEndSegmentLength=m>0?m:NaN)}}else{let y=t.sourceEdges;for(;y.next();){let b=y.value.link;b!==null&&!b.isAvoiding&&(b.toEndSegmentLength=m>0?m:NaN)}}}}hU(){if(this.network===null)return;if(this.layerStyle===62){let e=[],i=this.network.vertexes.iterator;for(;i.next();){let s=i.value,n=s.parent;n===null&&(n=s);let o=n.angle===0||n.angle===180,r=e[s.level];r===void 0&&(r=0),e[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s<e.length;s++)e[s]===void 0&&(e[s]=0);for(this.yL=e,i=this.network.vertexes.iterator;i.next();){let s=i.value,n=s.parent;n===null&&(n=s),n.angle===0||n.angle===180?(n.angle===180&&(s.focusX+=e[s.level]-s.width),s.width=e[s.level]):(n.angle===270&&(s.focusY+=e[s.level]-s.height),s.height=e[s.level])}}else if(this.layerStyle===61){let e=this.network.vertexes.iterator;for(;e.next();){let i=e.value,s=i.angle===0||i.angle===180,n=-1;for(let o=0;o<i.children.length;o++){let r=i.children[o];n=Math.max(n,s?r.width:r.height)}if(n>=0)for(let o=0;o<i.children.length;o++){let r=i.children[o];s?(i.angle===180&&(r.focusX+=n-r.width),r.width=n):(i.angle===270&&(r.focusY+=n-r.height),r.height=n)}}}let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof It&&this.layoutTree(e)}}layoutTree(t){if(t===null)return;let e=t.children,i=e.length;for(let s=0;s<i;s++){let n=e[s];this.layoutTree(n)}switch(t.compaction){case 30:this.RF(t);break;default:case 31:t.alignment===25?this.RF(t):this.gU(t);break}}RF(t){if(t.childrenCount===0){let Y=!1,X=0,G=21;t.parent!==null&&(X=t.parent.angle,G=t.parent.alignment,Y=this.isBusAlignment(G));let rt=this.xL(t);t.U.e(0,0),t.dt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((X===180||X===270)&&!Y||rt)?X===180&&!Y||(X===90||X===270)&&rt?t.at.e(t.width-t.focus.x*2,0):t.at.e(0,t.height-t.focus.y*2):t.at.e(0,0);return}let e=this.orthoAngle(t),i=e===90||e===270,s=0,n=t.children,o=n.length;for(let Y=0;Y<o;Y++){let X=n[Y];s=Math.max(s,i?X.dt.width:X.dt.height)}let r=t.alignment,a=r===22,h=r===23,l=this.isBusAlignment(r),c=Math.max(0,t.breadthLimit),u=this.computeLayerSpacing(t),d=t.nodeSpacing,f=this.computeNodeIndent(t),p=a||h?0:f/2,m=t.rowSpacing,y=0;(a||h)&&(y=Math.max(0,t.rowIndent));let b=t.width,v=t.height,w=0,k=0,S=0,M=0,F=0,D=0,N=0,L=0,R=0,O=0;if(l&&!this.Dw(r)&&e>135&&n.reverse(),this.Dw(r))if(o>1)for(let Y=0;Y<o;Y++){let X=n[Y],G=X.dt;Y%2===0&&Y!==o-1?R=Math.max(R,(i?G.width:G.height)+this.computeBusNodeSpacing(X)-d):Y%2!==0&&(O=Math.max(O,(i?G.width:G.height)+this.computeBusNodeSpacing(X)-d))}else o===1&&(R=i?n[0].dt.width:n[0].dt.height);if(l)switch(r){case 24:case 25:let Y=B.l();e<135?this.OF(t,n,R,O,w,k,Y):this.IF(t,n,R,O,w,k,Y),R=Y.x,w=Y.width,k=Y.height,B.i(Y);break;case 26:for(let X=0;X<o;X++){let G=n[X],rt=G.dt,lt=N===0?0:m;i?(G.U.e(s-rt.width,F+lt),w=Math.max(w,rt.width),k=Math.max(k,F+lt+rt.height),F+=lt+rt.height):(G.U.e(M+lt,s-rt.height),w=Math.max(w,M+lt+rt.width),k=Math.max(k,rt.height),M+=lt+rt.width),N++}break;case 27:for(let X=0;X<o;X++){let G=n[X],rt=G.dt,lt=N===0?0:m;i?(G.U.e(d/2+t.focus.x,F+lt),w=Math.max(w,rt.width),k=Math.max(k,F+lt+rt.height),F+=lt+rt.height):(G.U.e(M+lt,d/2+t.focus.y),w=Math.max(w,M+lt+rt.width),k=Math.max(k,rt.height),M+=lt+rt.width),N++}break}else for(let Y=0;Y<o;Y++){let X=n[Y],G=X.dt;if(i){c>0&&N>0&&M+d+G.width>c&&(M<s&&this.pc(t,r,s-M,0,L,Y-1),D++,N=0,L=Y,S=k,M=0,F=e>135?-k-m:k+m);let rt=N===0?p:d;this.fP(X,0,F),X.U.e(M+rt,F),w=Math.max(w,M+rt+G.width),k=Math.max(k,S+(D===0?0:m)+G.height),M+=rt+G.width}else{c>0&&N>0&&F+d+G.height>c&&(F<s&&this.pc(t,r,0,s-F,L,Y-1),D++,N=0,L=Y,S=w,F=0,M=e>135?-w-m:w+m);let rt=N===0?p:d;this.fP(X,M,0),X.U.e(M,F+rt),k=Math.max(k,F+rt+G.height),w=Math.max(w,S+(D===0?0:m)+G.width),F+=rt+G.height}N++}D>0&&(i?(k+=Math.max(0,u),M<w&&this.pc(t,r,w-M,0,L,o-1),y>0&&(h||this.xu(t,y,0,0,o-1),w+=y)):(w+=Math.max(0,u),F<k&&this.pc(t,r,0,k-F,L,o-1),y>0&&(h||this.xu(t,0,y,0,o-1),k+=y)));let V=0,K=0;switch(r){case 20:i?V+=w/2-t.focus.x-f/2:K+=k/2-t.focus.y-f/2;break;default:case 21:if(D>0)i?V+=w/2-t.focus.x-f/2:K+=k/2-t.focus.y-f/2;else{let X=o;if(i){let G=n[0].U.x+n[0].at.x,rt=n[X-1].U.x+n[X-1].at.x+n[X-1].focus.x*2;V+=G+(rt-G)/2-t.focus.x-f/2}else{let G=n[0].U.y+n[0].at.y,rt=n[X-1].U.y+n[X-1].at.y+n[X-1].focus.y*2;K+=G+(rt-G)/2-t.focus.y-f/2}}break;case 22:i?(V-=f,w+=f):(K-=f,k+=f);break;case 23:i?(V+=w-t.width+f,w+=f):(K+=k-t.height+f,k+=f);break;case 24:case 25:i?o>1?V+=R+d/2-t.focus.x:V+=n[0].focus.x-t.focus.x+n[0].at.x:o>1?K+=R+d/2-t.focus.y:K+=n[0].focus.y-t.focus.y+n[0].at.y;break;case 26:i?V+=w+d/2-t.focus.x:K+=k+d/2-t.focus.y;break;case 27:break;case 28:let Y=this.customAlignment(t,V,K,w,k);V=Y[0],K=Y[1],w=Y[2],k=Y[3];break}for(let Y=0;Y<o;Y++){let X=n[Y];i?X.U.e(X.U.x+X.at.x-V,X.U.y+(e>135?(l?-k:-X.dt.height)+X.at.y-u:v+u+X.at.y)):X.U.e(X.U.x+(e>135?(l?-w:-X.dt.width)+X.at.x-u:b+u+X.at.x),X.U.y+X.at.y-K)}i?(w=this.bL(t,w,V),V<0&&(V=0),e>135&&(K+=k+u),k=Math.max(Math.max(k,v),k+v+u)):(e>135&&(V+=w+u),w=Math.max(Math.max(w,b),w+b+u),k=this.kL(t,k,K),K<0&&(K=0)),t.at.e(V,K),t.dt.e(w,k)}customAlignment(t,e,i,s,n){return[e,i,s,n]}OF(t,e,i,s,n,o,r){let a=e.length;if(a===0)return r.e(i,0,n,o),r;if(a===1){let y=e[0];return n=y.dt.width,o=y.dt.height,r.e(i,0,n,o),r}let h=t.nodeSpacing,l=t.rowSpacing,c=this.orthoAngle(t)===90,u=0,d=0,f=0;for(let y=0;y<a;y++){if(y%2!==0||a>1&&y===a-1)continue;let b=e[y],v=b.dt,w=u===0?0:l;if(c){let k=this.computeBusNodeSpacing(b)-h;b.U.e(i-(v.width+k),f+w),n=Math.max(n,v.width+k),o=Math.max(o,f+w+v.height),f+=w+v.height}else{let k=this.computeBusNodeSpacing(b)-h;b.U.e(d+w,i-(v.height+k)),o=Math.max(o,v.height+k),n=Math.max(n,d+w+v.width),d+=w+v.width}u++}u=0;let p=d,m=f;c?(d=i+h,f=0):(d=0,f=i+h);for(let y=0;y<a;y++){if(y%2===0)continue;let b=e[y],v=b.dt,w=u===0?0:l;if(c){let k=this.computeBusNodeSpacing(b)-h;b.U.e(d+k,f+w),n=Math.max(n,d+v.width+k),o=Math.max(o,f+w+v.height),f+=w+v.height}else{let k=this.computeBusNodeSpacing(b)-h;b.U.e(d+w,f+k),n=Math.max(n,d+w+v.width),o=Math.max(o,f+v.height+k),d+=w+v.width}u++}if(a>1&&a%2===1){let y=e[a-1],b=y.dt,v=this.computeBusLastRowSpacing(y,c?Math.max(Math.abs(m),Math.abs(f)):Math.max(Math.abs(p),Math.abs(d)));if(c){y.U.e(i+h/2-y.focus.x-y.at.x,o+v);let w=i+h/2-y.focus.x-y.at.x;n=Math.max(n,w+b.width),w<0&&(n-=w),o=Math.max(o,Math.max(m,f)+v+b.height),y.U.x<0&&(i=this.uP(t,y.U.x,!1,i,h))}else{y.U.e(n+v,i+h/2-y.focus.y-y.at.y),n=Math.max(n,Math.max(p,d)+v+b.width);let w=i+h/2-y.focus.y-y.at.y;o=Math.max(o,w+b.height),w<0&&(o-=w),y.U.y<0&&(i=this.uP(t,y.U.y,!0,i,h))}}return r.e(i,0,n,o),r}IF(t,e,i,s,n,o,r){let a=e.length;if(a===0)return r.e(i,0,n,o),r;if(a===1){let y=e[0];return n=y.dt.width,o=y.dt.height,r.e(i,0,n,o),r}let h=t.nodeSpacing,l=t.rowSpacing,c=this.orthoAngle(t)===270,u=0,d=0,f=0;for(let y=0;y<a;y++){if(y%2!==0||a>1&&y===a-1)continue;let b=e[y],v=b.dt,w=u===0?0:l;if(c){let k=this.computeBusNodeSpacing(b)-h;f-=w+v.height,b.U.e(i-(v.width+k),f),n=Math.max(n,v.width+k),o=Math.max(o,Math.abs(f))}else{let k=this.computeBusNodeSpacing(b)-h;d-=w+v.width,b.U.e(d,i-(v.height+k)),o=Math.max(o,v.height+k),n=Math.max(n,Math.abs(d))}u++}u=0;let p=d,m=f;c?(d=i+h,f=0):(d=0,f=i+h);for(let y=0;y<a;y++){if(y%2===0)continue;let b=e[y],v=b.dt,w=u===0?0:l;if(c){let k=this.computeBusNodeSpacing(b)-h;f-=w+v.height,b.U.e(d+k,f),n=Math.max(n,d+v.width+k),o=Math.max(o,Math.abs(f))}else{let k=this.computeBusNodeSpacing(b)-h;d-=w+v.width,b.U.e(d,f+k),o=Math.max(o,f+v.height+k),n=Math.max(n,Math.abs(d))}u++}if(a>1&&a%2===1){let y=e[a-1],b=y.dt,v=this.computeBusLastRowSpacing(y,c?Math.max(Math.abs(m),Math.abs(f)):Math.max(Math.abs(p),Math.abs(d)));if(c){y.U.e(i+h/2-y.focus.x-y.at.x,-o-b.height-v);let w=i+h/2-y.focus.x-y.at.x;n=Math.max(n,w+b.width),w<0&&(n-=w),o=Math.max(o,Math.abs(Math.min(m,f))+v+b.height),y.U.x<0&&(i=this.uP(t,y.U.x,!1,i,h))}else{y.U.e(-n-b.width-v,i+h/2-y.focus.y-y.at.y),n=Math.max(n,Math.abs(Math.min(p,d))+v+b.width);let w=i+h/2-y.focus.y-y.at.y;o=Math.max(o,w+b.height),w<0&&(o-=w),y.U.y<0&&(i=this.uP(t,y.U.y,!0,i,h))}}for(let y=0;y<a;y++){let b=e[y];c?b.U.e(b.U.x,b.U.y+o):b.U.e(b.U.x+n,b.U.y)}return r.e(i,0,n,o),r}computeBusNodeSpacing(t){return t.parent===null?0:t.parent.nodeSpacing}computeBusLastRowSpacing(t,e){return t.parent===null?0:t.parent.rowSpacing}uP(t,e,i,s,n){let o=t.children,r=o.length;for(let h=0;h<r;h++)i?o[h].U.e(o[h].U.x,o[h].U.y-e):o[h].U.e(o[h].U.x-e,o[h].U.y);let a=o[r-1];return Math.max(s,i?a.at.y+a.focus.y-n/2:a.at.x+a.focus.x-n/2)}bL(t,e,i){switch(t.alignment){case 21:case 20:let s=e;return i+t.width>s&&(s=i+t.width),i<0&&(s-=i),s;case 22:return t.width>e?t.width:e;case 23:return t.focus.x*2>e?t.width:e+t.width-t.focus.x*2;case 24:case 25:let n=Math.min(0,i),o=Math.max(e,i+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+e;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+e);default:return e}}kL(t,e,i){switch(t.alignment){case 21:case 20:let s=e;return i+t.height>s&&(s=i+t.height),i<0&&(s-=i),s;case 22:return t.height>e?t.height:e;case 23:return t.focus.y*2>e?t.height:e+t.height-t.focus.y*2;case 24:case 25:let n=Math.min(0,i),o=Math.max(e,i+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+e;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+e);default:return e}}PL(t,e,i){switch(t){case 20:e/=2,i/=2;break;case 21:e/=2,i/=2;break;case 22:e=0,i=0;break;case 23:break;default:g.o("Unhandled alignment value "+t.toString())}return new P(e,i)}pc(t,e,i,s,n,o){let r=this.PL(e,i,s);this.xu(t,r.x,r.y,n,o)}xu(t,e,i,s,n){if(e===0&&i===0)return;let o=t.children;for(let r=s;r<=n;r++){let a=o[r].U;a.x+=e,a.y+=i}}fP(t,e,i){let s=t.parent;switch(this.ws){case 1:{let n=t.sourceEdges;for(;n.next();){let o=n.value;o.fromVertex===s&&o.relativePoint.e(e,i)}break}case 2:{let n=t.destinationEdges;for(;n.next();){let o=n.value;o.toVertex===s&&o.relativePoint.e(e,i)}break}default:g.o("Unhandled path value "+this.ws.toString())}}gU(t){if(t.childrenCount===0){let ot=t.parent,dt=!1,pt=0,vt=21;ot!==null&&(pt=ot.angle,vt=ot.alignment,dt=this.isBusAlignment(vt));let Ct=this.xL(t);t.U.e(0,0),t.dt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((pt===180||pt===270)&&!dt||Ct)?pt===180&&!dt||(pt===90||pt===270)&&Ct?t.at.e(t.width-t.focus.x*2,0):t.at.e(0,t.height-t.focus.y*2):t.at.e(0,0),t.$g=null,t.Zg=null;return}let e=this.orthoAngle(t),i=e===90||e===270,s=0,n=t.children,o=n.length;for(let ot=0;ot<o;ot++){let dt=n[ot];s=Math.max(s,i?dt.dt.width:dt.dt.height)}let r=t.alignment,a=r===22,h=r===23,l=this.isBusAlignment(r),c=Math.max(0,t.breadthLimit),u=this.computeLayerSpacing(t),d=t.nodeSpacing,f=this.computeNodeIndent(t),p=t.rowSpacing,m=0;(a||h)&&(m=Math.max(0,t.rowIndent));let y=t.width,b=t.height,v=0,w=0,k=0,S=null,M=null,F=0,D=0,N=0,L=0,R=0,O=0,V=0,K=0,Y=0;if(l&&!this.Dw(r)&&e>135&&n.reverse(),this.Dw(r))if(o>1)for(let ot=0;ot<o;ot++)ot%2===0&&ot!==o-1?K=Math.max(K,i?n[ot].dt.width:n[ot].dt.height):ot%2!==0&&(Y=Math.max(Y,i?n[ot].dt.width:n[ot].dt.height));else o===1&&(K=i?n[0].dt.width:n[0].dt.height);if(l){switch(r){case 24:let ot=B.l();e<135?this.OF(t,n,K,Y,v,w,ot):this.IF(t,n,K,Y,v,w,ot),K=ot.x,v=ot.width,w=ot.height,B.i(ot);break;case 26:for(let dt=0;dt<o;dt++){let pt=n[dt],vt=pt.dt,Ct=O===0?0:p;i?(pt.U.e(s-vt.width,L+Ct),v=Math.max(v,vt.width),w=Math.max(w,L+Ct+vt.height),L+=Ct+vt.height):(pt.U.e(N+Ct,s-vt.height),v=Math.max(v,N+Ct+vt.width),w=Math.max(w,vt.height),N+=Ct+vt.width),O++}break;case 27:for(let dt=0;dt<o;dt++){let pt=n[dt],vt=pt.dt,Ct=O===0?0:p;i?(pt.U.e(d/2+t.focus.x,L+Ct),v=Math.max(v,vt.width),w=Math.max(w,L+Ct+vt.height),L+=Ct+vt.height):(pt.U.e(N+Ct,d/2+t.focus.y),v=Math.max(v,N+Ct+vt.width),w=Math.max(w,vt.height),N+=Ct+vt.width),O++}break}S=this.mi(2),M=this.mi(2),i?(S[0].e(0,0),S[1].e(0,w),M[0].e(v,0),M[1].e(v,w)):(S[0].e(0,0),S[1].e(v,0),M[0].e(0,w),M[1].e(v,w))}else for(let ot=0;ot<o;ot++){let dt=n[ot],pt=dt.dt;if(i){c>0&&O>0&&N+d+pt.width>c&&(N<s&&this.pc(t,r,s-N,0,V,ot-1),R++,O=0,V=ot,k=w,N=0,L=e>135?-w-p:w+p),this.fP(dt,0,L);let vt=0;if(O===0)S=dt.$g,M=dt.Zg,F=pt.width,D=pt.height,(S===null||M===null||e!==this.orthoAngle(dt))&&(S=this.mi(2),M=this.mi(2),S[0].e(0,0),S[1].e(0,D),M[0].e(F,0),M[1].e(F,D));else{let Ct=g.ot(),nt=B.l();this.EF(t,dt,S,M,F,D,Ct,nt),vt=nt.x,S=Ct[0],M=Ct[1],F=nt.width,D=nt.height,g.Z(Ct),N<pt.width&&vt<0&&(this.xu(t,-vt,0,V,ot-1),this.dP(S,-vt,0),this.dP(M,-vt,0),vt=0),B.i(nt)}dt.U.e(vt,L),v=Math.max(v,F),w=Math.max(w,k+(R===0?0:p)+pt.height),N=F}else{c>0&&O>0&&L+d+pt.height>c&&(L<s&&this.pc(t,r,0,s-L,V,ot-1),R++,O=0,V=ot,k=v,L=0,N=e>135?-v-p:v+p),this.fP(dt,N,0);let vt=0;if(O===0)S=dt.$g,M=dt.Zg,F=pt.width,D=pt.height,(S===null||M===null||e!==this.orthoAngle(dt))&&(S=this.mi(2),M=this.mi(2),S[0].e(0,0),S[1].e(F,0),M[0].e(0,D),M[1].e(F,D));else{let Ct=g.ot(),nt=B.l();this.EF(t,dt,S,M,F,D,Ct,nt),vt=nt.x,S=Ct[0],M=Ct[1],F=nt.width,D=nt.height,g.Z(Ct),L<pt.height&&vt<0&&(this.xu(t,0,-vt,V,ot-1),this.dP(S,0,-vt),this.dP(M,0,-vt),vt=0),B.i(nt)}dt.U.e(N,vt),w=Math.max(w,D),v=Math.max(v,k+(R===0?0:p)+pt.width),L=D}O++}R>0&&(i?(w+=Math.max(0,u),N<v&&this.pc(t,r,v-N,0,V,o-1),m>0&&(h||this.xu(t,m,0,0,o-1),v+=m)):(v+=Math.max(0,u),L<w&&this.pc(t,r,0,w-L,V,o-1),m>0&&(h||this.xu(t,0,m,0,o-1),w+=m)));let X=0,G=0;switch(r){case 20:i?X+=v/2-t.focus.x-f/2:G+=w/2-t.focus.y-f/2;break;default:case 21:if(R>0)i?X+=v/2-t.focus.x-f/2:G+=w/2-t.focus.y-f/2;else{let dt=o;if(i){let pt=n[0].U.x+n[0].at.x,vt=n[dt-1].U.x+n[dt-1].at.x+n[dt-1].focus.x*2;X+=pt+(vt-pt)/2-t.focus.x-f/2}else{let pt=n[0].U.y+n[0].at.y,vt=n[dt-1].U.y+n[dt-1].at.y+n[dt-1].focus.y*2;G+=pt+(vt-pt)/2-t.focus.y-f/2}}break;case 22:i?(X-=f,v+=f):(G-=f,w+=f);break;case 23:i?(X+=v-t.width+f,v+=f):(G+=w-t.height+f,w+=f);break;case 24:i?o>1?X+=K+d/2-t.focus.x:X+=n[0].focus.x-t.focus.x+n[0].at.x:o>1?G+=K+d/2-t.focus.y:G+=n[0].focus.y-t.focus.y+n[0].at.y;break;case 26:i?X+=v+d/2-t.focus.x:G+=w+d/2-t.focus.y;break;case 27:break;case 28:let ot=this.customAlignment(t,X,G,v,w);X=ot[0],G=ot[1],v=ot[2],w=ot[3];break}for(let ot=0;ot<o;ot++){let dt=n[ot];i?dt.U.e(dt.U.x+dt.at.x-X,dt.U.y+(e>135?(l?-w:-dt.dt.height)+dt.at.y-u:b+u+dt.at.y)):dt.U.e(dt.U.x+(e>135?(l?-v:-dt.dt.width)+dt.at.x-u:y+u+dt.at.x),dt.U.y+dt.at.y-G)}let rt=0,lt=0;if(l)i?(v=this.bL(t,v,X),X<0&&(X=0),e>135&&(G+=w+u),w+=b+u,r===27&&(rt+=d/2+t.focus.x),lt+=b+u):(e>135&&(X+=v+u),v+=y+u,w=this.kL(t,w,G),G<0&&(G=0),r===27&&(lt+=d/2+t.focus.y),rt+=y+u);else if(i){if(t.comments===null){if(y>v){let ot=this.PL(r,y-v,0);rt=ot.x,lt=ot.y,v=y,X=0}}else v=this.bL(t,v,X);X<0&&(rt-=X,X=0),e>135&&(G+=w+u),w=Math.max(Math.max(w,b),w+b+u),lt+=b+u}else{if(e>135&&(X+=v+u),v=Math.max(Math.max(v,y),v+y+u),t.comments===null){if(b>w){let ot=this.PL(r,0,b-w);rt=ot.x,lt=ot.y,w=b,G=0}}else w=this.kL(t,w,G);G<0&&(lt-=G,G=0),rt+=y+u}let st,ht;if(R>0)st=this.mi(4),ht=this.mi(4),i?(st[2].e(0,b+u),st[3].e(st[2].x,w),ht[2].e(v,st[2].y),ht[3].e(ht[2].x,st[3].y)):(st[2].e(y+u,0),st[3].e(v,st[2].y),ht[2].e(st[2].x,w),ht[3].e(st[3].x,ht[2].y));else{st=this.mi(S.length+2),ht=this.mi(M.length+2);for(let ot=0;ot<S.length;ot++){let dt=S[ot];st[ot+2].e(dt.x+rt,dt.y+lt)}for(let ot=0;ot<M.length;ot++){let dt=M[ot];ht[ot+2].e(dt.x+rt,dt.y+lt)}}i?(st[0].e(X,0),st[1].e(st[0].x,b),st[2].y<st[1].y&&(st[2].x>st[0].x?st[2].h(st[1]):st[1].h(st[2])),st[3].y<st[2].y&&(st[3].x>st[0].x?st[3].h(st[2]):st[2].h(st[3])),ht[0].e(X+y,0),ht[1].e(ht[0].x,b),ht[2].y<ht[1].y&&(ht[2].x<ht[0].x?ht[2].h(ht[1]):ht[1].h(ht[2])),ht[3].y<ht[2].y&&(ht[3].x<ht[0].x?ht[3].h(ht[2]):ht[2].h(ht[3])),st[2].y-=u/2,ht[2].y-=u/2):(st[0].e(0,G),st[1].e(y,st[0].y),st[2].x<st[1].x&&(st[2].y>st[0].y?st[2].h(st[1]):st[1].h(st[2])),st[3].x<st[2].x&&(st[3].y>st[0].y?st[3].h(st[2]):st[2].h(st[3])),ht[0].e(0,G+b),ht[1].e(y,ht[0].y),ht[2].x<ht[1].x&&(ht[2].y<ht[0].y?ht[2].h(ht[1]):ht[1].h(ht[2])),ht[3].x<ht[2].x&&(ht[3].y<ht[0].y?ht[3].h(ht[2]):ht[2].h(ht[3])),st[2].x-=u/2,ht[2].x-=u/2),this.un(S),this.un(M),t.$g=st,t.Zg=ht,t.at.e(X,G),t.dt.e(v,w)}dP(t,e,i){for(let s=0;s<t.length;s++){let n=t[s];n.x+=e,n.y+=i}}EF(t,e,i,s,n,o,r,a){let h=this.orthoAngle(t),l=h===90||h===270,c=t.nodeSpacing,u=i,d=s,f=n,p=o,m=e.$g,y=e.Zg,b=e.dt,v=l?Math.max(p,b.height):Math.max(f,b.width);if((m===null||h!==this.orthoAngle(e))&&(m=this.mi(2),y=this.mi(2),l?(m[0].e(0,0),m[1].e(0,b.height),y[0].e(b.width,0),y[1].e(y[0].x,m[1].y)):(m[0].e(0,0),m[1].e(b.width,0),y[0].e(0,b.height),y[1].e(m[1].x,y[0].y))),l){let w=f,k=w-this.mU(d,m,w);return k+=c,i=this.pU(u,m,k),s=this.yU(d,y,k),n=Math.max(0,k)+b.width,o=v,this.un(u),this.un(m),this.un(d),this.un(y),r[0]=i,r[1]=s,a.e(k,0,n,o),a}else{let w=p,k=w-this.wU(d,m,w);return k+=c,i=this.xU(u,m,k),s=this.bU(d,y,k),n=v,o=Math.max(0,k)+b.height,this.un(u),this.un(m),this.un(d),this.un(y),r[0]=i,r[1]=s,a.e(k,0,n,o),a}}xU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.mi(t.length+e.length),n=0,o=0,r=0;for(;o<e.length&&e[o].x<t[0].x;){let l=e[o++];s[r++].e(l.x,l.y+i)}for(;n<t.length;){let l=t[n++];s[r++].e(l.x,l.y)}let a=t[t.length-1].x;for(;o<e.length&&e[o].x<=a;)o++;for(;o<e.length&&e[o].x>a;){let l=e[o++];s[r++].e(l.x,l.y+i)}let h=this.mi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.un(s),h}pU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.mi(t.length+e.length),n=0,o=0,r=0;for(;o<e.length&&e[o].y<t[0].y;){let l=e[o++];s[r++].e(l.x+i,l.y)}for(;n<t.length;){let l=t[n++];s[r++].e(l.x,l.y)}let a=t[t.length-1].y;for(;o<e.length&&e[o].y<=a;)o++;for(;o<e.length&&e[o].y>a;){let l=e[o++];s[r++].e(l.x+i,l.y)}let h=this.mi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.un(s),h}bU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.mi(t.length+e.length),n=0,o=0,r=0;for(;n<t.length&&t[n].x<e[0].x;){let l=t[n++];s[r++].e(l.x,l.y)}for(;o<e.length;){let l=e[o++];s[r++].e(l.x,l.y+i)}let a=e[e.length-1].x;for(;n<t.length&&t[n].x<=a;)n++;for(;n<t.length&&t[n].x>a;){let l=t[n++];s[r++].e(l.x,l.y)}let h=this.mi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.un(s),h}yU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.mi(t.length+e.length),n=0,o=0,r=0;for(;n<t.length&&t[n].y<e[0].y;){let l=t[n++];s[r++].e(l.x,l.y)}for(;o<e.length;){let l=e[o++];s[r++].e(l.x+i,l.y)}let a=e[e.length-1].y;for(;n<t.length&&t[n].y<=a;)n++;for(;n<t.length&&t[n].y>a;){let l=t[n++];s[r++].e(l.x,l.y)}let h=this.mi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.un(s),h}wU(t,e,i){let s=9999999;if(t===null||t.length<2||e===null||e.length<2)return s;let n=0,o=0;for(;n<t.length&&o<e.length;){let r=t[n],a=e[o],h=a.x,l=a.y;l+=i;let c=r;n+1<t.length&&(c=t[n+1]);let u=a,d=u.x,f=u.y;o+1<e.length&&(u=e[o+1],d=u.x,f=u.y,f+=i);let p=s;r.x===h?p=l-r.y:r.x>h&&r.x<d?p=l+(r.x-h)/(d-h)*(f-l)-r.y:h>r.x&&h<c.x&&(p=l-(r.y+(h-r.x)/(c.x-r.x)*(c.y-r.y))),p<s&&(s=p),c.x<=r.x?n++:d<=h?o++:(c.x<=d&&n++,d<=c.x&&o++)}return s}mU(t,e,i){let s=9999999;if(t===null||t.length<2||e===null||e.length<2)return s;let n=0,o=0;for(;n<t.length&&o<e.length;){let r=t[n],a=e[o],h=a.x,l=a.y;h+=i;let c=r;n+1<t.length&&(c=t[n+1]);let u=a,d=u.x,f=u.y;o+1<e.length&&(u=e[o+1],d=u.x,f=u.y,d+=i);let p=s;r.y===l?p=h-r.x:r.y>l&&r.y<f?p=h+(r.y-l)/(f-l)*(d-h)-r.x:l>r.y&&l<c.y&&(p=h-(r.x+(l-r.y)/(c.y-r.y)*(c.x-r.x))),p<s&&(s=p),c.y<=r.y?n++:f<=l?o++:(c.y<=f&&n++,f<=c.y&&o++)}return s}mi(t){let e=this.cP[t];if(e!==void 0){let s=e.pop();if(s!==void 0)return s}let i=[];for(let s=0;s<t;s++)i[s]=new P;return i}un(t){if(!t)return;let e=t.length,i=this.cP[e];i===void 0&&(i=[],this.cP[e]=i),i.push(t)}arrangeTrees(){if(this.He===52){let t=this.Ie.iterator;for(;t.next();){let e=t.value;if(!(e instanceof It))continue;let i=e.node;if(i===null)continue;let s=i.position,n=s.x,o=s.y;isFinite(n)||(n=0),isFinite(o)||(o=0),this.SL(e,n,o)}}else{let t=[],e=this.Ie.iterator;for(;e.next();){let o=e.value;o instanceof It&&t.push(o)}switch(this.sorting){default:case 10:break;case 11:t.reverse();break;case 12:t.sort(this.comparer);break;case 13:t.sort(this.comparer),t.reverse();break}let i=this.arrangementOrigin,s=i.x,n=i.y;for(let o=0;o<t.length;o++){let r=t[o];switch(this.SL(r,s+r.at.x,n+r.at.y),this.He){case 50:n+=r.dt.height+this.Us.height;break;default:case 51:s+=r.dt.width+this.Us.width;break}}}}SL(t,e,i){if(t===null)return;t.x=e,t.y=i;let s=t.children,n=s.length;for(let o=0;o<n;o++){let r=s[o];this.SL(r,e+r.U.x,i+r.U.y)}}commitLayout(){this.kw(),this.commitNodes(),this.pL(),this.isRouting&&this.commitLinks()}commitNodes(){if(this.network===null)return;let t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();for(t.reset();t.next();){let e=t.value;this.layoutComments(e)}}pL(){if(this.network===null||this.layerStyle!==62)return;let t=this.yL,e=[],i,s=this.network.vertexes.iterator;for(;s.next();){let h=s.value;i===void 0?i=h.bounds.copy():i.unionRect(h.bounds);let l=e[h.level];l===void 0?l=this.computeLayerSpacing(h):l=Math.max(l,this.computeLayerSpacing(h)),e[h.level]=l}if(!i)return;for(let h=0;h<e.length;h++)e[h]===void 0&&(e[h]=0);let n;this.angle===90||this.angle===270?(i.inflate(this.nodeSpacing/2,this.layerSpacing),n=new P(-this.nodeSpacing/2,-this.layerSpacing/2)):(i.inflate(this.layerSpacing,this.nodeSpacing/2),n=new P(-this.layerSpacing/2,-this.nodeSpacing/2));let o=[],r=this.angle===90||this.angle===270?i.width:i.height,a=0;if(this.angle===180||this.angle===270)for(let h=0;h<t.length;h++)a+=t[h]+e[h];for(let h=0;h<t.length;h++){let l=t[h]+e[h];this.angle===270?(a-=l,o.push(new B(0,a,r,l))):this.angle===90?(o.push(new B(0,a,r,l)),a+=l):this.angle===180?(a-=l,o.push(new B(a,0,l,r))):(o.push(new B(a,0,l,r)),a+=l)}this.commitLayers(o,n)}commitLayers(t,e){}commitLinks(){if(this.network===null)return;let t=this.network.edges.iterator;for(;t.next();)t.value.commit()}kw(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof It&&this.UF(e)}}UF(t){if(t===null)return;this.setPortSpots(t);let e=t.children,i=e.length;for(let s=0;s<i;s++){let n=e[s];this.UF(n)}}setPortSpots(t){let e=t.alignment;if(this.isBusAlignment(e))this.kU(t,e);else{let i=this.orthoAngle(t);if(this.ws===1){let s=t.destinationEdges;for(;s.next();){let n=s.value.link;if(n!==null){if(t.setsPortSpot)if(t.portSpot.isDefault())switch(i){case 0:n.fromSpot=T.MiddleRight;break;case 90:n.fromSpot=T.MiddleBottom;break;case 180:n.fromSpot=T.MiddleLeft;break;default:n.fromSpot=T.MiddleTop;break}else n.fromSpot=t.portSpot;if(t.setsChildPortSpot)if(t.childPortSpot.isDefault())switch(i){case 0:n.toSpot=T.MiddleLeft;break;case 90:n.toSpot=T.MiddleTop;break;case 180:n.toSpot=T.MiddleRight;break;default:n.toSpot=T.MiddleBottom;break}else n.toSpot=t.childPortSpot}}}else{let s=t.sourceEdges;for(;s.next();){let n=s.value.link;if(n!==null){if(t.setsPortSpot)if(t.portSpot.isDefault())switch(i){case 0:n.toSpot=T.MiddleRight;break;case 90:n.toSpot=T.MiddleBottom;break;case 180:n.toSpot=T.MiddleLeft;break;default:n.toSpot=T.MiddleTop;break}else n.toSpot=t.portSpot;if(t.setsChildPortSpot)if(t.childPortSpot.isDefault())switch(i){case 0:n.fromSpot=T.MiddleLeft;break;case 90:n.fromSpot=T.MiddleTop;break;case 180:n.fromSpot=T.MiddleRight;break;default:n.fromSpot=T.MiddleBottom;break}else n.fromSpot=t.childPortSpot}}}}}kU(t,e){let i=this.ws===1,s=this.orthoAngle(t),n;switch(s){case 0:n=T.MiddleRight;break;case 90:n=T.MiddleBottom;break;case 180:n=T.MiddleLeft;break;default:n=T.MiddleTop;break}let o=t.children,r=o.length;switch(e){case 24:case 25:{for(let a=0;a<r;a++){let h=o[a],l=(i?h.sourceEdges:h.destinationEdges).first();if(l===null)continue;let c=l.link;if(c!==null){let u=s===90||s===270?T.MiddleLeft:T.MiddleTop;if(r===1||a===r-1&&r%2===1)switch(s){case 0:u=T.MiddleLeft;break;case 90:u=T.MiddleTop;break;case 180:u=T.MiddleRight;break;default:u=T.MiddleBottom;break}else a%2===0&&(u=s===90||s===270?T.MiddleRight:T.MiddleBottom);i?(t.setsPortSpot&&(c.fromSpot=n),t.setsChildPortSpot&&(c.toSpot=u)):(t.setsPortSpot&&(c.fromSpot=u),t.setsChildPortSpot&&(c.toSpot=n))}}break}case 26:{let a=s===90||s===270?T.MiddleRight:T.MiddleBottom,h=i?t.destinationEdges:t.sourceEdges;for(;h.next();){let l=h.value.link;l!==null&&(i?(t.setsPortSpot&&(l.fromSpot=n),t.setsChildPortSpot&&(l.toSpot=a)):(t.setsPortSpot&&(l.fromSpot=a),t.setsChildPortSpot&&(l.toSpot=n)))}break}case 27:{let a=s===90||s===270?T.MiddleLeft:T.MiddleTop,h=i?t.destinationEdges:t.sourceEdges;for(;h.next();){let l=h.value.link;l!==null&&(i?(t.setsPortSpot&&(l.fromSpot=n),t.setsChildPortSpot&&(l.toSpot=a)):(t.setsPortSpot&&(l.fromSpot=a),t.setsChildPortSpot&&(l.toSpot=n)))}break}}}orthoAngle(t){let e=t.angle;return e<=45?0:e<=135?90:e<=225?180:e<=315?270:0}computeLayerSpacing(t){let e=this.orthoAngle(t),i=e===90||e===270,s=t.layerSpacing;if(t.layerSpacingParentOverlap>0){let n=Math.min(1,t.layerSpacingParentOverlap);s-=i?t.height*n:t.width*n}return s<(i?-t.height:-t.width)&&(s=i?-t.height:-t.width),s}computeNodeIndent(t){let e=this.orthoAngle(t),i=e===90||e===270,s=t.nodeIndent;if(t.nodeIndentPastParent>0){let n=Math.min(1,t.nodeIndentPastParent);s+=i?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ie}set roots(t){this.Ie!==t&&(this.Ie=t,this.p())}get path(){return this.Fe}set path(t){this.Fe!==t&&(this.Fe=t,this.p())}get treeStyle(){return this.wu}set treeStyle(t){this.wu!==t&&(t===40||t===42||t===41||t===43)&&(this.wu=t,this.p())}get layerStyle(){return this.Jg}set layerStyle(t){this.Jg!==t&&(t===60||t===61||t===62)&&(this.Jg=t,this.p())}get comments(){return this.Xi}set comments(t){this.Xi!==t&&(g.s(t,"boolean",Ut,"comments"),this.Xi=t,this.p())}get arrangement(){return this.He}set arrangement(t){this.He!==t&&(t===50||t===51||t===52)&&(this.He=t,this.p())}get arrangementSpacing(){return this.Us}set arrangementSpacing(t){this.Us.equals(t)||(this.Us.h(t),this.p())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.p())}get alternateDefaults(){return this.B}set alternateDefaults(t){this.B!==t&&(this.B=t,this.p())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.p())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(g.S(t,Ut,"comparer"),this.V.comparer=t,this.p())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(g.s(t,"number",Ut,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.p()):g.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.p())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(g.s(t,"number",Ut,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.p()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(g.s(t,"number",Ut,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.p()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(g.s(t,"number",Ut,"nodeSpacing"),this.V.nodeSpacing=t,this.p())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(g.s(t,"number",Ut,"layerSpacing"),this.V.layerSpacing=t,this.p())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(g.s(t,"number",Ut,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.p()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.p())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(g.s(t,"number",Ut,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.p()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(g.s(t,"number",Ut,"rowSpacing"),this.V.rowSpacing=t,this.p())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(g.s(t,"number",Ut,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.p()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(g.s(t,"number",Ut,"commentSpacing"),this.V.commentSpacing=t,this.p())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(g.s(t,"number",Ut,"commentMargin"),this.V.commentMargin=t,this.p())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(g.s(t,"boolean",Ut,"setsPortSpot"),this.V.setsPortSpot=t,this.p())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.p())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(g.s(t,"boolean",Ut,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.p())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.p())}get alternateSorting(){return this.B.sorting}set alternateSorting(t){this.B.sorting!==t&&(this.B.sorting=t,this.p())}get alternateComparer(){return this.B.comparer}set alternateComparer(t){this.B.comparer!==t&&(g.S(t,Ut,"alternateComparer"),this.B.comparer=t,this.p())}get alternateAngle(){return this.B.angle}set alternateAngle(t){this.B.angle!==t&&(g.s(t,"number",Ut,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.B.angle=t,this.p()))}get alternateAlignment(){return this.B.alignment}set alternateAlignment(t){this.B.alignment!==t&&(this.B.alignment=t,this.p())}get alternateNodeIndent(){return this.B.nodeIndent}set alternateNodeIndent(t){this.B.nodeIndent!==t&&(g.s(t,"number",Ut,"alternateNodeIndent"),t>=0&&(this.B.nodeIndent=t,this.p()))}get alternateNodeIndentPastParent(){return this.B.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.B.nodeIndentPastParent!==t&&(g.s(t,"number",Ut,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.B.nodeIndentPastParent=t,this.p()))}get alternateNodeSpacing(){return this.B.nodeSpacing}set alternateNodeSpacing(t){this.B.nodeSpacing!==t&&(g.s(t,"number",Ut,"alternateNodeSpacing"),this.B.nodeSpacing=t,this.p())}get alternateLayerSpacing(){return this.B.layerSpacing}set alternateLayerSpacing(t){this.B.layerSpacing!==t&&(g.s(t,"number",Ut,"alternateLayerSpacing"),this.B.layerSpacing=t,this.p())}get alternateLayerSpacingParentOverlap(){return this.B.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.B.layerSpacingParentOverlap!==t&&(g.s(t,"number",Ut,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.B.layerSpacingParentOverlap=t,this.p()))}get alternateCompaction(){return this.B.compaction}set alternateCompaction(t){this.B.compaction!==t&&(t===30||t===31)&&(this.B.compaction=t,this.p())}get alternateBreadthLimit(){return this.B.breadthLimit}set alternateBreadthLimit(t){this.B.breadthLimit!==t&&(g.s(t,"number",Ut,"alternateBreadthLimit"),t>=0&&(this.B.breadthLimit=t,this.p()))}get alternateRowSpacing(){return this.B.rowSpacing}set alternateRowSpacing(t){this.B.rowSpacing!==t&&(g.s(t,"number",Ut,"alternateRowSpacing"),this.B.rowSpacing=t,this.p())}get alternateRowIndent(){return this.B.rowIndent}set alternateRowIndent(t){this.B.rowIndent!==t&&(g.s(t,"number",Ut,"alternateRowIndent"),t>=0&&(this.B.rowIndent=t,this.p()))}get alternateCommentSpacing(){return this.B.commentSpacing}set alternateCommentSpacing(t){this.B.commentSpacing!==t&&(g.s(t,"number",Ut,"alternateCommentSpacing"),this.B.commentSpacing=t,this.p())}get alternateCommentMargin(){return this.B.commentMargin}set alternateCommentMargin(t){this.B.commentMargin!==t&&(g.s(t,"number",Ut,"alternateCommentMargin"),this.B.commentMargin=t,this.p())}get alternateSetsPortSpot(){return this.B.setsPortSpot}set alternateSetsPortSpot(t){this.B.setsPortSpot!==t&&(g.s(t,"boolean",Ut,"alternateSetsPortSpot"),this.B.setsPortSpot=t,this.p())}get alternatePortSpot(){return this.B.portSpot}set alternatePortSpot(t){this.B.portSpot.equals(t)||(this.B.portSpot=t,this.p())}get alternateSetsChildPortSpot(){return this.B.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.B.setsChildPortSpot!==t&&(g.s(t,"boolean",Ut,"alternateSetsChildPortSpot"),this.B.setsChildPortSpot=t,this.p())}get alternateChildPortSpot(){return this.B.childPortSpot}set alternateChildPortSpot(t){this.B.childPortSpot.equals(t)||(this.B.childPortSpot=t,this.p())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class Zs extends Je{constructor(t){super(t)}createVertex(){return new It(this)}createEdge(){return new jn(this)}}class It extends Ze{U;dt;at;gP;mP;pP;yP;wP;xP;bP;Xi;$g;Zg;Si;Mi;Xt;de;vw;Fw;Rw;Vs;Ow;Iw;Ew;Uw;Vw;Bw;zw;Xw;Gw;Yw;Kw;constructor(t){super(t),this.gP=!1,this.mP=null,this.pP=[],this.yP=0,this.wP=0,this.xP=0,this.bP=0,this.Xi=null,this.U=new P(0,0),this.dt=new _(0,0),this.at=new P(0,0),this.$g=null,this.Zg=null,this.Si=10,this.Mi=Ze.standardComparer,this.Xt=0,this.de=21,this.vw=0,this.Fw=0,this.Rw=20,this.Vs=50,this.Ow=0,this.Iw=31,this.Ew=0,this.Uw=25,this.Vw=10,this.Bw=10,this.zw=20,this.Xw=!0,this.Gw=T.Default,this.Yw=!0,this.Kw=T.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.Si=t.sorting,this.Mi=t.comparer,this.Xt=t.angle,this.de=t.alignment,this.vw=t.nodeIndent,this.Fw=t.nodeIndentPastParent,this.Rw=t.nodeSpacing,this.Vs=t.layerSpacing,this.Ow=t.layerSpacingParentOverlap,this.Iw=t.compaction,this.Ew=t.breadthLimit,this.Uw=t.rowSpacing,this.Vw=t.rowIndent,this.Bw=t.commentSpacing,this.zw=t.commentMargin,this.Xw=t.setsPortSpot,this.Gw=t.portSpot,this.Yw=t.setsChildPortSpot,this.Kw=t.childPortSpot)}get initialized(){return this.gP}set initialized(t){this.gP!==t&&(g.s(t,"boolean",It,"initialized"),this.gP=t)}get parent(){return this.mP}set parent(t){this.mP!==t&&(this.mP=t)}get children(){return this.pP}set children(t){if(this.pP!==t){if(t!==null&&!Array.isArray(t)&&g.si(t,"Array",It,"children:value"),t!==null){let e=t.length;for(let i=0;i<e;i++){let s=t[i]}}this.pP=t}}get level(){return this.yP}set level(t){this.yP!==t&&(g.s(t,"number",It,"level"),this.yP=t)}get descendantCount(){return this.wP}set descendantCount(t){this.wP!==t&&(g.s(t,"number",It,"descendantCount"),this.wP=t)}get maxChildrenCount(){return this.xP}set maxChildrenCount(t){this.xP!==t&&(g.s(t,"number",It,"maxChildrenCount"),this.xP=t)}get maxGenerationCount(){return this.bP}set maxGenerationCount(t){this.bP!==t&&(g.s(t,"number",It,"maxGenerationCount"),this.bP=t)}get comments(){return this.Xi}set comments(t){if(this.Xi!==t){if(t!==null&&!Array.isArray(t)&&g.si(t,"Array",It,"comments:value"),t!==null){let e=t.length;for(let i=0;i<e;i++){let s=t[i]}}this.Xi=t}}get sorting(){return this.Si}set sorting(t){this.Si!==t&&(this.Si=t)}get comparer(){return this.Mi}set comparer(t){this.Mi!==t&&(g.S(t,It,"comparer"),this.Mi=t)}get angle(){return this.Xt}set angle(t){this.Xt!==t&&(g.s(t,"number",It,"angle"),this.Xt=t)}get alignment(){return this.de}set alignment(t){this.de!==t&&(this.de=t)}get nodeIndent(){return this.vw}set nodeIndent(t){this.vw!==t&&(g.s(t,"number",It,"nodeIndent"),this.vw=t)}get nodeIndentPastParent(){return this.Fw}set nodeIndentPastParent(t){this.Fw!==t&&(g.s(t,"number",It,"nodeIndentPastParent"),this.Fw=t)}get nodeSpacing(){return this.Rw}set nodeSpacing(t){this.Rw!==t&&(g.s(t,"number",It,"nodeSpacing"),this.Rw=t)}get layerSpacing(){return this.Vs}set layerSpacing(t){this.Vs!==t&&(g.s(t,"number",It,"layerSpacing"),this.Vs=t)}get layerSpacingParentOverlap(){return this.Ow}set layerSpacingParentOverlap(t){this.Ow!==t&&(g.s(t,"number",It,"layerSpacingParentOverlap"),this.Ow=t)}get compaction(){return this.Iw}set compaction(t){this.Iw!==t&&(this.Iw=t)}get breadthLimit(){return this.Ew}set breadthLimit(t){this.Ew!==t&&(g.s(t,"number",It,"breadthLimit"),this.Ew=t)}get rowSpacing(){return this.Uw}set rowSpacing(t){this.Uw!==t&&(g.s(t,"number",It,"rowSpacing"),this.Uw=t)}get rowIndent(){return this.Vw}set rowIndent(t){this.Vw!==t&&(g.s(t,"number",It,"rowIndent"),this.Vw=t)}get commentSpacing(){return this.Bw}set commentSpacing(t){this.Bw!==t&&(g.s(t,"number",It,"commentSpacing"),this.Bw=t)}get commentMargin(){return this.zw}set commentMargin(t){this.zw!==t&&(g.s(t,"number",It,"commentMargin"),this.zw=t)}get setsPortSpot(){return this.Xw}set setsPortSpot(t){this.Xw!==t&&(g.s(t,"boolean",It,"setsPortSpot"),this.Xw=t)}get portSpot(){return this.Gw}set portSpot(t){this.Gw.equals(t)||(this.Gw=t)}get setsChildPortSpot(){return this.Yw}set setsChildPortSpot(t){this.Yw!==t&&(g.s(t,"boolean",It,"setsChildPortSpot"),this.Yw=t)}get childPortSpot(){return this.Kw}set childPortSpot(t){this.Kw.equals(t)||(this.Kw=t)}get childrenCount(){return this.children.length}get relativePosition(){return this.U}set relativePosition(t){this.U.set(t)}get subtreeSize(){return this.dt}set subtreeSize(t){this.dt.set(t)}get subtreeOffset(){return this.at}set subtreeOffset(t){this.at.set(t)}}class jn extends xi{kP;constructor(t){super(t),this.kP=new P(0,0)}commit(){let t=this.link;if(t===null||t.isAvoiding)return;let e=this.network.layout,i=null,s=null;switch(e.ws){case 1:i=this.fromVertex,s=this.toVertex;break;case 2:i=this.toVertex,s=this.fromVertex;break;default:g.o("Unhandled path value "+e.ws.toString())}if(i===null||s===null)return;let n=this.kP;if(n.x===0&&n.y===0){this.PU(i,s);return}let o=i.bounds,r=e.orthoAngle(i),a=e.computeLayerSpacing(i),h=i.rowSpacing;t.updateRoute();let l=t.curve===9,c=t.isOrthogonal,u=0,d,f;if(t.startRoute(),c||l){for(u=2;t.pointsCount>4;)t.removePoint(2);d=t.getPoint(1),f=t.getPoint(2)}else{for(u=1;t.pointsCount>3;)t.removePoint(1);d=t.getPoint(0),f=t.getPoint(t.pointsCount-1)}let p=t.getPoint(t.pointsCount-1),m=0;r===0?(i.alignment===23?(m=o.bottom+n.y,n.y===0&&d.y>p.y+i.rowIndent&&(m=Math.min(m,Math.max(d.y,m-e.computeNodeIndent(i))))):i.alignment===22?(m=o.top+n.y,n.y===0&&d.y<p.y-i.rowIndent&&(m=Math.max(m,Math.min(d.y,m+e.computeNodeIndent(i))))):m=o.y+o.height/2+n.y,l?(t.insertPointAt(u,d.x,m),u++,t.insertPointAt(u,o.right+a,m),u++,t.insertPointAt(u,o.right+a+(n.x-h)/3,m),u++,t.insertPointAt(u,o.right+a+(n.x-h)*2/3,m),u++,t.insertPointAt(u,o.right+a+(n.x-h),m),u++,t.insertPointAt(u,f.x,m),u++):(c&&(t.insertPointAt(u,o.right+a/2,d.y),u++),t.insertPointAt(u,o.right+a/2,m),u++,t.insertPointAt(u,o.right+a+n.x-(c?h/2:h),m),u++,c&&(t.insertPointAt(u,t.getPoint(u-1).x,f.y),u++))):r===90?(i.alignment===23?(m=o.right+n.x,n.x===0&&d.x>p.x+i.rowIndent&&(m=Math.min(m,Math.max(d.x,m-e.computeNodeIndent(i))))):i.alignment===22?(m=o.left+n.x,n.x===0&&d.x<p.x-i.rowIndent&&(m=Math.max(m,Math.min(d.x,m+e.computeNodeIndent(i))))):m=o.x+o.width/2+n.x,l?(t.insertPointAt(u,m,d.y),u++,t.insertPointAt(u,m,o.bottom+a),u++,t.insertPointAt(u,m,o.bottom+a+(n.y-h)/3),u++,t.insertPointAt(u,m,o.bottom+a+(n.y-h)*2/3),u++,t.insertPointAt(u,m,o.bottom+a+(n.y-h)),u++,t.insertPointAt(u,m,f.y),u++):(c&&(t.insertPointAt(u,d.x,o.bottom+a/2),u++),t.insertPointAt(u,m,o.bottom+a/2),u++,t.insertPointAt(u,m,o.bottom+a+n.y-(c?h/2:h)),u++,c&&(t.insertPointAt(u,f.x,t.getPoint(u-1).y),u++))):r===180?(i.alignment===23?(m=o.bottom+n.y,n.y===0&&d.y>p.y+i.rowIndent&&(m=Math.min(m,Math.max(d.y,m-e.computeNodeIndent(i))))):i.alignment===22?(m=o.top+n.y,n.y===0&&d.y<p.y-i.rowIndent&&(m=Math.max(m,Math.min(d.y,m+e.computeNodeIndent(i))))):m=o.y+o.height/2+n.y,l?(t.insertPointAt(u,d.x,m),u++,t.insertPointAt(u,o.left-a,m),u++,t.insertPointAt(u,o.left-a+(n.x+h)/3,m),u++,t.insertPointAt(u,o.left-a+(n.x+h)*2/3,m),u++,t.insertPointAt(u,o.left-a+(n.x+h),m),u++,t.insertPointAt(u,f.x,m),u++):(c&&(t.insertPointAt(u,o.left-a/2,d.y),u++),t.insertPointAt(u,o.left-a/2,m),u++,t.insertPointAt(u,o.left-a+n.x+(c?h/2:h),m),u++,c&&(t.insertPointAt(u,t.getPoint(u-1).x,f.y),u++))):r===270?(i.alignment===23?(m=o.right+n.x,n.x===0&&d.x>p.x+i.rowIndent&&(m=Math.min(m,Math.max(d.x,m-e.computeNodeIndent(i))))):i.alignment===22?(m=o.left+n.x,n.x===0&&d.x<p.x-i.rowIndent&&(m=Math.max(m,Math.min(d.x,m+e.computeNodeIndent(i))))):m=o.x+o.width/2+n.x,l?(t.insertPointAt(u,m,d.y),u++,t.insertPointAt(u,m,o.top-a),u++,t.insertPointAt(u,m,o.top-a+(n.y+h)/3),u++,t.insertPointAt(u,m,o.top-a+(n.y+h)*2/3),u++,t.insertPointAt(u,m,o.top-a+(n.y+h)),u++,t.insertPointAt(u,m,f.y),u++):(c&&(t.insertPointAt(u,d.x,o.top-a/2),u++),t.insertPointAt(u,m,o.top-a/2),u++,t.insertPointAt(u,m,o.top-a+n.y+(c?h/2:h)),u++,c&&(t.insertPointAt(u,f.x,t.getPoint(u-1).y),u++))):g.o("Invalid angle "+r),t.commitRoute()}PU(t,e){let i=this.link;if(i===null)return;let s=this.network.layout,n=s.orthoAngle(t),o=s.orthoAngle(e);if(n===o)return;let r=s.computeLayerSpacing(t),a=t.bounds,h=e.bounds;if(n===0&&h.left-a.right<r+1||n===90&&h.top-a.bottom<r+1||n===180&&a.left-h.right<r+1||n===270&&a.top-h.bottom<r+1)return;i.updateRoute();let l=i.curve===9,c=i.isOrthogonal,u=this.fromVertex,d=s.isBusAlignment(u.alignment);if(i.startRoute(),n===0){let f=a.right+r/2;if(l){if(i.pointsCount===4){let p=i.getPoint(3).y;i.setPointAt(1,f-20,i.getPoint(1).y),i.insertPointAt(2,f-20,p),i.insertPointAt(3,f,p),i.insertPointAt(4,f+20,p),i.setPointAt(5,i.getPoint(5).x,p)}}else c?d?i.setPointAt(3,i.getPoint(2).x,i.getPoint(4).y):i.pointsCount===6&&(i.setPointAt(2,f,i.getPoint(2).y),i.setPointAt(3,f,i.getPoint(3).y)):i.pointsCount===4?i.insertPointAt(2,f,i.getPoint(2).y):i.pointsCount===3?i.setPointAt(1,f,i.getPoint(2).y):i.pointsCount===2&&i.insertPointAt(1,f,i.getPoint(1).y)}else if(n===90){let f=a.bottom+r/2;if(l){if(i.pointsCount===4){let p=i.getPoint(3).x;i.setPointAt(1,i.getPoint(1).x,f-20),i.insertPointAt(2,p,f-20),i.insertPointAt(3,p,f),i.insertPointAt(4,p,f+20),i.setPointAt(5,p,i.getPoint(5).y)}}else c?d?i.setPointAt(3,i.getPoint(2).x,i.getPoint(4).y):i.pointsCount===6&&(i.setPointAt(2,i.getPoint(2).x,f),i.setPointAt(3,i.getPoint(3).x,f)):i.pointsCount===4?i.insertPointAt(2,i.getPoint(2).x,f):i.pointsCount===3?i.setPointAt(1,i.getPoint(2).x,f):i.pointsCount===2&&i.insertPointAt(1,i.getPoint(1).x,f)}else if(n===180){let f=a.left-r/2;if(l){if(i.pointsCount===4){let p=i.getPoint(3).y;i.setPointAt(1,f+20,i.getPoint(1).y),i.insertPointAt(2,f+20,p),i.insertPointAt(3,f,p),i.insertPointAt(4,f-20,p),i.setPointAt(5,i.getPoint(5).x,p)}}else c?d?i.setPointAt(3,i.getPoint(2).x,i.getPoint(4).y):i.pointsCount===6&&(i.setPointAt(2,f,i.getPoint(2).y),i.setPointAt(3,f,i.getPoint(3).y)):i.pointsCount===4?i.insertPointAt(2,f,i.getPoint(2).y):i.pointsCount===3?i.setPointAt(1,f,i.getPoint(2).y):i.pointsCount===2&&i.insertPointAt(1,f,i.getPoint(1).y)}else if(n===270){let f=a.top-r/2;if(l){if(i.pointsCount===4){let p=i.getPoint(3).x;i.setPointAt(1,i.getPoint(1).x,f+20),i.insertPointAt(2,p,f+20),i.insertPointAt(3,p,f),i.insertPointAt(4,p,f-20),i.setPointAt(5,p,i.getPoint(5).y)}}else c?d?i.setPointAt(3,i.getPoint(2).x,i.getPoint(4).y):i.pointsCount===6&&(i.setPointAt(2,i.getPoint(2).x,f),i.setPointAt(3,i.getPoint(3).x,f)):i.pointsCount===4?i.insertPointAt(2,i.getPoint(2).x,f):i.pointsCount===3?i.setPointAt(1,i.getPoint(2).x,f):i.pointsCount===2&&i.insertPointAt(1,i.getPoint(1).x,f)}i.commitRoute()}get fromVertex(){return this.ss}set fromVertex(t){this.ss!==t&&(this.ss=t)}get toVertex(){return this.ns}set toVertex(t){this.ns!==t&&(this.ns=t)}get relativePoint(){return this.kP}set relativePoint(t){this.kP.set(t)}}class De{constructor(){}static Light={colors:{text:"#0a0a0a",comment:"#ca8a04",link:"#0a0a0a",group:"#a3a3a344",outline:"#a3a3a3",selection:"#0ea5e9",div:"#fff",gridMinor:"#e5e5e5",gridMajor:"#a3a3a3",overviewBox:"#c026d3",tempLink:"#2563eb",tempPort:"#c026d3",adornmentFill:"#0ea5e9",adornmentStroke:"#1e40af",dragSelect:"#c026d3"},fonts:{normal:"10pt sans-serif",bold:"bold 12pt sans-serif"},numbers:{group:1,selection:3},margins:{group:new Dt(5)},arrowheads:{toArrow:"Standard"}};static Dark={colors:{text:"#f5f5f5",comment:"#facc15",link:"#f5f5f5",group:"#a3a3a388",outline:"#a3a3a3",selection:"#38bdf8",div:"#171717",gridMinor:"#262626",gridMajor:"#404040",overviewBox:"#e879f9",tempLink:"#60a5fa",tempPort:"#e879f9",adornmentFill:"#38bdf8",adornmentStroke:"#2563eb",dragSelect:"#e879f9"},fonts:{normal:"10pt sans-serif",bold:"bold 12pt sans-serif"},numbers:{group:1,selection:3},margins:{group:new Dt(5)},arrowheads:{toArrow:"Standard"}}}class ai{hs=new Set;bu=new wt;PP="light";SP="light";MP=!1;ML=!0;Qg="light";VF=t=>{let e=t.matches?"dark":"light";e!==this.Qg&&(this.Qg=e,this.SP==="system"&&this.updateDiagrams())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.bu.set("light",{colors:{...De.Light.colors},fonts:{...De.Light.fonts},numbers:{...De.Light.numbers},margins:{...De.Light.margins},arrowheads:{...De.Light.arrowheads}}),this.bu.set("dark",{colors:{...De.Dark.colors},fonts:{...De.Dark.fonts},numbers:{...De.Dark.numbers},margins:{...De.Dark.margins},arrowheads:{...De.Dark.arrowheads}})),C.matchMedia&&(this.Qg=C.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.bu}set themeMap(t){this.bu!==t&&(this.bu=t,this.updateDiagrams())}get defaultTheme(){return this.PP}set defaultTheme(t){this.PP!==t&&(g.s(t,"string",ai,"defaultTheme"),this.PP=t,this.updateDiagrams())}get currentTheme(){return this.SP}set currentTheme(t){this.SP!==t&&(g.s(t,"string",ai,"currentTheme"),this.SP=t,this.updateDiagrams())}get changesDivBackground(){return this.MP}set changesDivBackground(t){if(this.MP!==t&&(this.MP=t,t))for(let e of this.hs)e.setDivBackground(this.findValue("div","","fill")),e.T("ThemeChanged",this)}get readsCssVariables(){return this.ML}set readsCssVariables(t){this.ML!==t&&(this.ML=t,this.updateDiagrams())}get preferredColorScheme(){return this.Qg}addDiagram(t){return this.hs.add(t),this.NL(t),this}removeDiagram(t){return this.hs.delete(t),this.NL(t),this}tO(){this.hs.size===0&&C.matchMedia&&C.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.VF)}eO(){this.hs.size===0&&C.matchMedia&&C.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.VF)}set(t,e){t===""&&(t=this.PP),t==="system"&&(t=this.Qg);let i=this.bu.get(t);return i?i=this.BF(i,e):i=e,this.bu.set(t,i),this.updateDiagrams(),this}findValue(t,e,i){return this.getValue(this.findTheme(this.currentTheme),t,e,i)||this.getValue(this.findTheme(this.defaultTheme),t,e,i)}getValue(t,e,i,s){if(!t)return;i==null&&(i="");let n=t,o=a=>{if(n===void 0||a==="")return;if(typeof a=="number"||!(Array.isArray(a)||a.includes(".")))return n[a];let h=Array.isArray(a)?a:a.split(".");for(let l=0;l<h.length;l++){let c=h[l];if(c!==""&&(n=n[c],n===void 0))return}return n},r=()=>{if(!(i!==""&&(n=o(i),n===void 0)))return Array.isArray(n)&&typeof e=="number"?n=n[e%n.length]:n=o(e),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let a=t.targetPropertyMap?.get(s);if(a?n=t[a]:(a=ai.SU.get(s),n=a?t[a]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Qg:t)}updateDiagrams(){for(let t of this.hs)this.NL(t)}NL(t){let e=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.MP&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=e,t.T("ThemeChanged",this)}BF(t,e){for(let i in e)if(g.Hw(e,i))try{e[i]?.constructor===Object?t[i]=this.BF(t[i]??{},e[i]):t[i]=e[i]}catch{delete t[i]}return t}static SU=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Gn{Pt;a;Be;Pl;constructor(){this.a=j.Rm(),this.Pt="",this.Be=!0,this.Pl=!0}get name(){return this.Pt}set name(t){this.Pt=t}get isEnabled(){return this.Be}set isEnabled(t){this.Be=t}get isRealtime(){return this.Pl}set isRealtime(t){this.Pl=t}get diagram(){return this.a}set diagram(t){this.a!==t&&(this.a=t,t.Fl=!0,t.requestUpdate())}invalidateRouter(){this.a!==null&&(this.a.Fl=!0,this.a.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;let e=this.diagram;return!(e&&(!this.isRealtime&&e.Iu||e.animationManager.isTicking))}isRoutable(t,e){return!0}routeLinks(t,e){}toString(){return this.name!==""?this.name+" Router":g.Hn(this.constructor)}}class wr extends Gn{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof j?t.rp:t.diagram?.rp)?super.canRoute(t):!1}isRoutable(t,e){return!(!t.isAvoiding||t.containingGroup!==(e instanceof ft?e:null)||t.toNode===null||t.fromNode===null||t.pointsCount<4)}routeLinks(t,e){let i=e instanceof j?null:e,s=t.iterator,n=this.diagram.getPositions(!0,i,null);for(;s.next();){let o=s.value;if(!this.isRoutable(o,e))continue;o.startRoute();let r=o.pointsCount,a=o.getPoint(1),h=o.getPoint(r-2),l=o.fromNode.actualBounds.copy();l.inflate(q.va,q.va),l.unionPoint(o.getPoint(0));let c=o.toNode.actualBounds.copy();c.inflate(q.va,q.va),c.unionPoint(o.getPoint(r-1)),this.MU(o,l,c,n)&&this.NU(o,a,o.PC,h,o.SC,l,c,n),o.commitRoute()}}MU(t,e,i,s){let n=t.diagram,o=t.pointsCount;if(n===null||!t.fromNode||!t.toNode||t.fromNode===t.toNode||!t.layer||t.layer.isTemporary||e.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||i.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;let r=t.getPoint(1),a=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c<o-3;c++){let u=t.getPoint(c),d=t.getPoint(c+1);if(!s.isUnoccupied(Math.min(u.x,d.x),Math.min(u.y,d.y),Math.abs(u.x-d.x),Math.abs(u.y-d.y)))return!0}let l=t.getPoint(o-3);return!s.isUnoccupied(Math.min(l.x,a.x),Math.min(l.y,a.y),Math.abs(l.x-a.x),Math.abs(l.y-a.y))}NU(t,e,i,s,n,o,r,a){let h=t.diagram;if(h===null)return;let l=e,c=s,u=P.mn,d=P.mn;if(h.isVirtualized){let m=a.bounds.copy(),y=t.getPoint(2),b=t.getPoint(t.pointsCount-3);m.inflate(-a.cellWidth,-a.cellHeight);let v=P.l();a.sg(e.x,e.y)||(A.Cl(m.x,m.y,m.x+m.width,m.y+m.height,e.x,e.y,y.x,y.y,v)?(u=e=v.copy(),i=v.directionPoint(y)):A.Cl(m.x,m.y,m.x+m.width,m.y+m.height,y.x,y.y,b.x,b.y,v)?(u=e=v.copy(),i=v.directionPoint(b)):A.Cl(m.x,m.y,m.x+m.width,m.y+m.height,b.x,b.y,s.x,s.y,v)&&(u=e=v.copy(),i=v.directionPoint(s))),a.sg(s.x,s.y)||(A.Cl(m.x,m.y,m.x+m.width,m.y+m.height,s.x,s.y,b.x,b.y,v)?(d=s=v.copy(),n=b.directionPoint(v)):A.Cl(m.x,m.y,m.x+m.width,m.y+m.height,b.x,b.y,y.x,y.y,v)?(d=s=v.copy(),n=y.directionPoint(v)):A.Cl(m.x,m.y,m.x+m.width,m.y+m.height,y.x,y.y,e.x,e.y,v)&&(d=s=v.copy(),n=e.directionPoint(v))),P.i(v)}let f=o.copy().unionRect(r);f.inflate(a.cellWidth*a.af,a.cellHeight*a.af),a.yv(e,i,s,n,f,!0);let p=a.bo(s.x,s.y);if(!a._y&&p>=Et.ig&&(a.TT(),f.inflate(a.cellWidth*a.I2,a.cellHeight*a.E2),a.yv(e,i,s,n,f,!1),p=a.bo(s.x,s.y)),!a._y&&p<Et.ig&&!a.GE(s.x,s.y)){t.points.removeRange(2,t.pointsCount-3),this.CL(t,a,s.x,s.y,n,!0);let m=0,y=90,b=180,v=270,w=t.getPoint(2);if(t.pointsCount<4)i===m||i===b?(w.x=e.x,w.y=s.y):(w.x=s.x,w.y=e.y),t.setPointAt(2,w.x,w.y),t.insertPointAt(3,w.x,w.y);else{let k=t.getPoint(3);if(i===m||i===b)if(A.u(w.x,k.x)){let S=i===m?Math.max(w.x,e.x):Math.min(w.x,e.x);t.setPointAt(2,S,e.y),t.setPointAt(3,S,k.y)}else A.u(w.y,k.y)?(Math.abs(e.y-w.y)<=a.cellHeight/2&&(t.setPointAt(2,w.x,e.y),t.setPointAt(3,k.x,e.y)),t.insertPointAt(2,w.x,e.y)):t.setPointAt(2,e.x,w.y);else if(i===y||i===v)if(A.u(w.y,k.y)){let S=i===y?Math.max(w.y,e.y):Math.min(w.y,e.y);t.setPointAt(2,e.x,S),t.setPointAt(3,k.x,S)}else A.u(w.x,k.x)?(Math.abs(e.x-w.x)<=a.cellWidth/2&&(t.setPointAt(2,e.x,w.y),t.setPointAt(3,e.x,k.y)),t.insertPointAt(2,e.x,w.y)):t.setPointAt(2,w.x,e.y)}if(u.isReal()){let k=t.getPoint(1),S=t.getPoint(2);k.x!==S.x&&k.y!==S.y?i===m||i===b?t.insertPointAt(2,k.x,S.y):t.insertPointAt(2,S.x,k.y):i===m||i===b?t.insertPointAt(2,l.x,u.y):t.insertPointAt(2,u.x,l.y)}d.isReal()&&(n===m||n===b?t.insertPointAt(t.pointsCount-2,c.x,d.y):t.insertPointAt(t.pointsCount-2,d.x,c.y))}}CL(t,e,i,s,n,o){let r=e.cellWidth,a=e.cellHeight,h=e.bo(i,s),l=i,c=s,u=l,d=c;for(n===0?u+=r:n===90?d+=a:n===180?u-=r:d-=a,t.TC&&h>Et.sc&&e.bo(u,d)!==h-1&&(e.bo(l-r,c)===h-1?(n=180,u=l-r,d=c):e.bo(l+r,c)===h-1?(n=0,u=l+r,d=c):e.bo(l,c-a)===h-1?(n=270,u=l,d=c-a):e.bo(l,c+a)===h-1&&(n=90,u=l,d=c+a));h>Et.sc&&e.bo(u,d)===h-1;)l=u,c=d,n===0?u+=r:n===90?d+=a:n===180?u-=r:d-=a,h-=1;if(o?h>Et.sc&&(n===180||n===0?l=Math.floor(l/r)*r+r/2:(n===90||n===270)&&(c=Math.floor(c/a)*a+a/2)):(l=Math.floor(l/r)*r+r/2,c=Math.floor(c/a)*a+a/2),h>Et.sc){let f=n,p=l,m=c;if(n===0?(f=90,m+=a):n===90?(f=180,p-=r):n===180?(f=270,m-=a):n===270&&(f=0,p+=r),e.bo(p,m)===h-1)this.CL(t,e,p,m,f,!1);else{let y=l,b=c;n===0?(f=270,b-=a):n===90?(f=0,y+=r):n===180?(f=90,b+=a):n===270&&(f=180,y-=r),e.bo(y,b)===h-1&&this.CL(t,e,y,b,f,!1)}}t.insertPointAt(t.pointsCount-2,l,c)}}de.prototype.initializeStandardTools=function(){this.Jt("Action",new wn,this.mouseDownTools),this.Jt("Relinking",new di,this.mouseDownTools),this.Jt("LinkReshaping",new fi,this.mouseDownTools),this.Jt("Rotating",new qe,this.mouseDownTools),this.Jt("Resizing",new gi,this.mouseDownTools),this.Jt("Linking",new Ge,this.mouseMoveTools),this.Jt("Dragging",new Tt,this.mouseMoveTools),this.Jt("DragSelecting",new Oi,this.mouseMoveTools),this.Jt("Panning",new ts,this.mouseMoveTools),this.Jt("ContextMenu",new Xt,this.mouseUpTools),this.Jt("TextEditing",new fe,this.mouseUpTools),this.Jt("ClickCreating",new mi,this.mouseUpTools),this.Jt("ClickSelecting",new bn,this.mouseUpTools)},j.d2("GraphLinksModel",xr),j.d2("TreeModel",br);let rs=C.go,Xi={get version(){return j.version},Group:ft,List:U,Set:I,Map:wt,Point:P,Size:_,Rect:B,Margin:Dt,Spot:T,Geometry:St,PathFigure:jt,PathSegment:xt,InputEvent:Se,DiagramEvent:Qi,ChangedEvent:si,Model:mt,GraphLinksModel:Yt,TreeModel:Qe,Binding:re,ThemeBinding:bi,Transaction:Fi,UndoManager:_i,CommandHandler:Jt,Tool:ie,DraggingTool:Tt,DraggingInfo:ni,DraggingOptions:es,LinkingBaseTool:xe,LinkingTool:Ge,RelinkingTool:di,LinkReshapingTool:fi,ResizingTool:gi,RotatingTool:qe,ClickSelectingTool:bn,ActionTool:wn,ClickCreatingTool:mi,HTMLInfo:Me,ContextMenuTool:Xt,DragSelectingTool:Oi,PanningTool:ts,TextEditingTool:fe,ToolManager:de,Animation:Te,AnimationManager:be,AnimationTrigger:Ri,Layer:Vt,Diagram:j,Palette:er,Overview:Ei,Brush:E,GraphObject:tt,Panel:H,RowColumnDefinition:Gt,Shape:at,TextBlock:gt,Picture:zt,Part:bt,Adornment:Mt,Node:it,Link:q,Placeholder:we,Layout:oe,LayoutNetwork:Je,LayoutVertex:Ze,LayoutEdge:xi,GridLayout:ri,PanelLayout:Ft,CircularLayout:_e,CircularNetwork:In,CircularVertex:zi,CircularEdge:Bn,ForceDirectedLayout:ae,ForceDirectedNetwork:Vn,ForceDirectedVertex:ti,ForceDirectedEdge:Ki,LayeredDigraphLayout:Ue,LayeredDigraphNetwork:Yn,LayeredDigraphVertex:wi,LayeredDigraphEdge:Be,TreeLayout:Ut,TreeNetwork:Zs,TreeVertex:It,TreeEdge:jn,Themes:De,ThemeManager:ai,Router:Gn,AnimationStyle:Sn,AutoScale:bs,CycleMode:Nn,Flip:Tn,TextFormat:Ms,ImageStretch:Cs,LayoutConditions:On,LinkAdjusting:Ls,Curve:Fs,Routing:Ds,Orientation:vs,TextOverflow:Fn,PortSpreading:Rn,ScrollMode:Cn,CollapsePolicy:An,Sizing:ks,TriggerStart:Mn,Stretch:ws,ViewboxStretch:Dn,Wrap:Ss,BrushType:We,ColorSpace:Ln,GeometryStretch:ys,GeometryType:ii,SegmentType:Di,BindingMode:os,ChangeType:xs,CircularArrangement:Bs,CircularDirection:Vs,CircularNodeDiameterFormula:Ks,CircularSorting:zs,GridAlignment:Rs,GridArrangement:Es,GridSorting:Is,LayeredDigraphAggressive:js,LayeredDigraphAlign:Xn,LayeredDigraphCycleRemove:Xs,LayeredDigraphInit:Us,LayeredDigraphLayering:Ys,LayeredDigraphPack:Kn,TreeAlignment:Hs,TreeArrangement:Js,TreeCompaction:Ws,TreeLayerStyle:Un,TreePath:Gs,TreeSorting:qs,TreeStyle:$s,GestureMode:pn,LinkingDirection:yn,ReshapingBehavior:xn,TextEditingAccept:vn,TextEditingStarting:kn,TextEditingState:Pn,WheelMode:mn};for(let x in Xi){let t=Xi[x];g.nt(t)&&t!==Ms&&(t.className=x)}g.$(rs)&&rs.version&&g.ne("WARNING: a `go` object on the root object is already defined. "+("Debug"in rs?"debug ":"")+"version: "+rs.version+", replaced with version: "+Xi.version),j.prototype.go=Xi,C.go=Xi})();var wa=typeof global<"u"?global.go:self.go,Z=typeof global<"u"?global.go:self.go,va=Z.Group,ka=Z.List,Pa=Z.Set;var Sa=Z.Map;var Qn=Z.Point,Ui=Z.Size,Ma=Z.Rect,tn=Z.Margin,ze=Z.Spot,Na=Z.Geometry,Ca=Z.PathFigure,Aa=Z.PathSegment,Ta=Z.InputEvent,La=Z.DiagramEvent,Da=Z.ChangedEvent,Fa=Z.Model,_n=Z.GraphLinksModel,Oa=Z.TreeModel,Ra=Z.Binding,Ea=Z.ThemeBinding,Ia=Z.Transaction,Ba=Z.UndoManager,Va=Z.CommandHandler,za=Z.Tool,Ka=Z.DraggingTool,Xa=Z.DraggingInfo,Ya=Z.DraggingOptions,Ua=Z.LinkingBaseTool,ja=Z.LinkingTool,Ga=Z.RelinkingTool,qa=Z.LinkReshapingTool,Ha=Z.ResizingTool,Wa=Z.RotatingTool,$a=Z.ClickSelectingTool,Ja=Z.ActionTool,Za=Z.ClickCreatingTool,Qa=Z.HTMLInfo,_a=Z.ContextMenuTool,th=Z.DragSelectingTool,eh=Z.PanningTool,ih=Z.TextEditingTool,sh=Z.ToolManager,en=Z.Animation,nh=Z.AnimationManager,oh=Z.AnimationTrigger,rh=Z.Layer,ji=Z.Diagram,ah=Z.Palette,hh=Z.Overview,lh=Z.Brush,ch=Z.GraphObject,hi=Z.Panel,uh=Z.RowColumnDefinition,Gi=Z.Shape,as=Z.TextBlock,to=Z.Picture,dh=Z.Part,sn=Z.Adornment,nn=Z.Node,eo=Z.Link,io=Z.Placeholder,fh=Z.Layout,gh=Z.LayoutNetwork,mh=Z.LayoutVertex,ph=Z.LayoutEdge,yh=Z.GridLayout,xh=Z.PanelLayout,bh=Z.CircularLayout,wh=Z.CircularNetwork,vh=Z.CircularVertex,kh=Z.CircularEdge,Ph=Z.ForceDirectedLayout,Sh=Z.ForceDirectedNetwork,Mh=Z.ForceDirectedVertex,Nh=Z.ForceDirectedEdge,so=Z.LayeredDigraphLayout,Ch=Z.LayeredDigraphNetwork,Ah=Z.LayeredDigraphVertex,Th=Z.LayeredDigraphEdge,Lh=Z.TreeLayout,Dh=Z.TreeNetwork,Fh=Z.TreeVertex,Oh=Z.TreeEdge,Rh=Z.Themes,Eh=Z.ThemeManager,Ih=Z.Router,Bh=Z.version,Vh=Z.AnimationStyle,no=Z.AutoScale,zh=Z.Curve,Kh=Z.CycleMode,Xh=Z.Flip,Yh=Z.ImageStretch,Uh=Z.LayoutConditions,jh=Z.LinkAdjusting,Gh=Z.Orientation,qh=Z.PortSpreading,oo=Z.Routing,ro=Z.ScrollMode,Hh=Z.CollapsePolicy,Wh=Z.Sizing,$h=Z.TriggerStart,ao=Z.Stretch,Jh=Z.TextFormat,on=Z.TextOverflow,Zh=Z.ViewboxStretch,rn=Z.Wrap,Qh=Z.BrushType,_h=Z.ColorSpace,tl=Z.GeometryStretch,el=Z.GeometryType,il=Z.SegmentType,sl=Z.BindingMode,nl=Z.ChangeType,ol=Z.CircularArrangement,rl=Z.CircularDirection,al=Z.CircularNodeDiameterFormula,hl=Z.CircularSorting,ll=Z.GridAlignment,cl=Z.GridArrangement,ul=Z.GridSorting,dl=Z.LayeredDigraphAggressive,fl=Z.LayeredDigraphAlign,gl=Z.LayeredDigraphCycleRemove,ml=Z.LayeredDigraphInit,pl=Z.LayeredDigraphLayering,yl=Z.LayeredDigraphPack,xl=Z.TreeAlignment,bl=Z.TreeArrangement,wl=Z.TreeCompaction,vl=Z.TreeLayerStyle,kl=Z.TreePath,Pl=Z.TreeSorting,Sl=Z.TreeStyle,Ml=Z.GestureMode,Nl=Z.LinkingDirection,Cl=Z.ReshapingBehavior,Al=Z.TextEditingAccept,Tl=Z.TextEditingStarting,Ll=Z.TextEditingState,ho=Z.WheelMode;var kr=!1;function Pr(C){if(C.sheet)return C.sheet;for(var g=0;g<document.styleSheets.length;g++)if(document.styleSheets[g].ownerNode===C)return document.styleSheets[g]}function Sr(C){var g=document.createElement("style");return g.setAttribute("data-emotion",C.key),C.nonce!==void 0&&g.setAttribute("nonce",C.nonce),g.appendChild(document.createTextNode("")),g.setAttribute("data-s",""),g}var lo=(function(){function C(z){var W=this;this._insertTag=function(J){var $;W.tags.length===0?W.insertionPoint?$=W.insertionPoint.nextSibling:W.prepend?$=W.container.firstChild:$=W.before:$=W.tags[W.tags.length-1].nextSibling,W.container.insertBefore(J,$),W.tags.push(J)},this.isSpeedy=z.speedy===void 0?!kr:z.speedy,this.tags=[],this.ctr=0,this.nonce=z.nonce,this.key=z.key,this.container=z.container,this.prepend=z.prepend,this.insertionPoint=z.insertionPoint,this.before=null}var g=C.prototype;return g.hydrate=function(W){W.forEach(this._insertTag)},g.insert=function(W){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(Sr(this));var J=this.tags[this.tags.length-1];if(this.isSpeedy){var $=Pr(J);try{$.insertRule(W,$.cssRules.length)}catch{}}else J.appendChild(document.createTextNode(W));this.ctr++},g.flush=function(){this.tags.forEach(function(W){var J;return(J=W.parentNode)==null?void 0:J.removeChild(W)}),this.tags=[],this.ctr=0},C})();var he="-ms-",qi="-moz-",Kt="-webkit-",hs="comm",vi="rule",ki="decl";var co="@import";var ls="@keyframes";var uo="@layer";var fo=Math.abs,li=String.fromCharCode,go=Object.assign;function mo(C,g){return ee(C,0)^45?(((g<<2^ee(C,0))<<2^ee(C,1))<<2^ee(C,2))<<2^ee(C,3):0}function cs(C){return C.trim()}function an(C,g){return(C=g.exec(C))?C[0]:C}function Bt(C,g,z){return C.replace(g,z)}function Hi(C,g){return C.indexOf(g)}function ee(C,g){return C.charCodeAt(g)|0}function ei(C,g,z){return C.slice(g,z)}function me(C){return C.length}function Pi(C){return C.length}function Si(C,g){return g.push(C),C}function hn(C,g){return C.map(g).join("")}var us=1,Mi=1,po=0,pe=0,se=0,Ci="";function Wi(C,g,z,W,J,$,et){return{value:C,root:g,parent:z,type:W,props:J,children:$,line:us,column:Mi,length:et,return:""}}function Ai(C,g){return go(Wi("",null,null,"",null,null,0),C,{length:-C.length},g)}function yo(){return se}function xo(){return se=pe>0?ee(Ci,--pe):0,Mi--,se===10&&(Mi=1,us--),se}function ye(){return se=pe<po?ee(Ci,pe++):0,Mi++,se===10&&(Mi=1,us++),se}function Ae(){return ee(Ci,pe)}function $i(){return pe}function Ti(C,g){return ei(Ci,C,g)}function Ni(C){switch(C){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function ds(C){return us=Mi=1,po=me(Ci=C),pe=0,[]}function fs(C){return Ci="",C}function Li(C){return cs(Ti(pe-1,ln(C===91?C+2:C===40?C+1:C)))}function bo(C){for(;(se=Ae())&&se<33;)ye();return Ni(C)>2||Ni(se)>3?"":" "}function wo(C,g){for(;--g&&ye()&&!(se<48||se>102||se>57&&se<65||se>70&&se<97););return Ti(C,$i()+(g<6&&Ae()==32&&ye()==32))}function ln(C){for(;ye();)switch(se){case C:return pe;case 34:case 39:C!==34&&C!==39&&ln(se);break;case 40:C===41&&ln(C);break;case 92:ye();break}return pe}function vo(C,g){for(;ye()&&C+se!==57;)if(C+se===84&&Ae()===47)break;return"/*"+Ti(g,pe-1)+"*"+li(C===47?C:ye())}function ko(C){for(;!Ni(Ae());)ye();return Ti(C,pe)}function Mo(C){return fs(gs("",null,null,null,[""],C=ds(C),0,[0],C))}function gs(C,g,z,W,J,$,et,ct,U){for(var Lt=0,I=0,Rt=et,le=0,Ee=0,Ht=0,$t=1,wt=1,P=1,_=0,B="",Dt=J,T=$,Pt=W,A=B;wt;)switch(Ht=_,_=ye()){case 40:if(Ht!=108&&ee(A,Rt-1)==58){Hi(A+=Bt(Li(_),"&","&\f"),"&\f")!=-1&&(P=-1);break}case 34:case 39:case 91:A+=Li(_);break;case 9:case 10:case 13:case 32:A+=bo(Ht);break;case 92:A+=wo($i()-1,7);continue;case 47:switch(Ae()){case 42:case 47:Si(Mr(vo(ye(),$i()),g,z),U);break;default:A+="/"}break;case 123*$t:ct[Lt++]=me(A)*P;case 125*$t:case 59:case 0:switch(_){case 0:case 125:wt=0;case 59+I:P==-1&&(A=Bt(A,/\f/g,"")),Ee>0&&me(A)-Rt&&Si(Ee>32?So(A+";",W,z,Rt-1):So(Bt(A," ","")+";",W,z,Rt-2),U);break;case 59:A+=";";default:if(Si(Pt=Po(A,g,z,Lt,I,J,ct,B,Dt=[],T=[],Rt),$),_===123)if(I===0)gs(A,g,Pt,Pt,Dt,$,Rt,ct,T);else switch(le===99&&ee(A,3)===110?100:le){case 100:case 108:case 109:case 115:gs(C,Pt,Pt,W&&Si(Po(C,Pt,Pt,0,0,J,ct,B,J,Dt=[],Rt),T),J,T,Rt,ct,W?Dt:T);break;default:gs(A,Pt,Pt,Pt,[""],T,0,ct,T)}}Lt=I=Ee=0,$t=P=1,B=A="",Rt=et;break;case 58:Rt=1+me(A),Ee=Ht;default:if($t<1){if(_==123)--$t;else if(_==125&&$t++==0&&xo()==125)continue}switch(A+=li(_),_*$t){case 38:P=I>0?1:(A+="\f",-1);break;case 44:ct[Lt++]=(me(A)-1)*P,P=1;break;case 64:Ae()===45&&(A+=Li(ye())),le=Ae(),I=Rt=me(B=A+=ko($i())),_++;break;case 45:Ht===45&&me(A)==2&&($t=0)}}return $}function Po(C,g,z,W,J,$,et,ct,U,Lt,I){for(var Rt=J-1,le=J===0?$:[""],Ee=Pi(le),Ht=0,$t=0,wt=0;Ht<W;++Ht)for(var P=0,_=ei(C,Rt+1,Rt=fo($t=et[Ht])),B=C;P<Ee;++P)(B=cs($t>0?le[P]+" "+_:Bt(_,/&\f/g,le[P])))&&(U[wt++]=B);return Wi(C,g,z,J===0?vi:ct,U,Lt,I)}function Mr(C,g,z){return Wi(C,g,z,hs,li(yo()),ei(C,2,-2),0)}function So(C,g,z,W){return Wi(C,g,z,ki,ei(C,0,W),ei(C,W+1,-1),W)}function ci(C,g){for(var z="",W=Pi(C),J=0;J<W;J++)z+=g(C[J],J,C,g)||"";return z}function No(C,g,z,W){switch(C.type){case uo:if(C.children.length)break;case co:case ki:return C.return=C.return||C.value;case hs:return"";case ls:return C.return=C.value+"{"+ci(C.children,W)+"}";case vi:C.value=C.props.join(",")}return me(z=ci(C.children,W))?C.return=C.value+"{"+z+"}":""}function Co(C){var g=Pi(C);return function(z,W,J,$){for(var et="",ct=0;ct<g;ct++)et+=C[ct](z,W,J,$)||"";return et}}function Ao(C){return function(g){g.root||(g=g.return)&&C(g)}}function To(C){var g=Object.create(null);return function(z){return g[z]===void 0&&(g[z]=C(z)),g[z]}}var Nr=function(g,z,W){for(var J=0,$=0;J=$,$=Ae(),J===38&&$===12&&(z[W]=1),!Ni($);)ye();return Ti(g,pe)},Cr=function(g,z){var W=-1,J=44;do switch(Ni(J)){case 0:J===38&&Ae()===12&&(z[W]=1),g[W]+=Nr(pe-1,z,W);break;case 2:g[W]+=Li(J);break;case 4:if(J===44){g[++W]=Ae()===58?"&\f":"",z[W]=g[W].length;break}default:g[W]+=li(J)}while(J=ye());return g},Ar=function(g,z){return fs(Cr(ds(g),z))},Lo=new WeakMap,Tr=function(g){if(!(g.type!=="rule"||!g.parent||g.length<1)){for(var z=g.value,W=g.parent,J=g.column===W.column&&g.line===W.line;W.type!=="rule";)if(W=W.parent,!W)return;if(!(g.props.length===1&&z.charCodeAt(0)!==58&&!Lo.get(W))&&!J){Lo.set(g,!0);for(var $=[],et=Ar(z,$),ct=W.props,U=0,Lt=0;U<et.length;U++)for(var I=0;I<ct.length;I++,Lt++)g.props[Lt]=$[U]?et[U].replace(/&\f/g,ct[I]):ct[I]+" "+et[U]}}},Lr=function(g){if(g.type==="decl"){var z=g.value;z.charCodeAt(0)===108&&z.charCodeAt(2)===98&&(g.return="",g.value="")}};function Do(C,g){switch(mo(C,g)){case 5103:return Kt+"print-"+C+C;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Kt+C+C;case 5349:case 4246:case 4810:case 6968:case 2756:return Kt+C+qi+C+he+C+C;case 6828:case 4268:return Kt+C+he+C+C;case 6165:return Kt+C+he+"flex-"+C+C;case 5187:return Kt+C+Bt(C,/(\w+).+(:[^]+)/,Kt+"box-$1$2"+he+"flex-$1$2")+C;case 5443:return Kt+C+he+"flex-item-"+Bt(C,/flex-|-self/,"")+C;case 4675:return Kt+C+he+"flex-line-pack"+Bt(C,/align-content|flex-|-self/,"")+C;case 5548:return Kt+C+he+Bt(C,"shrink","negative")+C;case 5292:return Kt+C+he+Bt(C,"basis","preferred-size")+C;case 6060:return Kt+"box-"+Bt(C,"-grow","")+Kt+C+he+Bt(C,"grow","positive")+C;case 4554:return Kt+Bt(C,/([^-])(transform)/g,"$1"+Kt+"$2")+C;case 6187:return Bt(Bt(Bt(C,/(zoom-|grab)/,Kt+"$1"),/(image-set)/,Kt+"$1"),C,"")+C;case 5495:case 3959:return Bt(C,/(image-set\([^]*)/,Kt+"$1$`$1");case 4968:return Bt(Bt(C,/(.+:)(flex-)?(.*)/,Kt+"box-pack:$3"+he+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Kt+C+C;case 4095:case 3583:case 4068:case 2532:return Bt(C,/(.+)-inline(.+)/,Kt+"$1$2")+C;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(me(C)-1-g>6)switch(ee(C,g+1)){case 109:if(ee(C,g+4)!==45)break;case 102:return Bt(C,/(.+:)(.+)-([^]+)/,"$1"+Kt+"$2-$3$1"+qi+(ee(C,g+3)==108?"$3":"$2-$3"))+C;case 115:return~Hi(C,"stretch")?Do(Bt(C,"stretch","fill-available"),g)+C:C}break;case 4949:if(ee(C,g+1)!==115)break;case 6444:switch(ee(C,me(C)-3-(~Hi(C,"!important")&&10))){case 107:return Bt(C,":",":"+Kt)+C;case 101:return Bt(C,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Kt+(ee(C,14)===45?"inline-":"")+"box$3$1"+Kt+"$2$3$1"+he+"$2box$3")+C}break;case 5936:switch(ee(C,g+11)){case 114:return Kt+C+he+Bt(C,/[svh]\w+-[tblr]{2}/,"tb")+C;case 108:return Kt+C+he+Bt(C,/[svh]\w+-[tblr]{2}/,"tb-rl")+C;case 45:return Kt+C+he+Bt(C,/[svh]\w+-[tblr]{2}/,"lr")+C}return Kt+C+he+C+C}return C}var Dr=function(g,z,W,J){if(g.length>-1&&!g.return)switch(g.type){case ki:g.return=Do(g.value,g.length);break;case ls:return ci([Ai(g,{value:Bt(g.value,"@","@"+Kt)})],J);case vi:if(g.length)return hn(g.props,function($){switch(an($,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return ci([Ai(g,{props:[Bt($,/:(read-\w+)/,":"+qi+"$1")]})],J);case"::placeholder":return ci([Ai(g,{props:[Bt($,/:(plac\w+)/,":"+Kt+"input-$1")]}),Ai(g,{props:[Bt($,/:(plac\w+)/,":"+qi+"$1")]}),Ai(g,{props:[Bt($,/:(plac\w+)/,he+"input-$1")]})],J)}return""})}},Fr=[Dr],Fo=function(g){var z=g.key;if(z==="css"){var W=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(W,function($t){var wt=$t.getAttribute("data-emotion");wt.indexOf(" ")!==-1&&(document.head.appendChild($t),$t.setAttribute("data-s",""))})}var J=g.stylisPlugins||Fr,$={},et,ct=[];et=g.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+z+' "]'),function($t){for(var wt=$t.getAttribute("data-emotion").split(" "),P=1;P<wt.length;P++)$[wt[P]]=!0;ct.push($t)});var U,Lt=[Tr,Lr];{var I,Rt=[No,Ao(function($t){I.insert($t)})],le=Co(Lt.concat(J,Rt)),Ee=function(wt){return ci(Mo(wt),le)};U=function(wt,P,_,B){I=_,Ee(wt?wt+"{"+P.styles+"}":P.styles),B&&(Ht.inserted[P.name]=!0)}}var Ht={key:z,sheet:new lo({key:z,container:et,nonce:g.nonce,speedy:g.speedy,prepend:g.prepend,insertionPoint:g.insertionPoint}),nonce:g.nonce,inserted:$,registered:{},insert:U};return Ht.sheet.hydrate(ct),Ht};function Oo(C){for(var g=0,z,W=0,J=C.length;J>=4;++W,J-=4)z=C.charCodeAt(W)&255|(C.charCodeAt(++W)&255)<<8|(C.charCodeAt(++W)&255)<<16|(C.charCodeAt(++W)&255)<<24,z=(z&65535)*1540483477+((z>>>16)*59797<<16),z^=z>>>24,g=(z&65535)*1540483477+((z>>>16)*59797<<16)^(g&65535)*1540483477+((g>>>16)*59797<<16);switch(J){case 3:g^=(C.charCodeAt(W+2)&255)<<16;case 2:g^=(C.charCodeAt(W+1)&255)<<8;case 1:g^=C.charCodeAt(W)&255,g=(g&65535)*1540483477+((g>>>16)*59797<<16)}return g^=g>>>13,g=(g&65535)*1540483477+((g>>>16)*59797<<16),((g^g>>>15)>>>0).toString(36)}var Ro={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};var Or=!1,Rr=/[A-Z]|^ms/g,Er=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Vo=function(g){return g.charCodeAt(1)===45},Eo=function(g){return g!=null&&typeof g!="boolean"},cn=To(function(C){return Vo(C)?C:C.replace(Rr,"-$&").toLowerCase()}),Io=function(g,z){switch(g){case"animation":case"animationName":if(typeof z=="string")return z.replace(Er,function(W,J,$){return Ke={name:J,styles:$,next:Ke},J})}return Ro[g]!==1&&!Vo(g)&&typeof z=="number"&&z!==0?z+"px":z},Ir="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function Ji(C,g,z){if(z==null)return"";var W=z;if(W.__emotion_styles!==void 0)return W;switch(typeof z){case"boolean":return"";case"object":{var J=z;if(J.anim===1)return Ke={name:J.name,styles:J.styles,next:Ke},J.name;var $=z;if($.styles!==void 0){var et=$.next;if(et!==void 0)for(;et!==void 0;)Ke={name:et.name,styles:et.styles,next:Ke},et=et.next;var ct=$.styles+";";return ct}return Br(C,g,z)}case"function":{if(C!==void 0){var U=Ke,Lt=z(C);return Ke=U,Ji(C,g,Lt)}break}}var I=z;if(g==null)return I;var Rt=g[I];return Rt!==void 0?Rt:I}function Br(C,g,z){var W="";if(Array.isArray(z))for(var J=0;J<z.length;J++)W+=Ji(C,g,z[J])+";";else for(var $ in z){var et=z[$];if(typeof et!="object"){var ct=et;g!=null&&g[ct]!==void 0?W+=$+"{"+g[ct]+"}":Eo(ct)&&(W+=cn($)+":"+Io($,ct)+";")}else{if($==="NO_COMPONENT_SELECTOR"&&Or)throw new Error(Ir);if(Array.isArray(et)&&typeof et[0]=="string"&&(g==null||g[et[0]]===void 0))for(var U=0;U<et.length;U++)Eo(et[U])&&(W+=cn($)+":"+Io($,et[U])+";");else{var Lt=Ji(C,g,et);switch($){case"animation":case"animationName":{W+=cn($)+":"+Lt+";";break}default:W+=$+"{"+Lt+"}"}}}}return W}var Bo=/label:\s*([^\s;{]+)\s*(;|$)/g,Ke;function ms(C,g,z){if(C.length===1&&typeof C[0]=="object"&&C[0]!==null&&C[0].styles!==void 0)return C[0];var W=!0,J="";Ke=void 0;var $=C[0];if($==null||$.raw===void 0)W=!1,J+=Ji(z,g,$);else{var et=$;J+=et[0]}for(var ct=1;ct<C.length;ct++)if(J+=Ji(z,g,C[ct]),W){var U=$;J+=U[ct]}Bo.lastIndex=0;for(var Lt="",I;(I=Bo.exec(J))!==null;)Lt+="-"+I[1];var Rt=Oo(J)+Lt;return{name:Rt,styles:J,next:Ke}}var Vr=!0;function un(C,g,z){var W="";return z.split(" ").forEach(function(J){C[J]!==void 0?g.push(C[J]+";"):J&&(W+=J+" ")}),W}var zr=function(g,z,W){var J=g.key+"-"+z.name;(W===!1||Vr===!1)&&g.registered[J]===void 0&&(g.registered[J]=z.styles)},zo=function(g,z,W){zr(g,z,W);var J=g.key+"-"+z.name;if(g.inserted[z.name]===void 0){var $=z;do g.insert(z===$?"."+J:"",$,g.sheet,!0),$=$.next;while($!==void 0)}};function Ko(C,g){if(C.inserted[g.name]===void 0)return C.insert("",g,C.sheet,!0)}function Xo(C,g,z){var W=[],J=un(C,W,z);return W.length<2?z:J+g(W)}var Yo=function(g){var z=Fo(g);z.sheet.speedy=function(ct){this.isSpeedy=ct},z.compat=!0;var W=function(){for(var U=arguments.length,Lt=new Array(U),I=0;I<U;I++)Lt[I]=arguments[I];var Rt=ms(Lt,z.registered,void 0);return zo(z,Rt,!1),z.key+"-"+Rt.name},J=function(){for(var U=arguments.length,Lt=new Array(U),I=0;I<U;I++)Lt[I]=arguments[I];var Rt=ms(Lt,z.registered),le="animation-"+Rt.name;return Ko(z,{name:Rt.name,styles:"@keyframes "+le+"{"+Rt.styles+"}"}),le},$=function(){for(var U=arguments.length,Lt=new Array(U),I=0;I<U;I++)Lt[I]=arguments[I];var Rt=ms(Lt,z.registered);Ko(z,Rt)},et=function(){for(var U=arguments.length,Lt=new Array(U),I=0;I<U;I++)Lt[I]=arguments[I];return Xo(z.registered,W,Kr(Lt))};return{css:W,cx:et,injectGlobal:$,keyframes:J,hydrate:function(U){U.forEach(function(Lt){z.inserted[Lt]=!0})},flush:function(){z.registered={},z.inserted={},z.sheet.flush()},sheet:z.sheet,cache:z,getRegisteredStyles:un.bind(null,z.registered),merge:Xo.bind(null,z.registered,W)}},Kr=function C(g){for(var z="",W=0;W<g.length;W++){var J=g[W];if(J!=null){var $=void 0;switch(typeof J){case"boolean":break;case"object":{if(Array.isArray(J))$=C(J);else{$="";for(var et in J)J[et]&&et&&($&&($+=" "),$+=et)}break}default:$=J}$&&(z&&(z+=" "),z+=$)}}return z};var Xe=Yo({key:"css"}),fc=Xe.flush,gc=Xe.hydrate,mc=Xe.cx,pc=Xe.merge,yc=Xe.getRegisteredStyles,Uo=Xe.injectGlobal,xc=Xe.keyframes,bc=Xe.css,wc=Xe.sheet,vc=Xe.cache;var Xr=qn`/** @license
53
+ * Copyright 2025 Esri
54
+ *
55
+ * Licensed under the Apache License, Version 2.0 (the "License");
56
+ * you may not use this file except in compliance with the License.
57
+ * You may obtain a copy of the License at
58
+ *
59
+ * http://www.apache.org/licenses/LICENSE-2.0
60
+ *
61
+ * Unless required by applicable law or agreed to in writing, software
62
+ * distributed under the License is distributed on an "AS IS" BASIS,
63
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64
+ * See the License for the specific language governing permissions and
65
+ * limitations under the License.
66
+ */#filter-bar{background-color:#f4f4f4;position:absolute;top:16px;right:220px;z-index:100}#filteredViewButtonDiv{padding:16px 16px 4px}#graph-navigation-bar{background-color:#f4f4f4;position:absolute;top:16px;right:16px;z-index:100}#graph-navigation-controls{position:absolute;top:0;right:0}.z-index-1{z-index:1}`;var Yr=15,Ur=15,jr=10,Zi=new Ui(220,48),Gr=1,qr=8,jo=new Ui(48,48),Hr=new Ui(16,16),Go=new Ui(153,17),Wr='400 0.75rem "Avenir Next", Avenir, "Helvetica Neue", sans-serif',$r='700 0.75rem "Avenir Next", Avenir, "Helvetica Neue", sans-serif',Jr="#f4f4f4",Zr="#cacaca",Qr="#ffffff",qo="#4a4a4a",Ho="#6a6a6a",_r="#ffffff",ps=1,$o=.3,dn=1,Jo=.2,ta=1;function ea(C){let g=document.createElement("div");g.style.width="100%",g.style.height="100%",C.appendChild(g);let z=new ji(g,{click:la,contentAlignment:ze.Center,dragSelectingTool:null,hoverDelay:50,initialAutoScale:no.Uniform,layout:new so({columnSpacing:Yr,layerSpacing:Ur}),padding:jr,scrollMode:ro.Infinite,"toolManager.hoverDelay":50,"toolManager.mouseWheelBehavior":ho.Zoom});z.nodeTemplate=new nn("Auto",{click:ca,movable:!1,opacity:ps,toolTip:new sn("Auto",{isShadowed:!0,margin:new tn(12,16,6,16),padding:0,shadowBlur:16,shadowColor:"rgba(0, 0, 0, 0.16)",shadowOffset:new Qn(0,0)}).add(new hi("Vertical",{background:_r,margin:0}).add(new as({margin:14}).bind("text","title")))}).bind("text","title").add(new Gi({desiredSize:Zi,fill:Qr,geometryString:ha(Zi.width,Zi.height,qr,jo.width,!0),height:Zi.height,portId:"",stroke:Zr,strokeWidth:Gr,width:Zi.width})).add(new hi("Horizontal",{alignment:ze.Left,stretch:ao.Horizontal}).add(new hi("Horizontal",{alignment:ze.Left,desiredSize:jo,margin:1}).add(new hi("Horizontal",{alignment:ze.Center,margin:16}).add(new to({desiredSize:Hr}).bind("source","",$=>Zn($.itemType,$.itemTypeKeywords)))),new hi("Horizontal",{alignment:ze.Right,margin:new tn(4,8,0,8)}).add(new hi("Vertical",{}).add(new as({alignment:ze.Left,desiredSize:Go,font:$r,overflow:on.Ellipsis,stroke:qo,wrap:rn.None}).bind("text","title"),new as({alignment:ze.Left,desiredSize:Go,font:Wr,overflow:on.Ellipsis,stroke:qo,wrap:rn.None}).bind("text","itemTypeForDisplay"))))),z.commandHandler.zoomFactor=1.05,z.setDivBackground(Jr);let W=z.toolManager.clickSelectingTool;W.standardMouseSelect=function(){};let J=z.toolManager.draggingTool;return J.isEnabled=!1,z.linkTemplate=new eo({corner:5,movable:!1,routing:oo.Orthogonal,selectable:!1}).add(new Gi({opacity:dn,stroke:Ho}),new Gi({fill:Ho,opacity:dn,stroke:null,toArrow:"Standard"})),z}function ui(C,g){C.model=new _n(g.nodes,g.links,{linkFromPortIdProperty:"fromPort",linkToPortIdProperty:"toPort"})}function ia(C,g,z,W=!0){if(W){let U=ua(C,z);U.addEventListener("calciteSwitchChange",()=>document.dispatchEvent(new CustomEvent("filteredViewChanged",{detail:U.checked})))}let{resetButton:J,centerButton:$,zoomInButton:et,zoomOutButton:ct}=da(C,z);J.addEventListener("click",()=>ga(g)),$.addEventListener("click",()=>g.zoomToFit()),et.addEventListener("click",()=>g.commandHandler.increaseZoom()),ct.addEventListener("click",()=>g.commandHandler.decreaseZoom())}function sa(C,g,z){ma();let W=ea(C);return ui(W,g),ia(C,W,z),W}function Zo(C){let g=new Set,z=new Set;function W($){$.findLinksInto().each(et=>{z.add(et);let ct=et.fromNode;ct&&!g.has(ct)&&(g.add(ct),W(ct))})}W(C);function J($){$.findLinksOutOf().each(et=>{z.add(et);let ct=et.toNode;ct&&!g.has(ct)&&(g.add(ct),J(ct))})}return J(C),{connectedNodes:g,connectedLinks:z}}function na(C,g=!1,z){let W=[],J=C.map(et=>{if(et.type!=="Group"){let ct=aa(et);return ra(et,ct,g,z)}else{W.push(et.id);return}}).filter(et=>et!==void 0),$=[];return J.forEach(et=>{(C.find(ct=>ct.id===et.itemId)?.dependencies||[]).forEach(ct=>{let U=J.find(Lt=>Lt?.itemId===ct);U&&$.push({from:U.key,fromSpot:ze.AllSides,to:et.key,toSpot:ze.AllSides})})}),{nodes:J,links:$,groupPseudoNodes:W}}function oa(C,g,z,W=!0){let J=C.diagram;if(!J)return;let $={};if(W){for(let et of J.nodes)$[et.key]=et===C?ps:$o;for(let et of J.links){let ct=`${et.fromNode?.key}-${et.toNode?.key}`;$[ct]=Jo}{let{connectedNodes:et,connectedLinks:ct}=Zo(C);for(let U of et)$[U.key]=ps;for(let U of ct){let Lt=`${U.fromNode?.key}-${U.toNode?.key}`;$[Lt]=ta}}}if(z&&(z.adornedObject=C),W){let et=new en;et.duration=1;for(let ct of J.nodes)et.add(ct,"opacity",ct.opacity,$[ct.key]);for(let ct of J.links){let U=`${ct.fromNode?.key}-${ct.toNode?.key}`;et.add(ct,"opacity",ct.opacity,$[U])}et.start()}}function Wo(C,g,z,W,J=!0){if(C.length===0)return;let $=g[0].diagram;if(!$)return;let et={};if(J){for(let ct of $.nodes){let U=C.includes(ct.key);et[ct.key]=!z||U?ps:$o}for(let ct of $.links){let U=`${ct.fromNode?.key}-${ct.toNode?.key}`;et[U]=z?Jo:dn}}if(Object.keys(W).forEach(ct=>{W[ct].adornedObject=null}),J){let ct=new en;ct.duration=1;for(let U of $.nodes)ct.add(U,"opacity",U.opacity,et[U.key]);for(let U of $.links){let Lt=`${U.fromNode?.key}-${U.toNode?.key}`;ct.add(U,"opacity",U.opacity,et[Lt])}ct.start()}}function ra(C,g,z=!1,W){return{key:g,title:C.title,itemId:C.id,itemType:C.type,itemTypeForDisplay:fa(C.type,C.typeKeywords),itemTypeKeywords:C.typeKeywords,group:C.type,url:z?`${W}?id=${C.id}`:void 0}}function aa(C){return C.id}function ha(C,g,z,W=0,J=!1){let $="";J&&($+="F");let et=C-2*z,ct=g-2*z;return $+=" M0 0",$+=` h${et}`,$+=` a${z} ${z} 0 0 1 ${z} ${z}`,$+=` v${ct}`,$+=` a${z} ${z} 0 0 1 ${-z} ${z}`,$+=` h${-et}`,$+=` a${z} ${z} 0 0 1 ${-z} ${-z}`,$+=` v${-ct}`,$+=` a${z} ${z} 0 0 1 ${z} ${-z}`,W>0&&($+=` M${W-z} 0 v${g}`),$}function la(){document.dispatchEvent(new CustomEvent("clickInDiagram"))}function ca(C,g){let z=g.part;z instanceof nn&&(z.selectionAdorned=!1,document.dispatchEvent(new CustomEvent("clickOnNode",{detail:z})))}function ua(C,g){let z=document.createElement("calcite-switch");z.id="filteredViewButton",z.label=g.filteredView;let W=document.createElement("calcite-label");W.id="filteredViewButtonLabel",W.setAttribute("layout","inline"),W.innerHTML=g.filteredView,W.appendChild(z);let J=document.createElement("div");J.id="filteredViewButtonDiv",J.appendChild(W);let $=document.createElement("calcite-action-pad");$.id="filter-bar-controls",$.layout="horizontal",$.expandDisabled=!0,$.appendChild(J);let et=document.createElement("div");return et.id="filter-bar",C.appendChild(et),et.appendChild($),z}function da(C,g){let z=document.createElement("calcite-action");z.icon="reset",z.id="showHideGrayedOutButton";let W=document.createElement("calcite-tooltip");W.id="resetButtonTooltip",W.innerHTML=g.reset,W.overlayPositioning="fixed",W.placement="bottom",W.referenceElement=z.id;let J=document.createElement("calcite-action");J.icon="zoom-to-object",J.id="centerButton";let $=document.createElement("calcite-tooltip");$.id="centerButtonTooltip",$.innerHTML=g.centerDiagram,$.overlayPositioning="fixed",$.placement="bottom",$.referenceElement=J.id;let et=document.createElement("calcite-action");et.icon="plus",et.id="zoomInButton";let ct=document.createElement("calcite-tooltip");ct.id="zoomInButtonTooltip",ct.innerHTML=g.zoomIn,ct.overlayPositioning="fixed",ct.placement="bottom",ct.referenceElement=et.id;let U=document.createElement("calcite-action");U.icon="minus",U.id="zoomOutButton";let Lt=document.createElement("calcite-tooltip");Lt.id="zoomOutButtonTooltip",Lt.innerHTML=g.zoomOut,Lt.overlayPositioning="fixed",Lt.placement="bottom",Lt.referenceElement=U.id;let I=document.createElement("calcite-action-pad");I.id="graph-navigation-controls",I.layout="horizontal",I.expandDisabled=!0,I.appendChild(z),I.appendChild(W),I.appendChild(J),I.appendChild($),I.appendChild(et),I.appendChild(ct),I.appendChild(U),I.appendChild(Lt);let Rt=document.createElement("div");return Rt.id="graph-navigation-bar",C.appendChild(Rt),Rt.appendChild(I),{resetButton:z,centerButton:J,zoomInButton:et,zoomOutButton:U}}function fa(C,g){let z=C;if(C==="Feature Service"){let W=g.indexOf("View Service")>-1,J=g.indexOf("Table")>-1;z=W&&J?"Table (hosted, view)":J?"Table (hosted)":W?"Feature Layer (hosted, view)":"Feature Layer (hosted)"}return C==="Web Mapping Application"&&(z=g.indexOf("configurableApp")>-1?"Instant App":z),z=C==="Geoprocessing Service"?"Tool":z,z=C==="Feed"?"Feed (hosted)":z,z=C==="Real Time Analytic"?"Real Time Analytic (hosted)":z,z=C==="Big Data Analytic"?"Big Data Analytic (hosted)":z,z=C==="Vector Tile Service"?"Tile Layer":z,z}function ga(C){C.zoomToFit(),document.dispatchEvent(new CustomEvent("reset"))}function ma(){Uo`
67
+ #filter-bar {
68
+ background-color: #f4f4f4;
69
+ position: absolute;
70
+ top: 16px;
71
+ right: 220px;
72
+ z-index: 100;
73
+ }
74
+ #filteredViewButtonDiv {
75
+ padding: 16px 16px 4px 16px;
76
+ }
77
+ #graph-navigation-bar {
78
+ background-color: #f4f4f4;
79
+ position: absolute;
80
+ top: 16px;
81
+ right: 16px;
82
+ z-index: 100;
83
+ }
84
+ #graph-navigation-controls {
85
+ position: absolute;
86
+ top: 0;
87
+ right: 0;
88
+ }
89
+ `}var pa=8,ya=15,xa="#1e90ff",ba=4;ji.licenseKey="";var fn=class{constructor(g,z,W,J){this.indexPanel=g,this.diagramPanel=z,this.diagramTranslations=W,this.diagramKey=J,this.currentSelectedGroupId="",this.currentSelectedItemId="",this.diagramNeedsRedraw=!1,this.usefilteredView=!1,this.handle_clickInDiagram=$=>{$.stopImmediatePropagation(),(this.currentSelectedGroupId||this.currentSelectedItemId)&&(this.currentSelectedGroupId="",this.currentSelectedItemId="",this.diagramNeedsRedraw=this.usefilteredView,this.redraw())},this.handle_clickOnNode=$=>{$.stopImmediatePropagation();let et=$.detail.data.key;this.redraw(et,et===this.currentSelectedItemId)},this.handle_filteredViewChanged=$=>{this.usefilteredView=$.detail,this.diagramNeedsRedraw=!!this.currentSelectedGroupId||!!this.currentSelectedItemId,this.redraw(this.currentSelectedItemId||this.currentSelectedGroupId)},this.handle_reset=$=>{$.stopImmediatePropagation(),this.reset()},this.handle_solutionItemSelect=$=>{$.stopImmediatePropagation();let et=$.detail.itemId;this.redraw(et,et===this.currentSelectedItemId||et===this.currentSelectedGroupId,!1)},this.indexPanel.innerHTML="",this.diagramPanel.innerHTML="",ji.licenseKey===""&&(ji.licenseKey=J)}create(g,z){this.collection=g,this.index=document.createElement("solution-item-accordion"),this.index.linkType="action",this.index.listSelectionMode="single",this.index.typeKeywords=z,this.index.style.overflowY="auto",this.indexPanel.appendChild(this.index),this.index.templateInfos=g,this.allNodesAndLinks=na(g),this.diagram=sa(this.diagramPanel,this.allNodesAndLinks,this.diagramTranslations),this.createNodeHighlighters(),document.addEventListener("clickInDiagram",this.handle_clickInDiagram),document.addEventListener("clickOnNode",this.handle_clickOnNode),document.addEventListener("filteredViewChanged",this.handle_filteredViewChanged),document.addEventListener("reset",this.handle_reset),this.index.addEventListener("solutionItemSelect",this.handle_solutionItemSelect)}dispose(){document.removeEventListener("clickInDiagram",this.handle_clickInDiagram),document.removeEventListener("clickOnNode",this.handle_clickOnNode),document.removeEventListener("filteredViewChanged",this.handle_filteredViewChanged),document.removeEventListener("reset",this.handle_reset),this.index.removeEventListener("solutionItemSelect",this.handle_solutionItemSelect),this.indexPanel.innerHTML="",this.diagramPanel.innerHTML=""}clearSelections(g=!0){this.index.deselectAll(),g&&this.index.collapseAll();let z=this.getNodesFromDiagram(this.diagram),W=z.map(J=>J.data.key);Wo(W,z,!1,this.diagramNodeHighlighterIndex)}createNodeHighlighters(){this.diagramNodeIndex={},this.diagramNodeHighlighterIndex={},this.getNodesFromDiagram(this.diagram).forEach(g=>{this.diagramNodeIndex[g.data.key]=g;let z=new sn("Auto",{background:"transparent",margin:2});z.add(new Gi("RoundedRectangle",{fill:"transparent",parameter1:pa,parameter2:ya,stroke:xa,strokeWidth:ba})),z.add(new io({margin:1})),this.diagramNodeHighlighterIndex[g.data.key]=z})}getNodeById(g){return this.diagramNodeIndex[g]}getNodesFromDiagram(g){let z=[],W=g.nodes.iterator;for(;W.next();)z.push(W.value);return z}redraw(g="",z=!1,W=!0){let J=this.allNodesAndLinks.groupPseudoNodes.includes(g);this.diagramNeedsRedraw&&(ui(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),this.diagramNeedsRedraw=!1);let $=!1;if(this.clearSelections(W),!!g){if(J){if(this.currentSelectedItemId="",this.currentSelectedGroupId!==g?this.currentSelectedGroupId=g:z&&(this.currentSelectedGroupId=this.currentSelectedGroupId?"":g,$=this.usefilteredView&&!this.currentSelectedGroupId),this.currentSelectedGroupId){this.usefilteredView&&(ui(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters());let et=this.collection.filter(U=>U.id===g)[0],ct=et.dependencies.map(U=>this.diagramNodeIndex[U]);if(this.usefilteredView){let U=ct.map(Lt=>Lt.data);ui(this.diagram,{nodes:U,links:[]})}else Wo(et.dependencies,ct,!0,this.diagramNodeHighlighterIndex);this.index.selectItem(this.currentSelectedGroupId)}}else{this.currentSelectedGroupId="",this.currentSelectedItemId!==g?this.currentSelectedItemId=g:z&&(this.currentSelectedItemId=this.currentSelectedItemId?"":g,$=this.usefilteredView&&!this.currentSelectedItemId);let et=this.getNodeById(g);if((!et||this.usefilteredView)&&(ui(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),et=this.getNodeById(g),!et))return;if(this.currentSelectedItemId){if(this.usefilteredView){let ct=Zo(et);ct.connectedNodes.add(et);let U=Array.from(ct.connectedNodes).map(I=>I.data),Lt=Array.from(ct.connectedLinks).map(I=>I.data);if(ui(this.diagram,{nodes:U,links:Lt}),this.createNodeHighlighters(),et=this.getNodeById(g),!et)return}et&&setTimeout(()=>oa(et,!0,this.diagramNodeHighlighterIndex[g]),1),this.index.selectItem(this.currentSelectedItemId)}}$&&this.reset()}}reset(){this.diagramNeedsRedraw=!1,this.currentSelectedGroupId="",this.currentSelectedItemId="",ui(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),this.clearSelections()}},gn=class extends Wn{constructor(){super(...arguments),this.diagramKey="",this.templateInfoGraph=[],this.typeKeywords=[],this._diagramPanel=Qs(),this._diagramShell=Qs(),this._translations=Jn({name:"solution-item-diagram",blocking:!0})}static{this.properties={diagramKey:1,templateInfoGraph:0,typeKeywords:0,_diagramPanel:16,_diagramShell:16,_translations:16}}static{this.styles=Xr}updated(){if(this.templateInfoGraph.length>0){let g={centerDiagram:this._translations.graphTranslations.centerDiagram,filteredView:this._translations.graphTranslations.filteredView,reset:this._translations.graphTranslations.reset,zoomIn:this._translations.graphTranslations.zoomIn,zoomOut:this._translations.graphTranslations.zoomOut};this.solutionDisplay=new fn(this._diagramShell.value,this._diagramPanel.value,g,this.diagramKey),this.solutionDisplay.create(this.templateInfoGraph,this.typeKeywords)}}render(){return Hn`<calcite-shell><calcite-shell-panel id=diagram-shell-panel slot=panel-start ${_s(this._diagramShell)}></calcite-shell-panel><calcite-panel class="z-index-1" id=diagram-panel slot=panel-bottom ${_s(this._diagramPanel)}></calcite-panel></calcite-shell>`}};$n("solution-item-diagram",gn);export{gn as SolutionItemDiagram};