@esri/solutions-components 5.1.0-next.20 → 5.1.0-next.21

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 (110) hide show
  1. package/dist/cdn/27JLIL6T.js +2 -0
  2. package/dist/cdn/2B6VLP3A.js +2 -0
  3. package/dist/cdn/{6DLDJH6I.js → 4DFGN2VE.js} +1 -1
  4. package/dist/cdn/{P5Q3LVYT.js → 4GZBBPZQ.js} +1 -1
  5. package/dist/cdn/5PUFVAJH.js +2 -0
  6. package/dist/cdn/{A5STEAY7.js → 6NE73ZT3.js} +1 -1
  7. package/dist/cdn/{AC3MHBPK.js → 7SLUGAMA.js} +1 -1
  8. package/dist/cdn/{FV7G3BY6.js → ACF2RXCB.js} +1 -1
  9. package/dist/cdn/ALB3HUJ2.js +2 -0
  10. package/dist/cdn/{Z6H6J4QH.js → ASTBVDA3.js} +1 -1
  11. package/dist/cdn/{BT2W7DVK.js → BPSXSDMN.js} +1 -1
  12. package/dist/cdn/{NOOFAZCT.js → CWEEG5MA.js} +1 -1
  13. package/dist/cdn/DJFFGBHM.js +2 -0
  14. package/dist/cdn/{673T7ZBJ.js → EBU4JF4W.js} +1 -1
  15. package/dist/cdn/EC6NYTSJ.js +2 -0
  16. package/dist/cdn/EDVUYJ5Q.js +2 -0
  17. package/dist/cdn/EIVJQY2S.js +2 -0
  18. package/dist/cdn/{4GHX4MVD.js → F7DLM4RF.js} +1 -1
  19. package/dist/cdn/{M4OPXH3T.js → FRWN4Q5V.js} +1 -1
  20. package/dist/cdn/G5MDCRT6.js +2 -0
  21. package/dist/cdn/{IORIFDK6.js → GJFVHF5H.js} +1 -1
  22. package/dist/cdn/{3ME5BVUE.js → GN6MDWLZ.js} +1 -1
  23. package/dist/cdn/GTD4LCLX.js +2 -0
  24. package/dist/cdn/HGEF25RL.js +2 -0
  25. package/dist/cdn/{5FKEDJRU.js → I5PBBAVM.js} +1 -1
  26. package/dist/cdn/{GTKRTZK6.js → IMPGTDMV.js} +1 -1
  27. package/dist/cdn/{UME5GDA2.js → ITULTY6G.js} +1 -1
  28. package/dist/cdn/JCDM3IJE.js +2 -0
  29. package/dist/cdn/KRFYU445.js +2 -0
  30. package/dist/cdn/N2KU5PYY.js +2 -0
  31. package/dist/cdn/NDGFJPG7.js +2 -0
  32. package/dist/cdn/NNCQFR7K.js +2 -0
  33. package/dist/cdn/NYUVCFEV.js +2 -0
  34. package/dist/cdn/{IUPEGG4M.js → OMIISLTG.js} +1 -1
  35. package/dist/cdn/OMURSGFL.js +2 -0
  36. package/dist/cdn/{BK3QFV3M.js → P65BBQ5T.js} +1 -1
  37. package/dist/cdn/{AGC6ZWMH.js → POE2XE6Y.js} +1 -1
  38. package/dist/cdn/{GGBXY3NT.js → PUCQJ7PY.js} +1 -1
  39. package/dist/cdn/QNNQGJS4.js +2 -0
  40. package/dist/cdn/QZ3GHISD.js +2 -0
  41. package/dist/cdn/R3KUBISH.js +2 -0
  42. package/dist/cdn/RF7NG5JX.js +2 -0
  43. package/dist/cdn/{EJRSL3ID.js → RTG3SBDS.js} +1 -1
  44. package/dist/cdn/{4L3MVJ5S.js → STEJOS7Q.js} +1 -1
  45. package/dist/cdn/U4MNIZYO.js +2 -0
  46. package/dist/cdn/UQ3MLIHV.js +21 -0
  47. package/dist/cdn/UY2AFOXQ.js +2 -0
  48. package/dist/cdn/{LI4CAGAZ.js → UYYMXFYQ.js} +1 -1
  49. package/dist/cdn/{3JF5JLS4.js → V3S3BZEP.js} +1 -1
  50. package/dist/cdn/{66Q5IRVS.js → V5PIAPEA.js} +1 -1
  51. package/dist/cdn/{DMRQFYLJ.js → VLZNUN6G.js} +12 -12
  52. package/dist/cdn/{C44FH5Z2.js → ZCGIQK3H.js} +1 -1
  53. package/dist/cdn/index.js +1 -1
  54. package/dist/chunks/helpers.js +1 -1
  55. package/dist/chunks/solution-deploy-dialog.js +1 -1
  56. package/dist/components/arcgis-solutions-assistant/customElement.js +1 -1
  57. package/dist/components/crowdsource-manager/customElement.js +3 -3
  58. package/dist/components/crowdsource-reporter/customElement.js +1 -1
  59. package/dist/components/edit-card/customElement.js +4 -4
  60. package/dist/components/feature-details/customElement.js +1 -1
  61. package/dist/components/feature-list/customElement.js +1 -1
  62. package/dist/components/info-card/customElement.js +1 -1
  63. package/dist/components/layer-table/customElement.js +1 -1
  64. package/dist/components/map-picker/customElement.js +1 -1
  65. package/dist/components/public-notification/customElement.js +1 -1
  66. package/dist/components/refine-selection/customElement.js +1 -1
  67. package/dist/components/solution-delete-dialog/customElement.js +1 -1
  68. package/dist/components/solution-deployed-card-panel/customElement.js +8 -8
  69. package/dist/components/solution-deploying-dialog/customElement.js +1 -1
  70. package/dist/components/solution-details-panel/customElement.js +1 -1
  71. package/dist/components/solution-item-diagram/customElement.js +1 -1
  72. package/dist/components/solution-snapshot-gallery/customElement.js +7 -7
  73. package/dist/components/solution-social-share/customElement.js +35 -35
  74. package/dist/components/solutions-all-panel/customElement.js +1 -1
  75. package/dist/components/solutions-all-shell/customElement.js +1 -1
  76. package/dist/components/solutions-deploy-app/customElement.js +4 -4
  77. package/dist/components/solutions-deployed-panel/customElement.js +1 -1
  78. package/dist/components/solutions-deployed-shell/customElement.js +5 -5
  79. package/dist/components/solutions-filter-panel/customElement.js +1 -1
  80. package/dist/components/solutions-resources-shell/customElement.js +38 -38
  81. package/dist/docs/api.json +1 -1
  82. package/dist/docs/docs.json +1 -1
  83. package/dist/docs/web-types.json +1 -1
  84. package/dist/solutions-components_commit.txt +7 -7
  85. package/package.json +1 -1
  86. package/dist/cdn/2WPJOTMI.js +0 -2
  87. package/dist/cdn/2XQOWXMT.js +0 -2
  88. package/dist/cdn/3SYLXG32.js +0 -2
  89. package/dist/cdn/3WO3DS32.js +0 -2
  90. package/dist/cdn/5GIHSPJZ.js +0 -2
  91. package/dist/cdn/74557KPJ.js +0 -2
  92. package/dist/cdn/A2LNKTGU.js +0 -2
  93. package/dist/cdn/AF2YWYJQ.js +0 -2
  94. package/dist/cdn/AT2EES2R.js +0 -21
  95. package/dist/cdn/DQV46RIT.js +0 -2
  96. package/dist/cdn/J5VTBFGR.js +0 -2
  97. package/dist/cdn/K5VEUOS3.js +0 -2
  98. package/dist/cdn/KKYXQLBJ.js +0 -2
  99. package/dist/cdn/KZDTATOG.js +0 -2
  100. package/dist/cdn/LO5Q55JH.js +0 -2
  101. package/dist/cdn/NIUMAAOQ.js +0 -2
  102. package/dist/cdn/OYQYXNHJ.js +0 -2
  103. package/dist/cdn/PKRYRZL7.js +0 -2
  104. package/dist/cdn/RKMY6VWP.js +0 -2
  105. package/dist/cdn/ULXATJK5.js +0 -2
  106. package/dist/cdn/VJEG4LOG.js +0 -2
  107. package/dist/cdn/VJYMTG4U.js +0 -2
  108. package/dist/cdn/WUCVRGH6.js +0 -2
  109. package/dist/cdn/XKDPK7SD.js +0 -2
  110. package/dist/cdn/Y6I6QW4M.js +0 -2
@@ -47,4 +47,4 @@ string: ${t}`);break}}let A=k.fm;if(Ce.JL(k),e){let F=A.figures.iterator;for(;F.
47
47
  "modifiedLinkData": `;eF=`,
48
48
  "removedLinkKeys": `;_v(t){let e=new V;for(let i=0;i<this.linkDataArray.length;i++){let s=this.linkDataArray[i];this.Dk(t,s,s,e)}return e}tL(t,e,i){if(this.linkKeyProperty===""){let c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let s=super.tL(t,e,i),n=this,o=new V,r=new V,a=new V;t.changes.each(c=>{if(c.model===n){if(c.modelChange==="linkDataArray")c.change===3?o.add(c.newValue):c.change===4&&a.add(c.oldValue);else if(n.containsLinkData(c.object))c.object!==null&&r.add(c.object);else if(c.object!==null)if(c.object!==null&&i.has(c.object)){let d=i.get(c.object);d&&d.each(f=>{n.containsLinkData(f)&&r.add(f)})}else{if(c.object instanceof ut||n.containsNodeData(c.object))return;n._v(c.object).each(d=>r.add(d))}}});let h=new V;o.each(c=>{let d=n.getKeyForLinkData(c);d!==void 0&&h.add(d),e||r.add(c)});let l=new V;a.each(c=>{let d=n.getKeyForLinkData(c);d!==void 0&&l.add(d),e&&r.add(c)});let u=s;return h.count>0&&(u+=(e?this.eF:this.tF)+this.za(h.toArray(),!0)),r.count>0&&(u+=this.u3+this.za(r.toArray(),!0)),l.count>0&&(u+=(e?this.tF:this.eF)+this.za(l.toArray(),!0)),u}hw(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)&&m.o("applyIncrementalJson cannot change Model properties"),super.hw(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.iF(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.nt(i,s,n);return}}else if(t.change===3){let i=t.newParam;if(t.modelChange==="linkDataArray"){let s=t.newValue;if(m.$(s)&&typeof i=="number"){let n=this.getKeyForLinkData(s);e?(this.lr.delete(s),this.Os[i]===s&&this.Mo(this.linkDataArray,i),n!==void 0&&this.Oe.delete(n)):(this.lr.add(s),this.Os[i]!==s&&this.rr(this.Os,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.Mo(n,i)):n.indexOf(t.newValue)<0&&this.rr(n,i,t.newValue));return}}else if(t.change===4){let i=t.oldParam;if(t.modelChange==="linkDataArray"){let s=t.oldValue;if(m.$(s)&&typeof i=="number"){let n=this.getKeyForLinkData(s);e?(this.lr.add(s),this.Os[i]!==s&&this.rr(this.Os,i,s),n!==void 0&&this.Oe.set(n,s)):(this.lr.delete(s),this.Os[i]===s&&this.Mo(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.rr(n,i,t.oldValue):(i=n.indexOf(t.oldValue),i>=0&&this.Mo(n,i)));return}}super.changeState(t,e)}}get archetypeNodeData(){return this.zl}set archetypeNodeData(t){let e=this.zl;e!==t&&(t!==null&&m.wc(t,Xt,"archetypeNodeData"),this.zl=t,this.t("archetypeNodeData",e,t))}oL(t){if(t===void 0)return;let e=this.zl;if(e!==null){let i=this.findNodeDataForKey(t);i===null&&(i=this.copyNodeData(e),this.nt(i,this.nodeKeyProperty,t),this.addNodeData(i))}return t}get linkFromKeyProperty(){return this.No}set linkFromKeyProperty(t){let e=this.No;e!==t&&(this.En(t,Xt,"linkFromKeyProperty"),this.No=t,this.t("linkFromKeyProperty",e,t))}getFromKeyForLinkData(t){return this.Vi(t,!0)}setFromKeyForLinkData(t,e){this.bg(t,e,!0)}get linkToKeyProperty(){return this.Co}set linkToKeyProperty(t){let e=this.Co;e!==t&&(this.En(t,Xt,"linkToKeyProperty"),this.Co=t,this.t("linkToKeyProperty",e,t))}getToKeyForLinkData(t){return this.Vi(t,!1)}setToKeyForLinkData(t,e){this.bg(t,e,!1)}Vi(t,e){if(t===null)return;let i=e?this.No:this.Co;if(i==="")return;let s=this.Lt(t,i);if(s!==void 0){if(this.isKeyType(s))return s;m.o((e?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}bg(t,e,i){if(e===null&&(e=void 0),e!==void 0&&!this.isKeyType(e)&&m.si(e,"number or string",Xt,i?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;let s=i?this.No:this.Co;if(s==="")return;if(e=this.oL(e),!this.containsLinkData(t)){this.nt(t,s,e);return}let n=this.Lt(t,s);n!==e&&(this.ln(n,t),this.nt(t,s,e),this.findNodeDataForKey(e)===null&&this.an(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.En(t,Xt,"linkFromPortIdProperty"),this.lc=t,this.t("linkFromPortIdProperty",e,t))}getFromPortIdForLinkData(t){return this.Nk(t,!0)}setFromPortIdForLinkData(t,e){this.kg(t,e,!0)}get linkToPortIdProperty(){return this.ac}set linkToPortIdProperty(t){let e=this.ac;e!==t&&(this.En(t,Xt,"linkToPortIdProperty"),this.ac=t,this.t("linkToPortIdProperty",e,t))}getToPortIdForLinkData(t){return this.Nk(t,!1)}setToPortIdForLinkData(t,e){this.kg(t,e,!1)}Nk(t,e){if(t===null)return"";let i=e?this.lc:this.ac;if(i==="")return"";let s=this.Lt(t,i);return s===void 0?"":s}kg(t,e,i){if(m.s(e,"string",Xt,i?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;let s=i?this.lc:this.ac;if(s==="")return;if(!this.containsLinkData(t)){this.nt(t,s,e);return}let n=this.Lt(t,s);n===void 0&&(n=""),n!==e&&(this.nt(t,s,e),this.Ft(i?"linkFromPortId":"linkToPortId",2,s,t,n,e),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.hn}set linkLabelKeysProperty(t){let e=this.hn;e!==t&&(this.En(t,Xt,"linkLabelKeysProperty"),this.hn=t,this.t("linkLabelKeysProperty",e,t))}getLabelKeysForLinkData(t){if(t===null)return Xt.EmptyArray;let e=this.hn;if(e==="")return Xt.EmptyArray;let i=this.Lt(t,e);return i===void 0?Xt.EmptyArray:i}setLabelKeysForLinkData(t,e){if(this.iL(e,Xt,"setLabelKeysForLinkData:arr"),t===null)return;let i=this.hn;if(i==="")return;if(!this.containsLinkData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);if(s===void 0&&(s=Xt.EmptyArray),s!==e){if(Array.isArray(s)){let o=s.length;for(let r=0;r<o;r++){let a=s[r];this.ln(a,t)}}this.nt(t,i,e);let n=e.length;for(let o=0;o<n;o++){let r=e[o];this.findNodeDataForKey(r)===null&&this.an(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)||m.si(e,"number or string",Xt,"addLabelKeyForLinkData:key"),t===null))return;let i=this.hn;if(i==="")return;let s=this.Lt(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.an(e,t),this.Ft("linkLabelKeys",3,i,t,null,e,null,n))}else m.o(i+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,e){if(e==null||(this.isKeyType(e)||m.si(e,"number or string",Xt,"removeLabelKeyForLinkData:key"),t===null))return;let i=this.hn;if(i==="")return;let s=this.Lt(t,i);if(Array.isArray(s)){let n=s.indexOf(e);if(n<0)return;this.Mo(s,n),this.containsLinkData(t)&&(this.ln(e,t),this.Ft("linkLabelKeys",4,i,t,e,null,n,null))}else s!==void 0&&m.o(i+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.Os}set linkDataArray(t){let e=this.Os;if(e!==t){this.iL(t,Xt,"linkDataArray"),this.Oe.clear();let i=t.length;for(let n=0;n<i;n++){let o=t[n];m.$(o)||m.o("GraphLinksModel.linkDataArray must only contain Objects, not: "+o)}if(this.Os=t,this.linkKeyProperty!==""){let n=new q;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 V;for(let n=0;n<i;n++){let o=t[n];s.add(o)}this.lr=s,this.Ft("linkDataArray",2,"linkDataArray",this,e,t);for(let n=0;n<i;n++){let o=t[n];this.rL(o)}}}get linkKeyProperty(){return this.Xa}set linkKeyProperty(t){let e=this.Xa;if(e!==t){this.En(t,Xt,"linkKeyProperty"),this.Xa=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.Xa;if(e==="")return;let i=this.Lt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;m.o("Key value for link data "+t+" is not a number or a string: "+i)}}setKeyForLinkData(t,e){if((e==null||!this.isKeyType(e))&&m.si(e,"number or string",Xt,"setKeyForLinkData:key"),t===null)return;let i=this.Xa;if(i==="")return;if(!this.containsLinkData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);if(s!==e){if(this.findLinkDataForKey(e)!==null)return;this.nt(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&&m.S(t,Xt,"makeUniqueLinkKeyFunction"),this.Zf=t,this.t("makeUniqueLinkKeyFunction",e,t))}findLinkDataForKey(t){return t===null&&m.o("GraphLinksModel.findLinkDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.Oe.get(t)}Rk(t){return t===void 0?!1:this.Oe.has(t)}makeLinkDataKeyUnique(t){if(t===null)return;let e=this.Xa;if(e==="")return;let i=this.getKeyForLinkData(t);if(i!==void 0&&!this.Rk(i))return;let s=this.Zf;if(s!==null&&(i=s(this,t),i!=null&&!this.Rk(i))){this.nt(t,e,i);return}if(typeof i=="string"){let n=2;for(;this.Rk(i+n);)n++;this.nt(t,e,i+n)}else if(i===void 0||typeof i=="number"){let n=-this.Oe.count-1;for(;this.Rk(n);)n--;this.nt(t,e,n)}}containsLinkData(t){return t===null?!1:this.lr.has(t)}addLinkData(t){t!==null&&(this.containsLinkData(t)||this.Bv(t,!0))}Bv(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&&m.o("GraphLinksModel.makeLinkDataKeyUnique failed on "+t+". Data not added to model."),this.Oe.set(s,t)}this.lr.add(t);let i=null;e&&(i=this.Os.length,this.rr(this.Os,i,t)),this.Ft("linkDataArray",3,"linkDataArray",this,null,t,null,i),this.rL(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.Vv(t,!0)}Vv(t,e){this.lr.delete(t);let i=this.getKeyForLinkData(t);i!==void 0&&this.Oe.delete(i);let s=null;if(e){if(s=this.Os.indexOf(t),s<0)return;this.Mo(this.Os,s)}this.Ft("linkDataArray",4,"linkDataArray",this,t,null,s,null),this.d3(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===""&&m.o("GraphLinksModel.linkKeyProperty must not be an empty string for .mergeLinkDataArray() to succeed."),t===this.linkDataArray||!Array.isArray(t))return;let e=new V;e.addAll(this.Oe.iteratorKeys);let i=new V,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.iF(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)}}}rL(t){let e=this.Vi(t,!0);e=this.oL(e),this.findNodeDataForKey(e)===null&&this.an(e,t),e=this.Vi(t,!1),e=this.oL(e),this.findNodeDataForKey(e)===null&&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.findNodeDataForKey(e)===null&&this.an(e,t)}}d3(t){let e=this.Vi(t,!0);this.ln(e,t),e=this.Vi(t,!1),this.ln(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.ln(e,t)}}get copyLinkDataFunction(){return this.Qf}set copyLinkDataFunction(t){let e=this.Qf;e!==t&&(t!==null&&m.S(t,Xt,"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.Fk(t,!0),m.$(e)&&(this.No!==""&&this.nt(e,this.No,void 0),this.Co!==""&&this.nt(e,this.Co,void 0),this.hn!==""&&this.nt(e,this.hn,[])),e}get nodeIsGroupProperty(){return this._f}set nodeIsGroupProperty(t){let e=this._f;e!==t&&(this.En(t,Xt,"nodeIsGroupProperty"),this._f=t,this.t("nodeIsGroupProperty",e,t))}isGroupForNodeData(t){if(t===null)return!1;let e=this._f;return e===""?!1:!!this.Lt(t,e)}isGroupForData(t){return this.isGroupForNodeData(t)}get nodeGroupKeyProperty(){return this.Ml}set nodeGroupKeyProperty(t){let e=this.Ml;e!==t&&(this.En(t,Xt,"nodeGroupKeyProperty"),this.Ml=t,this.t("nodeGroupKeyProperty",e,t))}getGroupKeyForNodeData(t){if(t===null)return;let e=this.Ml;if(e==="")return;let i=this.Lt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;m.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)&&m.si(e,"number or string",Xt,"setGroupKeyForNodeData:key"),t===null)return;let i=this.Ml;if(i==="")return;if(!this.containsNodeData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);s!==e&&(this.ln(s,t),this.nt(t,i,e),this.findNodeDataForKey(e)===null&&this.an(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.setGroupKeyForNodeData(e,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.bg(t,i,!0);return}else if(e===this.linkToKeyProperty){this.bg(t,i,!1);return}else if(e===this.linkFromPortIdProperty){this.kg(t,i,!0);return}else if(e===this.linkToPortIdProperty){this.kg(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.Lt(t,e);s!==i&&(this.nt(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.Lt(t,n)===e[n]||s&&n===this.linkKeyProperty)continue;this.setDataProperty(t,n,e[n])}}cw(t,e){super.cw(t,e);let i=this.be.iterator;for(;i.next();){let n=i.value;this.lL(n,t,e)}let s=this.lr.iterator;for(;s.next();){let n=s.value;this.g3(n,t,e)}}lL(t,e,i){if(this.getGroupKeyForNodeData(t)===e){let s=this.Ml;this.nt(t,s,i),this.Ft("nodeGroupKey",2,s,t,e,i),typeof s=="string"&&this.updateTargetBindings(t,s)}}g3(t,e,i){if(this.Vi(t,!0)===e){let n=this.No;this.nt(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.Co;this.nt(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.hn;for(let r=0;r<n;r++)s[r]===e&&(this.Jv(s,r,i),this.Ft("linkLabelKeys",3,o,t,e,i,r,r))}}sL(){super.sL();let t=this.linkDataArray,e=t.length;for(let i=0;i<e;i++){let s=t[i];this.rL(s)}}Dg(t){super.Dg(t);let e=this.getKeyForNodeData(t),i=this.iw(e);if(i!==null){let s=m.st(),n=i.iterator;for(;n.next();){let o=n.value;if(this.containsNodeData(o)){if(this.getGroupKeyForNodeData(o)===e){let r=this.Ml;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.No;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.Co;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.hn;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.ln(e,s[o]);m.Z(s)}}vg(t){super.vg(t);let e=this.getGroupKeyForNodeData(t);this.findNodeDataForKey(e)===null&&this.an(e,t)}fw(t){super.fw(t);let e=this.getGroupKeyForNodeData(t);this.ln(e,t)}get linkCategoryProperty(){return this.hc}set linkCategoryProperty(t){let e=this.hc;e!==t&&(this.En(t,Xt,"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.Lt(t,e);if(i===void 0)return"";if(typeof i=="string")return i;m.o("getCategoryForLinkData found a non-string category for "+t+": "+i)}getLinkCategoryForData(t){return this.getCategoryForLinkData(t)}setCategoryForLinkData(t,e){if(m.s(e,"string",Xt,"setCategoryForLinkData:cat"),t===null)return;let i=this.hc;if(i==="")return;if(!this.containsLinkData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);s===void 0&&(s=""),s!==e&&(this.nt(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)}Tg(t,e){super.Tg(t,e),this.setGroupKeyForNodeData(e,this.getGroupKeyForNodeData(t))}iF(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"}uS(){return!0}jh(){return!0}Cx(){return!0}Ah(){return!0}static EmptyArray=Object.freeze([])}ut.Sl(Xt,"GraphLinksModel"),ut.Wv=()=>new Xt,ut.g2=()=>new Xt;class je extends ut{Nl;cc;constructor(t,e){if(super(),this.Nl="parent",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.Nl=this.Nl,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+=`
49
49
  node data:`;let i=this.nodeDataArray,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+this.getKeyForNodeData(o)+":"+te.toString(o)}}return e}}Ag(){let t=super.Ag(),e="";return this.nodeParentKeyProperty!=="parent"&&typeof this.nodeParentKeyProperty=="string"&&(e+=`,
50
- "nodeParentKeyProperty": `+this.quote(this.nodeParentKeyProperty)),t+e}aw(t){super.aw(t),t.nodeParentKeyProperty&&(this.nodeParentKeyProperty=t.nodeParentKeyProperty)}hw(t){t.nodeParentKeyProperty!==void 0&&t.nodeParentKeyProperty!==this.nodeParentKeyProperty&&m.o("applyIncrementalJson cannot change Model properties"),super.hw(t)}maybeEnsureLinkReference(t){return t}get nodeParentKeyProperty(){return this.Nl}set nodeParentKeyProperty(t){let e=this.Nl;e!==t&&(this.En(t,je,"nodeParentKeyProperty"),this.Nl=t,this.t("nodeParentKeyProperty",e,t))}getParentKeyForNodeData(t){if(t===null)return;let e=this.Nl;if(e==="")return;let i=this.Lt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;m.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)&&m.si(e,"number or string",je,"setParentKeyForNodeData:key"),t===null)return;let i=this.Nl;if(i==="")return;if(e=this.maybeEnsureLinkReference(e),!this.containsNodeData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);s!==e&&(this.ln(s,t),this.nt(t,i,e),this.findNodeDataForKey(e)===null&&this.an(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.En(t,je,"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.Lt(t,e);if(i===void 0)return"";if(typeof i=="string")return i;m.o("getParentLinkCategoryForNodeData found a non-string category for "+t+": "+i)}getLinkCategoryForData(t){return this.getParentLinkCategoryForNodeData(t)}setParentLinkCategoryForNodeData(t,e){if(m.s(e,"string",je,"setParentLinkCategoryForNodeData:cat"),t===null)return;let i=this.cc;if(i==="")return;if(!this.containsNodeData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);s===void 0&&(s=""),s!==e&&(this.nt(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.setParentKeyForNodeData(e,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.Lt(t,e);s!==i&&(this.nt(t,e,i),this.raiseDataChanged(t,e,s,i))}cw(t,e){super.cw(t,e);let i=this.be.iterator;for(;i.next();){let s=i.value;this.lL(s,t,e)}}lL(t,e,i){if(this.getParentKeyForNodeData(t)===e){let s=this.Nl;this.nt(t,s,i),this.Ft("nodeParentKey",2,s,t,e,i),typeof s=="string"&&this.updateTargetBindings(t,s)}}Dg(t){super.Dg(t);let e=this.getKeyForNodeData(t),i=this.iw(e);if(i!==null){let s=m.st(),n=i.iterator;for(;n.next();){let o=n.value;if(this.containsNodeData(o)&&this.getParentKeyForNodeData(o)===e){let r=this.Nl;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.ln(e,s[o]);m.Z(s)}}vg(t){super.vg(t);let e=this.getParentKeyForNodeData(t);e=this.maybeEnsureLinkReference(e),this.findNodeDataForKey(e)===null&&this.an(e,t)}fw(t){super.fw(t);let e=this.getParentKeyForNodeData(t);this.ln(e,t)}Tg(t,e){super.Tg(t,e),this.setParentLinkCategoryForNodeData(e,this.getParentLinkCategoryForNodeData(t)),this.setParentKeyForNodeData(e,this.getParentKeyForNodeData(t))}get type(){return"TreeModel"}Nx(){return!0}Cx(){return!0}}ut.Sl(je,"TreeModel");var ts=(x=>(x[x.ConstantSpacing=0]="ConstantSpacing",x[x.ConstantDistance=1]="ConstantDistance",x[x.ConstantAngle=2]="ConstantAngle",x[x.Packed=3]="Packed",x))(ts||{}),es=(x=>(x[x.Clockwise=10]="Clockwise",x[x.Counterclockwise=11]="Counterclockwise",x[x.BidirectionalLeft=12]="BidirectionalLeft",x[x.BidirectionalRight=13]="BidirectionalRight",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[x.Optimized=24]="Optimized",x))(is||{}),ss=(x=>(x[x.Pythagorean=30]="Pythagorean",x[x.Circular=31]="Circular",x))(ss||{});class Be extends _t{gi;tu;Ok;Fg;Ik;Ga;aL;hL;cL;Is;uw;dw;fc;gw;sF;Rg;Og;Ig;eu;He;P;Si;Mi;In;Eg;constructor(t){super(),this.gi=0,this.tu=0,this.Ok=0,this.Fg=360,this.Ik=0,this.Ga=0,this.aL=new P,this.hL=30,this.cL=0,this.Is=0,this.uw=0,this.dw=new Hs,this.fc=0,this.gw=0,this.sF=600,this.Rg=NaN,this.Og=1,this.Ig=0,this.eu=360,this.He=0,this.P=10,this.Si=24,this.Mi=Ie.standardComparer,this.In=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.In=this.In,t.Eg=this.Eg}fe(t){t in is?this.sorting=t:t in es?this.direction=t:t in ts?this.arrangement=t:t in ss?this.nodeDiameterFormula=t:super.fe(t)}createNetwork(){return new Ws(this)}m3(t,e,i){t=this.p3(t);let s=this.Ik,n=this.hL,o=this.gi,r=this.tu,a=this.Ok,h=this.Fg,l=this.Ga,u=this.cL,c=this.Is,d=this.uw;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 g=0;!(g>=t.length||(e.add(t.elt(g)),g+1>=t.length));g+=2)i.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&e.reverse(),t=new q,t.addAll(e),t.addAll(i)):(this.arrangement===3&&i.reverse(),t=new q,t.addAll(i),t.addAll(e))}let f=t.length;u=0;let p=0;for(let g=0;g<t.length;g++){let y=a+h*p*(this.direction===10?1:-1)/f,b=t.elt(g).diameter;isNaN(b)&&(b=t.elt(g).Ya(y)),h<360&&(g===0||g===t.length-1)&&(b/=2),u+=b,p++}if(isNaN(o)||s===3){if(isNaN(l)&&(l=6),s!==0&&s!==3){let g=-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.Ya(0),isNaN(v.diameter)&&v.Ya(0),g=Math.max(g,(b.diameter+v.diameter)/2)}if(d=g+l,s===2){let y=2*Math.PI/f,b=(g+l)/y;r>1?(o=b,c=o*r):(c=b,o=c)}else o=this.Ek(d*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180)}else o=this.Ek(u+(h>=360?f:f-1)*(s!==3?l:l*1.6),r,a*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;let g=this.fL(o,c,a*Math.PI/180,h*Math.PI/180);if(isNaN(l))s===0&&(l=(g-u)/(h>=360?f:f-1));else if(s===0){let y=(g-u)/(h>=360?f:f-1);y<l?(o=this.Ek(u+l*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180),c=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.Ya(0),isNaN(S.diameter)&&S.Ya(0),y=Math.max(y,(k.diameter+S.diameter)/2)}let b=y+l,v=this.Ek(b*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180);v>o?(o=v,c=o*r,d=b):d=g/(h>=360?f:f-1)}}return this.Ik=s,this.hL=n,this.gi=o,this.tu=r,this.Ok=a,this.Fg=h,this.Ga=l,this.cL=u,this.Is=c,this.uw=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 q;i.addAll(e.iterator);let s=new q,n=new q;i=this.m3(i,s,n);let o=this.Ik,r=this.gi,a=this.Ok,h=this.Fg,l=this.Ga,u=this.Is,c=this.uw;if((this.direction===12||this.direction===13)&&o===3)this.nF(i,h,a-h/2,10);else if(this.direction===12||this.direction===13){let d=0;switch(o){case 1:d=this.Uk(r,u,a,c)*180/Math.PI;break;case 0:{let f=0,p=0,g=s.first();g!==null&&(f=g.Ya(Math.PI/2));let y=n.first();y!==null&&(p=y.Ya(Math.PI/2)),d=this.Uk(r,u,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.mw(s,h/2,a,11);break;case 0:this.pw(s,h/2,a,11);break;case 2:this.yw(s,h/2,a,11);break}switch(o){case 1:this.mw(n,h/2,a+d,10);break;case 0:this.pw(n,h/2,a+d,10);break;case 2:this.yw(n,h/2,a+d,10);break}}else{switch(o){case 1:this.mw(n,h/2,a,11);break;case 0:this.pw(n,h/2,a,11);break;case 2:this.yw(n,h/2,a,11);break}switch(o){case 1:this.mw(s,h/2,a+d,10);break;case 0:this.pw(s,h/2,a+d,10);break;case 2:this.yw(s,h/2,a+d,10);break}}}else switch(o){case 1:this.mw(i,h,a,this.direction);break;case 0:this.pw(i,h,a,this.direction);break;case 2:this.yw(i,h,a,this.direction);break;case 3:this.nF(i,h,a,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}yw(t,e,i,s){let n=this.Fg,o=this.gi,r=this.Is,a=i*Math.PI/180,h=e*Math.PI/180,l=t.length;for(let u=0;u<l;u++){let c=a+(s===10?u*h/(n>=360?l:l-1):-(u*h)/l),d=t.elt(u),f=o*Math.tan(c)/r,p=Math.sqrt((o*o+r*r*f*f)/(1+f*f));d.centerX=p*Math.cos(c),d.centerY=p*Math.sin(c),d.actualAngle=c*180/Math.PI}}pw(t,e,i,s){let n=this.gi,o=this.Is,r=this.Ga,a=i*Math.PI/180,h=t.length;for(let l=0;l<h;l++){let u=t.elt(l),c=t.elt(l===h-1?0:l+1),d=n*Math.cos(a),f=o*Math.sin(a);u.centerX=d,u.centerY=f,u.actualAngle=a*180/Math.PI,isNaN(u.diameter)&&u.Ya(0),isNaN(c.diameter)&&c.Ya(0);let p=(u.diameter+c.diameter)/2,g=this.Uk(n,o,s===10?a:-a,p+r);a+=s===10?g:-g}}mw(t,e,i,s){let n=this.gi,o=this.Is,r=this.uw,a=i*Math.PI/180,h=t.length;for(let l=0;l<h;l++){let u=t.elt(l);u.centerX=n*Math.cos(a),u.centerY=o*Math.sin(a),u.actualAngle=a*180/Math.PI;let c=this.Uk(n,o,s===10?a:-a,r);a+=s===10?c:-c}}nF(t,e,i,s){let n=this.gw,o=this.Fg;if(this.fc=0,this.dw=new Hs,e<360){for(n=i+(s===10?o:-o);n<0;)n+=360;n%=360,n>180&&(n-=360),n*=Math.PI/180,this.gw=n,this.oF(t,e,i,s)}else this.rF(t,e,i,s);this.dw.commit(t)}rF(t,e,i,s){let n=this.gi,o=this.Is,r=this.Ga,a=this.tu,h=n*Math.cos(i*Math.PI/180),l=o*Math.sin(i*Math.PI/180),u=t.toArray();if(u.length===3){u[0].centerX=n,u[0].centerY=0,u[1].centerX=u[0].centerX-u[0].width/2-u[1].width/2-r,u[1].y=u[0].y,u[2].centerX=(u[0].centerX+u[1].centerX)/2,u[2].y=u[0].y-u[2].height-r;return}else if(u.length===4){u[0].centerX=n,u[0].centerY=0,u[2].centerX=-u[0].centerX,u[2].centerY=u[0].centerY,u[1].centerX=0,u[1].y=Math.min(u[0].y,u[2].y)-u[1].height-r,u[3].centerX=0,u[3].y=Math.max(u[0].y+u[0].height+r,u[2].y+u[2].height+r);return}let c=P.l();for(let k=0;k<u.length&&(u[k].centerX=h,u[k].centerY=l,!(k>=u.length-1));k++)this.lF(h,l,u,k,s,c)||this.aF(h,l,u,k,s,c),h=c.x,l=c.y;if(P.i(c),this.fc++,this.fc>23)return;let d=u[0].centerX,f=u[0].centerY,p=u[u.length-1].centerX,g=u[u.length-1].centerY,y=Math.abs(d-p)-((u[0].width+u[u.length-1].width)/2+r),b=Math.abs(f-g)-((u[0].height+u[u.length-1].height)/2+r),v=0;if(Math.abs(b)<1){let k=Math.abs(d-p),S=(u[0].width+u[u.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(g)?w=p>0!=f>g:w=g>0!=d<p,w=s===10?w:!w,w&&(v=-Math.abs(v),v=Math.min(v,-u[u.length-1].width),v=Math.min(v,-u[u.length-1].height)),this.dw.y3(v,u),Math.abs(v)>1&&(this.fc<8?this.gi-=v/(2*Math.PI):u.length<5&&v>10?this.gi/=2:this.gi-=v>0?1.7:-2.3,this.Is=this.gi*a,this.rF(t,e,i,s))}oF(t,e,i,s){let n=this.gi,o=this.Is,r=this.tu,a=n*Math.cos(i*Math.PI/180),h=o*Math.sin(i*Math.PI/180),l=P.l(),u=t.toArray();for(let p=0;p<u.length&&(u[p].centerX=a,u[p].centerY=h,!(p>=u.length-1));p++)this.lF(a,h,u,p,s,l)||this.aF(a,h,u,p,s,l),a=l.x,h=l.y;if(P.i(l),this.fc++,this.fc>23)return;let c=Math.atan2(h,a),d=s===10?this.gw-c:c-this.gw;d=Math.abs(d)<Math.abs(d-2*Math.PI)?d:d-2*Math.PI;let f=d*(n+o)/2;this.dw.w3(f,u),Math.abs(f)>1&&(this.fc<8?this.gi-=f/(2*Math.PI):this.gi-=f>0?1.7:-2.3,this.Is=this.gi*r,this.oF(t,e,i,s))}lF(t,e,i,s,n,o){let r=this.Ga,a=this.gi,h=this.Is,l=0,u=0,c=(i[s].width+i[s+1].width)/2+r,d=!1;if(e>=0!=(n===10)){if(l=t+c,l>a){if(l=t-c,l<-a)return o.x=l,o.y=u,!1;d=!0}}else if(l=t-c,l<-a){if(l=t+c,l>a)return o.x=l,o.y=u,!1;d=!0}return u=Math.sqrt(1-Math.min(1,l*l/(a*a)))*h,e<0!==d&&(u=-u),Math.abs(e-u)>(i[s].height+i[s+1].height)/2?(o.x=l,o.y=u,!1):(o.x=l,o.y=u,!0)}aF(t,e,i,s,n,o){let r=this.Ga,a=this.gi,h=this.Is,l=0,u=0,c=(i[s].height+i[s+1].height)/2+r,d=!1;if(t>=0!=(n===10)){if(u=e-c,u<-h){if(u=e+c,u>h)return o.x=l,o.y=u,!1;d=!0}}else if(u=e+c,u>h){if(u=e-c,u<-h)return o.x=l,o.y=u,!1;d=!0}return l=Math.sqrt(1-Math.min(1,u*u/(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=u,!1):(o.x=l,o.y=u,!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.gi,i.y=this.arrangementOrigin.y+this.Is),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.aL=o.subtract(s)}}commitLinks(){if(this.network!==null){let t=this.network.edges.iterator;for(;t.next();)t.value.commit()}}fL(t,e,i,s){let n=this.sF;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 u=Math.sin(h);r+=Math.sqrt(1-o*o*u*u)*a}return i!==void 0&&s!==void 0?(t>e?t:e)*r:4*(t>e?t:e)*r}Ek(t,e,i,s){let n=0;return i!==void 0&&s!==void 0?n=this.fL(1,e,i,s):n=this.fL(1,e),t/n}Uk(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}}p3(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.x3(this.b3(t));default:m.o("Invalid sorting type.")}return t}b3(t){let e=[];for(let s=0;s<t.length;s++)e.push(0);let i=new q;for(let s=0;s<t.length;s++){let n=-1,o=-1;if(s===0)for(let u=0;u<t.length;u++){let c=t.elt(u).edgesCount;c>n&&(n=c,o=u)}else for(let u=0;u<t.length;u++){let c=e[u];c>n&&(n=c,o=u)}i.add(t.elt(o)),e[o]=-1;let r=t.elt(o),a=0,h=r.sourceEdges;for(;h.next();){let u=h.value.fromVertex;a=t.indexOf(u),!(a<0)&&e[a]>=0&&e[a]++}let l=r.destinationEdges;for(;l.next();){let u=l.value.toVertex;a=t.indexOf(u),!(a<0)&&e[a]>=0&&e[a]++}}return i}x3(t){let e=[];for(let c=0;c<t.length;c++){let d=t.elt(c);e[c]=[];let f=0,p=d.destinationEdges;for(;p.next();){let y=p.value.toVertex;f=t.indexOf(y),f!==c&&e[c].indexOf(f)<0&&e[c].push(f)}let g=d.sourceEdges;for(;g.next();){let y=g.value.fromVertex;f=t.indexOf(y),f!==c&&e[c].indexOf(f)<0&&e[c].push(f)}}let i=[];for(let c=0;c<e.length;c++)i[c]=0;let s=[],n=[],o=[],r=[],a=new q,h=0;for(let c=0;c<e.length;c++){let d=e[c].length;if(d===1){r.push(c);continue}if(d===0){a.add(t.elt(c));continue}if(h===0){s.push(c),h++;continue}let f=1/0,p=1/0,g=-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.k3(e[c],n,o,i,v,s),k=0;for(let S=0;S<e[c].length;S++){let N=e[c][S],D=s.indexOf(N);if(D>=0){let L=Math.abs(v-(D>=v?D+1:D));k+=L<s.length+1-L?L:s.length+1-L}}for(let S=0;S<n.length;S++){let N=i[n[S]],D=i[o[S]];if(N>=v&&N++,D>=v&&D++,N>D){let L=D;D=N,N=L}D-N<(s.length+2)/2==(N<v&&v<=D)&&k++}(w<f||w===f&&k<p)&&(f=w,p=k,g=v)}s.splice(g,0,c);for(let b=0;b<s.length;b++)i[s[b]]=b;for(let b=0;b<e[c].length;b++){let v=e[c][b];s.indexOf(v)>=0&&(n.push(c),o.push(v))}h++}let l=!1,u=s.length;for(;;){l=!0;for(let c=0;c<r.length;c++){let d=r[c],f=e[d][0],p=s.indexOf(f);if(p>=0){let g=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=u-w;g+=v<p!=w>k?1:-1}s.splice(g<0?p:p+1,0,d),r.splice(c,1),c--}else l=!1}if(l)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c<s.length;c++){let d=s[c];a.add(t.elt(d))}return a}k3(t,e,i,s,n,o){let r=0;for(let a=0;a<e.length;a++){let h=e[a],l=i[a],u=s[h],c=s[l],d=0,f=0;if(u<c?(d=u,f=c):(d=c,f=u),d<n&&n<=f)for(let p=0;p<t.length;p++){let g=t[p];o.indexOf(g)<0||d<s[g]&&s[g]<f||d===s[g]||f===s[g]||r++}else for(let p=0;p<t.length;p++){let g=t[p];o.indexOf(g)<0||!(d<s[g]&&s[g]<f)||d===s[g]||f===s[g]||r++}}return r}get radius(){return this.Rg}set radius(t){this.Rg!==t&&(m.s(t,"number",Be,"radius"),(t>0||isNaN(t))&&(this.Rg=t,this.p()))}get aspectRatio(){return this.Og}set aspectRatio(t){this.Og!==t&&(m.s(t,"number",Be,"aspectRatio"),t>0&&(this.Og=t,this.p()))}get startAngle(){return this.Ig}set startAngle(t){this.Ig!==t&&(m.s(t,"number",Be,"startAngle"),this.Ig=t,this.p())}get sweepAngle(){return this.eu}set sweepAngle(t){this.eu!==t&&(m.s(t,"number",Be,"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&&(m.S(t,Be,"comparer"),this.Mi=t,this.p())}get spacing(){return this.In}set spacing(t){this.In!==t&&(m.s(t,"number",Be,"spacing"),this.In=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.gi}get actualYRadius(){return this.Is}get actualSpacing(){return this.Ga}get actualCenter(){return this.aL}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 Hs{iu;uc;su;constructor(){this.iu=-1/0,this.uc=null,this.su=null}y3(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}}w3(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 Ws extends Ee{constructor(t){super(t)}createVertex(){return new di(this)}createEdge(){return new $s(this)}}class di extends Ie{Lo;Vk;constructor(t){super(t),this.Lo=NaN,this.Vk=NaN}Ya(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.Lo=Math.max(this.width,this.height),this.Lo;{let s=Math.abs(Math.sin(t)),n=Math.abs(Math.cos(t));return s===0?this.width:n===0?this.height:(this.Lo=Math.min(this.height/s,this.width/n),this.Lo)}}else return i.nodeDiameterFormula===31?(this.Lo=Math.max(this.width,this.height),this.Lo):(this.Lo=Math.sqrt(this.width*this.width+this.height*this.height),this.Lo)}get diameter(){return this.Lo}set diameter(t){this.Lo!==t&&(m.s(t,"number",di,"diameter"),this.Lo=t)}get actualAngle(){return this.Vk}set actualAngle(t){this.Vk!==t&&(m.s(t,"number",di,"actualAngle"),this.Vk=t)}}class $s extends ei{constructor(t){super(t)}}class ee extends _t{ww;Ka;Es;Ug;Un;zi;Vg;Bg;zg;nu;Xg;Gg;ou;ru;lu;au;Yg;Kg;hu;dc;constructor(t){super(),this.ww=0,this.Ka=0,this.Es=new st(100,100).k(),this.Ug=!1,this.Un=!0,this.zi=!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.Es.h(this.Es),t.Ug=this.Ug,t.Un=this.Un,t.zi=this.zi,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 Js(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.uL(),this.Ka=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.P3(r,n),r=o.iterator;r.next();){let a=r.value,h=a.vertexes.iterator;for(;h.next();){let u=h.value;n.addVertex(u)}let l=a.edges.iterator;for(;l.next();){let u=l.value;n.addEdge(u)}}}else this.hF(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 Zs(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.S3(i,r,this.maxPrelayoutIterations,t.vertexes.count),this.hF(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 c=l.value;i.has(c.idInCluster)||c.hierarchicalVertexes.length<a&&(a=c.hierarchicalVertexes.length,h=c)}let u=e.createVertex();u.hierarchicalVertexes.addAll(r.hierarchicalVertexes),h!=null&&u.hierarchicalVertexes.addAll(h.hierarchicalVertexes),i.set(r.idInCluster,u),h!=null&&i.set(h.idInCluster,u),e.addVertex(u)}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}nx(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}P3(t,e){let i=this.arrangementSpacing,s=t.count,n=!0,o=0,r=0,a=m.st();for(let c=0;c<s+e.vertexes.count+2;c++)a[c]=null;let h=0;t.reset();let l=I.l(),u;for(;t.next();){let c=t.value;if(this.nx(c,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.cF(a,h,o,r,l.width,l.height,i),f=a[d],p=new P(f.x+l.width+i.width,f.y),g=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]=g,h++;let y=f.x-l.x,b=f.y-l.y;for(u=c.vertexes.iterator;u.next();){let v=u.value;this.isFixed(v)||(v.centerX+=y,v.centerY+=b)}}}for(I.i(l),u=e.vertexes.iterator;u.next();){let c=u.value,d=c.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.cF(a,h,o,r,d.width,d.height,i),p=a[f],g=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]=g,a[f+1]=y,h++,this.isFixed(c)||(c.centerX=p.x+c.width/2,c.centerY=p.y+c.height/2)}m.Z(a)}cF(t,e,i,s,n,o,r){let a=9e19,h=-1;t:for(let l=0;l<e;l++){let u=t[l],c=u.x-i,d=u.y-s,f=c*c+d*d;if(f<a){for(let p=l-1;p>=0;p--)if(t[p].y>u.y&&t[p].x-u.x<n+r.width)continue t;for(let p=l+1;p<e;p++)if(t[p].x>u.x&&t[p].y-u.y<o+r.height)continue t;h=l,a=f}}return h}uL(){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}}}fF(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,u=a.width,c=a.height;if(s+o<h)if(n>l+c){let d=s+o-h,f=n-l-c;return C._w(d*d+f*f)}else if(n+r<l){let d=s+o-h,f=n+r-l;return C._w(d*d+f*f)}else return h-(s+o);else if(s>h+u)if(n>l+c){let d=s-h-u,f=n-l-c;return C._w(d*d+f*f)}else if(n+r<l){let d=s-h-u,f=n+r-l;return C._w(d*d+f*f)}else return s-(h+u);else return n>l+c?n-(l+c):n+r<l?l-(n+r):.1}hF(t,e){let i=this.Ka+e;for(;this.Ka<i&&(this.Ka++,!!this.M3(t)););}M3(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 g=e[p];g.forceX=0,g.forceY=0;let y=g.centerX,b=g.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,g)=>p===null||g===null||p===g?0:p.centerX-g.centerX):e.sort((p,g)=>p===null||g===null||p===g?0:p.centerY-g.centerY);let h=this.nu,l=0,u=0,c=0;for(let p=0;p<e.length;p++){let g=e[p],y=g.bounds,b=g.focus,v=y.x+b.x,w=y.y+b.y;u=g.charge*this.electricalFieldX(v,w),c=g.charge*this.electricalFieldY(v,w),u+=g.mass*this.gravitationalFieldX(v,w),c+=g.mass*this.gravitationalFieldY(v,w),g.forceX+=u,g.forceY+=c;for(let k=p+1;k<e.length;k++){let S=e[k];if(!this.shouldInteract(g,S)||k===p)continue;let N=S.bounds,D=S.focus,L=N.x+D.x,M=N.y+D.y;if(v-L>h||L-v>h){if(a)break;continue}if(w-M>h||M-w>h){if(!a)break;continue}let A=this.fF(g,S),F=2*g.charge,O=2*S.charge;if(A>1)l=F*O/(A*A),u=l*(v-L)/A,c=l*(w-M)/A;else{let E=this.randomNumberGenerator;E===null&&(this.randomNumberGenerator=E=new Zs(0));let B=E.random(),X=E.random();if(v>L)u=Math.abs(S.bounds.right-g.bounds.x),u=F*O*(1+u)*B;else if(v<L)u=Math.abs(S.bounds.x-g.bounds.right),u=-(F*O)*(1+u)*B;else{let z=Math.max(S.width,g.width);u=F*O*((1+z)*B-z/2)}if(w>M)c=Math.abs(S.bounds.bottom-g.bounds.y),c=F*O*(1+c)*X;else if(v<L)c=Math.abs(S.bounds.y-g.bounds.bottom),c=-(F*O)*(1+c)*X;else{let z=Math.max(S.height,g.height);c=F*O*((1+z)*X-z/2)}}g.forceX+=u,g.forceY+=c,S.forceX-=u,S.forceY-=c}}let d=t.edges.iterator;for(;d.next();){let p=d.value,g=p.fromVertex,y=p.toVertex,b=g.bounds,v=g.focus,w=b.x+v.x,k=b.y+v.y,S=y.bounds,N=y.focus,D=S.x+N.x,L=S.y+N.y,M=this.fF(g,y);M>1&&(l=.1*p.stiffness*(M-p.length),u=l*.5*(g.width+y.height)*(w-D)/M,c=l*.5*(g.width+y.height)*(k-L)/M),g.forceX-=u,g.forceY-=c,y.forceX+=u,y.forceY+=c}let f=0;for(let p=0;p<e.length;p++){let g=e[p];this.isFixed(g)?this.moveFixedVertex(g):f=Math.max(f,this.moveVertex(g)||0)}return f>this.epsilonDistance*this.epsilonDistance}S3(t,e,i,s){let n=this.Ka+i,o=Math.sqrt(s);this.ww=this.dc*t.vertexes.count;let r=t.vertexes.toArray(),a=0,h=0,l=0;for(;this.Ka<n;){this.Ka++,h=a,a=0;for(let u=0;u<r.length;u++){r[u].forceX=0,r[u].forceY=0;for(let d=0;d<r.length;d++){if(u===d)continue;let f=Math.sqrt((r[u].centerX-r[d].centerX)**2+(r[u].centerY-r[d].centerY)**2),p=e[r[u].idInCluster][r[d].idInCluster],g=(f-this.dc*o*p)/f;r[u].forceX+=g*(r[d].x-r[u].x),r[u].forceY+=g*(r[d].y-r[u].y)}let c=Math.sqrt(r[u].forceX*r[u].forceX+r[u].forceY*r[u].forceY);if(c>0){r[u].forceX=this.ww*r[u].forceX/c,r[u].forceY=this.ww*r[u].forceY/c,this.isFixed(r[u])||(r[u].x+=r[u].forceX,r[u].y+=r[u].forceY);let d=r[u].hierarchicalVertexes.iterator;for(;d.next();){let f=d.value;this.isFixed(f)||(f.centerX+=r[u].forceX,f.centerY+=r[u].forceY)}}a+=c*c}if(a>=h){if(l++,l>=5)break}else l=0;this.ww*=.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.xw(),this.commitNodes(),this.isRouting&&this.commitLinks()}xw(){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=I.l();this.nx(this.network,n);let o=this.arrangementOrigin;t=o.x-n.x,e=o.y-n.y,I.i(n)}let i=I.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()}I.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.Ka}get arrangementSpacing(){return this.Es}set arrangementSpacing(t){this.Es.equals(t)||(this.Es.h(t),this.p())}get arrangesToOrigin(){return this.Ug}set arrangesToOrigin(t){this.Ug!==t&&(m.s(t,"boolean",ee,"arrangesToOrigin"),this.Ug=t,this.p())}get setsPortSpots(){return this.Un}set setsPortSpots(t){this.Un!==t&&(m.s(t,"boolean",ee,"setsPortSpots"),this.Un=t,this.p())}get comments(){return this.zi}set comments(t){this.zi!==t&&(m.s(t,"boolean",ee,"comments"),this.zi=t,this.p())}get maxPrelayoutIterations(){return this.Vg}set maxPrelayoutIterations(t){this.Vg!==t&&(m.s(t,"number",ee,"maxPrelayoutIterations"),t>=0&&(this.Vg=t,this.p()))}get maxIterations(){return this.Bg}set maxIterations(t){this.Bg!==t&&(m.s(t,"number",ee,"maxIterations"),t>=0&&(this.Bg=t,this.p()))}get epsilonDistance(){return this.zg}set epsilonDistance(t){this.zg!==t&&(m.s(t,"number",ee,"epsilonDistance"),t>0&&(this.zg=t,this.p()))}get infinityDistance(){return this.nu}set infinityDistance(t){this.nu!==t&&(m.s(t,"number",ee,"infinityDistance"),t>1&&(this.nu=t,this.p()))}get moveLimit(){return this.Xg}set moveLimit(t){this.Xg!==t&&(m.s(t,"number",ee,"moveLimit"),this.Xg=t,this.p())}get randomNumberGenerator(){return this.Gg}set randomNumberGenerator(t){this.Gg!==t&&(t!==null&&!m.it(t.random)&&m.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&&(m.s(t,"number",ee,"defaultSpringStiffness"),this.ou=t,this.p())}get defaultSpringLength(){return this.ru}set defaultSpringLength(t){this.ru!==t&&(m.s(t,"number",ee,"defaultSpringLength"),this.ru=t,this.p())}get defaultElectricalCharge(){return this.lu}set defaultElectricalCharge(t){this.lu!==t&&(m.s(t,"number",ee,"defaultElectricalCharge"),this.lu=t,this.p())}get defaultGravitationalMass(){return this.au}set defaultGravitationalMass(t){this.au!==t&&(m.s(t,"number",ee,"defaultGravitationalMass"),this.au=t,this.p())}get defaultCommentSpringLength(){return this.Yg}set defaultCommentSpringLength(t){this.Yg!==t&&(m.s(t,"number",ee,"defaultCommentSpringLength"),this.Yg=t,this.p())}get defaultCommentElectricalCharge(){return this.Kg}set defaultCommentElectricalCharge(t){this.Kg!==t&&(m.s(t,"number",ee,"defaultCommentElectricalCharge"),this.Kg=t,this.p())}get prelayoutQuality(){return this.hu}set prelayoutQuality(t){this.hu!==t&&(m.s(t,"number",ee,"prelayoutQuality"),this.hu=t,this.p())}get prelayoutSpread(){return this.dc}set prelayoutSpread(t){this.dc!==t&&(m.s(t,"number",ee,"prelayoutSpread"),this.dc=t,this.p())}}class Js extends Ee{constructor(t){super(t)}createVertex(){return new Ve(this)}createEdge(){return new fi(this)}}class Ve extends Ie{Bk;zk;Xk;Gk;Yk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Bk=!1,this.zk=NaN,this.Xk=NaN,this.Gk=0,this.Yk=0,this.hierarchicalVertexes=new q,this.idInCluster=-1}get isFixed(){return this.Bk}set isFixed(t){this.Bk!==t&&(m.s(t,"boolean",Ve,"isFixed"),this.Bk=t)}get charge(){return this.zk}set charge(t){this.zk!==t&&(m.s(t,"number",Ve,"charge"),this.zk=t)}get mass(){return this.Xk}set mass(t){this.Xk!==t&&(m.s(t,"number",Ve,"mass"),this.Xk=t)}get forceX(){return this.Gk}set forceX(t){this.Gk!==t&&(m.s(t,"number",Ve,"forceX"),this.Gk=t)}get forceY(){return this.Yk}set forceY(t){this.Yk!==t&&(m.s(t,"number",Ve,"forceY"),this.Yk=t)}}class fi extends ei{Kk;Hk;constructor(t){super(t),this.Kk=NaN,this.Hk=NaN}get stiffness(){return this.Kk}set stiffness(t){this.Kk!==t&&(m.s(t,"number",fi,"stiffness"),this.Kk=t)}get length(){return this.Hk}set length(t){this.Hk!==t&&(m.s(t,"number",fi,"length"),this.Hk=t)}}class Zs{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 ns=(x=>(x[x.DepthFirst=0]="DepthFirst",x[x.Greedy=1]="Greedy",x[x.FromLayers=2]="FromLayers",x))(ns||{}),os=(x=>(x[x.OptimalLinkLength=10]="OptimalLinkLength",x[x.LongestPathSink=11]="LongestPathSink",x[x.LongestPathSource=12]="LongestPathSource",x))(os||{}),rs=(x=>(x[x.DepthFirstOut=20]="DepthFirstOut",x[x.DepthFirstIn=21]="DepthFirstIn",x[x.Naive=22]="Naive",x))(rs||{}),as=(x=>(x[x.None=30]="None",x[x.Less=31]="Less",x[x.More=32]="More",x))(as||{}),Qs=(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))(Qs||{}),_s=(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))(_s||{});class Ae extends _t{Us;ti;P;cu;fu;uu;gc;du;ar;gu;Un;_;bw;zt;Hg;Vs;ie;Bs;ms;ps;Rt;qg;jg;qk;cn;mu;hr;Vn;Bn;dL;Ha;constructor(t){super(),this.Us=25,this.ti=25,this.P=0,this.cu=0,this.fu=10,this.uu=20,this.gc=4,this.du=31,this.ar=15,this.gu=10,this.Un=!0,this._=-1,this.bw=-1,this.zt=-1,this.Hg=0,this.Vs=0,this.ie=new Int16Array(0),this.Bs=new Float32Array(0),this.ms=new Float32Array(0),this.ps=new Float32Array(0),this.Rt=new Float32Array(0),this.qg=0,this.jg=new Int16Array(0),this.qk=new Int16Array(0),this.cn=0,this.mu=null,this.hr=new P,this.Vn=[],this.Vn.length=100,this.Bn=15,this.dL=0,this.Ha=!0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Us=this.Us,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.ar=this.ar,t.gu=this.gu,t.Un=this.Un,t.Bn=this.Bn,t.Ha=this.Ha}fe(t){t in as?this.aggressiveOption=t:t in ns?this.cycleRemoveOption=t:t in rs?this.initializeOption=t:t in os?this.layeringOption=t:super.fe(t)}createNetwork(){return new tn(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.N3(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.C3(),this.cycleRemoveOption===2&&this.removeCycles(),this.L3(),this.A3(),this.T3(),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.Wk;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.Wk=(t.bounds.width-t.focus.x)/this.ti+1|0:e?t.jk=t.focus.y/this.ti+1|0:t.Wk=(t.bounds.height-t.focus.y)/this.ti+1|0}ei(){let t=this.network.vertexes.count;this.jg.length<t*2&&(this.jg=new Int16Array(t*2));let e=0,i=this.network.vertexes.iterator;for(;i.next();){let s=i.value;this.jg[e]=s.column,e++,this.jg[e]=s.index,e++}return this.jg}ns(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++}}uF(t,e){let i=this.qa(t),s=this.ie[t];this.qk.length<s*s&&(this.qk=new Int16Array(s*s));let n=this.qk;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 u,c=0,d,f=0,p=0,g=0,y,b=0,v,w=0,k=0,S=0,N;if(e>=0){for(u=i[o].Po,c=0;c<u.length;c++)if(d=u[c],d.valid&&d.fromVertex.layer!==t)for(f=d.fromVertex.index,p=d.portToPos,g=d.portFromPos,b=c+1;b<u.length;b++)v=u[b],v.valid&&v.fromVertex.layer!==t&&(w=v.fromVertex.index,k=v.portToPos,S=v.portFromPos,p<k&&(f>w||f===w&&g>S)&&r++,k<p&&(w>f||w===f&&S>g)&&r++)}if(e<=0){for(u=i[o].nr,c=0;c<u.length;c++)if(d=u[c],d.valid&&d.toVertex.layer!==t)for(f=d.toVertex.index,p=d.portToPos,g=d.portFromPos,b=c+1;b<u.length;b++)v=u[b],v.valid&&v.toVertex.layer!==t&&(w=v.toVertex.index,k=v.portToPos,S=v.portFromPos,g<S&&(f>w||f===w&&p>k)&&r++,S<g&&(w>f||w===f&&k>p)&&r++)}for(n[o*s+o]=r,l=o+1;l<s;l++){let D=0,L=0;if(e>=0){for(y=i[o].Po,N=i[l].Po,c=0;c<y.length;c++)if(d=y[c],d.valid&&d.fromVertex.layer!==t)for(f=d.fromVertex.index,p=d.portToPos,g=d.portFromPos,b=0;b<N.length;b++)v=N[b],v.valid&&v.fromVertex.layer!==t&&(w=v.fromVertex.index,k=v.portToPos,S=v.portFromPos,(f<w||f===w&&g<S)&&L++,(w<f||w===f&&S<g)&&D++)}if(e<=0){for(y=i[o].nr,N=i[l].nr,c=0;c<y.length;c++)if(d=y[c],d.valid&&d.toVertex.layer!==t)for(f=d.toVertex.index,p=d.portToPos,g=d.portFromPos,b=0;b<N.length;b++)v=N[b],v.valid&&v.toVertex.layer!==t&&(w=v.toVertex.index,k=v.portToPos,S=v.portFromPos,(f<w||f===w&&p<k)&&L++,(w<f||w===f&&k<p)&&D++)}n[o*s+l]=D,n[l*s+o]=L}}return this.ja(t,i),n}countCrossings(){let t=0;for(let e=0;e<=this._;e++){let i=this.uF(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}D3(t,e,i){let s=this.qa(t),n=this.ie[t],o=0;for(let r=0;r<n;r++){let a=null;e<=0&&(a=s[r].Po);let h=null;e>=0&&(h=s[r].nr);let l,u=0,c=0;if(a!==null)for(let d=0;d<a.length;d++)l=a[d],l.valid&&l.fromVertex.layer!==t&&(u=l.fromVertex.column+l.portFromColOffset,c=l.toVertex.column+l.portToColOffset,i?o+=Math.abs(u-c)*this.linkStraightenWeight(l):o+=Math.abs(u-c));if(h!==null)for(let d=0;d<h.length;d++)l=h[d],l.valid&&l.toVertex.layer!==t&&(u=l.fromVertex.column+l.portFromColOffset,c=l.toVertex.column+l.portToColOffset,i?o+=(Math.abs(u-c)+1)*this.linkStraightenWeight(l):o+=Math.abs(u-c))}return this.ja(t,s),o}Jk(t){let e=0;for(let i=0;i<=this._;i++)e+=this.D3(i,1,t);return e}kw(){let t=1/0;this.zt=-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.zt=Math.max(this.zt,i.column+this.nodeMinColumnSpace(i,!1))}for(e.reset();e.next();){let i=e.value;i.column-=t}this.zt-=t}Pw(t,e){let i=this.qa(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.Po);let h=null;e>=0&&(h=r.nr);let l=0,u=0,c=r.near;c!==null&&c.layer===r.layer&&(l+=c.column-1,u++);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,u++)}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,u++)}u===0?n[o]=-1:n[o]=l/u}return this.ja(t,i),n}dF(t,e){let i=this.qa(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.Po);let h=null;e>=0&&(h=r.nr);let l=0,u=[],c=r.near;c!==null&&c.layer===r.layer&&(u[l]=c.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&&(u[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&&(u[l]=p.column+d.portToColOffset,l++)}if(l===0)n[o]=-1;else{u.sort((p,g)=>p-g);let f=l>>1;(l&1)!==0?n[o]=u[f]:n[o]=u[f-1]+u[f]>>1}}return this.ja(t,i),n}Sw(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.Sw(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.Sw(l,e,i,s,n)}}}}gL(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.gL(r,e,i,s,n)}}if(n){let o=t.sourceEdges;for(;o.next();){let r=o.value.fromVertex;this.gL(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.v3();break;case 0:this.F3();break;case 2:this.R3();break}}R3(){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)}}}v3(){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.O3(t)!==null;){let r;for(r=this.gF(t);r!==null;)s[i]=r,i--,r.ii=!1,r=this.gF(t);for(r=this.mF(t);r!==null;)s[e]=r,e++,r.ii=!1,r=this.mF(t);r=this.I3(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)}}O3(t){let e=t.vertexes.iterator;for(;e.next();){let i=e.value;if(i.ii)return i}return null}gF(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}mF(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}I3(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}F3(){let t=this.network.vertexes.iterator;for(;t.next();){let i=t.value;i.pu=-1,i.Zn=-1}let e=this.network.edges.iterator;for(;e.next();){let i=e.value;i.forest=!1}for(this.qg=0,t.reset();t.next();){let i=t.value;i.sourceEdges.count===0&&this.mL(i)}for(t.reset();t.next();){let i=t.value;i.pu===-1&&this.mL(i)}for(e.reset();e.next();){let i=e.value;if(!i.forest){let s=i.fromVertex,n=s.pu,o=s.Zn,r=i.toVertex,a=r.pu,h=r.Zn;a<n&&o<h&&(this.network.reverseEdge(i),i.rev=!0)}}}mL(t){t.pu=this.qg,this.qg++;let e=t.destinationEdges;for(;e.next();){let i=e.value,s=i.toVertex;s.pu===-1&&(i.forest=!0,this.mL(s))}t.Zn=this.qg,this.qg++}C3(){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&&m.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.pF();break;case 12:this.E3();break;default:case 10:this.U3();break}}pF(){let t=this.network.vertexes.iterator;for(;t.next();){let e=t.value,i=this.yF(e);this._=Math.max(i,this._)}}yF(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.yF(n)+o)}t.layer=e}else e=t.layer;return e}E3(){let t=0,e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;t=this.wF(i),this._=Math.max(t,this._)}for(e.reset();e.next();){let i=e.value;i.layer=this._-i.layer}}wF(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.wF(n)+o)}t.layer=e}else e=t.layer;return e}U3(){this.pF();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.xF(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)}}xF(t){if(!t.ii){t.ii=!0;let e=t.destinationEdges;for(;e.next();){let i=e.value.toVertex;this.xF(i)}this.V3(t),this.B3(t)}}V3(t){let e=this.network.vertexes.iterator;for(;e.next();){let r=e.value;r.component=-1}let i=0,s=1,n=t.Po,o=n.length;for(let r=0;r<o;r++){let a=n[r],h=a.fromVertex,l=a.toVertex,u=this.linkMinLength(a);h.layer-l.layer>u&&this.Sw(h,i,-1,!0,!1)}for(this.Sw(t,s,-1,!0,!0);t.component!==i;){let r=0,a=1/0,h=0,l=null,u=this.network.vertexes.iterator;for(;u.next();){let c=u.value;if(c.component===s){let d=0,f=!1,p=c.Po;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-c.layer,k=this.linkMinLength(b);a=Math.min(a,w-k)}}let g=c.nr;o=g.length;for(let y=0;y<o;y++){let b=g[y],v=b.toVertex;d-=this.linkLengthWeight(b),v.component!==s?r-=this.linkLengthWeight(b):f=!0}(l===null||d<h)&&!f&&(l=c,h=d)}}if(r>0){for(e.reset();e.next();){let c=e.value;c.component===s&&(c.layer+=a)}t.component=i}else l.component=i}}B3(t){let e=this.network.vertexes.iterator;for(;e.next();){let n=e.value;n.component=-1}let i=0,s=1;for(this.Sw(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 u=0,c=!1,d=l.Po,f=d.length;for(let g=0;g<f;g++){let y=d[g],b=y.fromVertex;u+=this.linkLengthWeight(y),b.component!==s?n+=this.linkLengthWeight(y):c=!0}let p=l.nr;f=p.length;for(let g=0;g<f;g++){let y=p[g],b=y.toVertex;if(u-=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||u>r)&&!c&&(a=l,r=u)}}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}}L3(){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,u=0;if(n.link!==null){let S=n.link;if(S===null)continue;let N=o.node,D=r.node;if(N===null||D===null)continue;let L=S.fromNode,M=S.toNode,A=S.fromPort;for(;A!==null&&!A.isVisibleObject();)A=A.panel;let F=S.toPort;for(;F!==null&&!F.isVisibleObject();)F=F.panel;if(n.rev){let tt=L,nt=A;L=M,A=F,M=tt,F=nt}let O=o.focus,E=r.focus,B=n.rev?r.bounds:o.bounds,X=P.l();N!==L?B.isReal()&&L.isVisible()?L.actualBounds.isReal()?(L.getRelativePoint(A,T.Center,X),X.x+=L.actualBounds.x-B.x,X.y+=L.actualBounds.y-B.y):(L.getRelativePoint(A,T.Center,X),X.isReal()||X.h(O)):X.h(O):B.isReal()?(L.getRelativePoint(A,T.Center,X),X.isReal()||X.h(O)):X.h(O);let z=n.rev?o.bounds:r.bounds,U=P.l();D!==M?z.isReal()&&M.isVisible()?M.actualBounds.isReal()?(M.getRelativePoint(F,T.Center,U),U.x+=M.actualBounds.x-z.x,U.y+=M.actualBounds.y-z.y):(M.getRelativePoint(F,T.Center,U),U.isReal()||U.h(E)):U.h(E):z.isReal()?(M.getRelativePoint(F,T.Center,U),U.isReal()||U.h(E)):U.h(E),this.P===90||this.P===270?(a=Math.round((X.x-O.x)/this.ti),l=X.x,h=Math.round((U.x-E.x)/this.ti),u=U.x):(a=Math.round((X.y-O.y)/this.ti),l=X.y,h=Math.round((U.y-E.y)/this.ti),u=U.y),P.i(X),P.i(U),n.portFromColOffset=a,n.portFromPos=l,n.portToColOffset=h,n.portToPos=u}else n.portFromColOffset=0,n.portFromPos=0,n.portToColOffset=0,n.portToPos=0;let c=o.layer,d=r.layer,f=this.z3(n),p=f===1||f===3,g=f===2||f===3,y,b,v=null,w;g&&(v=this.X3(o,r),w=1,b=t.createVertex(),b.node=null,b.$k=1,b.layer=c,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--,c-d>k&&c>0){for(n.valid=!1,b=t.createVertex(),b.node=null,b.$k=2,b.layer=c-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=g?0:a,y.portToColOffset=0,y.portFromPos=g?0:l,y.portToPos=0,o=b,c--;c-d>k&&c>0;)b=t.createVertex(),b.node=null,b.$k=3,b.layer=c-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,c--;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=u}else n.valid=!0}}z3(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.Zk(!0),h=this.Zk(!1),l=this.setsPortSpots?a:i.computeSpot(!0,s),u=this.setsPortSpots?h:i.computeSpot(!1,n),c=i.isOrthogonal;if(l.isSide()&&l.includesSide(h)&&u.isSide()&&u.includesSide(a))return 0;let d=i.getLinkPoint(o,s,l,!0,c,r,n,P.l()),f=i.getLinkDirection(o,s,d,l,!0,c,r,n);P.i(d),(!l.isNone()&&f===this.bF(t,!0)||this.setsPortSpots&&o!==null&&o.ports.count===1&&t.rev)&&(e+=1);let p=i.getLinkPoint(r,n,u,!1,c,o,s,P.l()),g=i.getLinkDirection(r,n,p,u,!1,c,o,s);P.i(p),(!u.isNone()&&g===this.bF(t,!1)||this.setsPortSpots&&r!==null&&r.ports.count===1&&t.rev)&&(e+=2)}}}return e}bF(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}X3(t,e){let i=[];return i.push(e),this.kF(t,i)?i.reverse():[]}kF(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.kF(t,e))return!0;e.pop()}return!1}A3(){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.bw=-1,this.Hg=0,this.Vs=0;for(let i=0;i<=this._;i++)t[i]>t[this.Vs]&&(this.bw=t[i]-1,this.Vs=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.G3();break;case 20:this.Y3();break;case 21:this.K3();break}}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(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]++})}}Y3(){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.PF(s,t)}}PF(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.nr,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.PF(a,e)}}}K3(){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.SF(s,t)}}SF(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.Po,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.SF(r,e))}T3(){this.zt=-1;for(let t=0;t<=this._;t++){let e=this.qa(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.zt=Math.max(this.zt,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.Qk(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.Qk(s,-1),this.ys(s,-1,!1,-1);n=this.countCrossings(),n<t&&(t=n,e=this.ei())}for(this.ns(e),i=0;i<this.gc;i++){for(s=0;s<=this._;s++)this.Qk(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.Qk(s,0),this.ys(s,0,!1,0);n=this.countCrossings(),n<t&&(t=n,e=this.ei())}this.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(e):(t=n,e=this.ei())}break}this.ns(e)}Qk(t,e){let i=0,s=!1,n=this.qa(t),o=this.ie[t],r=this.dF(t,e),a=this.Pw(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 c=r[i];r[i]=r[i+1],r[i+1]=c;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 u=0;for(i=0;i<o;i++)l=n[i],l.index=i,u+=this.nodeMinColumnSpace(l,!0),l.column=u,u+=1,u+=this.nodeMinColumnSpace(l,!1);return this.ja(t,n),s}ys(t,e,i,s){let n=this.qa(t),o=this.ie[t],r=this.uF(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.Pw(t,-1);let l;if(!i||s<0)for(l=new Float32Array(o),a=0;a<o;a++)l[a]=-1;else l=this.Pw(t,1);let u=!1,c=!0;for(;c;)for(c=!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,g=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),N=y-v+k,D=b-w+S,L=0,M=0,A=0,F=0,O=0,E=0,B=0,X,z=0,U,tt=0,nt=n[a].sourceEdges.iterator;if(i&&s<=0)for(;nt.next();){let xt=nt.value;X=xt.fromVertex,xt.valid&&X.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,E=X.column,L+=(Math.abs(y+O-(E+F))+1)*A,M+=(Math.abs(D+O-(E+F))+1)*A)}for(nt.reset();nt.next();){let xt=nt.value;if(X=xt.fromVertex,xt.valid&&X.layer===t){for(z=0;z<n.length&&n[z]!==X;)z++;z<a&&(p+=2*(a-z),g+=2*(a+1-z)),z===a+1&&(p+=1),z>a+1&&(p+=4*(z-a),g+=4*(z-(a+1)))}}let Z=n[a].destinationEdges.iterator;if(i&&s>=0)for(;Z.next();){let xt=Z.value;U=xt.toVertex,xt.valid&&U.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,B=U.column,L+=(Math.abs(y+F-(B+O))+1)*A,M+=(Math.abs(D+F-(B+O))+1)*A)}for(Z.reset();Z.next();){let xt=Z.value;if(U=xt.toVertex,xt.valid&&U.layer===t){for(tt=0;tt<n.length&&n[tt]!==U;)tt++;tt===a+1&&(g+=1)}}let it=n[a+1].sourceEdges.iterator;if(i&&s<=0)for(;it.next();){let xt=it.value;X=xt.fromVertex,xt.valid&&X.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,E=X.column,L+=(Math.abs(b+O-(E+F))+1)*A,M+=(Math.abs(N+O-(E+F))+1)*A)}for(it.reset();it.next();){let xt=it.value;if(X=xt.fromVertex,xt.valid&&X.layer===t){for(z=0;z<n.length&&n[z]!==X;)z++;z<a&&(p+=2*(a+1-z),g+=2*(a-z)),z===a&&(g+=1),z>a+1&&(p+=4*(z-(a+1)),g+=4*(z-a))}}let _=n[a+1].destinationEdges.iterator;if(i&&s>=0)for(;_.next();){let xt=_.value;U=xt.toVertex,xt.valid&&U.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,B=U.column,L+=(Math.abs(b+F-(B+O))+1)*A,M+=(Math.abs(N+F-(B+O))+1)*A)}for(_.reset();_.next();){let xt=_.value;if(U=xt.toVertex,xt.valid&&U.layer===t){for(tt=0;tt<n.length&&n[tt]!==U;)tt++;tt===a&&(p+=1)}}let at=0,ct=0,yt=h[n[a].index],Ct=l[n[a].index],Q=h[n[a+1].index],St=l[n[a+1].index];if(yt!==-1&&(at+=Math.abs(yt-y),ct+=Math.abs(yt-D)),Ct!==-1&&(at+=Math.abs(Ct-y),ct+=Math.abs(Ct-D)),Q!==-1&&(at+=Math.abs(Q-b),ct+=Math.abs(Q-N)),St!==-1&&(at+=Math.abs(St-b),ct+=Math.abs(St-N)),g<p-.5||g===p&&f<d-.5||g===p&&f===d&&M<L-.5||g===p&&f===d&&M===L&&ct<at-.5){u=!0,c=!0,n[a].column=D,n[a+1].column=N;let xt=n[a];n[a]=n[a+1],n[a+1]=xt}}for(a=0;a<o;a++)n[a].index=a;return this.ja(t,n),u}straightenAndPack(){if(this.Bn!==0){this.H3();return}let t=0,e=!1,i=(this.ar&1)!==0,s=(this.ar&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 u=this.nodeMinColumnSpace(l,!1);n[t]=Math.max(n[t],r+u)}let h=8;for(a.reset();a.next();){let l=a.value;t=l.layer,r=l.column,l.column=((this.zt-n[t])*h>>1)+r*h}this.zt*=h}if((this.ar&2)!==0){e=!0;let n=0;for(;e&&n<this.gu;){for(e=!1,t=this.Vs+1;t<=this._;t++)e=this.Wg(t,1)||e;for(t=this.Vs-1;t>=0;t--)e=this.Wg(t,-1)||e;e=this.Wg(this.Vs,0)||e,n++}}if((this.ar&4)!==0){for(t=this.Vs+1;t<=this._;t++)this.pL(t,1);for(t=this.Vs-1;t>=0;t--)this.pL(t,-1);this.pL(this.Vs,0)}if(i&&(this.MF(-1),this.MF(1)),(this.ar&2)!==0){e=!0;let n=0;for(;e&&n<this.gu;){for(e=!1,e=this.Wg(this.Vs,0)||e,t=this.Vs+1;t<=this._;t++)e=this.Wg(t,0)||e;for(t=this.Vs-1;t>=0;t--)e=this.Wg(t,0)||e;n++}}}Wg(t,e){let i=!1;for(;this.q3(t,e);)i=!0;return i}q3(t,e){let i=0,s=this.qa(t),n=this.ie[t],o=this.Pw(t,-1);if(e>0)for(i=0;i<n;i++)o[i]=-1;let r=this.Pw(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,u=this.nodeMinColumnSpace(s[i],!0),c=this.nodeMinColumnSpace(s[i],!1),d=0;i-1<0||l-s[i-1].column-1>u+this.nodeMinColumnSpace(s[i-1],!1)?d=l-1:d=l;let f=0;i+1>=n||s[i+1].column-l-1>c+this.nodeMinColumnSpace(s[i+1],!0)?f=l+1:f=l;let p=0,g=0,y=0,b=0,v=0,w=0;if(e<=0){let M=s[i].sourceEdges.iterator;for(;M.next();){let A=M.value,F=A.fromVertex;if(A.valid&&F.layer!==t){b=this.linkStraightenWeight(A),v=A.portFromColOffset,w=A.portToColOffset;let O=F.column;p+=(Math.abs(l+w-(O+v))+1)*b,g+=(Math.abs(d+w-(O+v))+1)*b,y+=(Math.abs(f+w-(O+v))+1)*b}}}if(e>=0){let M=s[i].destinationEdges.iterator;for(;M.next();){let A=M.value,F=A.toVertex;if(A.valid&&F.layer!==t){b=this.linkStraightenWeight(A),v=A.portFromColOffset,w=A.portToColOffset;let O=F.column;p+=(Math.abs(l+v-(O+w))+1)*b,g+=(Math.abs(d+v-(O+w))+1)*b,y+=(Math.abs(f+v-(O+w))+1)*b}}}let k=0,S=0,N=0,D=o[s[i].index],L=r[s[i].index];D!==-1&&(k+=Math.abs(D-l),S+=Math.abs(D-d),N+=Math.abs(D-f)),L!==-1&&(k+=Math.abs(L-l),S+=Math.abs(L-d),N+=Math.abs(L-f)),g<p||g===p&&S<k?(a=!0,h=!0,s[i].column=d):(y<p||y===p&&N<k)&&(a=!0,h=!0,s[i].column=f)}return this.ja(t,s),this.kw(),a}pL(t,e){let i=0,s=this.qa(t),n=this.ie[t],o=this.dF(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,u=this.nodeMinColumnSpace(s[i],!0),c=this.nodeMinColumnSpace(s[i],!1),d=0,f=0,p=0,g=0,y=0;r[i]===-1?i===0&&i===n-1?d=l:i===0?(f=s[i+1].column,f-l===c+this.nodeMinColumnSpace(s[i+1],!0)?d=l-1:d=l):i===n-1?(p=s[i-1].column,l-p===u+this.nodeMinColumnSpace(s[i-1],!1)?d=l+1:d=l):(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+u+1,f=s[i+1].column,g=f-this.nodeMinColumnSpace(s[i+1],!0)-c-1,d=(y+g)/2|0):i===0&&i===n-1?d=r[i]:i===0?(f=s[i+1].column,g=f-this.nodeMinColumnSpace(s[i+1],!0)-c-1,d=Math.min(r[i],g)):i===n-1?(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+u+1,d=Math.max(r[i],y)):(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+u+1,f=s[i+1].column,g=f-this.nodeMinColumnSpace(s[i+1],!0)-c-1,y<r[i]&&r[i]<g?d=r[i]:y>=r[i]?d=y:g<=r[i]&&(d=g)),d!==l&&(a=!0,h=!0,s[i].column=d)}return this.ja(t,s),this.kw(),a}j3(){for(let t=0;t<=this.zt;t++)for(;this.W3(t,1););this.kw()}W3(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}J3(){this.j3();for(let t=0;t<this.zt;t++)for(;this.$3(t,1););this.kw()}$3(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,u=l.column-this.nodeMinColumnSpace(l,!0),c=l.column+this.nodeMinColumnSpace(l,!1);u<=t&&c>=t&&(n[l.layer]=!0),u<=i&&c>=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}MF(t){this.J3();let e=0,i,s=0,n=0,o=0;if(t>0)for(e=0;e<=this.zt;e++)for(i=this.ei(),s=this.Jk(!0),n=s+1;s<n;)n=s,this.NF(e,1),o=this.Jk(!0),o>s?this.ns(i):o<s&&(s=o,i=this.ei());if(t<0)for(e=this.zt;e>=0;e--)for(i=this.ei(),s=this.Jk(!0),n=s+1;s<n;)n=s,this.NF(e,-1),o=this.Jk(!0),o>s?this.ns(i):o<s&&(s=o,i=this.ei());this.kw()}NF(t,e){this.cn=0;let i=this.network.vertexes.iterator;for(;i.next();){let u=i.value;u.component=-1}if(e>0)for(i.reset();i.next();){let u=i.value;u.column-this.nodeMinColumnSpace(u,!0)<=t&&(u.component=this.cn)}if(e<0)for(i.reset();i.next();){let u=i.value;u.column+this.nodeMinColumnSpace(u,!1)>=t&&(u.component=this.cn)}for(this.cn++,i.reset();i.next();){let u=i.value;u.component===-1&&(this.gL(u,this.cn,-1,!0,!0),this.cn++)}let s=0,n=[];for(s=0;s<this.cn*this.cn;s++)n[s]=!1;let o=[];for(s=0;s<(this._+1)*(this.zt+1);s++)o[s]=-1;for(i.reset();i.next();){let u=i.value,c=u.layer,d=Math.max(0,u.column-this.nodeMinColumnSpace(u,!0)),f=Math.min(this.zt,u.column+this.nodeMinColumnSpace(u,!1));for(let p=d;p<=f;p++)o[c*(this.zt+1)+p]=u.component}for(let u=0;u<=this._;u++){if(e>0)for(let c=0;c<this.zt;c++)o[u*(this.zt+1)+c]!==-1&&o[u*(this.zt+1)+c+1]!==-1&&o[u*(this.zt+1)+c]!==o[u*(this.zt+1)+c+1]&&(n[o[u*(this.zt+1)+c]*this.cn+o[u*(this.zt+1)+c+1]]=!0);if(e<0)for(let c=this.zt;c>0;c--)o[u*(this.zt+1)+c]!==-1&&o[u*(this.zt+1)+c-1]!==-1&&o[u*(this.zt+1)+c]!==o[u*(this.zt+1)+c-1]&&(n[o[u*(this.zt+1)+c]*this.cn+o[u*(this.zt+1)+c-1]]=!0)}let r=[];for(s=0;s<this.cn;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.cn;s++)n[h*this.cn+s]&&a.splice(0,0,s);let l=!1;if(e>0)for(i.reset();i.next();){let u=i.value;r[u.component]&&(u.column-=1,l=!0)}if(e<0)for(i.reset();i.next();){let u=i.value;r[u.component]&&(u.column+=1,l=!0)}return l}H3(){let t=m.st(),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 V;this.Z3(t,s);let n=null,o=null,r=null,a=null,h=(this.Bn&1)!==0,l=(this.Bn&2)!==0,u=(this.Bn&4)!==0,c=(this.Bn&8)!==0;h&&(this.al(t,s,!0),n=this._k(t,!0,!1)),t.reverse(),u&&(this.al(t,s,!1),r=this._k(t,!1,!1));for(let d of t)d.reverse();c&&(this.al(t,s,!1),a=this._k(t,!1,!0)),t.reverse(),l&&(this.al(t,s,!0),o=this._k(t,!0,!0)),m.Z(t),this.Q3(n,o,r,a),this.network.vertexes.each(d=>{let f=d,p=m.st();h&&p.push(n.get(f)),l&&p.push(o.get(f)),u&&p.push(r.get(f)),c&&p.push(a.get(f)),p.sort((w,k)=>w-k);let g=p.length,y=Math.floor((g-1)/2),b=Math.ceil((g-1)/2),v=(p[y]+p[b])/2;m.Z(p),f.mi=v})}Z3(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],u=this._3(l);if(h===a.length-1||u){let c=r.length-1;for(u&&(c=l.getProperSourceVertexes()[0].index);o<=h;){let d=a[o].getProperSourceEdges();for(let f of d){let p=f.fromVertex.index;(p<n||p>c)&&e.add(f)}o++}n=c}}}}_3(t){if(t.node===null){let e=t.getProperSourceVertexes();if(e.length>0)return e[0].node===null}return!1}al(t,e,i){this.tU(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,u)=>l.Wa-u.Wa);let h=(a-1)/2;for(let l=Math.floor(h),u=Math.ceil(h);l<=u;l++)if(o.zn===o){let c=r[l],d;i?d=c.getDestinationEdge(o):d=o.getDestinationEdge(c),!e.has(d)&&n<c.Wa&&(c.zn=o,o.mc=c.mc,o.zn=c.mc,n=c.Wa)}}}}}tU(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.zn=n,n.CF=e,n.Wa=s}}}_k(t,e,i){let s=this.P===90||this.P===270;for(let o of t)for(let r of o)r.os=r,r.yu=1/0,r.mi=NaN,r.Xn=0;this.eU(t,e,i);for(let o of t)for(let r of o)r.mc===r&&this.LF(r,t);for(let o=0;o<t.length;o++){if(t[o].length<=0)continue;let r=t[o][0];if(r.os===r){r.os.yu===1/0&&(r.os.yu=0);let a=o,h=0,l;do{for(l=t[a][h];l.zn!==l.mc;)if(l=l.zn,a++,l.Wa>0){let u=this.AF(l,t),c=s?u.width:u.height,d=l.os.yu+l.mi+l.Xn-(u.mi+u.Xn+c+this.columnSpacing);u.os.yu=Math.min(u.os.yu,d)}h=l.Wa+1}while(a<t.length&&h<t[a].length&&l.os===t[a][h].os)}}let n=new Mt;for(let o of t)for(let r of o){r.mi=r.mi+r.os.yu+r.Xn;let a=s?r.width:r.height;n.set(r,i?-r.mi-a:r.mi)}return n}eU(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.zn!==o;){let h=a.zn,l=s?a.width:a.height,u=s?h.width:h.height,c,d,f,p;e?(f=a.getDestinationEdge(h),c=f.portFromPos,d=f.portToPos,f.link!==null&&(a.node&&a.node!==f.link.fromNode&&(c=s?a.focusX:a.focusY),h.node&&h.node!==f.link.toNode&&(d=s?h.focusX:h.focusY)),i?p=a.Xn+(l-c)-(u-d):p=a.Xn+c-d):(f=h.getDestinationEdge(a),c=f.portToPos,d=f.portFromPos,f.link!==null&&(a.node&&a.node!==f.link.toNode&&(c=s?a.focusX:a.focusY),h.node&&h.node!==f.link.fromNode&&(d=s?h.focusX:h.focusY)),i?p=a.Xn+(l-c)-(u-d):p=a.Xn+c-d),h.Xn=p,r=Math.min(r,p),a=a.zn}a=o;do a.Xn=a.Xn-r,a=a.zn;while(a!==o)}}LF(t,e){if(!isNaN(t.mi))return;t.mi=0;let i=t;do{if(i.Wa>0){let s=this.AF(i,e),n=s.mc;this.LF(n,e),t.os===t&&(t.os=n.os);let o=this.P===90||this.P===270?s.width:s.height;if(t.os===n.os){let r=n.mi+s.Xn+o-i.Xn+this.columnSpacing;t.mi=Math.max(t.mi,r)}}i=i.zn}while(i!==t);for(;i.zn!==t;)i=i.zn,i.mi=t.mi,i.os=t.os}AF(t,e){let i=t.CF,s=t.Wa;return s<1&&m.o("Could not determine previous vertex in layer"),e[i][s-1]}Q3(...t){let e=-1,i=m.st(),s=m.st(),n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;let r=this.iU(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)})}m.Z(i),m.Z(s)}iU(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.xw(),this.commitNodes(),this.yL(),this.isRouting&&this.commitLinks()}xw(){if(!this.setsPortSpots)return;let t=this.Zk(!0),e=this.Zk(!1),i=this.network.edges.iterator;for(;i.next();){let s=i.value.link;s!==null&&(s.fromSpot=t,s.toSpot=e)}}Zk(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.Bs.length!==this._+1&&(this.Bs=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.Bs[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.Bs[p]=Math.max(this.Bs[p],this.nodeMinLayerSpace(f,!0)),this.ms[p]=Math.max(this.ms[p],this.nodeMinLayerSpace(f,!1))}let e=0,i=this.Us;for(let f=0;f<=this._;f++){let p=i;this.Bs[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.Bs[f]):(e+=this.Bs[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.Bn!==0;t.reset();let r=this.P===270||this.P===90,a=1/0,h=1/0,l=1/0,u=-1/0;for(;t.next();){let f=t.value,p=f.layer,g=f.column|0,y=0,b=0;r?(y=n.x+this.ti*g,b=this.ps[p]):(y=this.ps[p],b=n.y+this.ti*g),f.centerX=y,f.centerY=b,o&&isFinite(f.mi)&&(r?f.node?f.x=n.x+f.mi:f.centerX=n.x+f.mi:f.node?f.y=n.y+f.mi:f.centerY=n.y+f.mi),a=Math.min(f.x,a),h=Math.min(f.y,h),r?(l=a,u=Math.max(u,f.bounds.right)):(l=h,u=Math.max(u,f.bounds.bottom))}this.dL=u-l;let c=n.x-a,d=n.y-h;for(this.hr=new P(o&&r?0:c,o&&!r?0:d),t.reset();t.next();){let f=t.value;f.x+=c,f.y+=d,f.commit()}}yL(){let t=0,e=this.Us;for(let n=0;n<=this._;n++)t+=this.Bs[n],t+=this.ms[n];t+=this._*e;let i=[],s=this.Bn!==0?this.dL:this.ti*this.zt;for(let n=this.maxLayer;n>=0;n--)this.P===270?n===0?i.push(new I(0,0,s,Math.abs(this.Rt[0]))):i.push(new I(0,this.Rt[n-1],s,Math.abs(this.Rt[n-1]-this.Rt[n]))):this.P===90?n===0?i.push(new I(0,this.Rt[0],s,Math.abs(this.Rt[0]-t))):i.push(new I(0,this.Rt[n],s,Math.abs(this.Rt[n-1]-this.Rt[n]))):this.P===180?n===0?i.push(new I(0,0,Math.abs(this.Rt[0]),s)):i.push(new I(this.Rt[n-1],0,Math.abs(this.Rt[n-1]-this.Rt[n]),s)):n===0?i.push(new I(this.Rt[0],0,Math.abs(this.Rt[0]-t),s)):i.push(new I(this.Rt[n],0,Math.abs(this.Rt[n-1]-this.Rt[n]),s));this.commitLayers(i,this.hr)}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 A=n.findVisibleNode();A!==null&&A!==n&&(n=A,r=A.port)}if(o!==null){let A=o.findVisibleNode();A!==null&&A!==o&&(o=A,a=A.port)}let h=e.computeSpot(!0,r),l=e.computeSpot(!1,a),u=i.fromVertex,c=i.toVertex;if(i.valid){if(e.curve===9&&e.pointsCount===4)if(u.column===c.column&&this.alignOption===0){let A=e.getLinkPoint(n,r,h,!0,!1,o,a),F=e.getLinkPoint(o,a,l,!1,!1,n,r);A.isReal()||A.set(n.actualBounds.center),F.isReal()||F.set(o.actualBounds.center),e.clearPoints(),e.addPointAt(A.x,A.y),e.addPointAt((2*A.x+F.x)/3,(2*A.y+F.y)/3),e.addPointAt((A.x+2*F.x)/3,(A.y+2*F.y)/3),e.addPointAt(F.x,F.y)}else{let A=!1,F=!1;if(r!==null&&e.bl(h)&&(A=!0),a!==null&&e.bl(l)&&(F=!0),A||F){let O=null;A&&(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 E=null;if(F&&(E=e.getLinkPointFromPoint(o,a,a.getDocumentPoint(T.Center),e.getPoint(0),!1),E.isReal()||E.set(o.actualBounds.center),e.setPointAt(3,E.x,E.y)),O){let B=e.getPoint(2);e.setPointAt(1,(O.x*2+B.x)/3,(O.y*2+B.y)/3)}if(E){let B=e.getPoint(1);e.setPointAt(2,(E.x*2+B.x)/3,(E.y*2+B.y)/3)}}}e.commitRoute();continue}if(u.layer===c.layer){e.commitRoute();continue}let d=!1,f=!1,p=this.Us,g=0,y=e.firstPickIndex+1;if(e.isOrthogonal)f=!0,g=e.pointsCount,g>4&&e.points.removeRange(2,g-3);else if(e.curve===9)d=!0,g=e.pointsCount,g>4&&e.points.removeRange(2,g-3),g===4&&(y=2);else{g=e.pointsCount;let A=h===T.None,F=l===T.None;g>2&&A&&F?e.points.removeRange(1,g-2):g>3&&A&&!F?e.points.removeRange(1,g-3):g>3&&!A&&F?e.points.removeRange(2,g-2):g>4&&!A&&!F&&e.points.removeRange(2,g-3)}let b,v,w=0,k=0,S=0,N=0,D=0,L=0,M=0;if(i.rev){let A=0;for(;c!==null&&u!==c;){b=null,v=null;let F=c.sourceEdges.iterator;for(;F.next();){let O=F.value;if(O.link===i.link&&(b=O.fromVertex,v=O.toVertex,b.node===null))break}if(b===null)break;if(b!==u)if(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=b.centerX,N=b.centerY,f)this.P===180||this.P===0?y===e.firstPickIndex+1?(e.insertPointAt(y++,w,k),e.insertPointAt(y++,w,N)):(v!==null?v.centerY:k)!==N&&(D=this.Rt[b.layer-1]+this.hr.x,e.insertPointAt(y++,D,k),e.insertPointAt(y++,D,N)):y===e.firstPickIndex+1?(e.insertPointAt(y++,w,k),e.insertPointAt(y++,S,k)):(v!==null?v.centerX:w)!==S&&(D=this.Rt[b.layer-1]+this.hr.y,e.insertPointAt(y++,w,D),e.insertPointAt(y++,S,D));else if(y===e.firstPickIndex+1)if(L=Math.max(10,this.Bs[c.layer]),M=Math.max(10,this.ms[c.layer]),d)this.P===180?S<=c.bounds.x?(A=c.bounds.x,e.insertPointAt(y++,A-L,N),e.insertPointAt(y++,A,N),e.insertPointAt(y++,A+M,N)):(e.insertPointAt(y++,S-L,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S+M,N)):this.P===90?N>=c.bounds.bottom?(A=c.bounds.y+c.bounds.height,e.insertPointAt(y++,S,A+M),e.insertPointAt(y++,S,A),e.insertPointAt(y++,S,A-L)):(e.insertPointAt(y++,S,N+M),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N-L)):this.P===270?N<=c.bounds.y?(A=c.bounds.y,e.insertPointAt(y++,S,A-L),e.insertPointAt(y++,S,A),e.insertPointAt(y++,S,A+M)):(e.insertPointAt(y++,S,N-L),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N+M)):this.P===0&&(S>=c.bounds.right?(A=c.bounds.x+c.bounds.width,e.insertPointAt(y++,A+M,N),e.insertPointAt(y++,A,N),e.insertPointAt(y++,A-L,N)):(e.insertPointAt(y++,S+M,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S-L,N)));else{e.insertPointAt(y++,w,k);let O=0;this.P===180||this.P===0?((this.P===180?S>=c.bounds.right:S<=c.bounds.x)&&(O=(this.P===0?-L:M)/2),e.insertPointAt(y++,w+O,N)):((this.P===270?N>=c.bounds.bottom:N<=c.bounds.y)&&(O=(this.P===90?-L:M)/2),e.insertPointAt(y++,S,k+O)),e.insertPointAt(y++,S,N)}else L=Math.max(10,this.Bs[b.layer]),M=Math.max(10,this.ms[b.layer]),d?this.P===180?(e.insertPointAt(y++,S-L-Math.max(10,p),N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S+M+p,N)):this.P===90?(e.insertPointAt(y++,S,N+M+Math.max(10,p)),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N-L-p)):this.P===270?(e.insertPointAt(y++,S,N-L-Math.max(10,p)),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N+M+p)):(e.insertPointAt(y++,S+M+Math.max(10,p),N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S-L-p,N)):(this.P===180||this.P===90||this.P,e.insertPointAt(y++,S,N));c=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,N=e.getPoint(y).y,f){let F=this.ms[u.layer],O=0;this.P===180||this.P===0?(O=k,O>=u.bounds.y&&O<=u.bounds.bottom&&(this.P===180?S>=u.bounds.x:S<=u.bounds.right)&&(A=u.centerX+(this.P===180?-F:F),O<u.bounds.y+u.bounds.height/2?O=u.bounds.y-this.ti/2:O=u.bounds.bottom+this.ti/2,e.insertPointAt(y++,A,k),e.insertPointAt(y++,A,O)),e.insertPointAt(y++,S,O),e.insertPointAt(y++,S,N)):(O=w,O>=u.bounds.x&&O<=u.bounds.right&&(this.P===270?N>=u.bounds.y:N<=u.bounds.bottom)&&(A=u.centerY+(this.P===270?-F:F),O<u.bounds.x+u.bounds.width/2?O=u.bounds.x-this.ti/2:O=u.bounds.right+this.ti/2,e.insertPointAt(y++,w,A),e.insertPointAt(y++,O,A)),e.insertPointAt(y++,O,N),e.insertPointAt(y++,S,N))}else if(d)L=Math.max(10,this.Bs[u.layer]),M=Math.max(10,this.ms[u.layer]),this.P===180&&S>=u.bounds.x?(A=u.bounds.x+u.bounds.width,e.setPointAt(y-2,A,k),e.setPointAt(y-1,A+M,k)):this.P===90&&N<=u.bounds.bottom?(A=u.bounds.y,e.setPointAt(y-2,w,A),e.setPointAt(y-1,w,A-L)):this.P===270&&N>=u.bounds.y?(A=u.bounds.y+u.bounds.height,e.setPointAt(y-2,w,A),e.setPointAt(y-1,w,A+M)):this.P===0&&S<=u.bounds.right&&(A=u.bounds.x,e.setPointAt(y-2,A,k),e.setPointAt(y-1,A-L,k));else{L=Math.max(10,this.Bs[u.layer]),M=Math.max(10,this.ms[u.layer]);let F=0;this.P===180||this.P===0?((this.P===180?S<=u.bounds.x:S>=u.bounds.right)&&(F=(this.P===0?M:-L)/2),e.insertPointAt(y++,S+F,k)):((this.P===270?N<=u.bounds.y:N>=u.bounds.bottom)&&(F=(this.P===90?M:-L)/2),e.insertPointAt(y++,w,N+F)),e.insertPointAt(y++,S,N)}}else{for(;u!==null&&u!==c;){b=null,v=null;let A=u.destinationEdges.iterator;for(;A.next();){let F=A.value;if(F.link===i.link&&(b=F.toVertex,v=F.fromVertex,v.node!==null&&(v=null),b.node===null))break}if(b===null)break;b!==c&&(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=b.centerX,N=b.centerY,f?this.P===180||this.P===0?(v!==null?v.centerY:k)!==N&&(D=this.Rt[b.layer]+this.hr.x,y===e.firstPickIndex+1&&(this.P===0?D=Math.max(D,w):D=Math.min(D,w)),e.insertPointAt(y++,D,k),e.insertPointAt(y++,D,N)):(v!==null?v.centerX:w)!==S&&(D=this.Rt[b.layer]+this.hr.y,y===e.firstPickIndex+1&&(this.P===90?D=Math.max(D,k):D=Math.min(D,k)),e.insertPointAt(y++,w,D),e.insertPointAt(y++,S,D)):(L=Math.max(10,this.Bs[b.layer]),M=Math.max(10,this.ms[b.layer]),d?this.P===180?(e.insertPointAt(y++,S+M+Math.max(10,p),N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S-L-p,N)):this.P===90?(e.insertPointAt(y++,S,N-L-Math.max(10,p)),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N+M+p)):this.P===270?(e.insertPointAt(y++,S,N+M+Math.max(10,p)),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N-L-p)):(e.insertPointAt(y++,S-L-Math.max(10,p),N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S+M+p,N)):this.P===180?(e.insertPointAt(y++,S+M,N),e.insertPointAt(y++,S-L,N)):this.P===90?(e.insertPointAt(y++,S,N-L),e.insertPointAt(y++,S,N+M)):this.P===270?(e.insertPointAt(y++,S,N+M),e.insertPointAt(y++,S,N-L)):(e.insertPointAt(y++,S-L,N),e.insertPointAt(y++,S+M,N)))),u=b}f&&(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=e.getPoint(y).x,N=e.getPoint(y).y,this.P===180||this.P===0?k!==N&&(this.P===0?D=Math.min(Math.max((S+w)/2,this.Rt[c.layer]+this.hr.x),S):D=Math.max(Math.min((S+w)/2,this.Rt[c.layer]+this.hr.x),S),e.insertPointAt(y++,D,k),e.insertPointAt(y++,D,N)):w!==S&&(this.P===90?D=Math.min(Math.max((N+k)/2,this.Rt[c.layer]+this.hr.y),N):D=Math.max(Math.min((N+k)/2,this.Rt[c.layer]+this.hr.y),N),e.insertPointAt(y++,w,D),e.insertPointAt(y++,S,D)))}if(s!==null&&d&&e.pointsCount>=4){if(n!==null&&r!==null&&s.bl(h)){let A=r.getDocumentPoint(T.Center);A.isReal()||A.setTo(n.actualBounds.centerX,n.actualBounds.centerY);let F=e.getPoint(3),O=e.getPoint(2);this.direction===90||this.direction===270?(e.setPointAt(1,F.x,(O.y+F.y)/2),e.setPointAt(2,F.x,(O.y+F.y)/2)):(e.setPointAt(1,(O.x+F.x)/2,F.y),e.setPointAt(2,(O.x+F.x)/2,F.y));let E=e.getLinkPointFromPoint(n,r,A,e.getPoint(1),!0);e.setPointAt(0,E.x,E.y)}if(o!==null&&a!==null&&s.bl(l)){let A=a.getDocumentPoint(T.Center);A.isReal()||A.setTo(o.actualBounds.centerX,o.actualBounds.centerY);let F=e.getPoint(e.pointsCount-4),O=e.getLinkPointFromPoint(o,a,A,F,!1),E=e.getPoint(e.pointsCount-3);this.direction===90||this.direction===270?(e.setPointAt(e.pointsCount-2,F.x,(E.y+O.y)/2),e.setPointAt(e.pointsCount-3,F.x,(E.y+O.y)/2)):(e.setPointAt(e.pointsCount-2,(E.x+O.x)/2,F.y),e.setPointAt(e.pointsCount-3,(E.x+O.x)/2,F.y));let B=e.getLinkPointFromPoint(o,a,A,e.getPoint(e.pointsCount-2),!1);e.setPointAt(e.pointsCount-1,B.x,B.y)}}e.commitRoute(),i.commit()}}N3(){this.bw=-1,this.Hg=0,this.Vs=0,this.mu=null;for(let t=0;t<this.Vn.length;t++)this.Vn[t]=null}qa(t){let e,i=this.ie[t];if(i>=this.Vn.length){let n=[];for(let o=0;o<this.Vn.length;o++)n[o]=this.Vn[o];this.Vn=n}this.Vn[i]===void 0||this.Vn[i]===null?e=[]:(e=this.Vn[i],this.Vn[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.Vn[this.ie[t]]=e}get layerSpacing(){return this.Us}set layerSpacing(t){this.Us!==t&&(m.s(t,"number",Ae,"layerSpacing"),t>=0&&(this.Us=t,this.p()))}get columnSpacing(){return this.ti}set columnSpacing(t){this.ti!==t&&(m.s(t,"number",Ae,"columnSpacing"),t>0&&(this.ti=t,this.p()))}get direction(){return this.P}set direction(t){this.P!==t&&(m.s(t,"number",Ae,"direction"),t===0||t===90||t===180||t===270?(this.P=t,this.p()):m.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.ar}set packOption(t){this.ar!==t&&(m.s(t,"number",Ae,"packOption"),t>=0&&t<8&&(this.ar=t,this.p()))}get packIterations(){return this.gu}set packIterations(t){this.gu=t}get alignOption(){return this.Bn}set alignOption(t){this.Bn!==t&&(m.s(t,"number",Ae,"align"),t>=0&&t<16&&(this.Bn=t,this.p()))}get centered(){return this.Ha}set centered(t){this.centered!==t&&(m.s(t,"boolean",Ae,"centered"),this.Ha=t,this.p())}get setsPortSpots(){return this.Un}set setsPortSpots(t){this.Un!==t&&(m.s(t,"boolean",Ae,"setsPortSpots"),this.Un=t,this.p())}get maxLayer(){return this._}get maxIndex(){return this.bw}get maxColumn(){return this.zt}get minIndexLayer(){return this.Hg}get maxIndexLayer(){return this.Vs}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 tn extends Ee{constructor(t){super(t)}createVertex(){let t=new si(this);return t.centered=this.layout.centered,t}createEdge(){return new Se(this)}}class si extends Ie{gl;pa;Tt;tP;eP;Ha;ii;pu;Zn;$k;jk;Wk;mc;zn;CF;Wa;os;yu;mi;Xn;Mw=null;Nw=null;Cw=null;Lw=null;constructor(t){super(t),this.gl=-1,this.pa=-1,this.Tt=-1,this.tP=NaN,this.eP=null,this.Ha=!0,this.ii=!1,this.pu=NaN,this.Zn=NaN,this.$k=0,this.jk=null,this.Wk=null}static TF(t,e){return t.index-e.index}getProperSourceEdges(){if(!this.Cw){let t=[];for(let e of this.Po){let i=e;i.valid&&t.push(i)}this.Cw=t}return this.Cw}getProperDestinationEdges(){if(!this.Lw){let t=[];for(let e of this.nr){let i=e;i.valid&&t.push(i)}this.Lw=t}return this.Lw}getDestinationEdge(t){let e=this.getProperDestinationEdges();for(let i of e)if(i.toVertex===t)return i;m.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.Mw){let t=[];for(let e of this.Po){let i=e;!i.valid||i.fromVertex.layer<=i.toVertex.layer||t.push(i.fromVertex)}t.sort(si.TF),this.Mw=t}return this.Mw}getProperDestinationVertexes(){if(!this.Nw){let t=[];for(let e of this.nr){let i=e;!i.valid||i.fromVertex.layer<=i.toVertex.layer||t.push(i.toVertex)}t.sort(si.TF),this.Nw=t}return this.Nw}addSourceEdge(t){super.addSourceEdge(t),this.Mw=null,this.Cw=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.Mw=null,this.Cw=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Nw=null,this.Lw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Nw=null,this.Lw=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.gl}set layer(t){this.gl=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.tP}set component(t){this.tP!==t&&(m.s(t,"number",si,"component"),this.tP=t)}get near(){return this.eP}set near(t){this.eP!==t&&(this.eP=t)}get centered(){return this.Ha}set centered(t){this.Ha=t}}class Se extends ei{ii;iP;sP;nP;oP;rP;lP;constructor(t){super(t),this.ii=!1,this.iP=!1,this.sP=!1,this.nP=NaN,this.oP=NaN,this.rP=0,this.lP=0}get fromVertex(){return this.is}set fromVertex(t){this.is!==t&&(this.is=t)}get toVertex(){return this.ss}set toVertex(t){this.ss!==t&&(this.ss=t)}get valid(){return this.ii}set valid(t){this.ii!==t&&(m.s(t,"boolean",Se,"valid"),this.ii=t)}get rev(){return this.iP}set rev(t){this.iP!==t&&(m.s(t,"boolean",Se,"rev"),this.iP=t)}get forest(){return this.sP}set forest(t){this.sP!==t&&(m.s(t,"boolean",Se,"forest"),this.sP=t)}get portFromPos(){return this.nP}set portFromPos(t){this.nP!==t&&(m.s(t,"number",Se,"portFromPos"),this.nP=t)}get portToPos(){return this.oP}set portToPos(t){this.oP!==t&&(m.s(t,"number",Se,"portToPos"),this.oP=t)}get portFromColOffset(){return this.rP}set portFromColOffset(t){this.rP!==t&&(m.s(t,"number",Se,"portFromColOffset"),this.rP=t)}get portToColOffset(){return this.lP}set portToColOffset(t){this.lP!==t&&(m.s(t,"number",Se,"portToColOffset"),this.lP=t)}}var hs=(x=>(x[x.Default=0]="Default",x[x.Destination=1]="Destination",x[x.Source=2]="Source",x))(hs||{}),ls=(x=>(x[x.Forwards=10]="Forwards",x[x.Reverse=11]="Reverse",x[x.Ascending=12]="Ascending",x[x.Descending=13]="Descending",x))(ls||{}),us=(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))(us||{}),cs=(x=>(x[x.None=30]="None",x[x.Block=31]="Block",x))(cs||{}),ds=(x=>(x[x.Layered=40]="Layered",x[x.LastParents=41]="LastParents",x[x.Alternating=42]="Alternating",x[x.RootOnly=43]="RootOnly",x))(ds||{}),fs=(x=>(x[x.Vertical=50]="Vertical",x[x.Horizontal=51]="Horizontal",x[x.FixedRoots=52]="FixedRoots",x))(fs||{}),en=(x=>(x[x.Individual=60]="Individual",x[x.Siblings=61]="Siblings",x[x.Uniform=62]="Uniform",x))(en||{});class Vt extends _t{Ie;Fe;wu;Jg;wL;zi;He;Es;V;B;aP;ws;constructor(t){super(),this.Ie=new V,this.Fe=0,this.ws=1,this.wu=40,this.Jg=60,this.wL=[],this.zi=!0,this.He=50,this.Es=new st(10,10).k();let e=new gs(this);this.V=new Rt(e),this.B=new Rt(e),this.aP=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Fe=this.Fe,t.wu=this.wu,t.Jg=this.Jg,t.zi=this.zi,t.He=this.He,t.Es.h(this.Es),t.V.copyInheritedPropertiesFrom(this.V),t.B.copyInheritedPropertiesFrom(this.B)}fe(t){t in us?this.alignment=t:t in fs?this.arrangement=t:t in cs?this.compaction=t:t in hs?this.path=t:t in ls?this.sorting=t:t in ds?this.treeStyle=t:super.fe(t)}createNetwork(){return new gs(this)}makeNetwork(t){let e=this.createNetwork(),i=s=>{if(s instanceof $)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof j){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 Y?(e.addParts(t.nodes,!0,i),e.addParts(t.links,!0,i)):t instanceof ht?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 Y&&(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.lU(),this.aU(),this.hU(),this.cU(),this.uL(),this.fU(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ie=new V,this.isValidLayout=!0}lU(){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 V,o=this.Ie.iterator;for(;o.next();){let r=o.value;if(r instanceof $){let a=this.network.findVertex(r);a!==null&&n.add(a)}else r instanceof Rt&&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.xL(n))}let i=this.network.vertexes,s=null;for(;s=this.uU(i),s.count>0;){let n=this.DF(s);n!==null&&(this.Ie.add(n),n.initialized=!0,this.xL(n)),i=s}}uU(t){let e=new V,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:m.o("Unhandled path value "+this.ws.toString())}}if(this.Ie.count===0){let i=this.DF(t);i!==null&&this.Ie.add(i)}}DF(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:m.o("Unhandled path value "+this.ws.toString())}}return i}xL(t){if(t===null)return;switch(this.ws){case 1:if(t.destinationEdges.count>0){let s=new q,n=t.destinationVertexes;for(;n.next();){let o=n.value;this.vF(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){let s=new q,n=t.sourceVertexes;for(;n.next();){let o=n.value;this.vF(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:m.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.xL(n)}}vF(t,e){return e.initialized?this.dU(e,t)||e.level>t.level?!1:(this.gU(e.parent,e),!0):!0}dU(t,e){if(e===null)return!1;let i=e.parent;for(;i!==null&&i!==t;)i=i.parent;return i===t}gU(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}}aU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.FF(e)}}FF(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.FF(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}mU(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.mU(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}hU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.RF(e)}}RF(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.RF(n)}}assignTreeVertexValues(t){}cU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.OF(e)}}OF(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.OF(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}}uL(){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,u=0,c=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 g=p.measuredBounds;r&&!h||!o&&!a&&h||o&&a&&h?(l=Math.max(l,g.width),u+=g.height+Math.abs(c)):(l+=g.width+Math.abs(c),u=Math.max(u,g.height)),c=d}}if(t.comments!==null){r&&!h||!o&&!a&&h||o&&a&&h?(l+=Math.abs(t.commentMargin),u=Math.max(0,u-t.height)):(u+=Math.abs(t.commentMargin),l=Math.max(0,l-t.width));let f=I.z(0,0,t.bounds.width+l,t.bounds.height+u);t.bounds=f,I.i(f)}}isBusAlignment(t){return t===24||t===25||t===26||t===27}Aw(t){return t===24||t===25}bL(t){let e=t.parent;if(e!==null){let i=e.alignment;if(this.isBusAlignment(i))if(this.Aw(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,u=this.bL(t),c=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&&u)if(t.commentMargin>=0){p.e(t.bounds.x-t.commentMargin-v.width,t.bounds.y+c),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+c),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+c),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+c),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?c+=v.height+t.commentSpacing:c+=t.commentSpacing-v.height}else{if(n>135&&!r||!h&&u)if(t.commentMargin>=0){p.e(t.bounds.x+c,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+c,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+c,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+c,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?c+=v.width+t.commentSpacing:c+=t.commentSpacing-v.width}}P.i(p);let g=c-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=g>0?g:NaN)}}else{let y=t.sourceEdges;for(;y.next();){let b=y.value.link;b!==null&&!b.isAvoiding&&(b.toEndSegmentLength=g>0?g:NaN)}}}}fU(){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.wL=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 Rt&&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.IF(t);break;default:case 31:t.alignment===25?this.IF(t):this.pU(t);break}}IF(t){if(t.childrenCount===0){let X=!1,z=0,U=21;t.parent!==null&&(z=t.parent.angle,U=t.parent.alignment,X=this.isBusAlignment(U));let tt=this.bL(t);t.U.e(0,0),t.dt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((z===180||z===270)&&!X||tt)?z===180&&!X||(z===90||z===270)&&tt?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 X=0;X<o;X++){let z=n[X];s=Math.max(s,i?z.dt.width:z.dt.height)}let r=t.alignment,a=r===22,h=r===23,l=this.isBusAlignment(r),u=Math.max(0,t.breadthLimit),c=this.computeLayerSpacing(t),d=t.nodeSpacing,f=this.computeNodeIndent(t),p=a||h?0:f/2,g=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,N=0,D=0,L=0,M=0,A=0,F=0,O=0;if(l&&!this.Aw(r)&&e>135&&n.reverse(),this.Aw(r))if(o>1)for(let X=0;X<o;X++){let z=n[X],U=z.dt;X%2===0&&X!==o-1?F=Math.max(F,(i?U.width:U.height)+this.computeBusNodeSpacing(z)-d):X%2!==0&&(O=Math.max(O,(i?U.width:U.height)+this.computeBusNodeSpacing(z)-d))}else o===1&&(F=i?n[0].dt.width:n[0].dt.height);if(l)switch(r){case 24:case 25:let X=I.l();e<135?this.EF(t,n,F,O,w,k,X):this.UF(t,n,F,O,w,k,X),F=X.x,w=X.width,k=X.height,I.i(X);break;case 26:for(let z=0;z<o;z++){let U=n[z],tt=U.dt,nt=M===0?0:g;i?(U.U.e(s-tt.width,D+nt),w=Math.max(w,tt.width),k=Math.max(k,D+nt+tt.height),D+=nt+tt.height):(U.U.e(N+nt,s-tt.height),w=Math.max(w,N+nt+tt.width),k=Math.max(k,tt.height),N+=nt+tt.width),M++}break;case 27:for(let z=0;z<o;z++){let U=n[z],tt=U.dt,nt=M===0?0:g;i?(U.U.e(d/2+t.focus.x,D+nt),w=Math.max(w,tt.width),k=Math.max(k,D+nt+tt.height),D+=nt+tt.height):(U.U.e(N+nt,d/2+t.focus.y),w=Math.max(w,N+nt+tt.width),k=Math.max(k,tt.height),N+=nt+tt.width),M++}break}else for(let X=0;X<o;X++){let z=n[X],U=z.dt;if(i){u>0&&M>0&&N+d+U.width>u&&(N<s&&this.pc(t,r,s-N,0,A,X-1),L++,M=0,A=X,S=k,N=0,D=e>135?-k-g:k+g);let tt=M===0?p:d;this.hP(z,0,D),z.U.e(N+tt,D),w=Math.max(w,N+tt+U.width),k=Math.max(k,S+(L===0?0:g)+U.height),N+=tt+U.width}else{u>0&&M>0&&D+d+U.height>u&&(D<s&&this.pc(t,r,0,s-D,A,X-1),L++,M=0,A=X,S=w,D=0,N=e>135?-w-g:w+g);let tt=M===0?p:d;this.hP(z,N,0),z.U.e(N,D+tt),k=Math.max(k,D+tt+U.height),w=Math.max(w,S+(L===0?0:g)+U.width),D+=tt+U.height}M++}L>0&&(i?(k+=Math.max(0,c),N<w&&this.pc(t,r,w-N,0,A,o-1),y>0&&(h||this.xu(t,y,0,0,o-1),w+=y)):(w+=Math.max(0,c),D<k&&this.pc(t,r,0,k-D,A,o-1),y>0&&(h||this.xu(t,0,y,0,o-1),k+=y)));let E=0,B=0;switch(r){case 20:i?E+=w/2-t.focus.x-f/2:B+=k/2-t.focus.y-f/2;break;default:case 21:if(L>0)i?E+=w/2-t.focus.x-f/2:B+=k/2-t.focus.y-f/2;else{let z=o;if(i){let U=n[0].U.x+n[0].at.x,tt=n[z-1].U.x+n[z-1].at.x+n[z-1].focus.x*2;E+=U+(tt-U)/2-t.focus.x-f/2}else{let U=n[0].U.y+n[0].at.y,tt=n[z-1].U.y+n[z-1].at.y+n[z-1].focus.y*2;B+=U+(tt-U)/2-t.focus.y-f/2}}break;case 22:i?(E-=f,w+=f):(B-=f,k+=f);break;case 23:i?(E+=w-t.width+f,w+=f):(B+=k-t.height+f,k+=f);break;case 24:case 25:i?o>1?E+=F+d/2-t.focus.x:E+=n[0].focus.x-t.focus.x+n[0].at.x:o>1?B+=F+d/2-t.focus.y:B+=n[0].focus.y-t.focus.y+n[0].at.y;break;case 26:i?E+=w+d/2-t.focus.x:B+=k+d/2-t.focus.y;break;case 27:break;case 28:let X=this.customAlignment(t,E,B,w,k);E=X[0],B=X[1],w=X[2],k=X[3];break}for(let X=0;X<o;X++){let z=n[X];i?z.U.e(z.U.x+z.at.x-E,z.U.y+(e>135?(l?-k:-z.dt.height)+z.at.y-c:v+c+z.at.y)):z.U.e(z.U.x+(e>135?(l?-w:-z.dt.width)+z.at.x-c:b+c+z.at.x),z.U.y+z.at.y-B)}i?(w=this.kL(t,w,E),E<0&&(E=0),e>135&&(B+=k+c),k=Math.max(Math.max(k,v),k+v+c)):(e>135&&(E+=w+c),w=Math.max(Math.max(w,b),w+b+c),k=this.PL(t,k,B),B<0&&(B=0)),t.at.e(E,B),t.dt.e(w,k)}customAlignment(t,e,i,s,n){return[e,i,s,n]}EF(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,u=this.orthoAngle(t)===90,c=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=c===0?0:l;if(u){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}c++}c=0;let p=d,g=f;u?(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=c===0?0:l;if(u){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}c++}if(a>1&&a%2===1){let y=e[a-1],b=y.dt,v=this.computeBusLastRowSpacing(y,u?Math.max(Math.abs(g),Math.abs(f)):Math.max(Math.abs(p),Math.abs(d)));if(u){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(g,f)+v+b.height),y.U.x<0&&(i=this.cP(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.cP(t,y.U.y,!0,i,h))}}return r.e(i,0,n,o),r}UF(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,u=this.orthoAngle(t)===270,c=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=c===0?0:l;if(u){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))}c++}c=0;let p=d,g=f;u?(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=c===0?0:l;if(u){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))}c++}if(a>1&&a%2===1){let y=e[a-1],b=y.dt,v=this.computeBusLastRowSpacing(y,u?Math.max(Math.abs(g),Math.abs(f)):Math.max(Math.abs(p),Math.abs(d)));if(u){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(g,f))+v+b.height),y.U.x<0&&(i=this.cP(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.cP(t,y.U.y,!0,i,h))}}for(let y=0;y<a;y++){let b=e[y];u?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}cP(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)}kL(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}}PL(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}}SL(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:m.o("Unhandled alignment value "+t.toString())}return new P(e,i)}pc(t,e,i,s,n,o){let r=this.SL(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}}hP(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:m.o("Unhandled path value "+this.ws.toString())}}pU(t){if(t.childrenCount===0){let _=t.parent,at=!1,ct=0,yt=21;_!==null&&(ct=_.angle,yt=_.alignment,at=this.isBusAlignment(yt));let Ct=this.bL(t);t.U.e(0,0),t.dt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((ct===180||ct===270)&&!at||Ct)?ct===180&&!at||(ct===90||ct===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 _=0;_<o;_++){let at=n[_];s=Math.max(s,i?at.dt.width:at.dt.height)}let r=t.alignment,a=r===22,h=r===23,l=this.isBusAlignment(r),u=Math.max(0,t.breadthLimit),c=this.computeLayerSpacing(t),d=t.nodeSpacing,f=this.computeNodeIndent(t),p=t.rowSpacing,g=0;(a||h)&&(g=Math.max(0,t.rowIndent));let y=t.width,b=t.height,v=0,w=0,k=0,S=null,N=null,D=0,L=0,M=0,A=0,F=0,O=0,E=0,B=0,X=0;if(l&&!this.Aw(r)&&e>135&&n.reverse(),this.Aw(r))if(o>1)for(let _=0;_<o;_++)_%2===0&&_!==o-1?B=Math.max(B,i?n[_].dt.width:n[_].dt.height):_%2!==0&&(X=Math.max(X,i?n[_].dt.width:n[_].dt.height));else o===1&&(B=i?n[0].dt.width:n[0].dt.height);if(l){switch(r){case 24:let _=I.l();e<135?this.EF(t,n,B,X,v,w,_):this.UF(t,n,B,X,v,w,_),B=_.x,v=_.width,w=_.height,I.i(_);break;case 26:for(let at=0;at<o;at++){let ct=n[at],yt=ct.dt,Ct=O===0?0:p;i?(ct.U.e(s-yt.width,A+Ct),v=Math.max(v,yt.width),w=Math.max(w,A+Ct+yt.height),A+=Ct+yt.height):(ct.U.e(M+Ct,s-yt.height),v=Math.max(v,M+Ct+yt.width),w=Math.max(w,yt.height),M+=Ct+yt.width),O++}break;case 27:for(let at=0;at<o;at++){let ct=n[at],yt=ct.dt,Ct=O===0?0:p;i?(ct.U.e(d/2+t.focus.x,A+Ct),v=Math.max(v,yt.width),w=Math.max(w,A+Ct+yt.height),A+=Ct+yt.height):(ct.U.e(M+Ct,d/2+t.focus.y),v=Math.max(v,M+Ct+yt.width),w=Math.max(w,yt.height),M+=Ct+yt.width),O++}break}S=this.pi(2),N=this.pi(2),i?(S[0].e(0,0),S[1].e(0,w),N[0].e(v,0),N[1].e(v,w)):(S[0].e(0,0),S[1].e(v,0),N[0].e(0,w),N[1].e(v,w))}else for(let _=0;_<o;_++){let at=n[_],ct=at.dt;if(i){u>0&&O>0&&M+d+ct.width>u&&(M<s&&this.pc(t,r,s-M,0,E,_-1),F++,O=0,E=_,k=w,M=0,A=e>135?-w-p:w+p),this.hP(at,0,A);let yt=0;if(O===0)S=at.$g,N=at.Zg,D=ct.width,L=ct.height,(S===null||N===null||e!==this.orthoAngle(at))&&(S=this.pi(2),N=this.pi(2),S[0].e(0,0),S[1].e(0,L),N[0].e(D,0),N[1].e(D,L));else{let Ct=m.st(),Q=I.l();this.VF(t,at,S,N,D,L,Ct,Q),yt=Q.x,S=Ct[0],N=Ct[1],D=Q.width,L=Q.height,m.Z(Ct),M<ct.width&&yt<0&&(this.xu(t,-yt,0,E,_-1),this.fP(S,-yt,0),this.fP(N,-yt,0),yt=0),I.i(Q)}at.U.e(yt,A),v=Math.max(v,D),w=Math.max(w,k+(F===0?0:p)+ct.height),M=D}else{u>0&&O>0&&A+d+ct.height>u&&(A<s&&this.pc(t,r,0,s-A,E,_-1),F++,O=0,E=_,k=v,A=0,M=e>135?-v-p:v+p),this.hP(at,M,0);let yt=0;if(O===0)S=at.$g,N=at.Zg,D=ct.width,L=ct.height,(S===null||N===null||e!==this.orthoAngle(at))&&(S=this.pi(2),N=this.pi(2),S[0].e(0,0),S[1].e(D,0),N[0].e(0,L),N[1].e(D,L));else{let Ct=m.st(),Q=I.l();this.VF(t,at,S,N,D,L,Ct,Q),yt=Q.x,S=Ct[0],N=Ct[1],D=Q.width,L=Q.height,m.Z(Ct),A<ct.height&&yt<0&&(this.xu(t,0,-yt,E,_-1),this.fP(S,0,-yt),this.fP(N,0,-yt),yt=0),I.i(Q)}at.U.e(M,yt),w=Math.max(w,L),v=Math.max(v,k+(F===0?0:p)+ct.width),A=L}O++}F>0&&(i?(w+=Math.max(0,c),M<v&&this.pc(t,r,v-M,0,E,o-1),g>0&&(h||this.xu(t,g,0,0,o-1),v+=g)):(v+=Math.max(0,c),A<w&&this.pc(t,r,0,w-A,E,o-1),g>0&&(h||this.xu(t,0,g,0,o-1),w+=g)));let z=0,U=0;switch(r){case 20:i?z+=v/2-t.focus.x-f/2:U+=w/2-t.focus.y-f/2;break;default:case 21:if(F>0)i?z+=v/2-t.focus.x-f/2:U+=w/2-t.focus.y-f/2;else{let at=o;if(i){let ct=n[0].U.x+n[0].at.x,yt=n[at-1].U.x+n[at-1].at.x+n[at-1].focus.x*2;z+=ct+(yt-ct)/2-t.focus.x-f/2}else{let ct=n[0].U.y+n[0].at.y,yt=n[at-1].U.y+n[at-1].at.y+n[at-1].focus.y*2;U+=ct+(yt-ct)/2-t.focus.y-f/2}}break;case 22:i?(z-=f,v+=f):(U-=f,w+=f);break;case 23:i?(z+=v-t.width+f,v+=f):(U+=w-t.height+f,w+=f);break;case 24:i?o>1?z+=B+d/2-t.focus.x:z+=n[0].focus.x-t.focus.x+n[0].at.x:o>1?U+=B+d/2-t.focus.y:U+=n[0].focus.y-t.focus.y+n[0].at.y;break;case 26:i?z+=v+d/2-t.focus.x:U+=w+d/2-t.focus.y;break;case 27:break;case 28:let _=this.customAlignment(t,z,U,v,w);z=_[0],U=_[1],v=_[2],w=_[3];break}for(let _=0;_<o;_++){let at=n[_];i?at.U.e(at.U.x+at.at.x-z,at.U.y+(e>135?(l?-w:-at.dt.height)+at.at.y-c:b+c+at.at.y)):at.U.e(at.U.x+(e>135?(l?-v:-at.dt.width)+at.at.x-c:y+c+at.at.x),at.U.y+at.at.y-U)}let tt=0,nt=0;if(l)i?(v=this.kL(t,v,z),z<0&&(z=0),e>135&&(U+=w+c),w+=b+c,r===27&&(tt+=d/2+t.focus.x),nt+=b+c):(e>135&&(z+=v+c),v+=y+c,w=this.PL(t,w,U),U<0&&(U=0),r===27&&(nt+=d/2+t.focus.y),tt+=y+c);else if(i){if(t.comments===null){if(y>v){let _=this.SL(r,y-v,0);tt=_.x,nt=_.y,v=y,z=0}}else v=this.kL(t,v,z);z<0&&(tt-=z,z=0),e>135&&(U+=w+c),w=Math.max(Math.max(w,b),w+b+c),nt+=b+c}else{if(e>135&&(z+=v+c),v=Math.max(Math.max(v,y),v+y+c),t.comments===null){if(b>w){let _=this.SL(r,0,b-w);tt=_.x,nt=_.y,w=b,U=0}}else w=this.PL(t,w,U);U<0&&(nt-=U,U=0),tt+=y+c}let Z,it;if(F>0)Z=this.pi(4),it=this.pi(4),i?(Z[2].e(0,b+c),Z[3].e(Z[2].x,w),it[2].e(v,Z[2].y),it[3].e(it[2].x,Z[3].y)):(Z[2].e(y+c,0),Z[3].e(v,Z[2].y),it[2].e(Z[2].x,w),it[3].e(Z[3].x,it[2].y));else{Z=this.pi(S.length+2),it=this.pi(N.length+2);for(let _=0;_<S.length;_++){let at=S[_];Z[_+2].e(at.x+tt,at.y+nt)}for(let _=0;_<N.length;_++){let at=N[_];it[_+2].e(at.x+tt,at.y+nt)}}i?(Z[0].e(z,0),Z[1].e(Z[0].x,b),Z[2].y<Z[1].y&&(Z[2].x>Z[0].x?Z[2].h(Z[1]):Z[1].h(Z[2])),Z[3].y<Z[2].y&&(Z[3].x>Z[0].x?Z[3].h(Z[2]):Z[2].h(Z[3])),it[0].e(z+y,0),it[1].e(it[0].x,b),it[2].y<it[1].y&&(it[2].x<it[0].x?it[2].h(it[1]):it[1].h(it[2])),it[3].y<it[2].y&&(it[3].x<it[0].x?it[3].h(it[2]):it[2].h(it[3])),Z[2].y-=c/2,it[2].y-=c/2):(Z[0].e(0,U),Z[1].e(y,Z[0].y),Z[2].x<Z[1].x&&(Z[2].y>Z[0].y?Z[2].h(Z[1]):Z[1].h(Z[2])),Z[3].x<Z[2].x&&(Z[3].y>Z[0].y?Z[3].h(Z[2]):Z[2].h(Z[3])),it[0].e(0,U+b),it[1].e(y,it[0].y),it[2].x<it[1].x&&(it[2].y<it[0].y?it[2].h(it[1]):it[1].h(it[2])),it[3].x<it[2].x&&(it[3].y<it[0].y?it[3].h(it[2]):it[2].h(it[3])),Z[2].x-=c/2,it[2].x-=c/2),this.fn(S),this.fn(N),t.$g=Z,t.Zg=it,t.at.e(z,U),t.dt.e(v,w)}fP(t,e,i){for(let s=0;s<t.length;s++){let n=t[s];n.x+=e,n.y+=i}}VF(t,e,i,s,n,o,r,a){let h=this.orthoAngle(t),l=h===90||h===270,u=t.nodeSpacing,c=i,d=s,f=n,p=o,g=e.$g,y=e.Zg,b=e.dt,v=l?Math.max(p,b.height):Math.max(f,b.width);if((g===null||h!==this.orthoAngle(e))&&(g=this.pi(2),y=this.pi(2),l?(g[0].e(0,0),g[1].e(0,b.height),y[0].e(b.width,0),y[1].e(y[0].x,g[1].y)):(g[0].e(0,0),g[1].e(b.width,0),y[0].e(0,b.height),y[1].e(g[1].x,y[0].y))),l){let w=f,k=w-this.yU(d,g,w);return k+=u,i=this.wU(c,g,k),s=this.xU(d,y,k),n=Math.max(0,k)+b.width,o=v,this.fn(c),this.fn(g),this.fn(d),this.fn(y),r[0]=i,r[1]=s,a.e(k,0,n,o),a}else{let w=p,k=w-this.bU(d,g,w);return k+=u,i=this.kU(c,g,k),s=this.PU(d,y,k),n=v,o=Math.max(0,k)+b.height,this.fn(c),this.fn(g),this.fn(d),this.fn(y),r[0]=i,r[1]=s,a.e(k,0,n,o),a}}kU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}wU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}PU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}xU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}bU(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 u=r;n+1<t.length&&(u=t[n+1]);let c=a,d=c.x,f=c.y;o+1<e.length&&(c=e[o+1],d=c.x,f=c.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<u.x&&(p=l-(r.y+(h-r.x)/(u.x-r.x)*(u.y-r.y))),p<s&&(s=p),u.x<=r.x?n++:d<=h?o++:(u.x<=d&&n++,d<=u.x&&o++)}return s}yU(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 u=r;n+1<t.length&&(u=t[n+1]);let c=a,d=c.x,f=c.y;o+1<e.length&&(c=e[o+1],d=c.x,f=c.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<u.y&&(p=h-(r.x+(l-r.y)/(u.y-r.y)*(u.x-r.x))),p<s&&(s=p),u.y<=r.y?n++:f<=l?o++:(u.y<=f&&n++,f<=u.y&&o++)}return s}pi(t){let e=this.aP[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}fn(t){if(!t)return;let e=t.length,i=this.aP[e];i===void 0&&(i=[],this.aP[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 Rt))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.ML(e,n,o)}}else{let t=[],e=this.Ie.iterator;for(;e.next();){let o=e.value;o instanceof Rt&&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.ML(r,s+r.at.x,n+r.at.y),this.He){case 50:n+=r.dt.height+this.Es.height;break;default:case 51:s+=r.dt.width+this.Es.width;break}}}}ML(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.ML(r,e+r.U.x,i+r.U.y)}}commitLayout(){this.xw(),this.commitNodes(),this.yL(),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)}}yL(){if(this.network===null||this.layerStyle!==62)return;let t=this.wL,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 I(0,a,r,l))):this.angle===90?(o.push(new I(0,a,r,l)),a+=l):this.angle===180?(a-=l,o.push(new I(a,0,l,r))):(o.push(new I(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()}xw(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.BF(e)}}BF(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.BF(n)}}setPortSpots(t){let e=t.alignment;if(this.isBusAlignment(e))this.SU(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}}}}}SU(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 u=l.link;if(u!==null){let c=s===90||s===270?T.MiddleLeft:T.MiddleTop;if(r===1||a===r-1&&r%2===1)switch(s){case 0:c=T.MiddleLeft;break;case 90:c=T.MiddleTop;break;case 180:c=T.MiddleRight;break;default:c=T.MiddleBottom;break}else a%2===0&&(c=s===90||s===270?T.MiddleRight:T.MiddleBottom);i?(t.setsPortSpot&&(u.fromSpot=n),t.setsChildPortSpot&&(u.toSpot=c)):(t.setsPortSpot&&(u.fromSpot=c),t.setsChildPortSpot&&(u.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.zi}set comments(t){this.zi!==t&&(m.s(t,"boolean",Vt,"comments"),this.zi=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.Es}set arrangementSpacing(t){this.Es.equals(t)||(this.Es.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&&(m.S(t,Vt,"comparer"),this.V.comparer=t,this.p())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(m.s(t,"number",Vt,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.p()):m.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&&(m.s(t,"number",Vt,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.p()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(m.s(t,"number",Vt,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.p()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(m.s(t,"number",Vt,"nodeSpacing"),this.V.nodeSpacing=t,this.p())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(m.s(t,"number",Vt,"layerSpacing"),this.V.layerSpacing=t,this.p())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(m.s(t,"number",Vt,"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&&(m.s(t,"number",Vt,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.p()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(m.s(t,"number",Vt,"rowSpacing"),this.V.rowSpacing=t,this.p())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(m.s(t,"number",Vt,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.p()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(m.s(t,"number",Vt,"commentSpacing"),this.V.commentSpacing=t,this.p())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(m.s(t,"number",Vt,"commentMargin"),this.V.commentMargin=t,this.p())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(m.s(t,"boolean",Vt,"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&&(m.s(t,"boolean",Vt,"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&&(m.S(t,Vt,"alternateComparer"),this.B.comparer=t,this.p())}get alternateAngle(){return this.B.angle}set alternateAngle(t){this.B.angle!==t&&(m.s(t,"number",Vt,"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&&(m.s(t,"number",Vt,"alternateNodeIndent"),t>=0&&(this.B.nodeIndent=t,this.p()))}get alternateNodeIndentPastParent(){return this.B.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.B.nodeIndentPastParent!==t&&(m.s(t,"number",Vt,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.B.nodeIndentPastParent=t,this.p()))}get alternateNodeSpacing(){return this.B.nodeSpacing}set alternateNodeSpacing(t){this.B.nodeSpacing!==t&&(m.s(t,"number",Vt,"alternateNodeSpacing"),this.B.nodeSpacing=t,this.p())}get alternateLayerSpacing(){return this.B.layerSpacing}set alternateLayerSpacing(t){this.B.layerSpacing!==t&&(m.s(t,"number",Vt,"alternateLayerSpacing"),this.B.layerSpacing=t,this.p())}get alternateLayerSpacingParentOverlap(){return this.B.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.B.layerSpacingParentOverlap!==t&&(m.s(t,"number",Vt,"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&&(m.s(t,"number",Vt,"alternateBreadthLimit"),t>=0&&(this.B.breadthLimit=t,this.p()))}get alternateRowSpacing(){return this.B.rowSpacing}set alternateRowSpacing(t){this.B.rowSpacing!==t&&(m.s(t,"number",Vt,"alternateRowSpacing"),this.B.rowSpacing=t,this.p())}get alternateRowIndent(){return this.B.rowIndent}set alternateRowIndent(t){this.B.rowIndent!==t&&(m.s(t,"number",Vt,"alternateRowIndent"),t>=0&&(this.B.rowIndent=t,this.p()))}get alternateCommentSpacing(){return this.B.commentSpacing}set alternateCommentSpacing(t){this.B.commentSpacing!==t&&(m.s(t,"number",Vt,"alternateCommentSpacing"),this.B.commentSpacing=t,this.p())}get alternateCommentMargin(){return this.B.commentMargin}set alternateCommentMargin(t){this.B.commentMargin!==t&&(m.s(t,"number",Vt,"alternateCommentMargin"),this.B.commentMargin=t,this.p())}get alternateSetsPortSpot(){return this.B.setsPortSpot}set alternateSetsPortSpot(t){this.B.setsPortSpot!==t&&(m.s(t,"boolean",Vt,"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&&(m.s(t,"boolean",Vt,"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 gs extends Ee{constructor(t){super(t)}createVertex(){return new Rt(this)}createEdge(){return new sn(this)}}class Rt extends Ie{U;dt;at;uP;dP;gP;mP;pP;yP;wP;zi;$g;Zg;Si;Mi;Xt;de;Tw;Dw;vw;Us;Fw;Rw;Ow;Iw;Ew;Uw;Vw;Bw;zw;Xw;Gw;constructor(t){super(t),this.uP=!1,this.dP=null,this.gP=[],this.mP=0,this.pP=0,this.yP=0,this.wP=0,this.zi=null,this.U=new P(0,0),this.dt=new st(0,0),this.at=new P(0,0),this.$g=null,this.Zg=null,this.Si=10,this.Mi=Ie.standardComparer,this.Xt=0,this.de=21,this.Tw=0,this.Dw=0,this.vw=20,this.Us=50,this.Fw=0,this.Rw=31,this.Ow=0,this.Iw=25,this.Ew=10,this.Uw=10,this.Vw=20,this.Bw=!0,this.zw=T.Default,this.Xw=!0,this.Gw=T.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.Si=t.sorting,this.Mi=t.comparer,this.Xt=t.angle,this.de=t.alignment,this.Tw=t.nodeIndent,this.Dw=t.nodeIndentPastParent,this.vw=t.nodeSpacing,this.Us=t.layerSpacing,this.Fw=t.layerSpacingParentOverlap,this.Rw=t.compaction,this.Ow=t.breadthLimit,this.Iw=t.rowSpacing,this.Ew=t.rowIndent,this.Uw=t.commentSpacing,this.Vw=t.commentMargin,this.Bw=t.setsPortSpot,this.zw=t.portSpot,this.Xw=t.setsChildPortSpot,this.Gw=t.childPortSpot)}get initialized(){return this.uP}set initialized(t){this.uP!==t&&(m.s(t,"boolean",Rt,"initialized"),this.uP=t)}get parent(){return this.dP}set parent(t){this.dP!==t&&(this.dP=t)}get children(){return this.gP}set children(t){if(this.gP!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",Rt,"children:value"),t!==null){let e=t.length;for(let i=0;i<e;i++){let s=t[i]}}this.gP=t}}get level(){return this.mP}set level(t){this.mP!==t&&(m.s(t,"number",Rt,"level"),this.mP=t)}get descendantCount(){return this.pP}set descendantCount(t){this.pP!==t&&(m.s(t,"number",Rt,"descendantCount"),this.pP=t)}get maxChildrenCount(){return this.yP}set maxChildrenCount(t){this.yP!==t&&(m.s(t,"number",Rt,"maxChildrenCount"),this.yP=t)}get maxGenerationCount(){return this.wP}set maxGenerationCount(t){this.wP!==t&&(m.s(t,"number",Rt,"maxGenerationCount"),this.wP=t)}get comments(){return this.zi}set comments(t){if(this.zi!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",Rt,"comments:value"),t!==null){let e=t.length;for(let i=0;i<e;i++){let s=t[i]}}this.zi=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&&(m.S(t,Rt,"comparer"),this.Mi=t)}get angle(){return this.Xt}set angle(t){this.Xt!==t&&(m.s(t,"number",Rt,"angle"),this.Xt=t)}get alignment(){return this.de}set alignment(t){this.de!==t&&(this.de=t)}get nodeIndent(){return this.Tw}set nodeIndent(t){this.Tw!==t&&(m.s(t,"number",Rt,"nodeIndent"),this.Tw=t)}get nodeIndentPastParent(){return this.Dw}set nodeIndentPastParent(t){this.Dw!==t&&(m.s(t,"number",Rt,"nodeIndentPastParent"),this.Dw=t)}get nodeSpacing(){return this.vw}set nodeSpacing(t){this.vw!==t&&(m.s(t,"number",Rt,"nodeSpacing"),this.vw=t)}get layerSpacing(){return this.Us}set layerSpacing(t){this.Us!==t&&(m.s(t,"number",Rt,"layerSpacing"),this.Us=t)}get layerSpacingParentOverlap(){return this.Fw}set layerSpacingParentOverlap(t){this.Fw!==t&&(m.s(t,"number",Rt,"layerSpacingParentOverlap"),this.Fw=t)}get compaction(){return this.Rw}set compaction(t){this.Rw!==t&&(this.Rw=t)}get breadthLimit(){return this.Ow}set breadthLimit(t){this.Ow!==t&&(m.s(t,"number",Rt,"breadthLimit"),this.Ow=t)}get rowSpacing(){return this.Iw}set rowSpacing(t){this.Iw!==t&&(m.s(t,"number",Rt,"rowSpacing"),this.Iw=t)}get rowIndent(){return this.Ew}set rowIndent(t){this.Ew!==t&&(m.s(t,"number",Rt,"rowIndent"),this.Ew=t)}get commentSpacing(){return this.Uw}set commentSpacing(t){this.Uw!==t&&(m.s(t,"number",Rt,"commentSpacing"),this.Uw=t)}get commentMargin(){return this.Vw}set commentMargin(t){this.Vw!==t&&(m.s(t,"number",Rt,"commentMargin"),this.Vw=t)}get setsPortSpot(){return this.Bw}set setsPortSpot(t){this.Bw!==t&&(m.s(t,"boolean",Rt,"setsPortSpot"),this.Bw=t)}get portSpot(){return this.zw}set portSpot(t){this.zw.equals(t)||(this.zw=t)}get setsChildPortSpot(){return this.Xw}set setsChildPortSpot(t){this.Xw!==t&&(m.s(t,"boolean",Rt,"setsChildPortSpot"),this.Xw=t)}get childPortSpot(){return this.Gw}set childPortSpot(t){this.Gw.equals(t)||(this.Gw=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 sn extends ei{xP;constructor(t){super(t),this.xP=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:m.o("Unhandled path value "+e.ws.toString())}if(i===null||s===null)return;let n=this.xP;if(n.x===0&&n.y===0){this.MU(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,u=t.isOrthogonal,c=0,d,f;if(t.startRoute(),u||l){for(c=2;t.pointsCount>4;)t.removePoint(2);d=t.getPoint(1),f=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);d=t.getPoint(0),f=t.getPoint(t.pointsCount-1)}let p=t.getPoint(t.pointsCount-1),g=0;r===0?(i.alignment===23?(g=o.bottom+n.y,n.y===0&&d.y>p.y+i.rowIndent&&(g=Math.min(g,Math.max(d.y,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.top+n.y,n.y===0&&d.y<p.y-i.rowIndent&&(g=Math.max(g,Math.min(d.y,g+e.computeNodeIndent(i))))):g=o.y+o.height/2+n.y,l?(t.insertPointAt(c,d.x,g),c++,t.insertPointAt(c,o.right+a,g),c++,t.insertPointAt(c,o.right+a+(n.x-h)/3,g),c++,t.insertPointAt(c,o.right+a+(n.x-h)*2/3,g),c++,t.insertPointAt(c,o.right+a+(n.x-h),g),c++,t.insertPointAt(c,f.x,g),c++):(u&&(t.insertPointAt(c,o.right+a/2,d.y),c++),t.insertPointAt(c,o.right+a/2,g),c++,t.insertPointAt(c,o.right+a+n.x-(u?h/2:h),g),c++,u&&(t.insertPointAt(c,t.getPoint(c-1).x,f.y),c++))):r===90?(i.alignment===23?(g=o.right+n.x,n.x===0&&d.x>p.x+i.rowIndent&&(g=Math.min(g,Math.max(d.x,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.left+n.x,n.x===0&&d.x<p.x-i.rowIndent&&(g=Math.max(g,Math.min(d.x,g+e.computeNodeIndent(i))))):g=o.x+o.width/2+n.x,l?(t.insertPointAt(c,g,d.y),c++,t.insertPointAt(c,g,o.bottom+a),c++,t.insertPointAt(c,g,o.bottom+a+(n.y-h)/3),c++,t.insertPointAt(c,g,o.bottom+a+(n.y-h)*2/3),c++,t.insertPointAt(c,g,o.bottom+a+(n.y-h)),c++,t.insertPointAt(c,g,f.y),c++):(u&&(t.insertPointAt(c,d.x,o.bottom+a/2),c++),t.insertPointAt(c,g,o.bottom+a/2),c++,t.insertPointAt(c,g,o.bottom+a+n.y-(u?h/2:h)),c++,u&&(t.insertPointAt(c,f.x,t.getPoint(c-1).y),c++))):r===180?(i.alignment===23?(g=o.bottom+n.y,n.y===0&&d.y>p.y+i.rowIndent&&(g=Math.min(g,Math.max(d.y,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.top+n.y,n.y===0&&d.y<p.y-i.rowIndent&&(g=Math.max(g,Math.min(d.y,g+e.computeNodeIndent(i))))):g=o.y+o.height/2+n.y,l?(t.insertPointAt(c,d.x,g),c++,t.insertPointAt(c,o.left-a,g),c++,t.insertPointAt(c,o.left-a+(n.x+h)/3,g),c++,t.insertPointAt(c,o.left-a+(n.x+h)*2/3,g),c++,t.insertPointAt(c,o.left-a+(n.x+h),g),c++,t.insertPointAt(c,f.x,g),c++):(u&&(t.insertPointAt(c,o.left-a/2,d.y),c++),t.insertPointAt(c,o.left-a/2,g),c++,t.insertPointAt(c,o.left-a+n.x+(u?h/2:h),g),c++,u&&(t.insertPointAt(c,t.getPoint(c-1).x,f.y),c++))):r===270?(i.alignment===23?(g=o.right+n.x,n.x===0&&d.x>p.x+i.rowIndent&&(g=Math.min(g,Math.max(d.x,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.left+n.x,n.x===0&&d.x<p.x-i.rowIndent&&(g=Math.max(g,Math.min(d.x,g+e.computeNodeIndent(i))))):g=o.x+o.width/2+n.x,l?(t.insertPointAt(c,g,d.y),c++,t.insertPointAt(c,g,o.top-a),c++,t.insertPointAt(c,g,o.top-a+(n.y+h)/3),c++,t.insertPointAt(c,g,o.top-a+(n.y+h)*2/3),c++,t.insertPointAt(c,g,o.top-a+(n.y+h)),c++,t.insertPointAt(c,g,f.y),c++):(u&&(t.insertPointAt(c,d.x,o.top-a/2),c++),t.insertPointAt(c,g,o.top-a/2),c++,t.insertPointAt(c,g,o.top-a+n.y+(u?h/2:h)),c++,u&&(t.insertPointAt(c,f.x,t.getPoint(c-1).y),c++))):m.o("Invalid angle "+r),t.commitRoute()}MU(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,u=i.isOrthogonal,c=this.fromVertex,d=s.isBusAlignment(c.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 u?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 u?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 u?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 u?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.is}set fromVertex(t){this.is!==t&&(this.is=t)}get toVertex(){return this.ss}set toVertex(t){this.ss!==t&&(this.ss=t)}get relativePoint(){return this.xP}set relativePoint(t){this.xP.set(t)}}class be{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 Ge{hs=new Set;bu=new Mt;bP="light";kP="light";PP=!1;NL=!0;Qg="light";zF=t=>{let e=t.matches?"dark":"light";e!==this.Qg&&(this.Qg=e,this.kP==="system"&&this.updateDiagrams())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.bu.set("light",{colors:{...be.Light.colors},fonts:{...be.Light.fonts},numbers:{...be.Light.numbers},margins:{...be.Light.margins},arrowheads:{...be.Light.arrowheads}}),this.bu.set("dark",{colors:{...be.Dark.colors},fonts:{...be.Dark.fonts},numbers:{...be.Dark.numbers},margins:{...be.Dark.margins},arrowheads:{...be.Dark.arrowheads}})),K.matchMedia&&(this.Qg=K.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.bP}set defaultTheme(t){this.bP!==t&&(m.s(t,"string",Ge,"defaultTheme"),this.bP=t,this.updateDiagrams())}get currentTheme(){return this.kP}set currentTheme(t){this.kP!==t&&(m.s(t,"string",Ge,"currentTheme"),this.kP=t,this.updateDiagrams())}get changesDivBackground(){return this.PP}set changesDivBackground(t){if(this.PP!==t&&(this.PP=t,t))for(let e of this.hs)e.setDivBackground(this.findValue("div","","fill")),e.T("ThemeChanged",this)}get readsCssVariables(){return this.NL}set readsCssVariables(t){this.NL!==t&&(this.NL=t,this.updateDiagrams())}get preferredColorScheme(){return this.Qg}addDiagram(t){return this.hs.add(t),this.CL(t),this}removeDiagram(t){return this.hs.delete(t),this.CL(t),this}iO(){this.hs.size===0&&K.matchMedia&&K.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.zF)}sO(){this.hs.size===0&&K.matchMedia&&K.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.zF)}set(t,e){t===""&&(t=this.bP),t==="system"&&(t=this.Qg);let i=this.bu.get(t);return i?i=this.XF(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 u=h[l];if(u!==""&&(n=n[u],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=Ge.NU.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.CL(t)}CL(t){let e=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.PP&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=e,t.T("ThemeChanged",this)}XF(t,e){for(let i in e)if(m.Yw(e,i))try{e[i]?.constructor===Object?t[i]=this.XF(t[i]??{},e[i]):t[i]=e[i]}catch{delete t[i]}return t}static NU=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 nn{Pt;a;Be;Pl;constructor(){this.a=Y.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.Ol=!0,t.requestUpdate())}invalidateRouter(){this.a!==null&&(this.a.Ol=!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":m.Gn(this.constructor)}}class _n extends nn{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Y?t.np:t.diagram?.np)?super.canRoute(t):!1}isRoutable(t,e){return!(!t.isAvoiding||t.containingGroup!==(e instanceof ht?e:null)||t.toNode===null||t.fromNode===null||t.pointsCount<4)}routeLinks(t,e){let i=e instanceof Y?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(j.va,j.va),l.unionPoint(o.getPoint(0));let u=o.toNode.actualBounds.copy();u.inflate(j.va,j.va),u.unionPoint(o.getPoint(r-1)),this.CU(o,l,u,n)&&this.LU(o,a,o.PC,h,o.SC,l,u,n),o.commitRoute()}}CU(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 u=2;u<o-3;u++){let c=t.getPoint(u),d=t.getPoint(u+1);if(!s.isUnoccupied(Math.min(c.x,d.x),Math.min(c.y,d.y),Math.abs(c.x-d.x),Math.abs(c.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))}LU(t,e,i,s,n,o,r,a){let h=t.diagram;if(h===null)return;let l=e,u=s,c=P.gn,d=P.gn;if(h.isVirtualized){let g=a.bounds.copy(),y=t.getPoint(2),b=t.getPoint(t.pointsCount-3);g.inflate(-a.cellWidth,-a.cellHeight);let v=P.l();a.og(e.x,e.y)||(C.Al(g.x,g.y,g.x+g.width,g.y+g.height,e.x,e.y,y.x,y.y,v)?(c=e=v.copy(),i=v.directionPoint(y)):C.Al(g.x,g.y,g.x+g.width,g.y+g.height,y.x,y.y,b.x,b.y,v)?(c=e=v.copy(),i=v.directionPoint(b)):C.Al(g.x,g.y,g.x+g.width,g.y+g.height,b.x,b.y,s.x,s.y,v)&&(c=e=v.copy(),i=v.directionPoint(s))),a.og(s.x,s.y)||(C.Al(g.x,g.y,g.x+g.width,g.y+g.height,s.x,s.y,b.x,b.y,v)?(d=s=v.copy(),n=b.directionPoint(v)):C.Al(g.x,g.y,g.x+g.width,g.y+g.height,b.x,b.y,y.x,y.y,v)?(d=s=v.copy(),n=y.directionPoint(v)):C.Al(g.x,g.y,g.x+g.width,g.y+g.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.cf,a.cellHeight*a.cf),a.wv(e,i,s,n,f,!0);let p=a.wo(s.x,s.y);if(!a.Zy&&p>=Ot.ng&&(a.DT(),f.inflate(a.cellWidth*a.E2,a.cellHeight*a.U2),a.wv(e,i,s,n,f,!1),p=a.wo(s.x,s.y)),!a.Zy&&p<Ot.ng&&!a.KE(s.x,s.y)){t.points.removeRange(2,t.pointsCount-3),this.LL(t,a,s.x,s.y,n,!0);let g=0,y=90,b=180,v=270,w=t.getPoint(2);if(t.pointsCount<4)i===g||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===g||i===b)if(C.c(w.x,k.x)){let S=i===g?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 C.c(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(C.c(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 C.c(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(c.isReal()){let k=t.getPoint(1),S=t.getPoint(2);k.x!==S.x&&k.y!==S.y?i===g||i===b?t.insertPointAt(2,k.x,S.y):t.insertPointAt(2,S.x,k.y):i===g||i===b?t.insertPointAt(2,l.x,c.y):t.insertPointAt(2,c.x,l.y)}d.isReal()&&(n===g||n===b?t.insertPointAt(t.pointsCount-2,u.x,d.y):t.insertPointAt(t.pointsCount-2,d.x,u.y))}}LL(t,e,i,s,n,o){let r=e.cellWidth,a=e.cellHeight,h=e.wo(i,s),l=i,u=s,c=l,d=u;for(n===0?c+=r:n===90?d+=a:n===180?c-=r:d-=a,t.DC&&h>Ot.sc&&e.wo(c,d)!==h-1&&(e.wo(l-r,u)===h-1?(n=180,c=l-r,d=u):e.wo(l+r,u)===h-1?(n=0,c=l+r,d=u):e.wo(l,u-a)===h-1?(n=270,c=l,d=u-a):e.wo(l,u+a)===h-1&&(n=90,c=l,d=u+a));h>Ot.sc&&e.wo(c,d)===h-1;)l=c,u=d,n===0?c+=r:n===90?d+=a:n===180?c-=r:d-=a,h-=1;if(o?h>Ot.sc&&(n===180||n===0?l=Math.floor(l/r)*r+r/2:(n===90||n===270)&&(u=Math.floor(u/a)*a+a/2)):(l=Math.floor(l/r)*r+r/2,u=Math.floor(u/a)*a+a/2),h>Ot.sc){let f=n,p=l,g=u;if(n===0?(f=90,g+=a):n===90?(f=180,p-=r):n===180?(f=270,g-=a):n===270&&(f=0,p+=r),e.wo(p,g)===h-1)this.LL(t,e,p,g,f,!1);else{let y=l,b=u;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.wo(y,b)===h-1&&this.LL(t,e,y,b,f,!1)}}t.insertPointAt(t.pointsCount-2,l,u)}}ne.prototype.initializeStandardTools=function(){return this.Jt("Action",new Fs,this.mouseDownTools),this.Jt("Relinking",new $e,this.mouseDownTools),this.Jt("LinkReshaping",new Je,this.mouseDownTools),this.Jt("Rotating",new De,this.mouseDownTools),this.Jt("Resizing",new Ze,this.mouseDownTools),this.Jt("Linking",new Le,this.mouseMoveTools),this.Jt("Dragging",new Tt,this.mouseMoveTools),this.Jt("DragSelecting",new ri,this.mouseMoveTools),this.Jt("Panning",new ki,this.mouseMoveTools),this.Jt("ContextMenu",new It,this.mouseUpTools),this.Jt("TextEditing",new oe,this.mouseUpTools),this.Jt("ClickCreating",new Qe,this.mouseUpTools),this.Jt("ClickSelecting",new Ds,this.mouseUpTools),this},Y.d2("GraphLinksModel",Zn),Y.d2("TreeModel",Qn);let Ai=K.go,gi={get version(){return Y.version},Group:ht,List:q,Set:V,Map:Mt,Point:P,Size:st,Rect:I,Margin:Dt,Spot:T,Geometry:wt,PathFigure:zt,PathSegment:mt,InputEvent:Qt,DiagramEvent:wi,ChangedEvent:Xe,Model:ut,GraphLinksModel:Xt,TreeModel:je,Binding:te,ThemeBinding:ii,Transaction:oi,UndoManager:vi,CommandHandler:jt,Tool:$t,DraggingTool:Tt,DraggingInfo:Ke,DraggingOptions:Pi,LinkingBaseTool:ae,LinkingTool:Le,RelinkingTool:$e,LinkReshapingTool:Je,ResizingTool:Ze,RotatingTool:De,ClickSelectingTool:Ds,ActionTool:Fs,ClickCreatingTool:Qe,HTMLInfo:fe,ContextMenuTool:It,DragSelectingTool:ri,PanningTool:ki,TextEditingTool:oe,ToolManager:ne,Animation:ye,AnimationManager:he,AnimationTrigger:ai,Layer:Et,Diagram:Y,Palette:Rn,Overview:hi,Brush:R,GraphObject:J,Panel:G,RowColumnDefinition:Kt,Shape:et,TextBlock:lt,Picture:Bt,Part:pt,Adornment:vt,Node:$,Link:j,Placeholder:le,Layout:_t,LayoutNetwork:Ee,LayoutVertex:Ie,LayoutEdge:ei,GridLayout:Ue,PanelLayout:Lt,CircularLayout:Be,CircularNetwork:Ws,CircularVertex:di,CircularEdge:$s,ForceDirectedLayout:ee,ForceDirectedNetwork:Js,ForceDirectedVertex:Ve,ForceDirectedEdge:fi,LayeredDigraphLayout:Ae,LayeredDigraphNetwork:tn,LayeredDigraphVertex:si,LayeredDigraphEdge:Se,TreeLayout:Vt,TreeNetwork:gs,TreeVertex:Rt,TreeEdge:sn,Themes:be,ThemeManager:Ge,Router:nn,AnimationStyle:Is,AutoScale:Ii,CycleMode:Vs,Flip:Ks,TextFormat:Yi,ImageStretch:ji,LayoutConditions:Gs,LinkAdjusting:Hi,Curve:$i,Routing:Wi,Orientation:Vi,TextOverflow:js,PortSpreading:qs,ScrollMode:zs,CollapsePolicy:Xs,Sizing:zi,TriggerStart:Bs,Stretch:Bi,ViewboxStretch:Us,Wrap:Ki,BrushType:Oe,ColorSpace:Ys,GeometryStretch:Ri,GeometryType:ze,SegmentType:ni,BindingMode:Ci,ChangeType:Ei,CircularArrangement:ts,CircularDirection:es,CircularNodeDiameterFormula:ss,CircularSorting:is,GridAlignment:Zi,GridArrangement:Qi,GridSorting:_i,LayeredDigraphAggressive:as,LayeredDigraphAlign:_s,LayeredDigraphCycleRemove:ns,LayeredDigraphInit:rs,LayeredDigraphLayering:os,LayeredDigraphPack:Qs,TreeAlignment:us,TreeArrangement:fs,TreeCompaction:cs,TreeLayerStyle:en,TreePath:hs,TreeSorting:ls,TreeStyle:ds,GestureMode:As,LinkingDirection:Ts,ReshapingBehavior:Ls,TextEditingAccept:Os,TextEditingStarting:Rs,TextEditingState:Es,WheelMode:Cs};for(let x in gi){let t=gi[x];m.it(t)&&t!==Yi&&(t.className=x)}m.$(Ai)&&Ai.version&&m.ne("WARNING: a `go` object on the root object is already defined. "+("Debug"in Ai?"debug ":"")+"version: "+Ai.version+", replaced with version: "+gi.version),Y.prototype.go=gi,K.go=gi})();var Eo=typeof global<"u"?global.go:self.go,H=typeof global<"u"?global.go:self.go,Io=H.Group,Bo=H.List,Vo=H.Set;var zo=H.Map;var cn=H.Point,pi=H.Size,Xo=H.Rect,ys=H.Margin,Ne=H.Spot,Ko=H.Geometry,Yo=H.PathFigure,Uo=H.PathSegment,jo=H.InputEvent,Go=H.DiagramEvent,qo=H.ChangedEvent,Ho=H.Model,dn=H.GraphLinksModel,Wo=H.TreeModel,$o=H.Binding,Jo=H.ThemeBinding,Zo=H.Transaction,Qo=H.UndoManager,_o=H.CommandHandler,tr=H.Tool,er=H.DraggingTool,ir=H.DraggingInfo,sr=H.DraggingOptions,nr=H.LinkingBaseTool,or=H.LinkingTool,rr=H.RelinkingTool,ar=H.LinkReshapingTool,hr=H.ResizingTool,lr=H.RotatingTool,ur=H.ClickSelectingTool,cr=H.ActionTool,dr=H.ClickCreatingTool,fr=H.HTMLInfo,gr=H.ContextMenuTool,mr=H.DragSelectingTool,pr=H.PanningTool,yr=H.TextEditingTool,xr=H.ToolManager,xs=H.Animation,br=H.AnimationManager,wr=H.AnimationTrigger,vr=H.Layer,Ti=H.Diagram,kr=H.Palette,Pr=H.Overview,Sr=H.Brush,Mr=H.GraphObject,qe=H.Panel,Nr=H.RowColumnDefinition,yi=H.Shape,Li=H.TextBlock,fn=H.Picture,Cr=H.Part,bs=H.Adornment,ws=H.Node,vs=H.Link,gn=H.Placeholder,Ar=H.Layout,Tr=H.LayoutNetwork,Lr=H.LayoutVertex,Dr=H.LayoutEdge,Fr=H.GridLayout,Or=H.PanelLayout,Rr=H.CircularLayout,Er=H.CircularNetwork,Ir=H.CircularVertex,Br=H.CircularEdge,Vr=H.ForceDirectedLayout,zr=H.ForceDirectedNetwork,Xr=H.ForceDirectedVertex,Kr=H.ForceDirectedEdge,mn=H.LayeredDigraphLayout,Yr=H.LayeredDigraphNetwork,Ur=H.LayeredDigraphVertex,jr=H.LayeredDigraphEdge,Gr=H.TreeLayout,qr=H.TreeNetwork,Hr=H.TreeVertex,Wr=H.TreeEdge,$r=H.Themes,Jr=H.ThemeManager,Zr=H.Router,Qr=H.version,_r=H.AnimationStyle,pn=H.AutoScale,ta=H.Curve,ea=H.CycleMode,ia=H.Flip,sa=H.ImageStretch,na=H.LayoutConditions,oa=H.LinkAdjusting,ra=H.Orientation,aa=H.PortSpreading,yn=H.Routing,xn=H.ScrollMode,ha=H.CollapsePolicy,la=H.Sizing,ua=H.TriggerStart,bn=H.Stretch,ca=H.TextFormat,ks=H.TextOverflow,da=H.ViewboxStretch,Ps=H.Wrap,fa=H.BrushType,ga=H.ColorSpace,ma=H.GeometryStretch,pa=H.GeometryType,ya=H.SegmentType,xa=H.BindingMode,ba=H.ChangeType,wa=H.CircularArrangement,va=H.CircularDirection,ka=H.CircularNodeDiameterFormula,Pa=H.CircularSorting,Sa=H.GridAlignment,Ma=H.GridArrangement,Na=H.GridSorting,Ca=H.LayeredDigraphAggressive,Aa=H.LayeredDigraphAlign,Ta=H.LayeredDigraphCycleRemove,La=H.LayeredDigraphInit,Da=H.LayeredDigraphLayering,Fa=H.LayeredDigraphPack,Oa=H.TreeAlignment,Ra=H.TreeArrangement,Ea=H.TreeCompaction,Ia=H.TreeLayerStyle,Ba=H.TreePath,Va=H.TreeSorting,za=H.TreeStyle,Xa=H.GestureMode,Ka=H.LinkingDirection,Ya=H.ReshapingBehavior,Ua=H.TextEditingAccept,ja=H.TextEditingStarting,Ga=H.TextEditingState,wn=H.WheelMode;var eo=on`#filter-bar{background-color:var(--calcite-color-foreground-1);position:absolute;top:16px;right:196px;z-index:100;box-shadow:var(--calcite-shadow-sm)}#filteredViewButtonDiv{padding:8px}#filteredViewButtonLabel{--calcite-label-margin-bottom: 0}#graph-navigation-bar{background-color:var(--calcite-color-foreground-1);position:absolute;top:16px;right:16px;z-index:100}#graph-navigation-controls{position:absolute;top:0;right:0;box-shadow:var(--calcite-shadow-sm)}.z-index-1{z-index:1}#diagram-panel{--calcite-panel-space: 0px}#diagram-shell-panel{--calcite-color-background: var(--calcite-color-foreground-1);padding:16px}`,io=15,so=15,no=10,xi=new pi(220,48),oo=1,ro=8,vn=new pi(48,48),ao=new pi(16,16),kn=new pi(153,17),ho='400 0.75rem "Avenir Next", Avenir, "Helvetica Neue", sans-serif',lo='500 0.75rem "Avenir Next", Avenir, "Helvetica Neue", sans-serif',uo="val(--calcite-color-background)",co=bi("--calcite-color-border-1"),Pn=bi("--calcite-color-foreground-1"),Di=bi("--calcite-color-text-1"),Sn=bi("--calcite-color-border-input"),fo=bi("--calcite-color-foreground-1"),Fi=1,Nn=.3,Ss=1,Cn=.2,go=1;function mo(K){let m=document.createElement("div");m.style.width="100%",m.style.height="100%",K.appendChild(m);let rt=new Ti(m,{click:Po,contentAlignment:Ne.Center,dragSelectingTool:null,hoverDelay:50,initialAutoScale:pn.Uniform,layout:new mn({columnSpacing:io,layerSpacing:so}),padding:no,scrollMode:xn.Infinite,"toolManager.hoverDelay":50,"toolManager.mouseWheelBehavior":wn.Zoom});rt.nodeTemplate=new ws("Auto",{click:So,movable:!1,opacity:Fi,toolTip:new bs("Auto",{isShadowed:!0,margin:new ys(12,16,6,16),padding:0,shadowBlur:16,shadowColor:To(Di,.05),shadowOffset:new cn(0,0)}).add(new qe("Vertical",{background:fo,margin:0}).add(new Li({margin:14,stroke:Di}).bind("text","title")))}).bind("text","title").add(new yi({desiredSize:xi,fill:Pn,geometryString:ko(xi.width,xi.height,ro,vn.width,!!Pn),height:xi.height,portId:"",stroke:co,strokeWidth:oo,width:xi.width})).add(new qe("Horizontal",{alignment:Ne.Left,stretch:bn.Horizontal}).add(new qe("Horizontal",{alignment:Ne.Left,desiredSize:vn,margin:1}).add(new qe("Horizontal",{alignment:Ne.Center,margin:16}).add(new fn({desiredSize:ao}).bind("source","",dt=>un(dt.itemType,dt.itemTypeKeywords)))),new qe("Horizontal",{alignment:Ne.Right,margin:new ys(4,8,0,8)}).add(new qe("Vertical",{}).add(new Li({alignment:Ne.Left,desiredSize:kn,font:lo,overflow:ks.Ellipsis,stroke:Di,wrap:Ps.None}).bind("text","title"),new Li({alignment:Ne.Left,desiredSize:kn,font:ho,overflow:ks.Ellipsis,stroke:Di,wrap:Ps.None}).bind("text","itemTypeForDisplay"))))),rt.commandHandler.zoomFactor=1.05,rt.setDivBackground(uo);let bt=rt.toolManager.clickSelectingTool;bt.standardMouseSelect=function(){};let Pt=rt.toolManager.draggingTool;return Pt.isEnabled=!1,rt.linkTemplate=new vs({corner:5,movable:!1,routing:yn.Orthogonal,selectable:!1}).add(new yi({opacity:Ss,stroke:Sn}),new yi({fill:Sn,opacity:Ss,stroke:null,toArrow:"Standard"})),rt}function He(K,m){K.model=new dn(m.nodes,m.links,{linkFromPortIdProperty:"fromPort",linkToPortIdProperty:"toPort"})}function po(K,m,rt,bt=!0){if(bt){let q=Mo(K,rt);q.addEventListener("calciteSwitchChange",()=>document.dispatchEvent(new CustomEvent("filteredViewChanged",{detail:q.checked})))}let{resetButton:Pt,centerButton:dt,zoomInButton:gt,zoomOutButton:kt}=No(K,rt);Pt.addEventListener("click",()=>Ao(m)),dt.addEventListener("click",()=>m.zoomToFit()),gt.addEventListener("click",()=>m.commandHandler.increaseZoom()),kt.addEventListener("click",()=>m.commandHandler.decreaseZoom())}function yo(K,m,rt){let bt=mo(K);return He(bt,m),po(K,bt,rt),bt}function An(K){let m=new Set,rt=new Set;function bt(dt){dt.findLinksInto().each(gt=>{rt.add(gt);let kt=gt.fromNode;kt&&!m.has(kt)&&(m.add(kt),bt(kt))})}bt(K);function Pt(dt){dt.findLinksOutOf().each(gt=>{rt.add(gt);let kt=gt.toNode;kt&&!m.has(kt)&&(m.add(kt),Pt(kt))})}return Pt(K),{connectedNodes:m,connectedLinks:rt}}function xo(K,m=!1,rt){let bt=[],Pt=K.map(gt=>{if(gt.type!=="Group"){let kt=vo(gt);return wo(gt,kt,m,rt)}else{bt.push(gt.id);return}}).filter(gt=>gt!==void 0),dt=[];return Pt.forEach(gt=>{(K.find(kt=>kt.id===gt.itemId)?.dependencies||[]).forEach(kt=>{let q=Pt.find(Zt=>Zt?.itemId===kt);q&&dt.push({from:q.key,fromSpot:Ne.AllSides,to:gt.key,toSpot:Ne.AllSides})})}),{nodes:Pt,links:dt,groupPseudoNodes:bt}}function bo(K,m,rt,bt=!0){let Pt=K.diagram;if(!Pt)return;let dt={};if(bt){for(let gt of Pt.nodes)dt[gt.key]=gt===K?Fi:Nn;for(let gt of Pt.links){let kt=`${gt.fromNode?.key}-${gt.toNode?.key}`;dt[kt]=Cn}{let{connectedNodes:gt,connectedLinks:kt}=An(K);for(let q of gt)dt[q.key]=Fi;for(let q of kt){let Zt=`${q.fromNode?.key}-${q.toNode?.key}`;dt[Zt]=go}}}if(rt&&(rt.adornedObject=K),bt){let gt=new xs;gt.duration=1;for(let kt of Pt.nodes)gt.add(kt,"opacity",kt.opacity,dt[kt.key]);for(let kt of Pt.links){let q=`${kt.fromNode?.key}-${kt.toNode?.key}`;gt.add(kt,"opacity",kt.opacity,dt[q])}gt.start()}}function Mn(K,m,rt,bt,Pt=!0){if(K.length===0)return;let dt=m[0].diagram;if(!dt)return;let gt={};if(Pt){for(let kt of dt.nodes){let q=K.includes(kt.key);gt[kt.key]=!rt||q?Fi:Nn}for(let kt of dt.links){let q=`${kt.fromNode?.key}-${kt.toNode?.key}`;gt[q]=rt?Cn:Ss}}if(Object.keys(bt).forEach(kt=>{bt[kt].adornedObject=null}),Pt){let kt=new xs;kt.duration=1;for(let q of dt.nodes)kt.add(q,"opacity",q.opacity,gt[q.key]);for(let q of dt.links){let Zt=`${q.fromNode?.key}-${q.toNode?.key}`;kt.add(q,"opacity",q.opacity,gt[Zt])}kt.start()}}function wo(K,m,rt=!1,bt){return{key:m,title:K.title,itemId:K.id,itemType:K.type,itemTypeForDisplay:Co(K.type,K.typeKeywords),itemTypeKeywords:K.typeKeywords,group:K.type,url:rt?`${bt}?id=${K.id}`:void 0}}function vo(K){return K.id}function ko(K,m,rt,bt=0,Pt=!1){let dt="";Pt&&(dt+="F");let gt=K-2*rt,kt=m-2*rt;return dt+=" M0 0",dt+=` h${gt}`,dt+=` a${rt} ${rt} 0 0 1 ${rt} ${rt}`,dt+=` v${kt}`,dt+=` a${rt} ${rt} 0 0 1 ${-rt} ${rt}`,dt+=` h${-gt}`,dt+=` a${rt} ${rt} 0 0 1 ${-rt} ${-rt}`,dt+=` v${-kt}`,dt+=` a${rt} ${rt} 0 0 1 ${rt} ${-rt}`,bt>0&&(dt+=` M${bt-rt} 0 v${m}`),dt}function Po(){document.dispatchEvent(new CustomEvent("clickInDiagram"))}function So(K,m){let rt=m.part;rt instanceof ws&&(rt.selectionAdorned=!1,document.dispatchEvent(new CustomEvent("clickOnNode",{detail:rt})))}function Mo(K,m){let rt=document.createElement("calcite-switch");rt.id="filteredViewButton",rt.label=m.filteredView;let bt=document.createElement("calcite-label");bt.id="filteredViewButtonLabel",bt.setAttribute("layout","inline"),bt.innerHTML=m.filteredView,bt.appendChild(rt);let Pt=document.createElement("div");Pt.id="filteredViewButtonDiv",Pt.appendChild(bt);let dt=document.createElement("calcite-action-bar");dt.id="filter-bar-controls",dt.layout="horizontal",dt.expandDisabled=!0,dt.appendChild(Pt);let gt=document.createElement("div");return gt.id="filter-bar",K.appendChild(gt),gt.appendChild(dt),rt}function No(K,m){let rt=document.createElement("calcite-action");rt.icon="reset",rt.id="showHideGrayedOutButton";let bt=document.createElement("calcite-tooltip");bt.id="resetButtonTooltip",bt.innerHTML=m.reset,bt.overlayPositioning="fixed",bt.placement="bottom",bt.referenceElement=rt.id;let Pt=document.createElement("calcite-action");Pt.icon="zoom-to-object",Pt.id="centerButton";let dt=document.createElement("calcite-tooltip");dt.id="centerButtonTooltip",dt.innerHTML=m.centerDiagram,dt.overlayPositioning="fixed",dt.placement="bottom",dt.referenceElement=Pt.id;let gt=document.createElement("calcite-action");gt.icon="plus",gt.id="zoomInButton";let kt=document.createElement("calcite-tooltip");kt.id="zoomInButtonTooltip",kt.innerHTML=m.zoomIn,kt.overlayPositioning="fixed",kt.placement="bottom",kt.referenceElement=gt.id;let q=document.createElement("calcite-action");q.appearance="solid",q.icon="minus",q.id="zoomOutButton";let Zt=document.createElement("calcite-tooltip");Zt.id="zoomOutButtonTooltip",Zt.innerHTML=m.zoomOut,Zt.overlayPositioning="fixed",Zt.placement="bottom",Zt.referenceElement=q.id;let V=document.createElement("calcite-action-bar");V.id="graph-navigation-controls",V.layout="horizontal",V.expandDisabled=!0,V.appendChild(rt),V.appendChild(bt),V.appendChild(Pt),V.appendChild(dt),V.appendChild(gt),V.appendChild(kt),V.appendChild(q),V.appendChild(Zt);let We=document.createElement("div");return We.id="graph-navigation-bar",K.appendChild(We),We.appendChild(V),{resetButton:rt,centerButton:Pt,zoomInButton:gt,zoomOutButton:q}}function Co(K,m){let rt=K;if(K==="Feature Service"){let bt=m.indexOf("View Service")>-1,Pt=m.indexOf("Table")>-1;rt=bt&&Pt?"Table (hosted, view)":Pt?"Table (hosted)":bt?"Feature Layer (hosted, view)":"Feature Layer (hosted)"}return K==="Web Mapping Application"&&(rt=m.indexOf("configurableApp")>-1?"Instant App":rt),rt=K==="Geoprocessing Service"?"Tool":rt,rt=K==="Feed"?"Feed (hosted)":rt,rt=K==="Real Time Analytic"?"Real Time Analytic (hosted)":rt,rt=K==="Big Data Analytic"?"Big Data Analytic (hosted)":rt,rt=K==="Vector Tile Service"?"Tile Layer":rt,rt}function Ao(K){K.zoomToFit(),document.dispatchEvent(new CustomEvent("reset"))}function bi(K){let m=document.body;return getComputedStyle(m).getPropertyValue(K).trim()}function To(K,m){if(K=K.replace(/^#/,""),K.length===3&&(K=K.split("").map(dt=>dt+dt).join("")),K.length!==6)throw new Error("Invalid hex color");let rt=parseInt(K.slice(0,2),16),bt=parseInt(K.slice(2,4),16),Pt=parseInt(K.slice(4,6),16);return`rgba(${rt}, ${bt}, ${Pt}, ${m})`}var Lo=8,Do=15,Fo=Ro("--calcite-color-brand"),Oo=4;function Ro(K){let m=document.documentElement;return getComputedStyle(m).getPropertyValue(K).trim()}var Ms=class{constructor(m,rt,bt,Pt){this.indexPanel=m,this.diagramPanel=rt,this.diagramTranslations=bt,this.diagramKey=Pt,this.currentSelectedGroupId="",this.currentSelectedItemId="",this.diagramNeedsRedraw=!1,this.usefilteredView=!1,this.handle_clickInDiagram=dt=>{dt.stopImmediatePropagation(),(this.currentSelectedGroupId||this.currentSelectedItemId)&&(this.currentSelectedGroupId="",this.currentSelectedItemId="",this.diagramNeedsRedraw=this.usefilteredView,this.redraw())},this.handle_clickOnNode=dt=>{dt.stopImmediatePropagation();let gt=dt.detail.data.key;this.redraw(gt,gt===this.currentSelectedItemId)},this.handle_filteredViewChanged=dt=>{this.usefilteredView=dt.detail,this.diagramNeedsRedraw=!!this.currentSelectedGroupId||!!this.currentSelectedItemId,this.redraw(this.currentSelectedItemId||this.currentSelectedGroupId)},this.handle_reset=dt=>{dt.stopImmediatePropagation(),this.reset()},this.handle_solutionItemSelect=dt=>{dt.stopImmediatePropagation();let gt=dt.detail.itemId;this.redraw(gt,gt===this.currentSelectedItemId||gt===this.currentSelectedGroupId,!1)},Ti.licenseKey===""&&(Ti.licenseKey=Pt??"")}create(m,rt){this.collection=m,this.index=document.createElement("solution-item-accordion"),this.index.linkType="action",this.index.listSelectionMode="single",this.index.typeKeywords=rt,this.index.style.overflowY="auto",this.indexPanel.appendChild(this.index),this.index.templateInfos=m,this.allNodesAndLinks=xo(m),this.diagram=yo(this.diagramPanel,this.allNodesAndLinks,this.diagramTranslations),this.diagram.addDiagramListener("LayoutCompleted",()=>{setTimeout(()=>{this.diagram.zoomToFit()},1e3)}),vs.setRoutingParameter(44,600942),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(m=!0){this.index.deselectAll(),m&&this.index.collapseAll();let rt=this.getNodesFromDiagram(this.diagram),bt=rt.map(Pt=>Pt.data.key);Mn(bt,rt,!1,this.diagramNodeHighlighterIndex)}createNodeHighlighters(){this.diagramNodeIndex={},this.diagramNodeHighlighterIndex={},this.getNodesFromDiagram(this.diagram).forEach(m=>{this.diagramNodeIndex[m.data.key]=m;let rt=new bs("Auto",{background:"transparent",margin:2});rt.add(new yi("RoundedRectangle",{fill:"transparent",parameter1:Lo,parameter2:Do,stroke:Fo,strokeWidth:Oo})),rt.add(new gn({margin:1})),this.diagramNodeHighlighterIndex[m.data.key]=rt})}getNodeById(m){return this.diagramNodeIndex[m]}getNodesFromDiagram(m){let rt=[],bt=m.nodes.iterator;for(;bt.next();)rt.push(bt.value);return rt}redraw(m="",rt=!1,bt=!0){let Pt=this.allNodesAndLinks.groupPseudoNodes.includes(m);this.diagramNeedsRedraw&&(He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),this.diagramNeedsRedraw=!1);let dt=!1;if(this.clearSelections(bt),!!m){if(Pt){if(this.currentSelectedItemId="",this.currentSelectedGroupId!==m?this.currentSelectedGroupId=m:rt&&(this.currentSelectedGroupId=this.currentSelectedGroupId?"":m,dt=this.usefilteredView&&!this.currentSelectedGroupId),this.currentSelectedGroupId){this.usefilteredView&&(He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters());let gt=this.collection.filter(q=>q.id===m)[0],kt=gt.dependencies.map(q=>this.diagramNodeIndex[q]);if(this.usefilteredView){let q=kt.map(Zt=>Zt.data);He(this.diagram,{nodes:q,links:[]})}else Mn(gt.dependencies,kt,!0,this.diagramNodeHighlighterIndex);this.index.selectItem(this.currentSelectedGroupId)}}else{this.currentSelectedGroupId="",this.currentSelectedItemId!==m?this.currentSelectedItemId=m:rt&&(this.currentSelectedItemId=this.currentSelectedItemId?"":m,dt=this.usefilteredView&&!this.currentSelectedItemId);let gt=this.getNodeById(m);if((!gt||this.usefilteredView)&&(He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),gt=this.getNodeById(m),!gt))return;if(this.currentSelectedItemId){if(this.usefilteredView){let kt=An(gt);kt.connectedNodes.add(gt);let q=Array.from(kt.connectedNodes).map(V=>V.data),Zt=Array.from(kt.connectedLinks).map(V=>V.data);if(He(this.diagram,{nodes:q,links:Zt}),this.createNodeHighlighters(),gt=this.getNodeById(m),!gt)return}gt&&setTimeout(()=>bo(gt,!0,this.diagramNodeHighlighterIndex[m]),1),this.index.selectItem(this.currentSelectedItemId)}}dt&&this.reset()}}reset(){this.diagramNeedsRedraw=!1,this.currentSelectedGroupId="",this.currentSelectedItemId="",He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),this.clearSelections()}},Ns=class extends an{constructor(){super(...arguments),this.diagramKey="",this.templateInfoGraph=[],this.typeKeywords=[],this._diagramPanel=ms(),this._diagramShell=ms(),this._translations=ln({name:"solution-item-diagram",blocking:!0})}static{this.properties={diagramKey:1,templateInfoGraph:0,typeKeywords:0,_diagramPanel:16,_diagramShell:16,_translations:16}}static{this.styles=eo}updated(){if(this.solutionDisplay&&(this.solutionDisplay.dispose(),this.solutionDisplay=void 0),this.templateInfoGraph.length>0){let m={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 Ms(this._diagramShell.value,this._diagramPanel.value,m,this.diagramKey),this.solutionDisplay.create(this.templateInfoGraph,this.typeKeywords)}requestAnimationFrame(()=>this._preventDiagramScrollbars())}disconnectedCallback(){super.disconnectedCallback(),this.solutionDisplay&&(this.solutionDisplay.dispose(),this.solutionDisplay=void 0)}render(){return rn`<calcite-shell><calcite-shell-panel id=diagram-shell-panel slot=panel-start ${ps(this._diagramShell)}></calcite-shell-panel><calcite-panel class="z-index-1" id=diagram-panel slot=panel-bottom ${ps(this._diagramPanel)}></calcite-panel></calcite-shell>`}_preventDiagramScrollbars(){if(!this._diagramPanel.value)return;let m=this._diagramPanel.value.shadowRoot;if(!m)return;let rt=m.querySelector(".content-wrapper");rt instanceof HTMLElement&&(rt.style.overflow="hidden")}};hn("solution-item-diagram",Ns);export{Ns as SolutionItemDiagram};
50
+ "nodeParentKeyProperty": `+this.quote(this.nodeParentKeyProperty)),t+e}aw(t){super.aw(t),t.nodeParentKeyProperty&&(this.nodeParentKeyProperty=t.nodeParentKeyProperty)}hw(t){t.nodeParentKeyProperty!==void 0&&t.nodeParentKeyProperty!==this.nodeParentKeyProperty&&m.o("applyIncrementalJson cannot change Model properties"),super.hw(t)}maybeEnsureLinkReference(t){return t}get nodeParentKeyProperty(){return this.Nl}set nodeParentKeyProperty(t){let e=this.Nl;e!==t&&(this.En(t,je,"nodeParentKeyProperty"),this.Nl=t,this.t("nodeParentKeyProperty",e,t))}getParentKeyForNodeData(t){if(t===null)return;let e=this.Nl;if(e==="")return;let i=this.Lt(t,e);if(i!==void 0){if(this.isKeyType(i))return i;m.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)&&m.si(e,"number or string",je,"setParentKeyForNodeData:key"),t===null)return;let i=this.Nl;if(i==="")return;if(e=this.maybeEnsureLinkReference(e),!this.containsNodeData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);s!==e&&(this.ln(s,t),this.nt(t,i,e),this.findNodeDataForKey(e)===null&&this.an(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.En(t,je,"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.Lt(t,e);if(i===void 0)return"";if(typeof i=="string")return i;m.o("getParentLinkCategoryForNodeData found a non-string category for "+t+": "+i)}getLinkCategoryForData(t){return this.getParentLinkCategoryForNodeData(t)}setParentLinkCategoryForNodeData(t,e){if(m.s(e,"string",je,"setParentLinkCategoryForNodeData:cat"),t===null)return;let i=this.cc;if(i==="")return;if(!this.containsNodeData(t)){this.nt(t,i,e);return}let s=this.Lt(t,i);s===void 0&&(s=""),s!==e&&(this.nt(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.setParentKeyForNodeData(e,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.Lt(t,e);s!==i&&(this.nt(t,e,i),this.raiseDataChanged(t,e,s,i))}cw(t,e){super.cw(t,e);let i=this.be.iterator;for(;i.next();){let s=i.value;this.lL(s,t,e)}}lL(t,e,i){if(this.getParentKeyForNodeData(t)===e){let s=this.Nl;this.nt(t,s,i),this.Ft("nodeParentKey",2,s,t,e,i),typeof s=="string"&&this.updateTargetBindings(t,s)}}Dg(t){super.Dg(t);let e=this.getKeyForNodeData(t),i=this.iw(e);if(i!==null){let s=m.st(),n=i.iterator;for(;n.next();){let o=n.value;if(this.containsNodeData(o)&&this.getParentKeyForNodeData(o)===e){let r=this.Nl;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.ln(e,s[o]);m.Z(s)}}vg(t){super.vg(t);let e=this.getParentKeyForNodeData(t);e=this.maybeEnsureLinkReference(e),this.findNodeDataForKey(e)===null&&this.an(e,t)}fw(t){super.fw(t);let e=this.getParentKeyForNodeData(t);this.ln(e,t)}Tg(t,e){super.Tg(t,e),this.setParentLinkCategoryForNodeData(e,this.getParentLinkCategoryForNodeData(t)),this.setParentKeyForNodeData(e,this.getParentKeyForNodeData(t))}get type(){return"TreeModel"}Nx(){return!0}Cx(){return!0}}ut.Sl(je,"TreeModel");var ts=(x=>(x[x.ConstantSpacing=0]="ConstantSpacing",x[x.ConstantDistance=1]="ConstantDistance",x[x.ConstantAngle=2]="ConstantAngle",x[x.Packed=3]="Packed",x))(ts||{}),es=(x=>(x[x.Clockwise=10]="Clockwise",x[x.Counterclockwise=11]="Counterclockwise",x[x.BidirectionalLeft=12]="BidirectionalLeft",x[x.BidirectionalRight=13]="BidirectionalRight",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[x.Optimized=24]="Optimized",x))(is||{}),ss=(x=>(x[x.Pythagorean=30]="Pythagorean",x[x.Circular=31]="Circular",x))(ss||{});class Be extends _t{gi;tu;Ok;Fg;Ik;Ga;aL;hL;cL;Is;uw;dw;fc;gw;sF;Rg;Og;Ig;eu;He;P;Si;Mi;In;Eg;constructor(t){super(),this.gi=0,this.tu=0,this.Ok=0,this.Fg=360,this.Ik=0,this.Ga=0,this.aL=new P,this.hL=30,this.cL=0,this.Is=0,this.uw=0,this.dw=new Hs,this.fc=0,this.gw=0,this.sF=600,this.Rg=NaN,this.Og=1,this.Ig=0,this.eu=360,this.He=0,this.P=10,this.Si=24,this.Mi=Ie.standardComparer,this.In=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.In=this.In,t.Eg=this.Eg}fe(t){t in is?this.sorting=t:t in es?this.direction=t:t in ts?this.arrangement=t:t in ss?this.nodeDiameterFormula=t:super.fe(t)}createNetwork(){return new Ws(this)}m3(t,e,i){t=this.p3(t);let s=this.Ik,n=this.hL,o=this.gi,r=this.tu,a=this.Ok,h=this.Fg,l=this.Ga,u=this.cL,c=this.Is,d=this.uw;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 g=0;!(g>=t.length||(e.add(t.elt(g)),g+1>=t.length));g+=2)i.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&e.reverse(),t=new q,t.addAll(e),t.addAll(i)):(this.arrangement===3&&i.reverse(),t=new q,t.addAll(i),t.addAll(e))}let f=t.length;u=0;let p=0;for(let g=0;g<t.length;g++){let y=a+h*p*(this.direction===10?1:-1)/f,b=t.elt(g).diameter;isNaN(b)&&(b=t.elt(g).Ya(y)),h<360&&(g===0||g===t.length-1)&&(b/=2),u+=b,p++}if(isNaN(o)||s===3){if(isNaN(l)&&(l=6),s!==0&&s!==3){let g=-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.Ya(0),isNaN(v.diameter)&&v.Ya(0),g=Math.max(g,(b.diameter+v.diameter)/2)}if(d=g+l,s===2){let y=2*Math.PI/f,b=(g+l)/y;r>1?(o=b,c=o*r):(c=b,o=c)}else o=this.Ek(d*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180)}else o=this.Ek(u+(h>=360?f:f-1)*(s!==3?l:l*1.6),r,a*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;let g=this.fL(o,c,a*Math.PI/180,h*Math.PI/180);if(isNaN(l))s===0&&(l=(g-u)/(h>=360?f:f-1));else if(s===0){let y=(g-u)/(h>=360?f:f-1);y<l?(o=this.Ek(u+l*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180),c=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.Ya(0),isNaN(S.diameter)&&S.Ya(0),y=Math.max(y,(k.diameter+S.diameter)/2)}let b=y+l,v=this.Ek(b*(h>=360?f:f-1),r,a*Math.PI/180,h*Math.PI/180);v>o?(o=v,c=o*r,d=b):d=g/(h>=360?f:f-1)}}return this.Ik=s,this.hL=n,this.gi=o,this.tu=r,this.Ok=a,this.Fg=h,this.Ga=l,this.cL=u,this.Is=c,this.uw=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 q;i.addAll(e.iterator);let s=new q,n=new q;i=this.m3(i,s,n);let o=this.Ik,r=this.gi,a=this.Ok,h=this.Fg,l=this.Ga,u=this.Is,c=this.uw;if((this.direction===12||this.direction===13)&&o===3)this.nF(i,h,a-h/2,10);else if(this.direction===12||this.direction===13){let d=0;switch(o){case 1:d=this.Uk(r,u,a,c)*180/Math.PI;break;case 0:{let f=0,p=0,g=s.first();g!==null&&(f=g.Ya(Math.PI/2));let y=n.first();y!==null&&(p=y.Ya(Math.PI/2)),d=this.Uk(r,u,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.mw(s,h/2,a,11);break;case 0:this.pw(s,h/2,a,11);break;case 2:this.yw(s,h/2,a,11);break}switch(o){case 1:this.mw(n,h/2,a+d,10);break;case 0:this.pw(n,h/2,a+d,10);break;case 2:this.yw(n,h/2,a+d,10);break}}else{switch(o){case 1:this.mw(n,h/2,a,11);break;case 0:this.pw(n,h/2,a,11);break;case 2:this.yw(n,h/2,a,11);break}switch(o){case 1:this.mw(s,h/2,a+d,10);break;case 0:this.pw(s,h/2,a+d,10);break;case 2:this.yw(s,h/2,a+d,10);break}}}else switch(o){case 1:this.mw(i,h,a,this.direction);break;case 0:this.pw(i,h,a,this.direction);break;case 2:this.yw(i,h,a,this.direction);break;case 3:this.nF(i,h,a,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}yw(t,e,i,s){let n=this.Fg,o=this.gi,r=this.Is,a=i*Math.PI/180,h=e*Math.PI/180,l=t.length;for(let u=0;u<l;u++){let c=a+(s===10?u*h/(n>=360?l:l-1):-(u*h)/l),d=t.elt(u),f=o*Math.tan(c)/r,p=Math.sqrt((o*o+r*r*f*f)/(1+f*f));d.centerX=p*Math.cos(c),d.centerY=p*Math.sin(c),d.actualAngle=c*180/Math.PI}}pw(t,e,i,s){let n=this.gi,o=this.Is,r=this.Ga,a=i*Math.PI/180,h=t.length;for(let l=0;l<h;l++){let u=t.elt(l),c=t.elt(l===h-1?0:l+1),d=n*Math.cos(a),f=o*Math.sin(a);u.centerX=d,u.centerY=f,u.actualAngle=a*180/Math.PI,isNaN(u.diameter)&&u.Ya(0),isNaN(c.diameter)&&c.Ya(0);let p=(u.diameter+c.diameter)/2,g=this.Uk(n,o,s===10?a:-a,p+r);a+=s===10?g:-g}}mw(t,e,i,s){let n=this.gi,o=this.Is,r=this.uw,a=i*Math.PI/180,h=t.length;for(let l=0;l<h;l++){let u=t.elt(l);u.centerX=n*Math.cos(a),u.centerY=o*Math.sin(a),u.actualAngle=a*180/Math.PI;let c=this.Uk(n,o,s===10?a:-a,r);a+=s===10?c:-c}}nF(t,e,i,s){let n=this.gw,o=this.Fg;if(this.fc=0,this.dw=new Hs,e<360){for(n=i+(s===10?o:-o);n<0;)n+=360;n%=360,n>180&&(n-=360),n*=Math.PI/180,this.gw=n,this.oF(t,e,i,s)}else this.rF(t,e,i,s);this.dw.commit(t)}rF(t,e,i,s){let n=this.gi,o=this.Is,r=this.Ga,a=this.tu,h=n*Math.cos(i*Math.PI/180),l=o*Math.sin(i*Math.PI/180),u=t.toArray();if(u.length===3){u[0].centerX=n,u[0].centerY=0,u[1].centerX=u[0].centerX-u[0].width/2-u[1].width/2-r,u[1].y=u[0].y,u[2].centerX=(u[0].centerX+u[1].centerX)/2,u[2].y=u[0].y-u[2].height-r;return}else if(u.length===4){u[0].centerX=n,u[0].centerY=0,u[2].centerX=-u[0].centerX,u[2].centerY=u[0].centerY,u[1].centerX=0,u[1].y=Math.min(u[0].y,u[2].y)-u[1].height-r,u[3].centerX=0,u[3].y=Math.max(u[0].y+u[0].height+r,u[2].y+u[2].height+r);return}let c=P.l();for(let k=0;k<u.length&&(u[k].centerX=h,u[k].centerY=l,!(k>=u.length-1));k++)this.lF(h,l,u,k,s,c)||this.aF(h,l,u,k,s,c),h=c.x,l=c.y;if(P.i(c),this.fc++,this.fc>23)return;let d=u[0].centerX,f=u[0].centerY,p=u[u.length-1].centerX,g=u[u.length-1].centerY,y=Math.abs(d-p)-((u[0].width+u[u.length-1].width)/2+r),b=Math.abs(f-g)-((u[0].height+u[u.length-1].height)/2+r),v=0;if(Math.abs(b)<1){let k=Math.abs(d-p),S=(u[0].width+u[u.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(g)?w=p>0!=f>g:w=g>0!=d<p,w=s===10?w:!w,w&&(v=-Math.abs(v),v=Math.min(v,-u[u.length-1].width),v=Math.min(v,-u[u.length-1].height)),this.dw.y3(v,u),Math.abs(v)>1&&(this.fc<8?this.gi-=v/(2*Math.PI):u.length<5&&v>10?this.gi/=2:this.gi-=v>0?1.7:-2.3,this.Is=this.gi*a,this.rF(t,e,i,s))}oF(t,e,i,s){let n=this.gi,o=this.Is,r=this.tu,a=n*Math.cos(i*Math.PI/180),h=o*Math.sin(i*Math.PI/180),l=P.l(),u=t.toArray();for(let p=0;p<u.length&&(u[p].centerX=a,u[p].centerY=h,!(p>=u.length-1));p++)this.lF(a,h,u,p,s,l)||this.aF(a,h,u,p,s,l),a=l.x,h=l.y;if(P.i(l),this.fc++,this.fc>23)return;let c=Math.atan2(h,a),d=s===10?this.gw-c:c-this.gw;d=Math.abs(d)<Math.abs(d-2*Math.PI)?d:d-2*Math.PI;let f=d*(n+o)/2;this.dw.w3(f,u),Math.abs(f)>1&&(this.fc<8?this.gi-=f/(2*Math.PI):this.gi-=f>0?1.7:-2.3,this.Is=this.gi*r,this.oF(t,e,i,s))}lF(t,e,i,s,n,o){let r=this.Ga,a=this.gi,h=this.Is,l=0,u=0,c=(i[s].width+i[s+1].width)/2+r,d=!1;if(e>=0!=(n===10)){if(l=t+c,l>a){if(l=t-c,l<-a)return o.x=l,o.y=u,!1;d=!0}}else if(l=t-c,l<-a){if(l=t+c,l>a)return o.x=l,o.y=u,!1;d=!0}return u=Math.sqrt(1-Math.min(1,l*l/(a*a)))*h,e<0!==d&&(u=-u),Math.abs(e-u)>(i[s].height+i[s+1].height)/2?(o.x=l,o.y=u,!1):(o.x=l,o.y=u,!0)}aF(t,e,i,s,n,o){let r=this.Ga,a=this.gi,h=this.Is,l=0,u=0,c=(i[s].height+i[s+1].height)/2+r,d=!1;if(t>=0!=(n===10)){if(u=e-c,u<-h){if(u=e+c,u>h)return o.x=l,o.y=u,!1;d=!0}}else if(u=e+c,u>h){if(u=e-c,u<-h)return o.x=l,o.y=u,!1;d=!0}return l=Math.sqrt(1-Math.min(1,u*u/(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=u,!1):(o.x=l,o.y=u,!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.gi,i.y=this.arrangementOrigin.y+this.Is),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.aL=o.subtract(s)}}commitLinks(){if(this.network!==null){let t=this.network.edges.iterator;for(;t.next();)t.value.commit()}}fL(t,e,i,s){let n=this.sF;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 u=Math.sin(h);r+=Math.sqrt(1-o*o*u*u)*a}return i!==void 0&&s!==void 0?(t>e?t:e)*r:4*(t>e?t:e)*r}Ek(t,e,i,s){let n=0;return i!==void 0&&s!==void 0?n=this.fL(1,e,i,s):n=this.fL(1,e),t/n}Uk(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}}p3(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.x3(this.b3(t));default:m.o("Invalid sorting type.")}return t}b3(t){let e=[];for(let s=0;s<t.length;s++)e.push(0);let i=new q;for(let s=0;s<t.length;s++){let n=-1,o=-1;if(s===0)for(let u=0;u<t.length;u++){let c=t.elt(u).edgesCount;c>n&&(n=c,o=u)}else for(let u=0;u<t.length;u++){let c=e[u];c>n&&(n=c,o=u)}i.add(t.elt(o)),e[o]=-1;let r=t.elt(o),a=0,h=r.sourceEdges;for(;h.next();){let u=h.value.fromVertex;a=t.indexOf(u),!(a<0)&&e[a]>=0&&e[a]++}let l=r.destinationEdges;for(;l.next();){let u=l.value.toVertex;a=t.indexOf(u),!(a<0)&&e[a]>=0&&e[a]++}}return i}x3(t){let e=[];for(let c=0;c<t.length;c++){let d=t.elt(c);e[c]=[];let f=0,p=d.destinationEdges;for(;p.next();){let y=p.value.toVertex;f=t.indexOf(y),f!==c&&e[c].indexOf(f)<0&&e[c].push(f)}let g=d.sourceEdges;for(;g.next();){let y=g.value.fromVertex;f=t.indexOf(y),f!==c&&e[c].indexOf(f)<0&&e[c].push(f)}}let i=[];for(let c=0;c<e.length;c++)i[c]=0;let s=[],n=[],o=[],r=[],a=new q,h=0;for(let c=0;c<e.length;c++){let d=e[c].length;if(d===1){r.push(c);continue}if(d===0){a.add(t.elt(c));continue}if(h===0){s.push(c),h++;continue}let f=1/0,p=1/0,g=-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.k3(e[c],n,o,i,v,s),k=0;for(let S=0;S<e[c].length;S++){let N=e[c][S],D=s.indexOf(N);if(D>=0){let L=Math.abs(v-(D>=v?D+1:D));k+=L<s.length+1-L?L:s.length+1-L}}for(let S=0;S<n.length;S++){let N=i[n[S]],D=i[o[S]];if(N>=v&&N++,D>=v&&D++,N>D){let L=D;D=N,N=L}D-N<(s.length+2)/2==(N<v&&v<=D)&&k++}(w<f||w===f&&k<p)&&(f=w,p=k,g=v)}s.splice(g,0,c);for(let b=0;b<s.length;b++)i[s[b]]=b;for(let b=0;b<e[c].length;b++){let v=e[c][b];s.indexOf(v)>=0&&(n.push(c),o.push(v))}h++}let l=!1,u=s.length;for(;;){l=!0;for(let c=0;c<r.length;c++){let d=r[c],f=e[d][0],p=s.indexOf(f);if(p>=0){let g=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=u-w;g+=v<p!=w>k?1:-1}s.splice(g<0?p:p+1,0,d),r.splice(c,1),c--}else l=!1}if(l)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c<s.length;c++){let d=s[c];a.add(t.elt(d))}return a}k3(t,e,i,s,n,o){let r=0;for(let a=0;a<e.length;a++){let h=e[a],l=i[a],u=s[h],c=s[l],d=0,f=0;if(u<c?(d=u,f=c):(d=c,f=u),d<n&&n<=f)for(let p=0;p<t.length;p++){let g=t[p];o.indexOf(g)<0||d<s[g]&&s[g]<f||d===s[g]||f===s[g]||r++}else for(let p=0;p<t.length;p++){let g=t[p];o.indexOf(g)<0||!(d<s[g]&&s[g]<f)||d===s[g]||f===s[g]||r++}}return r}get radius(){return this.Rg}set radius(t){this.Rg!==t&&(m.s(t,"number",Be,"radius"),(t>0||isNaN(t))&&(this.Rg=t,this.p()))}get aspectRatio(){return this.Og}set aspectRatio(t){this.Og!==t&&(m.s(t,"number",Be,"aspectRatio"),t>0&&(this.Og=t,this.p()))}get startAngle(){return this.Ig}set startAngle(t){this.Ig!==t&&(m.s(t,"number",Be,"startAngle"),this.Ig=t,this.p())}get sweepAngle(){return this.eu}set sweepAngle(t){this.eu!==t&&(m.s(t,"number",Be,"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&&(m.S(t,Be,"comparer"),this.Mi=t,this.p())}get spacing(){return this.In}set spacing(t){this.In!==t&&(m.s(t,"number",Be,"spacing"),this.In=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.gi}get actualYRadius(){return this.Is}get actualSpacing(){return this.Ga}get actualCenter(){return this.aL}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 Hs{iu;uc;su;constructor(){this.iu=-1/0,this.uc=null,this.su=null}y3(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}}w3(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 Ws extends Ee{constructor(t){super(t)}createVertex(){return new di(this)}createEdge(){return new $s(this)}}class di extends Ie{Lo;Vk;constructor(t){super(t),this.Lo=NaN,this.Vk=NaN}Ya(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.Lo=Math.max(this.width,this.height),this.Lo;{let s=Math.abs(Math.sin(t)),n=Math.abs(Math.cos(t));return s===0?this.width:n===0?this.height:(this.Lo=Math.min(this.height/s,this.width/n),this.Lo)}}else return i.nodeDiameterFormula===31?(this.Lo=Math.max(this.width,this.height),this.Lo):(this.Lo=Math.sqrt(this.width*this.width+this.height*this.height),this.Lo)}get diameter(){return this.Lo}set diameter(t){this.Lo!==t&&(m.s(t,"number",di,"diameter"),this.Lo=t)}get actualAngle(){return this.Vk}set actualAngle(t){this.Vk!==t&&(m.s(t,"number",di,"actualAngle"),this.Vk=t)}}class $s extends ei{constructor(t){super(t)}}class ee extends _t{ww;Ka;Es;Ug;Un;zi;Vg;Bg;zg;nu;Xg;Gg;ou;ru;lu;au;Yg;Kg;hu;dc;constructor(t){super(),this.ww=0,this.Ka=0,this.Es=new st(100,100).k(),this.Ug=!1,this.Un=!0,this.zi=!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.Es.h(this.Es),t.Ug=this.Ug,t.Un=this.Un,t.zi=this.zi,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 Js(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.uL(),this.Ka=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.P3(r,n),r=o.iterator;r.next();){let a=r.value,h=a.vertexes.iterator;for(;h.next();){let u=h.value;n.addVertex(u)}let l=a.edges.iterator;for(;l.next();){let u=l.value;n.addEdge(u)}}}else this.hF(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 Zs(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.S3(i,r,this.maxPrelayoutIterations,t.vertexes.count),this.hF(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 c=l.value;i.has(c.idInCluster)||c.hierarchicalVertexes.length<a&&(a=c.hierarchicalVertexes.length,h=c)}let u=e.createVertex();u.hierarchicalVertexes.addAll(r.hierarchicalVertexes),h!=null&&u.hierarchicalVertexes.addAll(h.hierarchicalVertexes),i.set(r.idInCluster,u),h!=null&&i.set(h.idInCluster,u),e.addVertex(u)}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}nx(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}P3(t,e){let i=this.arrangementSpacing,s=t.count,n=!0,o=0,r=0,a=m.st();for(let c=0;c<s+e.vertexes.count+2;c++)a[c]=null;let h=0;t.reset();let l=I.l(),u;for(;t.next();){let c=t.value;if(this.nx(c,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.cF(a,h,o,r,l.width,l.height,i),f=a[d],p=new P(f.x+l.width+i.width,f.y),g=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]=g,h++;let y=f.x-l.x,b=f.y-l.y;for(u=c.vertexes.iterator;u.next();){let v=u.value;this.isFixed(v)||(v.centerX+=y,v.centerY+=b)}}}for(I.i(l),u=e.vertexes.iterator;u.next();){let c=u.value,d=c.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.cF(a,h,o,r,d.width,d.height,i),p=a[f],g=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]=g,a[f+1]=y,h++,this.isFixed(c)||(c.centerX=p.x+c.width/2,c.centerY=p.y+c.height/2)}m.Z(a)}cF(t,e,i,s,n,o,r){let a=9e19,h=-1;t:for(let l=0;l<e;l++){let u=t[l],c=u.x-i,d=u.y-s,f=c*c+d*d;if(f<a){for(let p=l-1;p>=0;p--)if(t[p].y>u.y&&t[p].x-u.x<n+r.width)continue t;for(let p=l+1;p<e;p++)if(t[p].x>u.x&&t[p].y-u.y<o+r.height)continue t;h=l,a=f}}return h}uL(){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}}}fF(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,u=a.width,c=a.height;if(s+o<h)if(n>l+c){let d=s+o-h,f=n-l-c;return C._w(d*d+f*f)}else if(n+r<l){let d=s+o-h,f=n+r-l;return C._w(d*d+f*f)}else return h-(s+o);else if(s>h+u)if(n>l+c){let d=s-h-u,f=n-l-c;return C._w(d*d+f*f)}else if(n+r<l){let d=s-h-u,f=n+r-l;return C._w(d*d+f*f)}else return s-(h+u);else return n>l+c?n-(l+c):n+r<l?l-(n+r):.1}hF(t,e){let i=this.Ka+e;for(;this.Ka<i&&(this.Ka++,!!this.M3(t)););}M3(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 g=e[p];g.forceX=0,g.forceY=0;let y=g.centerX,b=g.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,g)=>p===null||g===null||p===g?0:p.centerX-g.centerX):e.sort((p,g)=>p===null||g===null||p===g?0:p.centerY-g.centerY);let h=this.nu,l=0,u=0,c=0;for(let p=0;p<e.length;p++){let g=e[p],y=g.bounds,b=g.focus,v=y.x+b.x,w=y.y+b.y;u=g.charge*this.electricalFieldX(v,w),c=g.charge*this.electricalFieldY(v,w),u+=g.mass*this.gravitationalFieldX(v,w),c+=g.mass*this.gravitationalFieldY(v,w),g.forceX+=u,g.forceY+=c;for(let k=p+1;k<e.length;k++){let S=e[k];if(!this.shouldInteract(g,S)||k===p)continue;let N=S.bounds,D=S.focus,L=N.x+D.x,M=N.y+D.y;if(v-L>h||L-v>h){if(a)break;continue}if(w-M>h||M-w>h){if(!a)break;continue}let A=this.fF(g,S),F=2*g.charge,O=2*S.charge;if(A>1)l=F*O/(A*A),u=l*(v-L)/A,c=l*(w-M)/A;else{let E=this.randomNumberGenerator;E===null&&(this.randomNumberGenerator=E=new Zs(0));let B=E.random(),X=E.random();if(v>L)u=Math.abs(S.bounds.right-g.bounds.x),u=F*O*(1+u)*B;else if(v<L)u=Math.abs(S.bounds.x-g.bounds.right),u=-(F*O)*(1+u)*B;else{let z=Math.max(S.width,g.width);u=F*O*((1+z)*B-z/2)}if(w>M)c=Math.abs(S.bounds.bottom-g.bounds.y),c=F*O*(1+c)*X;else if(v<L)c=Math.abs(S.bounds.y-g.bounds.bottom),c=-(F*O)*(1+c)*X;else{let z=Math.max(S.height,g.height);c=F*O*((1+z)*X-z/2)}}g.forceX+=u,g.forceY+=c,S.forceX-=u,S.forceY-=c}}let d=t.edges.iterator;for(;d.next();){let p=d.value,g=p.fromVertex,y=p.toVertex,b=g.bounds,v=g.focus,w=b.x+v.x,k=b.y+v.y,S=y.bounds,N=y.focus,D=S.x+N.x,L=S.y+N.y,M=this.fF(g,y);M>1&&(l=.1*p.stiffness*(M-p.length),u=l*.5*(g.width+y.height)*(w-D)/M,c=l*.5*(g.width+y.height)*(k-L)/M),g.forceX-=u,g.forceY-=c,y.forceX+=u,y.forceY+=c}let f=0;for(let p=0;p<e.length;p++){let g=e[p];this.isFixed(g)?this.moveFixedVertex(g):f=Math.max(f,this.moveVertex(g)||0)}return f>this.epsilonDistance*this.epsilonDistance}S3(t,e,i,s){let n=this.Ka+i,o=Math.sqrt(s);this.ww=this.dc*t.vertexes.count;let r=t.vertexes.toArray(),a=0,h=0,l=0;for(;this.Ka<n;){this.Ka++,h=a,a=0;for(let u=0;u<r.length;u++){r[u].forceX=0,r[u].forceY=0;for(let d=0;d<r.length;d++){if(u===d)continue;let f=Math.sqrt((r[u].centerX-r[d].centerX)**2+(r[u].centerY-r[d].centerY)**2),p=e[r[u].idInCluster][r[d].idInCluster],g=(f-this.dc*o*p)/f;r[u].forceX+=g*(r[d].x-r[u].x),r[u].forceY+=g*(r[d].y-r[u].y)}let c=Math.sqrt(r[u].forceX*r[u].forceX+r[u].forceY*r[u].forceY);if(c>0){r[u].forceX=this.ww*r[u].forceX/c,r[u].forceY=this.ww*r[u].forceY/c,this.isFixed(r[u])||(r[u].x+=r[u].forceX,r[u].y+=r[u].forceY);let d=r[u].hierarchicalVertexes.iterator;for(;d.next();){let f=d.value;this.isFixed(f)||(f.centerX+=r[u].forceX,f.centerY+=r[u].forceY)}}a+=c*c}if(a>=h){if(l++,l>=5)break}else l=0;this.ww*=.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.xw(),this.commitNodes(),this.isRouting&&this.commitLinks()}xw(){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=I.l();this.nx(this.network,n);let o=this.arrangementOrigin;t=o.x-n.x,e=o.y-n.y,I.i(n)}let i=I.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()}I.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.Ka}get arrangementSpacing(){return this.Es}set arrangementSpacing(t){this.Es.equals(t)||(this.Es.h(t),this.p())}get arrangesToOrigin(){return this.Ug}set arrangesToOrigin(t){this.Ug!==t&&(m.s(t,"boolean",ee,"arrangesToOrigin"),this.Ug=t,this.p())}get setsPortSpots(){return this.Un}set setsPortSpots(t){this.Un!==t&&(m.s(t,"boolean",ee,"setsPortSpots"),this.Un=t,this.p())}get comments(){return this.zi}set comments(t){this.zi!==t&&(m.s(t,"boolean",ee,"comments"),this.zi=t,this.p())}get maxPrelayoutIterations(){return this.Vg}set maxPrelayoutIterations(t){this.Vg!==t&&(m.s(t,"number",ee,"maxPrelayoutIterations"),t>=0&&(this.Vg=t,this.p()))}get maxIterations(){return this.Bg}set maxIterations(t){this.Bg!==t&&(m.s(t,"number",ee,"maxIterations"),t>=0&&(this.Bg=t,this.p()))}get epsilonDistance(){return this.zg}set epsilonDistance(t){this.zg!==t&&(m.s(t,"number",ee,"epsilonDistance"),t>0&&(this.zg=t,this.p()))}get infinityDistance(){return this.nu}set infinityDistance(t){this.nu!==t&&(m.s(t,"number",ee,"infinityDistance"),t>1&&(this.nu=t,this.p()))}get moveLimit(){return this.Xg}set moveLimit(t){this.Xg!==t&&(m.s(t,"number",ee,"moveLimit"),this.Xg=t,this.p())}get randomNumberGenerator(){return this.Gg}set randomNumberGenerator(t){this.Gg!==t&&(t!==null&&!m.it(t.random)&&m.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&&(m.s(t,"number",ee,"defaultSpringStiffness"),this.ou=t,this.p())}get defaultSpringLength(){return this.ru}set defaultSpringLength(t){this.ru!==t&&(m.s(t,"number",ee,"defaultSpringLength"),this.ru=t,this.p())}get defaultElectricalCharge(){return this.lu}set defaultElectricalCharge(t){this.lu!==t&&(m.s(t,"number",ee,"defaultElectricalCharge"),this.lu=t,this.p())}get defaultGravitationalMass(){return this.au}set defaultGravitationalMass(t){this.au!==t&&(m.s(t,"number",ee,"defaultGravitationalMass"),this.au=t,this.p())}get defaultCommentSpringLength(){return this.Yg}set defaultCommentSpringLength(t){this.Yg!==t&&(m.s(t,"number",ee,"defaultCommentSpringLength"),this.Yg=t,this.p())}get defaultCommentElectricalCharge(){return this.Kg}set defaultCommentElectricalCharge(t){this.Kg!==t&&(m.s(t,"number",ee,"defaultCommentElectricalCharge"),this.Kg=t,this.p())}get prelayoutQuality(){return this.hu}set prelayoutQuality(t){this.hu!==t&&(m.s(t,"number",ee,"prelayoutQuality"),this.hu=t,this.p())}get prelayoutSpread(){return this.dc}set prelayoutSpread(t){this.dc!==t&&(m.s(t,"number",ee,"prelayoutSpread"),this.dc=t,this.p())}}class Js extends Ee{constructor(t){super(t)}createVertex(){return new Ve(this)}createEdge(){return new fi(this)}}class Ve extends Ie{Bk;zk;Xk;Gk;Yk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Bk=!1,this.zk=NaN,this.Xk=NaN,this.Gk=0,this.Yk=0,this.hierarchicalVertexes=new q,this.idInCluster=-1}get isFixed(){return this.Bk}set isFixed(t){this.Bk!==t&&(m.s(t,"boolean",Ve,"isFixed"),this.Bk=t)}get charge(){return this.zk}set charge(t){this.zk!==t&&(m.s(t,"number",Ve,"charge"),this.zk=t)}get mass(){return this.Xk}set mass(t){this.Xk!==t&&(m.s(t,"number",Ve,"mass"),this.Xk=t)}get forceX(){return this.Gk}set forceX(t){this.Gk!==t&&(m.s(t,"number",Ve,"forceX"),this.Gk=t)}get forceY(){return this.Yk}set forceY(t){this.Yk!==t&&(m.s(t,"number",Ve,"forceY"),this.Yk=t)}}class fi extends ei{Kk;Hk;constructor(t){super(t),this.Kk=NaN,this.Hk=NaN}get stiffness(){return this.Kk}set stiffness(t){this.Kk!==t&&(m.s(t,"number",fi,"stiffness"),this.Kk=t)}get length(){return this.Hk}set length(t){this.Hk!==t&&(m.s(t,"number",fi,"length"),this.Hk=t)}}class Zs{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 ns=(x=>(x[x.DepthFirst=0]="DepthFirst",x[x.Greedy=1]="Greedy",x[x.FromLayers=2]="FromLayers",x))(ns||{}),os=(x=>(x[x.OptimalLinkLength=10]="OptimalLinkLength",x[x.LongestPathSink=11]="LongestPathSink",x[x.LongestPathSource=12]="LongestPathSource",x))(os||{}),rs=(x=>(x[x.DepthFirstOut=20]="DepthFirstOut",x[x.DepthFirstIn=21]="DepthFirstIn",x[x.Naive=22]="Naive",x))(rs||{}),as=(x=>(x[x.None=30]="None",x[x.Less=31]="Less",x[x.More=32]="More",x))(as||{}),Qs=(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))(Qs||{}),_s=(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))(_s||{});class Ae extends _t{Us;ti;P;cu;fu;uu;gc;du;ar;gu;Un;_;bw;zt;Hg;Vs;ie;Bs;ms;ps;Rt;qg;jg;qk;cn;mu;hr;Vn;Bn;dL;Ha;constructor(t){super(),this.Us=25,this.ti=25,this.P=0,this.cu=0,this.fu=10,this.uu=20,this.gc=4,this.du=31,this.ar=15,this.gu=10,this.Un=!0,this._=-1,this.bw=-1,this.zt=-1,this.Hg=0,this.Vs=0,this.ie=new Int16Array(0),this.Bs=new Float32Array(0),this.ms=new Float32Array(0),this.ps=new Float32Array(0),this.Rt=new Float32Array(0),this.qg=0,this.jg=new Int16Array(0),this.qk=new Int16Array(0),this.cn=0,this.mu=null,this.hr=new P,this.Vn=[],this.Vn.length=100,this.Bn=15,this.dL=0,this.Ha=!0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Us=this.Us,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.ar=this.ar,t.gu=this.gu,t.Un=this.Un,t.Bn=this.Bn,t.Ha=this.Ha}fe(t){t in as?this.aggressiveOption=t:t in ns?this.cycleRemoveOption=t:t in rs?this.initializeOption=t:t in os?this.layeringOption=t:super.fe(t)}createNetwork(){return new tn(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.N3(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.C3(),this.cycleRemoveOption===2&&this.removeCycles(),this.L3(),this.A3(),this.T3(),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.Wk;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.Wk=(t.bounds.width-t.focus.x)/this.ti+1|0:e?t.jk=t.focus.y/this.ti+1|0:t.Wk=(t.bounds.height-t.focus.y)/this.ti+1|0}ei(){let t=this.network.vertexes.count;this.jg.length<t*2&&(this.jg=new Int16Array(t*2));let e=0,i=this.network.vertexes.iterator;for(;i.next();){let s=i.value;this.jg[e]=s.column,e++,this.jg[e]=s.index,e++}return this.jg}ns(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++}}uF(t,e){let i=this.qa(t),s=this.ie[t];this.qk.length<s*s&&(this.qk=new Int16Array(s*s));let n=this.qk;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 u,c=0,d,f=0,p=0,g=0,y,b=0,v,w=0,k=0,S=0,N;if(e>=0){for(u=i[o].Po,c=0;c<u.length;c++)if(d=u[c],d.valid&&d.fromVertex.layer!==t)for(f=d.fromVertex.index,p=d.portToPos,g=d.portFromPos,b=c+1;b<u.length;b++)v=u[b],v.valid&&v.fromVertex.layer!==t&&(w=v.fromVertex.index,k=v.portToPos,S=v.portFromPos,p<k&&(f>w||f===w&&g>S)&&r++,k<p&&(w>f||w===f&&S>g)&&r++)}if(e<=0){for(u=i[o].nr,c=0;c<u.length;c++)if(d=u[c],d.valid&&d.toVertex.layer!==t)for(f=d.toVertex.index,p=d.portToPos,g=d.portFromPos,b=c+1;b<u.length;b++)v=u[b],v.valid&&v.toVertex.layer!==t&&(w=v.toVertex.index,k=v.portToPos,S=v.portFromPos,g<S&&(f>w||f===w&&p>k)&&r++,S<g&&(w>f||w===f&&k>p)&&r++)}for(n[o*s+o]=r,l=o+1;l<s;l++){let D=0,L=0;if(e>=0){for(y=i[o].Po,N=i[l].Po,c=0;c<y.length;c++)if(d=y[c],d.valid&&d.fromVertex.layer!==t)for(f=d.fromVertex.index,p=d.portToPos,g=d.portFromPos,b=0;b<N.length;b++)v=N[b],v.valid&&v.fromVertex.layer!==t&&(w=v.fromVertex.index,k=v.portToPos,S=v.portFromPos,(f<w||f===w&&g<S)&&L++,(w<f||w===f&&S<g)&&D++)}if(e<=0){for(y=i[o].nr,N=i[l].nr,c=0;c<y.length;c++)if(d=y[c],d.valid&&d.toVertex.layer!==t)for(f=d.toVertex.index,p=d.portToPos,g=d.portFromPos,b=0;b<N.length;b++)v=N[b],v.valid&&v.toVertex.layer!==t&&(w=v.toVertex.index,k=v.portToPos,S=v.portFromPos,(f<w||f===w&&p<k)&&L++,(w<f||w===f&&k<p)&&D++)}n[o*s+l]=D,n[l*s+o]=L}}return this.ja(t,i),n}countCrossings(){let t=0;for(let e=0;e<=this._;e++){let i=this.uF(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}D3(t,e,i){let s=this.qa(t),n=this.ie[t],o=0;for(let r=0;r<n;r++){let a=null;e<=0&&(a=s[r].Po);let h=null;e>=0&&(h=s[r].nr);let l,u=0,c=0;if(a!==null)for(let d=0;d<a.length;d++)l=a[d],l.valid&&l.fromVertex.layer!==t&&(u=l.fromVertex.column+l.portFromColOffset,c=l.toVertex.column+l.portToColOffset,i?o+=Math.abs(u-c)*this.linkStraightenWeight(l):o+=Math.abs(u-c));if(h!==null)for(let d=0;d<h.length;d++)l=h[d],l.valid&&l.toVertex.layer!==t&&(u=l.fromVertex.column+l.portFromColOffset,c=l.toVertex.column+l.portToColOffset,i?o+=(Math.abs(u-c)+1)*this.linkStraightenWeight(l):o+=Math.abs(u-c))}return this.ja(t,s),o}Jk(t){let e=0;for(let i=0;i<=this._;i++)e+=this.D3(i,1,t);return e}kw(){let t=1/0;this.zt=-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.zt=Math.max(this.zt,i.column+this.nodeMinColumnSpace(i,!1))}for(e.reset();e.next();){let i=e.value;i.column-=t}this.zt-=t}Pw(t,e){let i=this.qa(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.Po);let h=null;e>=0&&(h=r.nr);let l=0,u=0,c=r.near;c!==null&&c.layer===r.layer&&(l+=c.column-1,u++);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,u++)}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,u++)}u===0?n[o]=-1:n[o]=l/u}return this.ja(t,i),n}dF(t,e){let i=this.qa(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.Po);let h=null;e>=0&&(h=r.nr);let l=0,u=[],c=r.near;c!==null&&c.layer===r.layer&&(u[l]=c.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&&(u[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&&(u[l]=p.column+d.portToColOffset,l++)}if(l===0)n[o]=-1;else{u.sort((p,g)=>p-g);let f=l>>1;(l&1)!==0?n[o]=u[f]:n[o]=u[f-1]+u[f]>>1}}return this.ja(t,i),n}Sw(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.Sw(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.Sw(l,e,i,s,n)}}}}gL(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.gL(r,e,i,s,n)}}if(n){let o=t.sourceEdges;for(;o.next();){let r=o.value.fromVertex;this.gL(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.v3();break;case 0:this.F3();break;case 2:this.R3();break}}R3(){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)}}}v3(){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.O3(t)!==null;){let r;for(r=this.gF(t);r!==null;)s[i]=r,i--,r.ii=!1,r=this.gF(t);for(r=this.mF(t);r!==null;)s[e]=r,e++,r.ii=!1,r=this.mF(t);r=this.I3(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)}}O3(t){let e=t.vertexes.iterator;for(;e.next();){let i=e.value;if(i.ii)return i}return null}gF(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}mF(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}I3(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}F3(){let t=this.network.vertexes.iterator;for(;t.next();){let i=t.value;i.pu=-1,i.Zn=-1}let e=this.network.edges.iterator;for(;e.next();){let i=e.value;i.forest=!1}for(this.qg=0,t.reset();t.next();){let i=t.value;i.sourceEdges.count===0&&this.mL(i)}for(t.reset();t.next();){let i=t.value;i.pu===-1&&this.mL(i)}for(e.reset();e.next();){let i=e.value;if(!i.forest){let s=i.fromVertex,n=s.pu,o=s.Zn,r=i.toVertex,a=r.pu,h=r.Zn;a<n&&o<h&&(this.network.reverseEdge(i),i.rev=!0)}}}mL(t){t.pu=this.qg,this.qg++;let e=t.destinationEdges;for(;e.next();){let i=e.value,s=i.toVertex;s.pu===-1&&(i.forest=!0,this.mL(s))}t.Zn=this.qg,this.qg++}C3(){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&&m.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.pF();break;case 12:this.E3();break;default:case 10:this.U3();break}}pF(){let t=this.network.vertexes.iterator;for(;t.next();){let e=t.value,i=this.yF(e);this._=Math.max(i,this._)}}yF(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.yF(n)+o)}t.layer=e}else e=t.layer;return e}E3(){let t=0,e=this.network.vertexes.iterator;for(;e.next();){let i=e.value;t=this.wF(i),this._=Math.max(t,this._)}for(e.reset();e.next();){let i=e.value;i.layer=this._-i.layer}}wF(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.wF(n)+o)}t.layer=e}else e=t.layer;return e}U3(){this.pF();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.xF(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)}}xF(t){if(!t.ii){t.ii=!0;let e=t.destinationEdges;for(;e.next();){let i=e.value.toVertex;this.xF(i)}this.V3(t),this.B3(t)}}V3(t){let e=this.network.vertexes.iterator;for(;e.next();){let r=e.value;r.component=-1}let i=0,s=1,n=t.Po,o=n.length;for(let r=0;r<o;r++){let a=n[r],h=a.fromVertex,l=a.toVertex,u=this.linkMinLength(a);h.layer-l.layer>u&&this.Sw(h,i,-1,!0,!1)}for(this.Sw(t,s,-1,!0,!0);t.component!==i;){let r=0,a=1/0,h=0,l=null,u=this.network.vertexes.iterator;for(;u.next();){let c=u.value;if(c.component===s){let d=0,f=!1,p=c.Po;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-c.layer,k=this.linkMinLength(b);a=Math.min(a,w-k)}}let g=c.nr;o=g.length;for(let y=0;y<o;y++){let b=g[y],v=b.toVertex;d-=this.linkLengthWeight(b),v.component!==s?r-=this.linkLengthWeight(b):f=!0}(l===null||d<h)&&!f&&(l=c,h=d)}}if(r>0){for(e.reset();e.next();){let c=e.value;c.component===s&&(c.layer+=a)}t.component=i}else l.component=i}}B3(t){let e=this.network.vertexes.iterator;for(;e.next();){let n=e.value;n.component=-1}let i=0,s=1;for(this.Sw(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 u=0,c=!1,d=l.Po,f=d.length;for(let g=0;g<f;g++){let y=d[g],b=y.fromVertex;u+=this.linkLengthWeight(y),b.component!==s?n+=this.linkLengthWeight(y):c=!0}let p=l.nr;f=p.length;for(let g=0;g<f;g++){let y=p[g],b=y.toVertex;if(u-=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||u>r)&&!c&&(a=l,r=u)}}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}}L3(){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,u=0;if(n.link!==null){let S=n.link;if(S===null)continue;let N=o.node,D=r.node;if(N===null||D===null)continue;let L=S.fromNode,M=S.toNode,A=S.fromPort;for(;A!==null&&!A.isVisibleObject();)A=A.panel;let F=S.toPort;for(;F!==null&&!F.isVisibleObject();)F=F.panel;if(n.rev){let tt=L,nt=A;L=M,A=F,M=tt,F=nt}let O=o.focus,E=r.focus,B=n.rev?r.bounds:o.bounds,X=P.l();N!==L?B.isReal()&&L.isVisible()?L.actualBounds.isReal()?(L.getRelativePoint(A,T.Center,X),X.x+=L.actualBounds.x-B.x,X.y+=L.actualBounds.y-B.y):(L.getRelativePoint(A,T.Center,X),X.isReal()||X.h(O)):X.h(O):B.isReal()?(L.getRelativePoint(A,T.Center,X),X.isReal()||X.h(O)):X.h(O);let z=n.rev?o.bounds:r.bounds,U=P.l();D!==M?z.isReal()&&M.isVisible()?M.actualBounds.isReal()?(M.getRelativePoint(F,T.Center,U),U.x+=M.actualBounds.x-z.x,U.y+=M.actualBounds.y-z.y):(M.getRelativePoint(F,T.Center,U),U.isReal()||U.h(E)):U.h(E):z.isReal()?(M.getRelativePoint(F,T.Center,U),U.isReal()||U.h(E)):U.h(E),this.P===90||this.P===270?(a=Math.round((X.x-O.x)/this.ti),l=X.x,h=Math.round((U.x-E.x)/this.ti),u=U.x):(a=Math.round((X.y-O.y)/this.ti),l=X.y,h=Math.round((U.y-E.y)/this.ti),u=U.y),P.i(X),P.i(U),n.portFromColOffset=a,n.portFromPos=l,n.portToColOffset=h,n.portToPos=u}else n.portFromColOffset=0,n.portFromPos=0,n.portToColOffset=0,n.portToPos=0;let c=o.layer,d=r.layer,f=this.z3(n),p=f===1||f===3,g=f===2||f===3,y,b,v=null,w;g&&(v=this.X3(o,r),w=1,b=t.createVertex(),b.node=null,b.$k=1,b.layer=c,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--,c-d>k&&c>0){for(n.valid=!1,b=t.createVertex(),b.node=null,b.$k=2,b.layer=c-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=g?0:a,y.portToColOffset=0,y.portFromPos=g?0:l,y.portToPos=0,o=b,c--;c-d>k&&c>0;)b=t.createVertex(),b.node=null,b.$k=3,b.layer=c-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,c--;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=u}else n.valid=!0}}z3(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.Zk(!0),h=this.Zk(!1),l=this.setsPortSpots?a:i.computeSpot(!0,s),u=this.setsPortSpots?h:i.computeSpot(!1,n),c=i.isOrthogonal;if(l.isSide()&&l.includesSide(h)&&u.isSide()&&u.includesSide(a))return 0;let d=i.getLinkPoint(o,s,l,!0,c,r,n,P.l()),f=i.getLinkDirection(o,s,d,l,!0,c,r,n);P.i(d),(!l.isNone()&&f===this.bF(t,!0)||this.setsPortSpots&&o!==null&&o.ports.count===1&&t.rev)&&(e+=1);let p=i.getLinkPoint(r,n,u,!1,c,o,s,P.l()),g=i.getLinkDirection(r,n,p,u,!1,c,o,s);P.i(p),(!u.isNone()&&g===this.bF(t,!1)||this.setsPortSpots&&r!==null&&r.ports.count===1&&t.rev)&&(e+=2)}}}return e}bF(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}X3(t,e){let i=[];return i.push(e),this.kF(t,i)?i.reverse():[]}kF(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.kF(t,e))return!0;e.pop()}return!1}A3(){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.bw=-1,this.Hg=0,this.Vs=0;for(let i=0;i<=this._;i++)t[i]>t[this.Vs]&&(this.bw=t[i]-1,this.Vs=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.G3();break;case 20:this.Y3();break;case 21:this.K3();break}}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(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]++})}}Y3(){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.PF(s,t)}}PF(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.nr,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.PF(a,e)}}}K3(){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.SF(s,t)}}SF(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.Po,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.SF(r,e))}T3(){this.zt=-1;for(let t=0;t<=this._;t++){let e=this.qa(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.zt=Math.max(this.zt,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.Qk(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.Qk(s,-1),this.ys(s,-1,!1,-1);n=this.countCrossings(),n<t&&(t=n,e=this.ei())}for(this.ns(e),i=0;i<this.gc;i++){for(s=0;s<=this._;s++)this.Qk(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.Qk(s,0),this.ys(s,0,!1,0);n=this.countCrossings(),n<t&&(t=n,e=this.ei())}this.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(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.ns(e):(t=n,e=this.ei())}break}this.ns(e)}Qk(t,e){let i=0,s=!1,n=this.qa(t),o=this.ie[t],r=this.dF(t,e),a=this.Pw(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 c=r[i];r[i]=r[i+1],r[i+1]=c;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 u=0;for(i=0;i<o;i++)l=n[i],l.index=i,u+=this.nodeMinColumnSpace(l,!0),l.column=u,u+=1,u+=this.nodeMinColumnSpace(l,!1);return this.ja(t,n),s}ys(t,e,i,s){let n=this.qa(t),o=this.ie[t],r=this.uF(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.Pw(t,-1);let l;if(!i||s<0)for(l=new Float32Array(o),a=0;a<o;a++)l[a]=-1;else l=this.Pw(t,1);let u=!1,c=!0;for(;c;)for(c=!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,g=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),N=y-v+k,D=b-w+S,L=0,M=0,A=0,F=0,O=0,E=0,B=0,X,z=0,U,tt=0,nt=n[a].sourceEdges.iterator;if(i&&s<=0)for(;nt.next();){let xt=nt.value;X=xt.fromVertex,xt.valid&&X.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,E=X.column,L+=(Math.abs(y+O-(E+F))+1)*A,M+=(Math.abs(D+O-(E+F))+1)*A)}for(nt.reset();nt.next();){let xt=nt.value;if(X=xt.fromVertex,xt.valid&&X.layer===t){for(z=0;z<n.length&&n[z]!==X;)z++;z<a&&(p+=2*(a-z),g+=2*(a+1-z)),z===a+1&&(p+=1),z>a+1&&(p+=4*(z-a),g+=4*(z-(a+1)))}}let Z=n[a].destinationEdges.iterator;if(i&&s>=0)for(;Z.next();){let xt=Z.value;U=xt.toVertex,xt.valid&&U.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,B=U.column,L+=(Math.abs(y+F-(B+O))+1)*A,M+=(Math.abs(D+F-(B+O))+1)*A)}for(Z.reset();Z.next();){let xt=Z.value;if(U=xt.toVertex,xt.valid&&U.layer===t){for(tt=0;tt<n.length&&n[tt]!==U;)tt++;tt===a+1&&(g+=1)}}let it=n[a+1].sourceEdges.iterator;if(i&&s<=0)for(;it.next();){let xt=it.value;X=xt.fromVertex,xt.valid&&X.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,E=X.column,L+=(Math.abs(b+O-(E+F))+1)*A,M+=(Math.abs(N+O-(E+F))+1)*A)}for(it.reset();it.next();){let xt=it.value;if(X=xt.fromVertex,xt.valid&&X.layer===t){for(z=0;z<n.length&&n[z]!==X;)z++;z<a&&(p+=2*(a+1-z),g+=2*(a-z)),z===a&&(g+=1),z>a+1&&(p+=4*(z-(a+1)),g+=4*(z-a))}}let _=n[a+1].destinationEdges.iterator;if(i&&s>=0)for(;_.next();){let xt=_.value;U=xt.toVertex,xt.valid&&U.layer!==t&&(A=this.linkStraightenWeight(xt),F=xt.portFromColOffset,O=xt.portToColOffset,B=U.column,L+=(Math.abs(b+F-(B+O))+1)*A,M+=(Math.abs(N+F-(B+O))+1)*A)}for(_.reset();_.next();){let xt=_.value;if(U=xt.toVertex,xt.valid&&U.layer===t){for(tt=0;tt<n.length&&n[tt]!==U;)tt++;tt===a&&(p+=1)}}let at=0,ct=0,yt=h[n[a].index],Ct=l[n[a].index],Q=h[n[a+1].index],St=l[n[a+1].index];if(yt!==-1&&(at+=Math.abs(yt-y),ct+=Math.abs(yt-D)),Ct!==-1&&(at+=Math.abs(Ct-y),ct+=Math.abs(Ct-D)),Q!==-1&&(at+=Math.abs(Q-b),ct+=Math.abs(Q-N)),St!==-1&&(at+=Math.abs(St-b),ct+=Math.abs(St-N)),g<p-.5||g===p&&f<d-.5||g===p&&f===d&&M<L-.5||g===p&&f===d&&M===L&&ct<at-.5){u=!0,c=!0,n[a].column=D,n[a+1].column=N;let xt=n[a];n[a]=n[a+1],n[a+1]=xt}}for(a=0;a<o;a++)n[a].index=a;return this.ja(t,n),u}straightenAndPack(){if(this.Bn!==0){this.H3();return}let t=0,e=!1,i=(this.ar&1)!==0,s=(this.ar&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 u=this.nodeMinColumnSpace(l,!1);n[t]=Math.max(n[t],r+u)}let h=8;for(a.reset();a.next();){let l=a.value;t=l.layer,r=l.column,l.column=((this.zt-n[t])*h>>1)+r*h}this.zt*=h}if((this.ar&2)!==0){e=!0;let n=0;for(;e&&n<this.gu;){for(e=!1,t=this.Vs+1;t<=this._;t++)e=this.Wg(t,1)||e;for(t=this.Vs-1;t>=0;t--)e=this.Wg(t,-1)||e;e=this.Wg(this.Vs,0)||e,n++}}if((this.ar&4)!==0){for(t=this.Vs+1;t<=this._;t++)this.pL(t,1);for(t=this.Vs-1;t>=0;t--)this.pL(t,-1);this.pL(this.Vs,0)}if(i&&(this.MF(-1),this.MF(1)),(this.ar&2)!==0){e=!0;let n=0;for(;e&&n<this.gu;){for(e=!1,e=this.Wg(this.Vs,0)||e,t=this.Vs+1;t<=this._;t++)e=this.Wg(t,0)||e;for(t=this.Vs-1;t>=0;t--)e=this.Wg(t,0)||e;n++}}}Wg(t,e){let i=!1;for(;this.q3(t,e);)i=!0;return i}q3(t,e){let i=0,s=this.qa(t),n=this.ie[t],o=this.Pw(t,-1);if(e>0)for(i=0;i<n;i++)o[i]=-1;let r=this.Pw(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,u=this.nodeMinColumnSpace(s[i],!0),c=this.nodeMinColumnSpace(s[i],!1),d=0;i-1<0||l-s[i-1].column-1>u+this.nodeMinColumnSpace(s[i-1],!1)?d=l-1:d=l;let f=0;i+1>=n||s[i+1].column-l-1>c+this.nodeMinColumnSpace(s[i+1],!0)?f=l+1:f=l;let p=0,g=0,y=0,b=0,v=0,w=0;if(e<=0){let M=s[i].sourceEdges.iterator;for(;M.next();){let A=M.value,F=A.fromVertex;if(A.valid&&F.layer!==t){b=this.linkStraightenWeight(A),v=A.portFromColOffset,w=A.portToColOffset;let O=F.column;p+=(Math.abs(l+w-(O+v))+1)*b,g+=(Math.abs(d+w-(O+v))+1)*b,y+=(Math.abs(f+w-(O+v))+1)*b}}}if(e>=0){let M=s[i].destinationEdges.iterator;for(;M.next();){let A=M.value,F=A.toVertex;if(A.valid&&F.layer!==t){b=this.linkStraightenWeight(A),v=A.portFromColOffset,w=A.portToColOffset;let O=F.column;p+=(Math.abs(l+v-(O+w))+1)*b,g+=(Math.abs(d+v-(O+w))+1)*b,y+=(Math.abs(f+v-(O+w))+1)*b}}}let k=0,S=0,N=0,D=o[s[i].index],L=r[s[i].index];D!==-1&&(k+=Math.abs(D-l),S+=Math.abs(D-d),N+=Math.abs(D-f)),L!==-1&&(k+=Math.abs(L-l),S+=Math.abs(L-d),N+=Math.abs(L-f)),g<p||g===p&&S<k?(a=!0,h=!0,s[i].column=d):(y<p||y===p&&N<k)&&(a=!0,h=!0,s[i].column=f)}return this.ja(t,s),this.kw(),a}pL(t,e){let i=0,s=this.qa(t),n=this.ie[t],o=this.dF(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,u=this.nodeMinColumnSpace(s[i],!0),c=this.nodeMinColumnSpace(s[i],!1),d=0,f=0,p=0,g=0,y=0;r[i]===-1?i===0&&i===n-1?d=l:i===0?(f=s[i+1].column,f-l===c+this.nodeMinColumnSpace(s[i+1],!0)?d=l-1:d=l):i===n-1?(p=s[i-1].column,l-p===u+this.nodeMinColumnSpace(s[i-1],!1)?d=l+1:d=l):(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+u+1,f=s[i+1].column,g=f-this.nodeMinColumnSpace(s[i+1],!0)-c-1,d=(y+g)/2|0):i===0&&i===n-1?d=r[i]:i===0?(f=s[i+1].column,g=f-this.nodeMinColumnSpace(s[i+1],!0)-c-1,d=Math.min(r[i],g)):i===n-1?(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+u+1,d=Math.max(r[i],y)):(p=s[i-1].column,y=p+this.nodeMinColumnSpace(s[i-1],!1)+u+1,f=s[i+1].column,g=f-this.nodeMinColumnSpace(s[i+1],!0)-c-1,y<r[i]&&r[i]<g?d=r[i]:y>=r[i]?d=y:g<=r[i]&&(d=g)),d!==l&&(a=!0,h=!0,s[i].column=d)}return this.ja(t,s),this.kw(),a}j3(){for(let t=0;t<=this.zt;t++)for(;this.W3(t,1););this.kw()}W3(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}J3(){this.j3();for(let t=0;t<this.zt;t++)for(;this.$3(t,1););this.kw()}$3(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,u=l.column-this.nodeMinColumnSpace(l,!0),c=l.column+this.nodeMinColumnSpace(l,!1);u<=t&&c>=t&&(n[l.layer]=!0),u<=i&&c>=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}MF(t){this.J3();let e=0,i,s=0,n=0,o=0;if(t>0)for(e=0;e<=this.zt;e++)for(i=this.ei(),s=this.Jk(!0),n=s+1;s<n;)n=s,this.NF(e,1),o=this.Jk(!0),o>s?this.ns(i):o<s&&(s=o,i=this.ei());if(t<0)for(e=this.zt;e>=0;e--)for(i=this.ei(),s=this.Jk(!0),n=s+1;s<n;)n=s,this.NF(e,-1),o=this.Jk(!0),o>s?this.ns(i):o<s&&(s=o,i=this.ei());this.kw()}NF(t,e){this.cn=0;let i=this.network.vertexes.iterator;for(;i.next();){let u=i.value;u.component=-1}if(e>0)for(i.reset();i.next();){let u=i.value;u.column-this.nodeMinColumnSpace(u,!0)<=t&&(u.component=this.cn)}if(e<0)for(i.reset();i.next();){let u=i.value;u.column+this.nodeMinColumnSpace(u,!1)>=t&&(u.component=this.cn)}for(this.cn++,i.reset();i.next();){let u=i.value;u.component===-1&&(this.gL(u,this.cn,-1,!0,!0),this.cn++)}let s=0,n=[];for(s=0;s<this.cn*this.cn;s++)n[s]=!1;let o=[];for(s=0;s<(this._+1)*(this.zt+1);s++)o[s]=-1;for(i.reset();i.next();){let u=i.value,c=u.layer,d=Math.max(0,u.column-this.nodeMinColumnSpace(u,!0)),f=Math.min(this.zt,u.column+this.nodeMinColumnSpace(u,!1));for(let p=d;p<=f;p++)o[c*(this.zt+1)+p]=u.component}for(let u=0;u<=this._;u++){if(e>0)for(let c=0;c<this.zt;c++)o[u*(this.zt+1)+c]!==-1&&o[u*(this.zt+1)+c+1]!==-1&&o[u*(this.zt+1)+c]!==o[u*(this.zt+1)+c+1]&&(n[o[u*(this.zt+1)+c]*this.cn+o[u*(this.zt+1)+c+1]]=!0);if(e<0)for(let c=this.zt;c>0;c--)o[u*(this.zt+1)+c]!==-1&&o[u*(this.zt+1)+c-1]!==-1&&o[u*(this.zt+1)+c]!==o[u*(this.zt+1)+c-1]&&(n[o[u*(this.zt+1)+c]*this.cn+o[u*(this.zt+1)+c-1]]=!0)}let r=[];for(s=0;s<this.cn;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.cn;s++)n[h*this.cn+s]&&a.splice(0,0,s);let l=!1;if(e>0)for(i.reset();i.next();){let u=i.value;r[u.component]&&(u.column-=1,l=!0)}if(e<0)for(i.reset();i.next();){let u=i.value;r[u.component]&&(u.column+=1,l=!0)}return l}H3(){let t=m.st(),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 V;this.Z3(t,s);let n=null,o=null,r=null,a=null,h=(this.Bn&1)!==0,l=(this.Bn&2)!==0,u=(this.Bn&4)!==0,c=(this.Bn&8)!==0;h&&(this.al(t,s,!0),n=this._k(t,!0,!1)),t.reverse(),u&&(this.al(t,s,!1),r=this._k(t,!1,!1));for(let d of t)d.reverse();c&&(this.al(t,s,!1),a=this._k(t,!1,!0)),t.reverse(),l&&(this.al(t,s,!0),o=this._k(t,!0,!0)),m.Z(t),this.Q3(n,o,r,a),this.network.vertexes.each(d=>{let f=d,p=m.st();h&&p.push(n.get(f)),l&&p.push(o.get(f)),u&&p.push(r.get(f)),c&&p.push(a.get(f)),p.sort((w,k)=>w-k);let g=p.length,y=Math.floor((g-1)/2),b=Math.ceil((g-1)/2),v=(p[y]+p[b])/2;m.Z(p),f.mi=v})}Z3(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],u=this._3(l);if(h===a.length-1||u){let c=r.length-1;for(u&&(c=l.getProperSourceVertexes()[0].index);o<=h;){let d=a[o].getProperSourceEdges();for(let f of d){let p=f.fromVertex.index;(p<n||p>c)&&e.add(f)}o++}n=c}}}}_3(t){if(t.node===null){let e=t.getProperSourceVertexes();if(e.length>0)return e[0].node===null}return!1}al(t,e,i){this.tU(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,u)=>l.Wa-u.Wa);let h=(a-1)/2;for(let l=Math.floor(h),u=Math.ceil(h);l<=u;l++)if(o.zn===o){let c=r[l],d;i?d=c.getDestinationEdge(o):d=o.getDestinationEdge(c),!e.has(d)&&n<c.Wa&&(c.zn=o,o.mc=c.mc,o.zn=c.mc,n=c.Wa)}}}}}tU(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.zn=n,n.CF=e,n.Wa=s}}}_k(t,e,i){let s=this.P===90||this.P===270;for(let o of t)for(let r of o)r.os=r,r.yu=1/0,r.mi=NaN,r.Xn=0;this.eU(t,e,i);for(let o of t)for(let r of o)r.mc===r&&this.LF(r,t);for(let o=0;o<t.length;o++){if(t[o].length<=0)continue;let r=t[o][0];if(r.os===r){r.os.yu===1/0&&(r.os.yu=0);let a=o,h=0,l;do{for(l=t[a][h];l.zn!==l.mc;)if(l=l.zn,a++,l.Wa>0){let u=this.AF(l,t),c=s?u.width:u.height,d=l.os.yu+l.mi+l.Xn-(u.mi+u.Xn+c+this.columnSpacing);u.os.yu=Math.min(u.os.yu,d)}h=l.Wa+1}while(a<t.length&&h<t[a].length&&l.os===t[a][h].os)}}let n=new Mt;for(let o of t)for(let r of o){r.mi=r.mi+r.os.yu+r.Xn;let a=s?r.width:r.height;n.set(r,i?-r.mi-a:r.mi)}return n}eU(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.zn!==o;){let h=a.zn,l=s?a.width:a.height,u=s?h.width:h.height,c,d,f,p;e?(f=a.getDestinationEdge(h),c=f.portFromPos,d=f.portToPos,f.link!==null&&(a.node&&a.node!==f.link.fromNode&&(c=s?a.focusX:a.focusY),h.node&&h.node!==f.link.toNode&&(d=s?h.focusX:h.focusY)),i?p=a.Xn+(l-c)-(u-d):p=a.Xn+c-d):(f=h.getDestinationEdge(a),c=f.portToPos,d=f.portFromPos,f.link!==null&&(a.node&&a.node!==f.link.toNode&&(c=s?a.focusX:a.focusY),h.node&&h.node!==f.link.fromNode&&(d=s?h.focusX:h.focusY)),i?p=a.Xn+(l-c)-(u-d):p=a.Xn+c-d),h.Xn=p,r=Math.min(r,p),a=a.zn}a=o;do a.Xn=a.Xn-r,a=a.zn;while(a!==o)}}LF(t,e){if(!isNaN(t.mi))return;t.mi=0;let i=t;do{if(i.Wa>0){let s=this.AF(i,e),n=s.mc;this.LF(n,e),t.os===t&&(t.os=n.os);let o=this.P===90||this.P===270?s.width:s.height;if(t.os===n.os){let r=n.mi+s.Xn+o-i.Xn+this.columnSpacing;t.mi=Math.max(t.mi,r)}}i=i.zn}while(i!==t);for(;i.zn!==t;)i=i.zn,i.mi=t.mi,i.os=t.os}AF(t,e){let i=t.CF,s=t.Wa;return s<1&&m.o("Could not determine previous vertex in layer"),e[i][s-1]}Q3(...t){let e=-1,i=m.st(),s=m.st(),n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;let r=this.iU(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)})}m.Z(i),m.Z(s)}iU(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.xw(),this.commitNodes(),this.yL(),this.isRouting&&this.commitLinks()}xw(){if(!this.setsPortSpots)return;let t=this.Zk(!0),e=this.Zk(!1),i=this.network.edges.iterator;for(;i.next();){let s=i.value.link;s!==null&&(s.fromSpot=t,s.toSpot=e)}}Zk(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.Bs.length!==this._+1&&(this.Bs=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.Bs[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.Bs[p]=Math.max(this.Bs[p],this.nodeMinLayerSpace(f,!0)),this.ms[p]=Math.max(this.ms[p],this.nodeMinLayerSpace(f,!1))}let e=0,i=this.Us;for(let f=0;f<=this._;f++){let p=i;this.Bs[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.Bs[f]):(e+=this.Bs[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.Bn!==0;t.reset();let r=this.P===270||this.P===90,a=1/0,h=1/0,l=1/0,u=-1/0;for(;t.next();){let f=t.value,p=f.layer,g=f.column|0,y=0,b=0;r?(y=n.x+this.ti*g,b=this.ps[p]):(y=this.ps[p],b=n.y+this.ti*g),f.centerX=y,f.centerY=b,o&&isFinite(f.mi)&&(r?f.node?f.x=n.x+f.mi:f.centerX=n.x+f.mi:f.node?f.y=n.y+f.mi:f.centerY=n.y+f.mi),a=Math.min(f.x,a),h=Math.min(f.y,h),r?(l=a,u=Math.max(u,f.bounds.right)):(l=h,u=Math.max(u,f.bounds.bottom))}this.dL=u-l;let c=n.x-a,d=n.y-h;for(this.hr=new P(o&&r?0:c,o&&!r?0:d),t.reset();t.next();){let f=t.value;f.x+=c,f.y+=d,f.commit()}}yL(){let t=0,e=this.Us;for(let n=0;n<=this._;n++)t+=this.Bs[n],t+=this.ms[n];t+=this._*e;let i=[],s=this.Bn!==0?this.dL:this.ti*this.zt;for(let n=this.maxLayer;n>=0;n--)this.P===270?n===0?i.push(new I(0,0,s,Math.abs(this.Rt[0]))):i.push(new I(0,this.Rt[n-1],s,Math.abs(this.Rt[n-1]-this.Rt[n]))):this.P===90?n===0?i.push(new I(0,this.Rt[0],s,Math.abs(this.Rt[0]-t))):i.push(new I(0,this.Rt[n],s,Math.abs(this.Rt[n-1]-this.Rt[n]))):this.P===180?n===0?i.push(new I(0,0,Math.abs(this.Rt[0]),s)):i.push(new I(this.Rt[n-1],0,Math.abs(this.Rt[n-1]-this.Rt[n]),s)):n===0?i.push(new I(this.Rt[0],0,Math.abs(this.Rt[0]-t),s)):i.push(new I(this.Rt[n],0,Math.abs(this.Rt[n-1]-this.Rt[n]),s));this.commitLayers(i,this.hr)}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 A=n.findVisibleNode();A!==null&&A!==n&&(n=A,r=A.port)}if(o!==null){let A=o.findVisibleNode();A!==null&&A!==o&&(o=A,a=A.port)}let h=e.computeSpot(!0,r),l=e.computeSpot(!1,a),u=i.fromVertex,c=i.toVertex;if(i.valid){if(e.curve===9&&e.pointsCount===4)if(u.column===c.column&&this.alignOption===0){let A=e.getLinkPoint(n,r,h,!0,!1,o,a),F=e.getLinkPoint(o,a,l,!1,!1,n,r);A.isReal()||A.set(n.actualBounds.center),F.isReal()||F.set(o.actualBounds.center),e.clearPoints(),e.addPointAt(A.x,A.y),e.addPointAt((2*A.x+F.x)/3,(2*A.y+F.y)/3),e.addPointAt((A.x+2*F.x)/3,(A.y+2*F.y)/3),e.addPointAt(F.x,F.y)}else{let A=!1,F=!1;if(r!==null&&e.bl(h)&&(A=!0),a!==null&&e.bl(l)&&(F=!0),A||F){let O=null;A&&(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 E=null;if(F&&(E=e.getLinkPointFromPoint(o,a,a.getDocumentPoint(T.Center),e.getPoint(0),!1),E.isReal()||E.set(o.actualBounds.center),e.setPointAt(3,E.x,E.y)),O){let B=e.getPoint(2);e.setPointAt(1,(O.x*2+B.x)/3,(O.y*2+B.y)/3)}if(E){let B=e.getPoint(1);e.setPointAt(2,(E.x*2+B.x)/3,(E.y*2+B.y)/3)}}}e.commitRoute();continue}if(u.layer===c.layer){e.commitRoute();continue}let d=!1,f=!1,p=this.Us,g=0,y=e.firstPickIndex+1;if(e.isOrthogonal)f=!0,g=e.pointsCount,g>4&&e.points.removeRange(2,g-3);else if(e.curve===9)d=!0,g=e.pointsCount,g>4&&e.points.removeRange(2,g-3),g===4&&(y=2);else{g=e.pointsCount;let A=h===T.None,F=l===T.None;g>2&&A&&F?e.points.removeRange(1,g-2):g>3&&A&&!F?e.points.removeRange(1,g-3):g>3&&!A&&F?e.points.removeRange(2,g-2):g>4&&!A&&!F&&e.points.removeRange(2,g-3)}let b,v,w=0,k=0,S=0,N=0,D=0,L=0,M=0;if(i.rev){let A=0;for(;c!==null&&u!==c;){b=null,v=null;let F=c.sourceEdges.iterator;for(;F.next();){let O=F.value;if(O.link===i.link&&(b=O.fromVertex,v=O.toVertex,b.node===null))break}if(b===null)break;if(b!==u)if(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=b.centerX,N=b.centerY,f)this.P===180||this.P===0?y===e.firstPickIndex+1?(e.insertPointAt(y++,w,k),e.insertPointAt(y++,w,N)):(v!==null?v.centerY:k)!==N&&(D=this.Rt[b.layer-1]+this.hr.x,e.insertPointAt(y++,D,k),e.insertPointAt(y++,D,N)):y===e.firstPickIndex+1?(e.insertPointAt(y++,w,k),e.insertPointAt(y++,S,k)):(v!==null?v.centerX:w)!==S&&(D=this.Rt[b.layer-1]+this.hr.y,e.insertPointAt(y++,w,D),e.insertPointAt(y++,S,D));else if(y===e.firstPickIndex+1)if(L=Math.max(10,this.Bs[c.layer]),M=Math.max(10,this.ms[c.layer]),d)this.P===180?S<=c.bounds.x?(A=c.bounds.x,e.insertPointAt(y++,A-L,N),e.insertPointAt(y++,A,N),e.insertPointAt(y++,A+M,N)):(e.insertPointAt(y++,S-L,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S+M,N)):this.P===90?N>=c.bounds.bottom?(A=c.bounds.y+c.bounds.height,e.insertPointAt(y++,S,A+M),e.insertPointAt(y++,S,A),e.insertPointAt(y++,S,A-L)):(e.insertPointAt(y++,S,N+M),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N-L)):this.P===270?N<=c.bounds.y?(A=c.bounds.y,e.insertPointAt(y++,S,A-L),e.insertPointAt(y++,S,A),e.insertPointAt(y++,S,A+M)):(e.insertPointAt(y++,S,N-L),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N+M)):this.P===0&&(S>=c.bounds.right?(A=c.bounds.x+c.bounds.width,e.insertPointAt(y++,A+M,N),e.insertPointAt(y++,A,N),e.insertPointAt(y++,A-L,N)):(e.insertPointAt(y++,S+M,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S-L,N)));else{e.insertPointAt(y++,w,k);let O=0;this.P===180||this.P===0?((this.P===180?S>=c.bounds.right:S<=c.bounds.x)&&(O=(this.P===0?-L:M)/2),e.insertPointAt(y++,w+O,N)):((this.P===270?N>=c.bounds.bottom:N<=c.bounds.y)&&(O=(this.P===90?-L:M)/2),e.insertPointAt(y++,S,k+O)),e.insertPointAt(y++,S,N)}else L=Math.max(10,this.Bs[b.layer]),M=Math.max(10,this.ms[b.layer]),d?this.P===180?(e.insertPointAt(y++,S-L-Math.max(10,p),N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S+M+p,N)):this.P===90?(e.insertPointAt(y++,S,N+M+Math.max(10,p)),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N-L-p)):this.P===270?(e.insertPointAt(y++,S,N-L-Math.max(10,p)),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N+M+p)):(e.insertPointAt(y++,S+M+Math.max(10,p),N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S-L-p,N)):(this.P===180||this.P===90||this.P,e.insertPointAt(y++,S,N));c=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,N=e.getPoint(y).y,f){let F=this.ms[u.layer],O=0;this.P===180||this.P===0?(O=k,O>=u.bounds.y&&O<=u.bounds.bottom&&(this.P===180?S>=u.bounds.x:S<=u.bounds.right)&&(A=u.centerX+(this.P===180?-F:F),O<u.bounds.y+u.bounds.height/2?O=u.bounds.y-this.ti/2:O=u.bounds.bottom+this.ti/2,e.insertPointAt(y++,A,k),e.insertPointAt(y++,A,O)),e.insertPointAt(y++,S,O),e.insertPointAt(y++,S,N)):(O=w,O>=u.bounds.x&&O<=u.bounds.right&&(this.P===270?N>=u.bounds.y:N<=u.bounds.bottom)&&(A=u.centerY+(this.P===270?-F:F),O<u.bounds.x+u.bounds.width/2?O=u.bounds.x-this.ti/2:O=u.bounds.right+this.ti/2,e.insertPointAt(y++,w,A),e.insertPointAt(y++,O,A)),e.insertPointAt(y++,O,N),e.insertPointAt(y++,S,N))}else if(d)L=Math.max(10,this.Bs[u.layer]),M=Math.max(10,this.ms[u.layer]),this.P===180&&S>=u.bounds.x?(A=u.bounds.x+u.bounds.width,e.setPointAt(y-2,A,k),e.setPointAt(y-1,A+M,k)):this.P===90&&N<=u.bounds.bottom?(A=u.bounds.y,e.setPointAt(y-2,w,A),e.setPointAt(y-1,w,A-L)):this.P===270&&N>=u.bounds.y?(A=u.bounds.y+u.bounds.height,e.setPointAt(y-2,w,A),e.setPointAt(y-1,w,A+M)):this.P===0&&S<=u.bounds.right&&(A=u.bounds.x,e.setPointAt(y-2,A,k),e.setPointAt(y-1,A-L,k));else{L=Math.max(10,this.Bs[u.layer]),M=Math.max(10,this.ms[u.layer]);let F=0;this.P===180||this.P===0?((this.P===180?S<=u.bounds.x:S>=u.bounds.right)&&(F=(this.P===0?M:-L)/2),e.insertPointAt(y++,S+F,k)):((this.P===270?N<=u.bounds.y:N>=u.bounds.bottom)&&(F=(this.P===90?M:-L)/2),e.insertPointAt(y++,w,N+F)),e.insertPointAt(y++,S,N)}}else{for(;u!==null&&u!==c;){b=null,v=null;let A=u.destinationEdges.iterator;for(;A.next();){let F=A.value;if(F.link===i.link&&(b=F.toVertex,v=F.fromVertex,v.node!==null&&(v=null),b.node===null))break}if(b===null)break;b!==c&&(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=b.centerX,N=b.centerY,f?this.P===180||this.P===0?(v!==null?v.centerY:k)!==N&&(D=this.Rt[b.layer]+this.hr.x,y===e.firstPickIndex+1&&(this.P===0?D=Math.max(D,w):D=Math.min(D,w)),e.insertPointAt(y++,D,k),e.insertPointAt(y++,D,N)):(v!==null?v.centerX:w)!==S&&(D=this.Rt[b.layer]+this.hr.y,y===e.firstPickIndex+1&&(this.P===90?D=Math.max(D,k):D=Math.min(D,k)),e.insertPointAt(y++,w,D),e.insertPointAt(y++,S,D)):(L=Math.max(10,this.Bs[b.layer]),M=Math.max(10,this.ms[b.layer]),d?this.P===180?(e.insertPointAt(y++,S+M+Math.max(10,p),N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S-L-p,N)):this.P===90?(e.insertPointAt(y++,S,N-L-Math.max(10,p)),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N+M+p)):this.P===270?(e.insertPointAt(y++,S,N+M+Math.max(10,p)),e.insertPointAt(y++,S,Math.max(N+M-p/2,N)),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,Math.min(N-L+p/2,N)),e.insertPointAt(y++,S,N-L-p)):(e.insertPointAt(y++,S-L-Math.max(10,p),N),e.insertPointAt(y++,Math.min(S-L+p/2,S),N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,S,N),e.insertPointAt(y++,Math.max(S+M-p/2,S),N),e.insertPointAt(y++,S+M+p,N)):this.P===180?(e.insertPointAt(y++,S+M,N),e.insertPointAt(y++,S-L,N)):this.P===90?(e.insertPointAt(y++,S,N-L),e.insertPointAt(y++,S,N+M)):this.P===270?(e.insertPointAt(y++,S,N+M),e.insertPointAt(y++,S,N-L)):(e.insertPointAt(y++,S-L,N),e.insertPointAt(y++,S+M,N)))),u=b}f&&(w=e.getPoint(y-1).x,k=e.getPoint(y-1).y,S=e.getPoint(y).x,N=e.getPoint(y).y,this.P===180||this.P===0?k!==N&&(this.P===0?D=Math.min(Math.max((S+w)/2,this.Rt[c.layer]+this.hr.x),S):D=Math.max(Math.min((S+w)/2,this.Rt[c.layer]+this.hr.x),S),e.insertPointAt(y++,D,k),e.insertPointAt(y++,D,N)):w!==S&&(this.P===90?D=Math.min(Math.max((N+k)/2,this.Rt[c.layer]+this.hr.y),N):D=Math.max(Math.min((N+k)/2,this.Rt[c.layer]+this.hr.y),N),e.insertPointAt(y++,w,D),e.insertPointAt(y++,S,D)))}if(s!==null&&d&&e.pointsCount>=4){if(n!==null&&r!==null&&s.bl(h)){let A=r.getDocumentPoint(T.Center);A.isReal()||A.setTo(n.actualBounds.centerX,n.actualBounds.centerY);let F=e.getPoint(3),O=e.getPoint(2);this.direction===90||this.direction===270?(e.setPointAt(1,F.x,(O.y+F.y)/2),e.setPointAt(2,F.x,(O.y+F.y)/2)):(e.setPointAt(1,(O.x+F.x)/2,F.y),e.setPointAt(2,(O.x+F.x)/2,F.y));let E=e.getLinkPointFromPoint(n,r,A,e.getPoint(1),!0);e.setPointAt(0,E.x,E.y)}if(o!==null&&a!==null&&s.bl(l)){let A=a.getDocumentPoint(T.Center);A.isReal()||A.setTo(o.actualBounds.centerX,o.actualBounds.centerY);let F=e.getPoint(e.pointsCount-4),O=e.getLinkPointFromPoint(o,a,A,F,!1),E=e.getPoint(e.pointsCount-3);this.direction===90||this.direction===270?(e.setPointAt(e.pointsCount-2,F.x,(E.y+O.y)/2),e.setPointAt(e.pointsCount-3,F.x,(E.y+O.y)/2)):(e.setPointAt(e.pointsCount-2,(E.x+O.x)/2,F.y),e.setPointAt(e.pointsCount-3,(E.x+O.x)/2,F.y));let B=e.getLinkPointFromPoint(o,a,A,e.getPoint(e.pointsCount-2),!1);e.setPointAt(e.pointsCount-1,B.x,B.y)}}e.commitRoute(),i.commit()}}N3(){this.bw=-1,this.Hg=0,this.Vs=0,this.mu=null;for(let t=0;t<this.Vn.length;t++)this.Vn[t]=null}qa(t){let e,i=this.ie[t];if(i>=this.Vn.length){let n=[];for(let o=0;o<this.Vn.length;o++)n[o]=this.Vn[o];this.Vn=n}this.Vn[i]===void 0||this.Vn[i]===null?e=[]:(e=this.Vn[i],this.Vn[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.Vn[this.ie[t]]=e}get layerSpacing(){return this.Us}set layerSpacing(t){this.Us!==t&&(m.s(t,"number",Ae,"layerSpacing"),t>=0&&(this.Us=t,this.p()))}get columnSpacing(){return this.ti}set columnSpacing(t){this.ti!==t&&(m.s(t,"number",Ae,"columnSpacing"),t>0&&(this.ti=t,this.p()))}get direction(){return this.P}set direction(t){this.P!==t&&(m.s(t,"number",Ae,"direction"),t===0||t===90||t===180||t===270?(this.P=t,this.p()):m.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.ar}set packOption(t){this.ar!==t&&(m.s(t,"number",Ae,"packOption"),t>=0&&t<8&&(this.ar=t,this.p()))}get packIterations(){return this.gu}set packIterations(t){this.gu=t}get alignOption(){return this.Bn}set alignOption(t){this.Bn!==t&&(m.s(t,"number",Ae,"align"),t>=0&&t<16&&(this.Bn=t,this.p()))}get centered(){return this.Ha}set centered(t){this.centered!==t&&(m.s(t,"boolean",Ae,"centered"),this.Ha=t,this.p())}get setsPortSpots(){return this.Un}set setsPortSpots(t){this.Un!==t&&(m.s(t,"boolean",Ae,"setsPortSpots"),this.Un=t,this.p())}get maxLayer(){return this._}get maxIndex(){return this.bw}get maxColumn(){return this.zt}get minIndexLayer(){return this.Hg}get maxIndexLayer(){return this.Vs}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 tn extends Ee{constructor(t){super(t)}createVertex(){let t=new si(this);return t.centered=this.layout.centered,t}createEdge(){return new Se(this)}}class si extends Ie{gl;pa;Tt;tP;eP;Ha;ii;pu;Zn;$k;jk;Wk;mc;zn;CF;Wa;os;yu;mi;Xn;Mw=null;Nw=null;Cw=null;Lw=null;constructor(t){super(t),this.gl=-1,this.pa=-1,this.Tt=-1,this.tP=NaN,this.eP=null,this.Ha=!0,this.ii=!1,this.pu=NaN,this.Zn=NaN,this.$k=0,this.jk=null,this.Wk=null}static TF(t,e){return t.index-e.index}getProperSourceEdges(){if(!this.Cw){let t=[];for(let e of this.Po){let i=e;i.valid&&t.push(i)}this.Cw=t}return this.Cw}getProperDestinationEdges(){if(!this.Lw){let t=[];for(let e of this.nr){let i=e;i.valid&&t.push(i)}this.Lw=t}return this.Lw}getDestinationEdge(t){let e=this.getProperDestinationEdges();for(let i of e)if(i.toVertex===t)return i;m.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.Mw){let t=[];for(let e of this.Po){let i=e;!i.valid||i.fromVertex.layer<=i.toVertex.layer||t.push(i.fromVertex)}t.sort(si.TF),this.Mw=t}return this.Mw}getProperDestinationVertexes(){if(!this.Nw){let t=[];for(let e of this.nr){let i=e;!i.valid||i.fromVertex.layer<=i.toVertex.layer||t.push(i.toVertex)}t.sort(si.TF),this.Nw=t}return this.Nw}addSourceEdge(t){super.addSourceEdge(t),this.Mw=null,this.Cw=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.Mw=null,this.Cw=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Nw=null,this.Lw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Nw=null,this.Lw=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.gl}set layer(t){this.gl=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.tP}set component(t){this.tP!==t&&(m.s(t,"number",si,"component"),this.tP=t)}get near(){return this.eP}set near(t){this.eP!==t&&(this.eP=t)}get centered(){return this.Ha}set centered(t){this.Ha=t}}class Se extends ei{ii;iP;sP;nP;oP;rP;lP;constructor(t){super(t),this.ii=!1,this.iP=!1,this.sP=!1,this.nP=NaN,this.oP=NaN,this.rP=0,this.lP=0}get fromVertex(){return this.is}set fromVertex(t){this.is!==t&&(this.is=t)}get toVertex(){return this.ss}set toVertex(t){this.ss!==t&&(this.ss=t)}get valid(){return this.ii}set valid(t){this.ii!==t&&(m.s(t,"boolean",Se,"valid"),this.ii=t)}get rev(){return this.iP}set rev(t){this.iP!==t&&(m.s(t,"boolean",Se,"rev"),this.iP=t)}get forest(){return this.sP}set forest(t){this.sP!==t&&(m.s(t,"boolean",Se,"forest"),this.sP=t)}get portFromPos(){return this.nP}set portFromPos(t){this.nP!==t&&(m.s(t,"number",Se,"portFromPos"),this.nP=t)}get portToPos(){return this.oP}set portToPos(t){this.oP!==t&&(m.s(t,"number",Se,"portToPos"),this.oP=t)}get portFromColOffset(){return this.rP}set portFromColOffset(t){this.rP!==t&&(m.s(t,"number",Se,"portFromColOffset"),this.rP=t)}get portToColOffset(){return this.lP}set portToColOffset(t){this.lP!==t&&(m.s(t,"number",Se,"portToColOffset"),this.lP=t)}}var hs=(x=>(x[x.Default=0]="Default",x[x.Destination=1]="Destination",x[x.Source=2]="Source",x))(hs||{}),ls=(x=>(x[x.Forwards=10]="Forwards",x[x.Reverse=11]="Reverse",x[x.Ascending=12]="Ascending",x[x.Descending=13]="Descending",x))(ls||{}),us=(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))(us||{}),cs=(x=>(x[x.None=30]="None",x[x.Block=31]="Block",x))(cs||{}),ds=(x=>(x[x.Layered=40]="Layered",x[x.LastParents=41]="LastParents",x[x.Alternating=42]="Alternating",x[x.RootOnly=43]="RootOnly",x))(ds||{}),fs=(x=>(x[x.Vertical=50]="Vertical",x[x.Horizontal=51]="Horizontal",x[x.FixedRoots=52]="FixedRoots",x))(fs||{}),en=(x=>(x[x.Individual=60]="Individual",x[x.Siblings=61]="Siblings",x[x.Uniform=62]="Uniform",x))(en||{});class Vt extends _t{Ie;Fe;wu;Jg;wL;zi;He;Es;V;B;aP;ws;constructor(t){super(),this.Ie=new V,this.Fe=0,this.ws=1,this.wu=40,this.Jg=60,this.wL=[],this.zi=!0,this.He=50,this.Es=new st(10,10).k();let e=new gs(this);this.V=new Rt(e),this.B=new Rt(e),this.aP=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Fe=this.Fe,t.wu=this.wu,t.Jg=this.Jg,t.zi=this.zi,t.He=this.He,t.Es.h(this.Es),t.V.copyInheritedPropertiesFrom(this.V),t.B.copyInheritedPropertiesFrom(this.B)}fe(t){t in us?this.alignment=t:t in fs?this.arrangement=t:t in cs?this.compaction=t:t in hs?this.path=t:t in ls?this.sorting=t:t in ds?this.treeStyle=t:super.fe(t)}createNetwork(){return new gs(this)}makeNetwork(t){let e=this.createNetwork(),i=s=>{if(s instanceof $)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof j){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 Y?(e.addParts(t.nodes,!0,i),e.addParts(t.links,!0,i)):t instanceof ht?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 Y&&(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.lU(),this.aU(),this.hU(),this.cU(),this.uL(),this.fU(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ie=new V,this.isValidLayout=!0}lU(){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 V,o=this.Ie.iterator;for(;o.next();){let r=o.value;if(r instanceof $){let a=this.network.findVertex(r);a!==null&&n.add(a)}else r instanceof Rt&&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.xL(n))}let i=this.network.vertexes,s=null;for(;s=this.uU(i),s.count>0;){let n=this.DF(s);n!==null&&(this.Ie.add(n),n.initialized=!0,this.xL(n)),i=s}}uU(t){let e=new V,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:m.o("Unhandled path value "+this.ws.toString())}}if(this.Ie.count===0){let i=this.DF(t);i!==null&&this.Ie.add(i)}}DF(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:m.o("Unhandled path value "+this.ws.toString())}}return i}xL(t){if(t===null)return;switch(this.ws){case 1:if(t.destinationEdges.count>0){let s=new q,n=t.destinationVertexes;for(;n.next();){let o=n.value;this.vF(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){let s=new q,n=t.sourceVertexes;for(;n.next();){let o=n.value;this.vF(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:m.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.xL(n)}}vF(t,e){return e.initialized?this.dU(e,t)||e.level>t.level?!1:(this.gU(e.parent,e),!0):!0}dU(t,e){if(e===null)return!1;let i=e.parent;for(;i!==null&&i!==t;)i=i.parent;return i===t}gU(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}}aU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.FF(e)}}FF(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.FF(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}mU(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.mU(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}hU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.RF(e)}}RF(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.RF(n)}}assignTreeVertexValues(t){}cU(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.OF(e)}}OF(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.OF(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}}uL(){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,u=0,c=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 g=p.measuredBounds;r&&!h||!o&&!a&&h||o&&a&&h?(l=Math.max(l,g.width),u+=g.height+Math.abs(c)):(l+=g.width+Math.abs(c),u=Math.max(u,g.height)),c=d}}if(t.comments!==null){r&&!h||!o&&!a&&h||o&&a&&h?(l+=Math.abs(t.commentMargin),u=Math.max(0,u-t.height)):(u+=Math.abs(t.commentMargin),l=Math.max(0,l-t.width));let f=I.z(0,0,t.bounds.width+l,t.bounds.height+u);t.bounds=f,I.i(f)}}isBusAlignment(t){return t===24||t===25||t===26||t===27}Aw(t){return t===24||t===25}bL(t){let e=t.parent;if(e!==null){let i=e.alignment;if(this.isBusAlignment(i))if(this.Aw(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,u=this.bL(t),c=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&&u)if(t.commentMargin>=0){p.e(t.bounds.x-t.commentMargin-v.width,t.bounds.y+c),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+c),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+c),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+c),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?c+=v.height+t.commentSpacing:c+=t.commentSpacing-v.height}else{if(n>135&&!r||!h&&u)if(t.commentMargin>=0){p.e(t.bounds.x+c,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+c,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+c,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+c,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?c+=v.width+t.commentSpacing:c+=t.commentSpacing-v.width}}P.i(p);let g=c-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=g>0?g:NaN)}}else{let y=t.sourceEdges;for(;y.next();){let b=y.value.link;b!==null&&!b.isAvoiding&&(b.toEndSegmentLength=g>0?g:NaN)}}}}fU(){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.wL=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 Rt&&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.IF(t);break;default:case 31:t.alignment===25?this.IF(t):this.pU(t);break}}IF(t){if(t.childrenCount===0){let X=!1,z=0,U=21;t.parent!==null&&(z=t.parent.angle,U=t.parent.alignment,X=this.isBusAlignment(U));let tt=this.bL(t);t.U.e(0,0),t.dt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((z===180||z===270)&&!X||tt)?z===180&&!X||(z===90||z===270)&&tt?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 X=0;X<o;X++){let z=n[X];s=Math.max(s,i?z.dt.width:z.dt.height)}let r=t.alignment,a=r===22,h=r===23,l=this.isBusAlignment(r),u=Math.max(0,t.breadthLimit),c=this.computeLayerSpacing(t),d=t.nodeSpacing,f=this.computeNodeIndent(t),p=a||h?0:f/2,g=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,N=0,D=0,L=0,M=0,A=0,F=0,O=0;if(l&&!this.Aw(r)&&e>135&&n.reverse(),this.Aw(r))if(o>1)for(let X=0;X<o;X++){let z=n[X],U=z.dt;X%2===0&&X!==o-1?F=Math.max(F,(i?U.width:U.height)+this.computeBusNodeSpacing(z)-d):X%2!==0&&(O=Math.max(O,(i?U.width:U.height)+this.computeBusNodeSpacing(z)-d))}else o===1&&(F=i?n[0].dt.width:n[0].dt.height);if(l)switch(r){case 24:case 25:let X=I.l();e<135?this.EF(t,n,F,O,w,k,X):this.UF(t,n,F,O,w,k,X),F=X.x,w=X.width,k=X.height,I.i(X);break;case 26:for(let z=0;z<o;z++){let U=n[z],tt=U.dt,nt=M===0?0:g;i?(U.U.e(s-tt.width,D+nt),w=Math.max(w,tt.width),k=Math.max(k,D+nt+tt.height),D+=nt+tt.height):(U.U.e(N+nt,s-tt.height),w=Math.max(w,N+nt+tt.width),k=Math.max(k,tt.height),N+=nt+tt.width),M++}break;case 27:for(let z=0;z<o;z++){let U=n[z],tt=U.dt,nt=M===0?0:g;i?(U.U.e(d/2+t.focus.x,D+nt),w=Math.max(w,tt.width),k=Math.max(k,D+nt+tt.height),D+=nt+tt.height):(U.U.e(N+nt,d/2+t.focus.y),w=Math.max(w,N+nt+tt.width),k=Math.max(k,tt.height),N+=nt+tt.width),M++}break}else for(let X=0;X<o;X++){let z=n[X],U=z.dt;if(i){u>0&&M>0&&N+d+U.width>u&&(N<s&&this.pc(t,r,s-N,0,A,X-1),L++,M=0,A=X,S=k,N=0,D=e>135?-k-g:k+g);let tt=M===0?p:d;this.hP(z,0,D),z.U.e(N+tt,D),w=Math.max(w,N+tt+U.width),k=Math.max(k,S+(L===0?0:g)+U.height),N+=tt+U.width}else{u>0&&M>0&&D+d+U.height>u&&(D<s&&this.pc(t,r,0,s-D,A,X-1),L++,M=0,A=X,S=w,D=0,N=e>135?-w-g:w+g);let tt=M===0?p:d;this.hP(z,N,0),z.U.e(N,D+tt),k=Math.max(k,D+tt+U.height),w=Math.max(w,S+(L===0?0:g)+U.width),D+=tt+U.height}M++}L>0&&(i?(k+=Math.max(0,c),N<w&&this.pc(t,r,w-N,0,A,o-1),y>0&&(h||this.xu(t,y,0,0,o-1),w+=y)):(w+=Math.max(0,c),D<k&&this.pc(t,r,0,k-D,A,o-1),y>0&&(h||this.xu(t,0,y,0,o-1),k+=y)));let E=0,B=0;switch(r){case 20:i?E+=w/2-t.focus.x-f/2:B+=k/2-t.focus.y-f/2;break;default:case 21:if(L>0)i?E+=w/2-t.focus.x-f/2:B+=k/2-t.focus.y-f/2;else{let z=o;if(i){let U=n[0].U.x+n[0].at.x,tt=n[z-1].U.x+n[z-1].at.x+n[z-1].focus.x*2;E+=U+(tt-U)/2-t.focus.x-f/2}else{let U=n[0].U.y+n[0].at.y,tt=n[z-1].U.y+n[z-1].at.y+n[z-1].focus.y*2;B+=U+(tt-U)/2-t.focus.y-f/2}}break;case 22:i?(E-=f,w+=f):(B-=f,k+=f);break;case 23:i?(E+=w-t.width+f,w+=f):(B+=k-t.height+f,k+=f);break;case 24:case 25:i?o>1?E+=F+d/2-t.focus.x:E+=n[0].focus.x-t.focus.x+n[0].at.x:o>1?B+=F+d/2-t.focus.y:B+=n[0].focus.y-t.focus.y+n[0].at.y;break;case 26:i?E+=w+d/2-t.focus.x:B+=k+d/2-t.focus.y;break;case 27:break;case 28:let X=this.customAlignment(t,E,B,w,k);E=X[0],B=X[1],w=X[2],k=X[3];break}for(let X=0;X<o;X++){let z=n[X];i?z.U.e(z.U.x+z.at.x-E,z.U.y+(e>135?(l?-k:-z.dt.height)+z.at.y-c:v+c+z.at.y)):z.U.e(z.U.x+(e>135?(l?-w:-z.dt.width)+z.at.x-c:b+c+z.at.x),z.U.y+z.at.y-B)}i?(w=this.kL(t,w,E),E<0&&(E=0),e>135&&(B+=k+c),k=Math.max(Math.max(k,v),k+v+c)):(e>135&&(E+=w+c),w=Math.max(Math.max(w,b),w+b+c),k=this.PL(t,k,B),B<0&&(B=0)),t.at.e(E,B),t.dt.e(w,k)}customAlignment(t,e,i,s,n){return[e,i,s,n]}EF(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,u=this.orthoAngle(t)===90,c=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=c===0?0:l;if(u){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}c++}c=0;let p=d,g=f;u?(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=c===0?0:l;if(u){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}c++}if(a>1&&a%2===1){let y=e[a-1],b=y.dt,v=this.computeBusLastRowSpacing(y,u?Math.max(Math.abs(g),Math.abs(f)):Math.max(Math.abs(p),Math.abs(d)));if(u){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(g,f)+v+b.height),y.U.x<0&&(i=this.cP(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.cP(t,y.U.y,!0,i,h))}}return r.e(i,0,n,o),r}UF(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,u=this.orthoAngle(t)===270,c=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=c===0?0:l;if(u){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))}c++}c=0;let p=d,g=f;u?(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=c===0?0:l;if(u){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))}c++}if(a>1&&a%2===1){let y=e[a-1],b=y.dt,v=this.computeBusLastRowSpacing(y,u?Math.max(Math.abs(g),Math.abs(f)):Math.max(Math.abs(p),Math.abs(d)));if(u){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(g,f))+v+b.height),y.U.x<0&&(i=this.cP(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.cP(t,y.U.y,!0,i,h))}}for(let y=0;y<a;y++){let b=e[y];u?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}cP(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)}kL(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}}PL(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}}SL(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:m.o("Unhandled alignment value "+t.toString())}return new P(e,i)}pc(t,e,i,s,n,o){let r=this.SL(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}}hP(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:m.o("Unhandled path value "+this.ws.toString())}}pU(t){if(t.childrenCount===0){let _=t.parent,at=!1,ct=0,yt=21;_!==null&&(ct=_.angle,yt=_.alignment,at=this.isBusAlignment(yt));let Ct=this.bL(t);t.U.e(0,0),t.dt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((ct===180||ct===270)&&!at||Ct)?ct===180&&!at||(ct===90||ct===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 _=0;_<o;_++){let at=n[_];s=Math.max(s,i?at.dt.width:at.dt.height)}let r=t.alignment,a=r===22,h=r===23,l=this.isBusAlignment(r),u=Math.max(0,t.breadthLimit),c=this.computeLayerSpacing(t),d=t.nodeSpacing,f=this.computeNodeIndent(t),p=t.rowSpacing,g=0;(a||h)&&(g=Math.max(0,t.rowIndent));let y=t.width,b=t.height,v=0,w=0,k=0,S=null,N=null,D=0,L=0,M=0,A=0,F=0,O=0,E=0,B=0,X=0;if(l&&!this.Aw(r)&&e>135&&n.reverse(),this.Aw(r))if(o>1)for(let _=0;_<o;_++)_%2===0&&_!==o-1?B=Math.max(B,i?n[_].dt.width:n[_].dt.height):_%2!==0&&(X=Math.max(X,i?n[_].dt.width:n[_].dt.height));else o===1&&(B=i?n[0].dt.width:n[0].dt.height);if(l){switch(r){case 24:let _=I.l();e<135?this.EF(t,n,B,X,v,w,_):this.UF(t,n,B,X,v,w,_),B=_.x,v=_.width,w=_.height,I.i(_);break;case 26:for(let at=0;at<o;at++){let ct=n[at],yt=ct.dt,Ct=O===0?0:p;i?(ct.U.e(s-yt.width,A+Ct),v=Math.max(v,yt.width),w=Math.max(w,A+Ct+yt.height),A+=Ct+yt.height):(ct.U.e(M+Ct,s-yt.height),v=Math.max(v,M+Ct+yt.width),w=Math.max(w,yt.height),M+=Ct+yt.width),O++}break;case 27:for(let at=0;at<o;at++){let ct=n[at],yt=ct.dt,Ct=O===0?0:p;i?(ct.U.e(d/2+t.focus.x,A+Ct),v=Math.max(v,yt.width),w=Math.max(w,A+Ct+yt.height),A+=Ct+yt.height):(ct.U.e(M+Ct,d/2+t.focus.y),v=Math.max(v,M+Ct+yt.width),w=Math.max(w,yt.height),M+=Ct+yt.width),O++}break}S=this.pi(2),N=this.pi(2),i?(S[0].e(0,0),S[1].e(0,w),N[0].e(v,0),N[1].e(v,w)):(S[0].e(0,0),S[1].e(v,0),N[0].e(0,w),N[1].e(v,w))}else for(let _=0;_<o;_++){let at=n[_],ct=at.dt;if(i){u>0&&O>0&&M+d+ct.width>u&&(M<s&&this.pc(t,r,s-M,0,E,_-1),F++,O=0,E=_,k=w,M=0,A=e>135?-w-p:w+p),this.hP(at,0,A);let yt=0;if(O===0)S=at.$g,N=at.Zg,D=ct.width,L=ct.height,(S===null||N===null||e!==this.orthoAngle(at))&&(S=this.pi(2),N=this.pi(2),S[0].e(0,0),S[1].e(0,L),N[0].e(D,0),N[1].e(D,L));else{let Ct=m.st(),Q=I.l();this.VF(t,at,S,N,D,L,Ct,Q),yt=Q.x,S=Ct[0],N=Ct[1],D=Q.width,L=Q.height,m.Z(Ct),M<ct.width&&yt<0&&(this.xu(t,-yt,0,E,_-1),this.fP(S,-yt,0),this.fP(N,-yt,0),yt=0),I.i(Q)}at.U.e(yt,A),v=Math.max(v,D),w=Math.max(w,k+(F===0?0:p)+ct.height),M=D}else{u>0&&O>0&&A+d+ct.height>u&&(A<s&&this.pc(t,r,0,s-A,E,_-1),F++,O=0,E=_,k=v,A=0,M=e>135?-v-p:v+p),this.hP(at,M,0);let yt=0;if(O===0)S=at.$g,N=at.Zg,D=ct.width,L=ct.height,(S===null||N===null||e!==this.orthoAngle(at))&&(S=this.pi(2),N=this.pi(2),S[0].e(0,0),S[1].e(D,0),N[0].e(0,L),N[1].e(D,L));else{let Ct=m.st(),Q=I.l();this.VF(t,at,S,N,D,L,Ct,Q),yt=Q.x,S=Ct[0],N=Ct[1],D=Q.width,L=Q.height,m.Z(Ct),A<ct.height&&yt<0&&(this.xu(t,0,-yt,E,_-1),this.fP(S,0,-yt),this.fP(N,0,-yt),yt=0),I.i(Q)}at.U.e(M,yt),w=Math.max(w,L),v=Math.max(v,k+(F===0?0:p)+ct.width),A=L}O++}F>0&&(i?(w+=Math.max(0,c),M<v&&this.pc(t,r,v-M,0,E,o-1),g>0&&(h||this.xu(t,g,0,0,o-1),v+=g)):(v+=Math.max(0,c),A<w&&this.pc(t,r,0,w-A,E,o-1),g>0&&(h||this.xu(t,0,g,0,o-1),w+=g)));let z=0,U=0;switch(r){case 20:i?z+=v/2-t.focus.x-f/2:U+=w/2-t.focus.y-f/2;break;default:case 21:if(F>0)i?z+=v/2-t.focus.x-f/2:U+=w/2-t.focus.y-f/2;else{let at=o;if(i){let ct=n[0].U.x+n[0].at.x,yt=n[at-1].U.x+n[at-1].at.x+n[at-1].focus.x*2;z+=ct+(yt-ct)/2-t.focus.x-f/2}else{let ct=n[0].U.y+n[0].at.y,yt=n[at-1].U.y+n[at-1].at.y+n[at-1].focus.y*2;U+=ct+(yt-ct)/2-t.focus.y-f/2}}break;case 22:i?(z-=f,v+=f):(U-=f,w+=f);break;case 23:i?(z+=v-t.width+f,v+=f):(U+=w-t.height+f,w+=f);break;case 24:i?o>1?z+=B+d/2-t.focus.x:z+=n[0].focus.x-t.focus.x+n[0].at.x:o>1?U+=B+d/2-t.focus.y:U+=n[0].focus.y-t.focus.y+n[0].at.y;break;case 26:i?z+=v+d/2-t.focus.x:U+=w+d/2-t.focus.y;break;case 27:break;case 28:let _=this.customAlignment(t,z,U,v,w);z=_[0],U=_[1],v=_[2],w=_[3];break}for(let _=0;_<o;_++){let at=n[_];i?at.U.e(at.U.x+at.at.x-z,at.U.y+(e>135?(l?-w:-at.dt.height)+at.at.y-c:b+c+at.at.y)):at.U.e(at.U.x+(e>135?(l?-v:-at.dt.width)+at.at.x-c:y+c+at.at.x),at.U.y+at.at.y-U)}let tt=0,nt=0;if(l)i?(v=this.kL(t,v,z),z<0&&(z=0),e>135&&(U+=w+c),w+=b+c,r===27&&(tt+=d/2+t.focus.x),nt+=b+c):(e>135&&(z+=v+c),v+=y+c,w=this.PL(t,w,U),U<0&&(U=0),r===27&&(nt+=d/2+t.focus.y),tt+=y+c);else if(i){if(t.comments===null){if(y>v){let _=this.SL(r,y-v,0);tt=_.x,nt=_.y,v=y,z=0}}else v=this.kL(t,v,z);z<0&&(tt-=z,z=0),e>135&&(U+=w+c),w=Math.max(Math.max(w,b),w+b+c),nt+=b+c}else{if(e>135&&(z+=v+c),v=Math.max(Math.max(v,y),v+y+c),t.comments===null){if(b>w){let _=this.SL(r,0,b-w);tt=_.x,nt=_.y,w=b,U=0}}else w=this.PL(t,w,U);U<0&&(nt-=U,U=0),tt+=y+c}let Z,it;if(F>0)Z=this.pi(4),it=this.pi(4),i?(Z[2].e(0,b+c),Z[3].e(Z[2].x,w),it[2].e(v,Z[2].y),it[3].e(it[2].x,Z[3].y)):(Z[2].e(y+c,0),Z[3].e(v,Z[2].y),it[2].e(Z[2].x,w),it[3].e(Z[3].x,it[2].y));else{Z=this.pi(S.length+2),it=this.pi(N.length+2);for(let _=0;_<S.length;_++){let at=S[_];Z[_+2].e(at.x+tt,at.y+nt)}for(let _=0;_<N.length;_++){let at=N[_];it[_+2].e(at.x+tt,at.y+nt)}}i?(Z[0].e(z,0),Z[1].e(Z[0].x,b),Z[2].y<Z[1].y&&(Z[2].x>Z[0].x?Z[2].h(Z[1]):Z[1].h(Z[2])),Z[3].y<Z[2].y&&(Z[3].x>Z[0].x?Z[3].h(Z[2]):Z[2].h(Z[3])),it[0].e(z+y,0),it[1].e(it[0].x,b),it[2].y<it[1].y&&(it[2].x<it[0].x?it[2].h(it[1]):it[1].h(it[2])),it[3].y<it[2].y&&(it[3].x<it[0].x?it[3].h(it[2]):it[2].h(it[3])),Z[2].y-=c/2,it[2].y-=c/2):(Z[0].e(0,U),Z[1].e(y,Z[0].y),Z[2].x<Z[1].x&&(Z[2].y>Z[0].y?Z[2].h(Z[1]):Z[1].h(Z[2])),Z[3].x<Z[2].x&&(Z[3].y>Z[0].y?Z[3].h(Z[2]):Z[2].h(Z[3])),it[0].e(0,U+b),it[1].e(y,it[0].y),it[2].x<it[1].x&&(it[2].y<it[0].y?it[2].h(it[1]):it[1].h(it[2])),it[3].x<it[2].x&&(it[3].y<it[0].y?it[3].h(it[2]):it[2].h(it[3])),Z[2].x-=c/2,it[2].x-=c/2),this.fn(S),this.fn(N),t.$g=Z,t.Zg=it,t.at.e(z,U),t.dt.e(v,w)}fP(t,e,i){for(let s=0;s<t.length;s++){let n=t[s];n.x+=e,n.y+=i}}VF(t,e,i,s,n,o,r,a){let h=this.orthoAngle(t),l=h===90||h===270,u=t.nodeSpacing,c=i,d=s,f=n,p=o,g=e.$g,y=e.Zg,b=e.dt,v=l?Math.max(p,b.height):Math.max(f,b.width);if((g===null||h!==this.orthoAngle(e))&&(g=this.pi(2),y=this.pi(2),l?(g[0].e(0,0),g[1].e(0,b.height),y[0].e(b.width,0),y[1].e(y[0].x,g[1].y)):(g[0].e(0,0),g[1].e(b.width,0),y[0].e(0,b.height),y[1].e(g[1].x,y[0].y))),l){let w=f,k=w-this.yU(d,g,w);return k+=u,i=this.wU(c,g,k),s=this.xU(d,y,k),n=Math.max(0,k)+b.width,o=v,this.fn(c),this.fn(g),this.fn(d),this.fn(y),r[0]=i,r[1]=s,a.e(k,0,n,o),a}else{let w=p,k=w-this.bU(d,g,w);return k+=u,i=this.kU(c,g,k),s=this.PU(d,y,k),n=v,o=Math.max(0,k)+b.height,this.fn(c),this.fn(g),this.fn(d),this.fn(y),r[0]=i,r[1]=s,a.e(k,0,n,o),a}}kU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}wU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}PU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}xU(t,e,i){if(t===null||t.length<2||e===null||e.length<2)return null;let s=this.pi(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.pi(r);for(n=0;n<r;n++)h[n].h(s[n]);return this.fn(s),h}bU(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 u=r;n+1<t.length&&(u=t[n+1]);let c=a,d=c.x,f=c.y;o+1<e.length&&(c=e[o+1],d=c.x,f=c.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<u.x&&(p=l-(r.y+(h-r.x)/(u.x-r.x)*(u.y-r.y))),p<s&&(s=p),u.x<=r.x?n++:d<=h?o++:(u.x<=d&&n++,d<=u.x&&o++)}return s}yU(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 u=r;n+1<t.length&&(u=t[n+1]);let c=a,d=c.x,f=c.y;o+1<e.length&&(c=e[o+1],d=c.x,f=c.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<u.y&&(p=h-(r.x+(l-r.y)/(u.y-r.y)*(u.x-r.x))),p<s&&(s=p),u.y<=r.y?n++:f<=l?o++:(u.y<=f&&n++,f<=u.y&&o++)}return s}pi(t){let e=this.aP[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}fn(t){if(!t)return;let e=t.length,i=this.aP[e];i===void 0&&(i=[],this.aP[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 Rt))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.ML(e,n,o)}}else{let t=[],e=this.Ie.iterator;for(;e.next();){let o=e.value;o instanceof Rt&&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.ML(r,s+r.at.x,n+r.at.y),this.He){case 50:n+=r.dt.height+this.Es.height;break;default:case 51:s+=r.dt.width+this.Es.width;break}}}}ML(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.ML(r,e+r.U.x,i+r.U.y)}}commitLayout(){this.xw(),this.commitNodes(),this.yL(),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)}}yL(){if(this.network===null||this.layerStyle!==62)return;let t=this.wL,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 I(0,a,r,l))):this.angle===90?(o.push(new I(0,a,r,l)),a+=l):this.angle===180?(a-=l,o.push(new I(a,0,l,r))):(o.push(new I(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()}xw(){let t=this.Ie.iterator;for(;t.next();){let e=t.value;e instanceof Rt&&this.BF(e)}}BF(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.BF(n)}}setPortSpots(t){let e=t.alignment;if(this.isBusAlignment(e))this.SU(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}}}}}SU(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 u=l.link;if(u!==null){let c=s===90||s===270?T.MiddleLeft:T.MiddleTop;if(r===1||a===r-1&&r%2===1)switch(s){case 0:c=T.MiddleLeft;break;case 90:c=T.MiddleTop;break;case 180:c=T.MiddleRight;break;default:c=T.MiddleBottom;break}else a%2===0&&(c=s===90||s===270?T.MiddleRight:T.MiddleBottom);i?(t.setsPortSpot&&(u.fromSpot=n),t.setsChildPortSpot&&(u.toSpot=c)):(t.setsPortSpot&&(u.fromSpot=c),t.setsChildPortSpot&&(u.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.zi}set comments(t){this.zi!==t&&(m.s(t,"boolean",Vt,"comments"),this.zi=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.Es}set arrangementSpacing(t){this.Es.equals(t)||(this.Es.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&&(m.S(t,Vt,"comparer"),this.V.comparer=t,this.p())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(m.s(t,"number",Vt,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.p()):m.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&&(m.s(t,"number",Vt,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.p()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(m.s(t,"number",Vt,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.p()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(m.s(t,"number",Vt,"nodeSpacing"),this.V.nodeSpacing=t,this.p())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(m.s(t,"number",Vt,"layerSpacing"),this.V.layerSpacing=t,this.p())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(m.s(t,"number",Vt,"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&&(m.s(t,"number",Vt,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.p()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(m.s(t,"number",Vt,"rowSpacing"),this.V.rowSpacing=t,this.p())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(m.s(t,"number",Vt,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.p()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(m.s(t,"number",Vt,"commentSpacing"),this.V.commentSpacing=t,this.p())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(m.s(t,"number",Vt,"commentMargin"),this.V.commentMargin=t,this.p())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(m.s(t,"boolean",Vt,"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&&(m.s(t,"boolean",Vt,"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&&(m.S(t,Vt,"alternateComparer"),this.B.comparer=t,this.p())}get alternateAngle(){return this.B.angle}set alternateAngle(t){this.B.angle!==t&&(m.s(t,"number",Vt,"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&&(m.s(t,"number",Vt,"alternateNodeIndent"),t>=0&&(this.B.nodeIndent=t,this.p()))}get alternateNodeIndentPastParent(){return this.B.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.B.nodeIndentPastParent!==t&&(m.s(t,"number",Vt,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.B.nodeIndentPastParent=t,this.p()))}get alternateNodeSpacing(){return this.B.nodeSpacing}set alternateNodeSpacing(t){this.B.nodeSpacing!==t&&(m.s(t,"number",Vt,"alternateNodeSpacing"),this.B.nodeSpacing=t,this.p())}get alternateLayerSpacing(){return this.B.layerSpacing}set alternateLayerSpacing(t){this.B.layerSpacing!==t&&(m.s(t,"number",Vt,"alternateLayerSpacing"),this.B.layerSpacing=t,this.p())}get alternateLayerSpacingParentOverlap(){return this.B.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.B.layerSpacingParentOverlap!==t&&(m.s(t,"number",Vt,"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&&(m.s(t,"number",Vt,"alternateBreadthLimit"),t>=0&&(this.B.breadthLimit=t,this.p()))}get alternateRowSpacing(){return this.B.rowSpacing}set alternateRowSpacing(t){this.B.rowSpacing!==t&&(m.s(t,"number",Vt,"alternateRowSpacing"),this.B.rowSpacing=t,this.p())}get alternateRowIndent(){return this.B.rowIndent}set alternateRowIndent(t){this.B.rowIndent!==t&&(m.s(t,"number",Vt,"alternateRowIndent"),t>=0&&(this.B.rowIndent=t,this.p()))}get alternateCommentSpacing(){return this.B.commentSpacing}set alternateCommentSpacing(t){this.B.commentSpacing!==t&&(m.s(t,"number",Vt,"alternateCommentSpacing"),this.B.commentSpacing=t,this.p())}get alternateCommentMargin(){return this.B.commentMargin}set alternateCommentMargin(t){this.B.commentMargin!==t&&(m.s(t,"number",Vt,"alternateCommentMargin"),this.B.commentMargin=t,this.p())}get alternateSetsPortSpot(){return this.B.setsPortSpot}set alternateSetsPortSpot(t){this.B.setsPortSpot!==t&&(m.s(t,"boolean",Vt,"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&&(m.s(t,"boolean",Vt,"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 gs extends Ee{constructor(t){super(t)}createVertex(){return new Rt(this)}createEdge(){return new sn(this)}}class Rt extends Ie{U;dt;at;uP;dP;gP;mP;pP;yP;wP;zi;$g;Zg;Si;Mi;Xt;de;Tw;Dw;vw;Us;Fw;Rw;Ow;Iw;Ew;Uw;Vw;Bw;zw;Xw;Gw;constructor(t){super(t),this.uP=!1,this.dP=null,this.gP=[],this.mP=0,this.pP=0,this.yP=0,this.wP=0,this.zi=null,this.U=new P(0,0),this.dt=new st(0,0),this.at=new P(0,0),this.$g=null,this.Zg=null,this.Si=10,this.Mi=Ie.standardComparer,this.Xt=0,this.de=21,this.Tw=0,this.Dw=0,this.vw=20,this.Us=50,this.Fw=0,this.Rw=31,this.Ow=0,this.Iw=25,this.Ew=10,this.Uw=10,this.Vw=20,this.Bw=!0,this.zw=T.Default,this.Xw=!0,this.Gw=T.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.Si=t.sorting,this.Mi=t.comparer,this.Xt=t.angle,this.de=t.alignment,this.Tw=t.nodeIndent,this.Dw=t.nodeIndentPastParent,this.vw=t.nodeSpacing,this.Us=t.layerSpacing,this.Fw=t.layerSpacingParentOverlap,this.Rw=t.compaction,this.Ow=t.breadthLimit,this.Iw=t.rowSpacing,this.Ew=t.rowIndent,this.Uw=t.commentSpacing,this.Vw=t.commentMargin,this.Bw=t.setsPortSpot,this.zw=t.portSpot,this.Xw=t.setsChildPortSpot,this.Gw=t.childPortSpot)}get initialized(){return this.uP}set initialized(t){this.uP!==t&&(m.s(t,"boolean",Rt,"initialized"),this.uP=t)}get parent(){return this.dP}set parent(t){this.dP!==t&&(this.dP=t)}get children(){return this.gP}set children(t){if(this.gP!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",Rt,"children:value"),t!==null){let e=t.length;for(let i=0;i<e;i++){let s=t[i]}}this.gP=t}}get level(){return this.mP}set level(t){this.mP!==t&&(m.s(t,"number",Rt,"level"),this.mP=t)}get descendantCount(){return this.pP}set descendantCount(t){this.pP!==t&&(m.s(t,"number",Rt,"descendantCount"),this.pP=t)}get maxChildrenCount(){return this.yP}set maxChildrenCount(t){this.yP!==t&&(m.s(t,"number",Rt,"maxChildrenCount"),this.yP=t)}get maxGenerationCount(){return this.wP}set maxGenerationCount(t){this.wP!==t&&(m.s(t,"number",Rt,"maxGenerationCount"),this.wP=t)}get comments(){return this.zi}set comments(t){if(this.zi!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",Rt,"comments:value"),t!==null){let e=t.length;for(let i=0;i<e;i++){let s=t[i]}}this.zi=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&&(m.S(t,Rt,"comparer"),this.Mi=t)}get angle(){return this.Xt}set angle(t){this.Xt!==t&&(m.s(t,"number",Rt,"angle"),this.Xt=t)}get alignment(){return this.de}set alignment(t){this.de!==t&&(this.de=t)}get nodeIndent(){return this.Tw}set nodeIndent(t){this.Tw!==t&&(m.s(t,"number",Rt,"nodeIndent"),this.Tw=t)}get nodeIndentPastParent(){return this.Dw}set nodeIndentPastParent(t){this.Dw!==t&&(m.s(t,"number",Rt,"nodeIndentPastParent"),this.Dw=t)}get nodeSpacing(){return this.vw}set nodeSpacing(t){this.vw!==t&&(m.s(t,"number",Rt,"nodeSpacing"),this.vw=t)}get layerSpacing(){return this.Us}set layerSpacing(t){this.Us!==t&&(m.s(t,"number",Rt,"layerSpacing"),this.Us=t)}get layerSpacingParentOverlap(){return this.Fw}set layerSpacingParentOverlap(t){this.Fw!==t&&(m.s(t,"number",Rt,"layerSpacingParentOverlap"),this.Fw=t)}get compaction(){return this.Rw}set compaction(t){this.Rw!==t&&(this.Rw=t)}get breadthLimit(){return this.Ow}set breadthLimit(t){this.Ow!==t&&(m.s(t,"number",Rt,"breadthLimit"),this.Ow=t)}get rowSpacing(){return this.Iw}set rowSpacing(t){this.Iw!==t&&(m.s(t,"number",Rt,"rowSpacing"),this.Iw=t)}get rowIndent(){return this.Ew}set rowIndent(t){this.Ew!==t&&(m.s(t,"number",Rt,"rowIndent"),this.Ew=t)}get commentSpacing(){return this.Uw}set commentSpacing(t){this.Uw!==t&&(m.s(t,"number",Rt,"commentSpacing"),this.Uw=t)}get commentMargin(){return this.Vw}set commentMargin(t){this.Vw!==t&&(m.s(t,"number",Rt,"commentMargin"),this.Vw=t)}get setsPortSpot(){return this.Bw}set setsPortSpot(t){this.Bw!==t&&(m.s(t,"boolean",Rt,"setsPortSpot"),this.Bw=t)}get portSpot(){return this.zw}set portSpot(t){this.zw.equals(t)||(this.zw=t)}get setsChildPortSpot(){return this.Xw}set setsChildPortSpot(t){this.Xw!==t&&(m.s(t,"boolean",Rt,"setsChildPortSpot"),this.Xw=t)}get childPortSpot(){return this.Gw}set childPortSpot(t){this.Gw.equals(t)||(this.Gw=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 sn extends ei{xP;constructor(t){super(t),this.xP=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:m.o("Unhandled path value "+e.ws.toString())}if(i===null||s===null)return;let n=this.xP;if(n.x===0&&n.y===0){this.MU(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,u=t.isOrthogonal,c=0,d,f;if(t.startRoute(),u||l){for(c=2;t.pointsCount>4;)t.removePoint(2);d=t.getPoint(1),f=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);d=t.getPoint(0),f=t.getPoint(t.pointsCount-1)}let p=t.getPoint(t.pointsCount-1),g=0;r===0?(i.alignment===23?(g=o.bottom+n.y,n.y===0&&d.y>p.y+i.rowIndent&&(g=Math.min(g,Math.max(d.y,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.top+n.y,n.y===0&&d.y<p.y-i.rowIndent&&(g=Math.max(g,Math.min(d.y,g+e.computeNodeIndent(i))))):g=o.y+o.height/2+n.y,l?(t.insertPointAt(c,d.x,g),c++,t.insertPointAt(c,o.right+a,g),c++,t.insertPointAt(c,o.right+a+(n.x-h)/3,g),c++,t.insertPointAt(c,o.right+a+(n.x-h)*2/3,g),c++,t.insertPointAt(c,o.right+a+(n.x-h),g),c++,t.insertPointAt(c,f.x,g),c++):(u&&(t.insertPointAt(c,o.right+a/2,d.y),c++),t.insertPointAt(c,o.right+a/2,g),c++,t.insertPointAt(c,o.right+a+n.x-(u?h/2:h),g),c++,u&&(t.insertPointAt(c,t.getPoint(c-1).x,f.y),c++))):r===90?(i.alignment===23?(g=o.right+n.x,n.x===0&&d.x>p.x+i.rowIndent&&(g=Math.min(g,Math.max(d.x,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.left+n.x,n.x===0&&d.x<p.x-i.rowIndent&&(g=Math.max(g,Math.min(d.x,g+e.computeNodeIndent(i))))):g=o.x+o.width/2+n.x,l?(t.insertPointAt(c,g,d.y),c++,t.insertPointAt(c,g,o.bottom+a),c++,t.insertPointAt(c,g,o.bottom+a+(n.y-h)/3),c++,t.insertPointAt(c,g,o.bottom+a+(n.y-h)*2/3),c++,t.insertPointAt(c,g,o.bottom+a+(n.y-h)),c++,t.insertPointAt(c,g,f.y),c++):(u&&(t.insertPointAt(c,d.x,o.bottom+a/2),c++),t.insertPointAt(c,g,o.bottom+a/2),c++,t.insertPointAt(c,g,o.bottom+a+n.y-(u?h/2:h)),c++,u&&(t.insertPointAt(c,f.x,t.getPoint(c-1).y),c++))):r===180?(i.alignment===23?(g=o.bottom+n.y,n.y===0&&d.y>p.y+i.rowIndent&&(g=Math.min(g,Math.max(d.y,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.top+n.y,n.y===0&&d.y<p.y-i.rowIndent&&(g=Math.max(g,Math.min(d.y,g+e.computeNodeIndent(i))))):g=o.y+o.height/2+n.y,l?(t.insertPointAt(c,d.x,g),c++,t.insertPointAt(c,o.left-a,g),c++,t.insertPointAt(c,o.left-a+(n.x+h)/3,g),c++,t.insertPointAt(c,o.left-a+(n.x+h)*2/3,g),c++,t.insertPointAt(c,o.left-a+(n.x+h),g),c++,t.insertPointAt(c,f.x,g),c++):(u&&(t.insertPointAt(c,o.left-a/2,d.y),c++),t.insertPointAt(c,o.left-a/2,g),c++,t.insertPointAt(c,o.left-a+n.x+(u?h/2:h),g),c++,u&&(t.insertPointAt(c,t.getPoint(c-1).x,f.y),c++))):r===270?(i.alignment===23?(g=o.right+n.x,n.x===0&&d.x>p.x+i.rowIndent&&(g=Math.min(g,Math.max(d.x,g-e.computeNodeIndent(i))))):i.alignment===22?(g=o.left+n.x,n.x===0&&d.x<p.x-i.rowIndent&&(g=Math.max(g,Math.min(d.x,g+e.computeNodeIndent(i))))):g=o.x+o.width/2+n.x,l?(t.insertPointAt(c,g,d.y),c++,t.insertPointAt(c,g,o.top-a),c++,t.insertPointAt(c,g,o.top-a+(n.y+h)/3),c++,t.insertPointAt(c,g,o.top-a+(n.y+h)*2/3),c++,t.insertPointAt(c,g,o.top-a+(n.y+h)),c++,t.insertPointAt(c,g,f.y),c++):(u&&(t.insertPointAt(c,d.x,o.top-a/2),c++),t.insertPointAt(c,g,o.top-a/2),c++,t.insertPointAt(c,g,o.top-a+n.y+(u?h/2:h)),c++,u&&(t.insertPointAt(c,f.x,t.getPoint(c-1).y),c++))):m.o("Invalid angle "+r),t.commitRoute()}MU(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,u=i.isOrthogonal,c=this.fromVertex,d=s.isBusAlignment(c.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 u?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 u?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 u?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 u?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.is}set fromVertex(t){this.is!==t&&(this.is=t)}get toVertex(){return this.ss}set toVertex(t){this.ss!==t&&(this.ss=t)}get relativePoint(){return this.xP}set relativePoint(t){this.xP.set(t)}}class be{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 Ge{hs=new Set;bu=new Mt;bP="light";kP="light";PP=!1;NL=!0;Qg="light";zF=t=>{let e=t.matches?"dark":"light";e!==this.Qg&&(this.Qg=e,this.kP==="system"&&this.updateDiagrams())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.bu.set("light",{colors:{...be.Light.colors},fonts:{...be.Light.fonts},numbers:{...be.Light.numbers},margins:{...be.Light.margins},arrowheads:{...be.Light.arrowheads}}),this.bu.set("dark",{colors:{...be.Dark.colors},fonts:{...be.Dark.fonts},numbers:{...be.Dark.numbers},margins:{...be.Dark.margins},arrowheads:{...be.Dark.arrowheads}})),K.matchMedia&&(this.Qg=K.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.bP}set defaultTheme(t){this.bP!==t&&(m.s(t,"string",Ge,"defaultTheme"),this.bP=t,this.updateDiagrams())}get currentTheme(){return this.kP}set currentTheme(t){this.kP!==t&&(m.s(t,"string",Ge,"currentTheme"),this.kP=t,this.updateDiagrams())}get changesDivBackground(){return this.PP}set changesDivBackground(t){if(this.PP!==t&&(this.PP=t,t))for(let e of this.hs)e.setDivBackground(this.findValue("div","","fill")),e.T("ThemeChanged",this)}get readsCssVariables(){return this.NL}set readsCssVariables(t){this.NL!==t&&(this.NL=t,this.updateDiagrams())}get preferredColorScheme(){return this.Qg}addDiagram(t){return this.hs.add(t),this.CL(t),this}removeDiagram(t){return this.hs.delete(t),this.CL(t),this}iO(){this.hs.size===0&&K.matchMedia&&K.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.zF)}sO(){this.hs.size===0&&K.matchMedia&&K.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.zF)}set(t,e){t===""&&(t=this.bP),t==="system"&&(t=this.Qg);let i=this.bu.get(t);return i?i=this.XF(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 u=h[l];if(u!==""&&(n=n[u],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=Ge.NU.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.CL(t)}CL(t){let e=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.PP&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=e,t.T("ThemeChanged",this)}XF(t,e){for(let i in e)if(m.Yw(e,i))try{e[i]?.constructor===Object?t[i]=this.XF(t[i]??{},e[i]):t[i]=e[i]}catch{delete t[i]}return t}static NU=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 nn{Pt;a;Be;Pl;constructor(){this.a=Y.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.Ol=!0,t.requestUpdate())}invalidateRouter(){this.a!==null&&(this.a.Ol=!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":m.Gn(this.constructor)}}class _n extends nn{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Y?t.np:t.diagram?.np)?super.canRoute(t):!1}isRoutable(t,e){return!(!t.isAvoiding||t.containingGroup!==(e instanceof ht?e:null)||t.toNode===null||t.fromNode===null||t.pointsCount<4)}routeLinks(t,e){let i=e instanceof Y?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(j.va,j.va),l.unionPoint(o.getPoint(0));let u=o.toNode.actualBounds.copy();u.inflate(j.va,j.va),u.unionPoint(o.getPoint(r-1)),this.CU(o,l,u,n)&&this.LU(o,a,o.PC,h,o.SC,l,u,n),o.commitRoute()}}CU(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 u=2;u<o-3;u++){let c=t.getPoint(u),d=t.getPoint(u+1);if(!s.isUnoccupied(Math.min(c.x,d.x),Math.min(c.y,d.y),Math.abs(c.x-d.x),Math.abs(c.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))}LU(t,e,i,s,n,o,r,a){let h=t.diagram;if(h===null)return;let l=e,u=s,c=P.gn,d=P.gn;if(h.isVirtualized){let g=a.bounds.copy(),y=t.getPoint(2),b=t.getPoint(t.pointsCount-3);g.inflate(-a.cellWidth,-a.cellHeight);let v=P.l();a.og(e.x,e.y)||(C.Al(g.x,g.y,g.x+g.width,g.y+g.height,e.x,e.y,y.x,y.y,v)?(c=e=v.copy(),i=v.directionPoint(y)):C.Al(g.x,g.y,g.x+g.width,g.y+g.height,y.x,y.y,b.x,b.y,v)?(c=e=v.copy(),i=v.directionPoint(b)):C.Al(g.x,g.y,g.x+g.width,g.y+g.height,b.x,b.y,s.x,s.y,v)&&(c=e=v.copy(),i=v.directionPoint(s))),a.og(s.x,s.y)||(C.Al(g.x,g.y,g.x+g.width,g.y+g.height,s.x,s.y,b.x,b.y,v)?(d=s=v.copy(),n=b.directionPoint(v)):C.Al(g.x,g.y,g.x+g.width,g.y+g.height,b.x,b.y,y.x,y.y,v)?(d=s=v.copy(),n=y.directionPoint(v)):C.Al(g.x,g.y,g.x+g.width,g.y+g.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.cf,a.cellHeight*a.cf),a.wv(e,i,s,n,f,!0);let p=a.wo(s.x,s.y);if(!a.Zy&&p>=Ot.ng&&(a.DT(),f.inflate(a.cellWidth*a.E2,a.cellHeight*a.U2),a.wv(e,i,s,n,f,!1),p=a.wo(s.x,s.y)),!a.Zy&&p<Ot.ng&&!a.KE(s.x,s.y)){t.points.removeRange(2,t.pointsCount-3),this.LL(t,a,s.x,s.y,n,!0);let g=0,y=90,b=180,v=270,w=t.getPoint(2);if(t.pointsCount<4)i===g||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===g||i===b)if(C.c(w.x,k.x)){let S=i===g?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 C.c(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(C.c(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 C.c(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(c.isReal()){let k=t.getPoint(1),S=t.getPoint(2);k.x!==S.x&&k.y!==S.y?i===g||i===b?t.insertPointAt(2,k.x,S.y):t.insertPointAt(2,S.x,k.y):i===g||i===b?t.insertPointAt(2,l.x,c.y):t.insertPointAt(2,c.x,l.y)}d.isReal()&&(n===g||n===b?t.insertPointAt(t.pointsCount-2,u.x,d.y):t.insertPointAt(t.pointsCount-2,d.x,u.y))}}LL(t,e,i,s,n,o){let r=e.cellWidth,a=e.cellHeight,h=e.wo(i,s),l=i,u=s,c=l,d=u;for(n===0?c+=r:n===90?d+=a:n===180?c-=r:d-=a,t.DC&&h>Ot.sc&&e.wo(c,d)!==h-1&&(e.wo(l-r,u)===h-1?(n=180,c=l-r,d=u):e.wo(l+r,u)===h-1?(n=0,c=l+r,d=u):e.wo(l,u-a)===h-1?(n=270,c=l,d=u-a):e.wo(l,u+a)===h-1&&(n=90,c=l,d=u+a));h>Ot.sc&&e.wo(c,d)===h-1;)l=c,u=d,n===0?c+=r:n===90?d+=a:n===180?c-=r:d-=a,h-=1;if(o?h>Ot.sc&&(n===180||n===0?l=Math.floor(l/r)*r+r/2:(n===90||n===270)&&(u=Math.floor(u/a)*a+a/2)):(l=Math.floor(l/r)*r+r/2,u=Math.floor(u/a)*a+a/2),h>Ot.sc){let f=n,p=l,g=u;if(n===0?(f=90,g+=a):n===90?(f=180,p-=r):n===180?(f=270,g-=a):n===270&&(f=0,p+=r),e.wo(p,g)===h-1)this.LL(t,e,p,g,f,!1);else{let y=l,b=u;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.wo(y,b)===h-1&&this.LL(t,e,y,b,f,!1)}}t.insertPointAt(t.pointsCount-2,l,u)}}ne.prototype.initializeStandardTools=function(){return this.Jt("Action",new Fs,this.mouseDownTools),this.Jt("Relinking",new $e,this.mouseDownTools),this.Jt("LinkReshaping",new Je,this.mouseDownTools),this.Jt("Rotating",new De,this.mouseDownTools),this.Jt("Resizing",new Ze,this.mouseDownTools),this.Jt("Linking",new Le,this.mouseMoveTools),this.Jt("Dragging",new Tt,this.mouseMoveTools),this.Jt("DragSelecting",new ri,this.mouseMoveTools),this.Jt("Panning",new ki,this.mouseMoveTools),this.Jt("ContextMenu",new It,this.mouseUpTools),this.Jt("TextEditing",new oe,this.mouseUpTools),this.Jt("ClickCreating",new Qe,this.mouseUpTools),this.Jt("ClickSelecting",new Ds,this.mouseUpTools),this},Y.d2("GraphLinksModel",Zn),Y.d2("TreeModel",Qn);let Ai=K.go,gi={get version(){return Y.version},Group:ht,List:q,Set:V,Map:Mt,Point:P,Size:st,Rect:I,Margin:Dt,Spot:T,Geometry:wt,PathFigure:zt,PathSegment:mt,InputEvent:Qt,DiagramEvent:wi,ChangedEvent:Xe,Model:ut,GraphLinksModel:Xt,TreeModel:je,Binding:te,ThemeBinding:ii,Transaction:oi,UndoManager:vi,CommandHandler:jt,Tool:$t,DraggingTool:Tt,DraggingInfo:Ke,DraggingOptions:Pi,LinkingBaseTool:ae,LinkingTool:Le,RelinkingTool:$e,LinkReshapingTool:Je,ResizingTool:Ze,RotatingTool:De,ClickSelectingTool:Ds,ActionTool:Fs,ClickCreatingTool:Qe,HTMLInfo:fe,ContextMenuTool:It,DragSelectingTool:ri,PanningTool:ki,TextEditingTool:oe,ToolManager:ne,Animation:ye,AnimationManager:he,AnimationTrigger:ai,Layer:Et,Diagram:Y,Palette:Rn,Overview:hi,Brush:R,GraphObject:J,Panel:G,RowColumnDefinition:Kt,Shape:et,TextBlock:lt,Picture:Bt,Part:pt,Adornment:vt,Node:$,Link:j,Placeholder:le,Layout:_t,LayoutNetwork:Ee,LayoutVertex:Ie,LayoutEdge:ei,GridLayout:Ue,PanelLayout:Lt,CircularLayout:Be,CircularNetwork:Ws,CircularVertex:di,CircularEdge:$s,ForceDirectedLayout:ee,ForceDirectedNetwork:Js,ForceDirectedVertex:Ve,ForceDirectedEdge:fi,LayeredDigraphLayout:Ae,LayeredDigraphNetwork:tn,LayeredDigraphVertex:si,LayeredDigraphEdge:Se,TreeLayout:Vt,TreeNetwork:gs,TreeVertex:Rt,TreeEdge:sn,Themes:be,ThemeManager:Ge,Router:nn,AnimationStyle:Is,AutoScale:Ii,CycleMode:Vs,Flip:Ks,TextFormat:Yi,ImageStretch:ji,LayoutConditions:Gs,LinkAdjusting:Hi,Curve:$i,Routing:Wi,Orientation:Vi,TextOverflow:js,PortSpreading:qs,ScrollMode:zs,CollapsePolicy:Xs,Sizing:zi,TriggerStart:Bs,Stretch:Bi,ViewboxStretch:Us,Wrap:Ki,BrushType:Oe,ColorSpace:Ys,GeometryStretch:Ri,GeometryType:ze,SegmentType:ni,BindingMode:Ci,ChangeType:Ei,CircularArrangement:ts,CircularDirection:es,CircularNodeDiameterFormula:ss,CircularSorting:is,GridAlignment:Zi,GridArrangement:Qi,GridSorting:_i,LayeredDigraphAggressive:as,LayeredDigraphAlign:_s,LayeredDigraphCycleRemove:ns,LayeredDigraphInit:rs,LayeredDigraphLayering:os,LayeredDigraphPack:Qs,TreeAlignment:us,TreeArrangement:fs,TreeCompaction:cs,TreeLayerStyle:en,TreePath:hs,TreeSorting:ls,TreeStyle:ds,GestureMode:As,LinkingDirection:Ts,ReshapingBehavior:Ls,TextEditingAccept:Os,TextEditingStarting:Rs,TextEditingState:Es,WheelMode:Cs};for(let x in gi){let t=gi[x];m.it(t)&&t!==Yi&&(t.className=x)}m.$(Ai)&&Ai.version&&m.ne("WARNING: a `go` object on the root object is already defined. "+("Debug"in Ai?"debug ":"")+"version: "+Ai.version+", replaced with version: "+gi.version),Y.prototype.go=gi,K.go=gi})();var Eo=typeof global<"u"?global.go:self.go,H=typeof global<"u"?global.go:self.go,Io=H.Group,Bo=H.List,Vo=H.Set;var zo=H.Map;var cn=H.Point,pi=H.Size,Xo=H.Rect,ys=H.Margin,Ne=H.Spot,Ko=H.Geometry,Yo=H.PathFigure,Uo=H.PathSegment,jo=H.InputEvent,Go=H.DiagramEvent,qo=H.ChangedEvent,Ho=H.Model,dn=H.GraphLinksModel,Wo=H.TreeModel,$o=H.Binding,Jo=H.ThemeBinding,Zo=H.Transaction,Qo=H.UndoManager,_o=H.CommandHandler,tr=H.Tool,er=H.DraggingTool,ir=H.DraggingInfo,sr=H.DraggingOptions,nr=H.LinkingBaseTool,or=H.LinkingTool,rr=H.RelinkingTool,ar=H.LinkReshapingTool,hr=H.ResizingTool,lr=H.RotatingTool,ur=H.ClickSelectingTool,cr=H.ActionTool,dr=H.ClickCreatingTool,fr=H.HTMLInfo,gr=H.ContextMenuTool,mr=H.DragSelectingTool,pr=H.PanningTool,yr=H.TextEditingTool,xr=H.ToolManager,xs=H.Animation,br=H.AnimationManager,wr=H.AnimationTrigger,vr=H.Layer,Ti=H.Diagram,kr=H.Palette,Pr=H.Overview,Sr=H.Brush,Mr=H.GraphObject,qe=H.Panel,Nr=H.RowColumnDefinition,yi=H.Shape,Li=H.TextBlock,fn=H.Picture,Cr=H.Part,bs=H.Adornment,ws=H.Node,vs=H.Link,gn=H.Placeholder,Ar=H.Layout,Tr=H.LayoutNetwork,Lr=H.LayoutVertex,Dr=H.LayoutEdge,Fr=H.GridLayout,Or=H.PanelLayout,Rr=H.CircularLayout,Er=H.CircularNetwork,Ir=H.CircularVertex,Br=H.CircularEdge,Vr=H.ForceDirectedLayout,zr=H.ForceDirectedNetwork,Xr=H.ForceDirectedVertex,Kr=H.ForceDirectedEdge,mn=H.LayeredDigraphLayout,Yr=H.LayeredDigraphNetwork,Ur=H.LayeredDigraphVertex,jr=H.LayeredDigraphEdge,Gr=H.TreeLayout,qr=H.TreeNetwork,Hr=H.TreeVertex,Wr=H.TreeEdge,$r=H.Themes,Jr=H.ThemeManager,Zr=H.Router,Qr=H.version,_r=H.AnimationStyle,pn=H.AutoScale,ta=H.Curve,ea=H.CycleMode,ia=H.Flip,sa=H.ImageStretch,na=H.LayoutConditions,oa=H.LinkAdjusting,ra=H.Orientation,aa=H.PortSpreading,yn=H.Routing,xn=H.ScrollMode,ha=H.CollapsePolicy,la=H.Sizing,ua=H.TriggerStart,bn=H.Stretch,ca=H.TextFormat,ks=H.TextOverflow,da=H.ViewboxStretch,Ps=H.Wrap,fa=H.BrushType,ga=H.ColorSpace,ma=H.GeometryStretch,pa=H.GeometryType,ya=H.SegmentType,xa=H.BindingMode,ba=H.ChangeType,wa=H.CircularArrangement,va=H.CircularDirection,ka=H.CircularNodeDiameterFormula,Pa=H.CircularSorting,Sa=H.GridAlignment,Ma=H.GridArrangement,Na=H.GridSorting,Ca=H.LayeredDigraphAggressive,Aa=H.LayeredDigraphAlign,Ta=H.LayeredDigraphCycleRemove,La=H.LayeredDigraphInit,Da=H.LayeredDigraphLayering,Fa=H.LayeredDigraphPack,Oa=H.TreeAlignment,Ra=H.TreeArrangement,Ea=H.TreeCompaction,Ia=H.TreeLayerStyle,Ba=H.TreePath,Va=H.TreeSorting,za=H.TreeStyle,Xa=H.GestureMode,Ka=H.LinkingDirection,Ya=H.ReshapingBehavior,Ua=H.TextEditingAccept,ja=H.TextEditingStarting,Ga=H.TextEditingState,wn=H.WheelMode;var eo=on`#filter-bar{background-color:var(--calcite-color-surface-2);position:absolute;top:16px;right:196px;z-index:100;box-shadow:var(--calcite-shadow-sm)}#filteredViewButtonDiv{padding:8px}#filteredViewButtonLabel{--calcite-label-margin-bottom: 0}#graph-navigation-bar{background-color:var(--calcite-color-surface-2);position:absolute;top:16px;right:16px;z-index:100}#graph-navigation-controls{position:absolute;top:0;right:0;box-shadow:var(--calcite-shadow-sm)}.z-index-1{z-index:1}#diagram-panel{--calcite-panel-space: 0px}#diagram-shell-panel{--calcite-color-surface-1: var(--calcite-color-surface-2);padding:16px}`,io=15,so=15,no=10,xi=new pi(220,48),oo=1,ro=8,vn=new pi(48,48),ao=new pi(16,16),kn=new pi(153,17),ho='400 0.75rem "Avenir Next", Avenir, "Helvetica Neue", sans-serif',lo='500 0.75rem "Avenir Next", Avenir, "Helvetica Neue", sans-serif',uo="val(--calcite-color-surface-1)",co=bi("--calcite-color-border-1"),Pn=bi("--calcite-color-surface-2"),Di=bi("--calcite-color-text-1"),Sn=bi("--calcite-color-border-input"),fo=bi("--calcite-color-surface-2"),Fi=1,Nn=.3,Ss=1,Cn=.2,go=1;function mo(K){let m=document.createElement("div");m.style.width="100%",m.style.height="100%",K.appendChild(m);let rt=new Ti(m,{click:Po,contentAlignment:Ne.Center,dragSelectingTool:null,hoverDelay:50,initialAutoScale:pn.Uniform,layout:new mn({columnSpacing:io,layerSpacing:so}),padding:no,scrollMode:xn.Infinite,"toolManager.hoverDelay":50,"toolManager.mouseWheelBehavior":wn.Zoom});rt.nodeTemplate=new ws("Auto",{click:So,movable:!1,opacity:Fi,toolTip:new bs("Auto",{isShadowed:!0,margin:new ys(12,16,6,16),padding:0,shadowBlur:16,shadowColor:To(Di,.05),shadowOffset:new cn(0,0)}).add(new qe("Vertical",{background:fo,margin:0}).add(new Li({margin:14,stroke:Di}).bind("text","title")))}).bind("text","title").add(new yi({desiredSize:xi,fill:Pn,geometryString:ko(xi.width,xi.height,ro,vn.width,!!Pn),height:xi.height,portId:"",stroke:co,strokeWidth:oo,width:xi.width})).add(new qe("Horizontal",{alignment:Ne.Left,stretch:bn.Horizontal}).add(new qe("Horizontal",{alignment:Ne.Left,desiredSize:vn,margin:1}).add(new qe("Horizontal",{alignment:Ne.Center,margin:16}).add(new fn({desiredSize:ao}).bind("source","",dt=>un(dt.itemType,dt.itemTypeKeywords)))),new qe("Horizontal",{alignment:Ne.Right,margin:new ys(4,8,0,8)}).add(new qe("Vertical",{}).add(new Li({alignment:Ne.Left,desiredSize:kn,font:lo,overflow:ks.Ellipsis,stroke:Di,wrap:Ps.None}).bind("text","title"),new Li({alignment:Ne.Left,desiredSize:kn,font:ho,overflow:ks.Ellipsis,stroke:Di,wrap:Ps.None}).bind("text","itemTypeForDisplay"))))),rt.commandHandler.zoomFactor=1.05,rt.setDivBackground(uo);let bt=rt.toolManager.clickSelectingTool;bt.standardMouseSelect=function(){};let Pt=rt.toolManager.draggingTool;return Pt.isEnabled=!1,rt.linkTemplate=new vs({corner:5,movable:!1,routing:yn.Orthogonal,selectable:!1}).add(new yi({opacity:Ss,stroke:Sn}),new yi({fill:Sn,opacity:Ss,stroke:null,toArrow:"Standard"})),rt}function He(K,m){K.model=new dn(m.nodes,m.links,{linkFromPortIdProperty:"fromPort",linkToPortIdProperty:"toPort"})}function po(K,m,rt,bt=!0){if(bt){let q=Mo(K,rt);q.addEventListener("calciteSwitchChange",()=>document.dispatchEvent(new CustomEvent("filteredViewChanged",{detail:q.checked})))}let{resetButton:Pt,centerButton:dt,zoomInButton:gt,zoomOutButton:kt}=No(K,rt);Pt.addEventListener("click",()=>Ao(m)),dt.addEventListener("click",()=>m.zoomToFit()),gt.addEventListener("click",()=>m.commandHandler.increaseZoom()),kt.addEventListener("click",()=>m.commandHandler.decreaseZoom())}function yo(K,m,rt){let bt=mo(K);return He(bt,m),po(K,bt,rt),bt}function An(K){let m=new Set,rt=new Set;function bt(dt){dt.findLinksInto().each(gt=>{rt.add(gt);let kt=gt.fromNode;kt&&!m.has(kt)&&(m.add(kt),bt(kt))})}bt(K);function Pt(dt){dt.findLinksOutOf().each(gt=>{rt.add(gt);let kt=gt.toNode;kt&&!m.has(kt)&&(m.add(kt),Pt(kt))})}return Pt(K),{connectedNodes:m,connectedLinks:rt}}function xo(K,m=!1,rt){let bt=[],Pt=K.map(gt=>{if(gt.type!=="Group"){let kt=vo(gt);return wo(gt,kt,m,rt)}else{bt.push(gt.id);return}}).filter(gt=>gt!==void 0),dt=[];return Pt.forEach(gt=>{(K.find(kt=>kt.id===gt.itemId)?.dependencies||[]).forEach(kt=>{let q=Pt.find(Zt=>Zt?.itemId===kt);q&&dt.push({from:q.key,fromSpot:Ne.AllSides,to:gt.key,toSpot:Ne.AllSides})})}),{nodes:Pt,links:dt,groupPseudoNodes:bt}}function bo(K,m,rt,bt=!0){let Pt=K.diagram;if(!Pt)return;let dt={};if(bt){for(let gt of Pt.nodes)dt[gt.key]=gt===K?Fi:Nn;for(let gt of Pt.links){let kt=`${gt.fromNode?.key}-${gt.toNode?.key}`;dt[kt]=Cn}{let{connectedNodes:gt,connectedLinks:kt}=An(K);for(let q of gt)dt[q.key]=Fi;for(let q of kt){let Zt=`${q.fromNode?.key}-${q.toNode?.key}`;dt[Zt]=go}}}if(rt&&(rt.adornedObject=K),bt){let gt=new xs;gt.duration=1;for(let kt of Pt.nodes)gt.add(kt,"opacity",kt.opacity,dt[kt.key]);for(let kt of Pt.links){let q=`${kt.fromNode?.key}-${kt.toNode?.key}`;gt.add(kt,"opacity",kt.opacity,dt[q])}gt.start()}}function Mn(K,m,rt,bt,Pt=!0){if(K.length===0)return;let dt=m[0].diagram;if(!dt)return;let gt={};if(Pt){for(let kt of dt.nodes){let q=K.includes(kt.key);gt[kt.key]=!rt||q?Fi:Nn}for(let kt of dt.links){let q=`${kt.fromNode?.key}-${kt.toNode?.key}`;gt[q]=rt?Cn:Ss}}if(Object.keys(bt).forEach(kt=>{bt[kt].adornedObject=null}),Pt){let kt=new xs;kt.duration=1;for(let q of dt.nodes)kt.add(q,"opacity",q.opacity,gt[q.key]);for(let q of dt.links){let Zt=`${q.fromNode?.key}-${q.toNode?.key}`;kt.add(q,"opacity",q.opacity,gt[Zt])}kt.start()}}function wo(K,m,rt=!1,bt){return{key:m,title:K.title,itemId:K.id,itemType:K.type,itemTypeForDisplay:Co(K.type,K.typeKeywords),itemTypeKeywords:K.typeKeywords,group:K.type,url:rt?`${bt}?id=${K.id}`:void 0}}function vo(K){return K.id}function ko(K,m,rt,bt=0,Pt=!1){let dt="";Pt&&(dt+="F");let gt=K-2*rt,kt=m-2*rt;return dt+=" M0 0",dt+=` h${gt}`,dt+=` a${rt} ${rt} 0 0 1 ${rt} ${rt}`,dt+=` v${kt}`,dt+=` a${rt} ${rt} 0 0 1 ${-rt} ${rt}`,dt+=` h${-gt}`,dt+=` a${rt} ${rt} 0 0 1 ${-rt} ${-rt}`,dt+=` v${-kt}`,dt+=` a${rt} ${rt} 0 0 1 ${rt} ${-rt}`,bt>0&&(dt+=` M${bt-rt} 0 v${m}`),dt}function Po(){document.dispatchEvent(new CustomEvent("clickInDiagram"))}function So(K,m){let rt=m.part;rt instanceof ws&&(rt.selectionAdorned=!1,document.dispatchEvent(new CustomEvent("clickOnNode",{detail:rt})))}function Mo(K,m){let rt=document.createElement("calcite-switch");rt.id="filteredViewButton",rt.label=m.filteredView;let bt=document.createElement("calcite-label");bt.id="filteredViewButtonLabel",bt.setAttribute("layout","inline"),bt.innerHTML=m.filteredView,bt.appendChild(rt);let Pt=document.createElement("div");Pt.id="filteredViewButtonDiv",Pt.appendChild(bt);let dt=document.createElement("calcite-action-bar");dt.id="filter-bar-controls",dt.layout="horizontal",dt.expandDisabled=!0,dt.appendChild(Pt);let gt=document.createElement("div");return gt.id="filter-bar",K.appendChild(gt),gt.appendChild(dt),rt}function No(K,m){let rt=document.createElement("calcite-action");rt.icon="reset",rt.id="showHideGrayedOutButton";let bt=document.createElement("calcite-tooltip");bt.id="resetButtonTooltip",bt.innerHTML=m.reset,bt.overlayPositioning="fixed",bt.placement="bottom",bt.referenceElement=rt.id;let Pt=document.createElement("calcite-action");Pt.icon="zoom-to-object",Pt.id="centerButton";let dt=document.createElement("calcite-tooltip");dt.id="centerButtonTooltip",dt.innerHTML=m.centerDiagram,dt.overlayPositioning="fixed",dt.placement="bottom",dt.referenceElement=Pt.id;let gt=document.createElement("calcite-action");gt.icon="plus",gt.id="zoomInButton";let kt=document.createElement("calcite-tooltip");kt.id="zoomInButtonTooltip",kt.innerHTML=m.zoomIn,kt.overlayPositioning="fixed",kt.placement="bottom",kt.referenceElement=gt.id;let q=document.createElement("calcite-action");q.appearance="solid",q.icon="minus",q.id="zoomOutButton";let Zt=document.createElement("calcite-tooltip");Zt.id="zoomOutButtonTooltip",Zt.innerHTML=m.zoomOut,Zt.overlayPositioning="fixed",Zt.placement="bottom",Zt.referenceElement=q.id;let V=document.createElement("calcite-action-bar");V.id="graph-navigation-controls",V.layout="horizontal",V.expandDisabled=!0,V.appendChild(rt),V.appendChild(bt),V.appendChild(Pt),V.appendChild(dt),V.appendChild(gt),V.appendChild(kt),V.appendChild(q),V.appendChild(Zt);let We=document.createElement("div");return We.id="graph-navigation-bar",K.appendChild(We),We.appendChild(V),{resetButton:rt,centerButton:Pt,zoomInButton:gt,zoomOutButton:q}}function Co(K,m){let rt=K;if(K==="Feature Service"){let bt=m.indexOf("View Service")>-1,Pt=m.indexOf("Table")>-1;rt=bt&&Pt?"Table (hosted, view)":Pt?"Table (hosted)":bt?"Feature Layer (hosted, view)":"Feature Layer (hosted)"}return K==="Web Mapping Application"&&(rt=m.indexOf("configurableApp")>-1?"Instant App":rt),rt=K==="Geoprocessing Service"?"Tool":rt,rt=K==="Feed"?"Feed (hosted)":rt,rt=K==="Real Time Analytic"?"Real Time Analytic (hosted)":rt,rt=K==="Big Data Analytic"?"Big Data Analytic (hosted)":rt,rt=K==="Vector Tile Service"?"Tile Layer":rt,rt}function Ao(K){K.zoomToFit(),document.dispatchEvent(new CustomEvent("reset"))}function bi(K){let m=document.body;return getComputedStyle(m).getPropertyValue(K).trim()}function To(K,m){if(K=K.replace(/^#/,""),K.length===3&&(K=K.split("").map(dt=>dt+dt).join("")),K.length!==6)throw new Error("Invalid hex color");let rt=parseInt(K.slice(0,2),16),bt=parseInt(K.slice(2,4),16),Pt=parseInt(K.slice(4,6),16);return`rgba(${rt}, ${bt}, ${Pt}, ${m})`}var Lo=8,Do=15,Fo=Ro("--calcite-color-brand"),Oo=4;function Ro(K){let m=document.documentElement;return getComputedStyle(m).getPropertyValue(K).trim()}var Ms=class{constructor(m,rt,bt,Pt){this.indexPanel=m,this.diagramPanel=rt,this.diagramTranslations=bt,this.diagramKey=Pt,this.currentSelectedGroupId="",this.currentSelectedItemId="",this.diagramNeedsRedraw=!1,this.usefilteredView=!1,this.handle_clickInDiagram=dt=>{dt.stopImmediatePropagation(),(this.currentSelectedGroupId||this.currentSelectedItemId)&&(this.currentSelectedGroupId="",this.currentSelectedItemId="",this.diagramNeedsRedraw=this.usefilteredView,this.redraw())},this.handle_clickOnNode=dt=>{dt.stopImmediatePropagation();let gt=dt.detail.data.key;this.redraw(gt,gt===this.currentSelectedItemId)},this.handle_filteredViewChanged=dt=>{this.usefilteredView=dt.detail,this.diagramNeedsRedraw=!!this.currentSelectedGroupId||!!this.currentSelectedItemId,this.redraw(this.currentSelectedItemId||this.currentSelectedGroupId)},this.handle_reset=dt=>{dt.stopImmediatePropagation(),this.reset()},this.handle_solutionItemSelect=dt=>{dt.stopImmediatePropagation();let gt=dt.detail.itemId;this.redraw(gt,gt===this.currentSelectedItemId||gt===this.currentSelectedGroupId,!1)},Ti.licenseKey===""&&(Ti.licenseKey=Pt??"")}create(m,rt){this.collection=m,this.index=document.createElement("solution-item-accordion"),this.index.linkType="action",this.index.listSelectionMode="single",this.index.typeKeywords=rt,this.index.style.overflowY="auto",this.indexPanel.appendChild(this.index),this.index.templateInfos=m,this.allNodesAndLinks=xo(m),this.diagram=yo(this.diagramPanel,this.allNodesAndLinks,this.diagramTranslations),this.diagram.addDiagramListener("LayoutCompleted",()=>{setTimeout(()=>{this.diagram.zoomToFit()},1e3)}),vs.setRoutingParameter(44,600942),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(m=!0){this.index.deselectAll(),m&&this.index.collapseAll();let rt=this.getNodesFromDiagram(this.diagram),bt=rt.map(Pt=>Pt.data.key);Mn(bt,rt,!1,this.diagramNodeHighlighterIndex)}createNodeHighlighters(){this.diagramNodeIndex={},this.diagramNodeHighlighterIndex={},this.getNodesFromDiagram(this.diagram).forEach(m=>{this.diagramNodeIndex[m.data.key]=m;let rt=new bs("Auto",{background:"transparent",margin:2});rt.add(new yi("RoundedRectangle",{fill:"transparent",parameter1:Lo,parameter2:Do,stroke:Fo,strokeWidth:Oo})),rt.add(new gn({margin:1})),this.diagramNodeHighlighterIndex[m.data.key]=rt})}getNodeById(m){return this.diagramNodeIndex[m]}getNodesFromDiagram(m){let rt=[],bt=m.nodes.iterator;for(;bt.next();)rt.push(bt.value);return rt}redraw(m="",rt=!1,bt=!0){let Pt=this.allNodesAndLinks.groupPseudoNodes.includes(m);this.diagramNeedsRedraw&&(He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),this.diagramNeedsRedraw=!1);let dt=!1;if(this.clearSelections(bt),!!m){if(Pt){if(this.currentSelectedItemId="",this.currentSelectedGroupId!==m?this.currentSelectedGroupId=m:rt&&(this.currentSelectedGroupId=this.currentSelectedGroupId?"":m,dt=this.usefilteredView&&!this.currentSelectedGroupId),this.currentSelectedGroupId){this.usefilteredView&&(He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters());let gt=this.collection.filter(q=>q.id===m)[0],kt=gt.dependencies.map(q=>this.diagramNodeIndex[q]);if(this.usefilteredView){let q=kt.map(Zt=>Zt.data);He(this.diagram,{nodes:q,links:[]})}else Mn(gt.dependencies,kt,!0,this.diagramNodeHighlighterIndex);this.index.selectItem(this.currentSelectedGroupId)}}else{this.currentSelectedGroupId="",this.currentSelectedItemId!==m?this.currentSelectedItemId=m:rt&&(this.currentSelectedItemId=this.currentSelectedItemId?"":m,dt=this.usefilteredView&&!this.currentSelectedItemId);let gt=this.getNodeById(m);if((!gt||this.usefilteredView)&&(He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),gt=this.getNodeById(m),!gt))return;if(this.currentSelectedItemId){if(this.usefilteredView){let kt=An(gt);kt.connectedNodes.add(gt);let q=Array.from(kt.connectedNodes).map(V=>V.data),Zt=Array.from(kt.connectedLinks).map(V=>V.data);if(He(this.diagram,{nodes:q,links:Zt}),this.createNodeHighlighters(),gt=this.getNodeById(m),!gt)return}gt&&setTimeout(()=>bo(gt,!0,this.diagramNodeHighlighterIndex[m]),1),this.index.selectItem(this.currentSelectedItemId)}}dt&&this.reset()}}reset(){this.diagramNeedsRedraw=!1,this.currentSelectedGroupId="",this.currentSelectedItemId="",He(this.diagram,this.allNodesAndLinks),this.createNodeHighlighters(),this.clearSelections()}},Ns=class extends an{constructor(){super(...arguments),this.diagramKey="",this.templateInfoGraph=[],this.typeKeywords=[],this._diagramPanel=ms(),this._diagramShell=ms(),this._translations=ln({name:"solution-item-diagram",blocking:!0})}static{this.properties={diagramKey:1,templateInfoGraph:0,typeKeywords:0,_diagramPanel:16,_diagramShell:16,_translations:16}}static{this.styles=eo}updated(){if(this.solutionDisplay&&(this.solutionDisplay.dispose(),this.solutionDisplay=void 0),this.templateInfoGraph.length>0){let m={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 Ms(this._diagramShell.value,this._diagramPanel.value,m,this.diagramKey),this.solutionDisplay.create(this.templateInfoGraph,this.typeKeywords)}requestAnimationFrame(()=>this._preventDiagramScrollbars())}disconnectedCallback(){super.disconnectedCallback(),this.solutionDisplay&&(this.solutionDisplay.dispose(),this.solutionDisplay=void 0)}render(){return rn`<calcite-shell><calcite-shell-panel id=diagram-shell-panel slot=panel-start ${ps(this._diagramShell)}></calcite-shell-panel><calcite-panel class="z-index-1" id=diagram-panel slot=panel-bottom ${ps(this._diagramPanel)}></calcite-panel></calcite-shell>`}_preventDiagramScrollbars(){if(!this._diagramPanel.value)return;let m=this._diagramPanel.value.shadowRoot;if(!m)return;let rt=m.querySelector(".content-wrapper");rt instanceof HTMLElement&&(rt.style.overflow="hidden")}};hn("solution-item-diagram",Ns);export{Ns as SolutionItemDiagram};