@relation-graph/react 3.0.3 → 3.0.4
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.
- package/package.json +1 -1
- package/relation-graph.js +9 -9
- package/relation-graph.mjs +1212 -1091
- package/relation-graph.umd.js +9 -9
- package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvas.d.ts +1 -0
- package/types/packages/platforms/svelte/src/core4svelte/RelationGraphWithProvider.svelte.d.ts +1 -0
- package/types/packages/platforms/vue2/src/core4vue/editing/RGConnectTarget.vue.d.ts +9 -0
- package/types/packages/platforms/vue2/src/index.d.ts +9 -0
- package/types/packages/relation-graph-models/data/RGOptionsDataUtils.d.ts +0 -2
- package/types/packages/relation-graph-models/layouts/RGForceLayout.d.ts +1 -1
- package/types/packages/relation-graph-models/models/RelationGraphWith1View.d.ts +5 -0
- package/types/packages/relation-graph-models/models/RelationGraphWith2Data.d.ts +2 -0
- package/types/packages/relation-graph-models/models/RelationGraphWith6Effect.d.ts +2 -0
- package/types/packages/relation-graph-models/models/RelationGraphWith93Image.d.ts +2 -0
- package/types/packages/relation-graph-models/models/RelationGraphWith95Dom.d.ts +1 -0
- package/types/packages/relation-graph-models/models/RelationGraphWith99API.d.ts +1 -1
- package/types/packages/relation-graph-models/utils/line/RGPathGeneratorFor8.d.ts +2 -0
- package/types/packages/types.ts +12 -8
package/relation-graph.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("@charset \"UTF-8\";.relation-graph{box-sizing:border-box;position:relative;min-width:300px;min-height:300px;--editor-main-color: rgb(64, 165, 248);--editor-light-color: rgb(125, 192, 248);--editor-light2-color: rgb(168, 212, 248);--editor-light-opacity: rgba(57, 144, 216, .1);--rg-node-opacity: 1;--rg-node-font-size: 1rem;--rg-node-font-color: #000000;--rg-node-color: #eeeeee;--rg-node-border-color: #333333;--rg-node-border-width: 1px;--rg-node-border-radius: 3px;--rg-node-width: fit-content;--rg-node-height: fit-content;--rg-node-text-px: 10px;--rg-node-text-py: 3px;--rg-background-color: transparent;--rg-line-color: #888888;--rg-line-width: 1px;--rg-line-fontcolor: var(--rg-line-color, #666666);--rg-line-fontsize: 12px;--rg-line-opacity: 1;--rg-checked-item-bg-color: rgba(150, 150, 150, .2);--rg-checked-line-text-bg-color: rgb(234, 232, 232)}.relation-graph:focus{outline:none}.relation-graph .rg-graph-plugs{position:absolute;left:0px;top:0px;z-index:90;width:100%;height:100%;pointer-events:none;user-select:none}.relation-graph .rg-graph-plugs .rg-view-slot{position:relative;width:100%;height:100%}.relation-graph .rg-watermark{position:absolute;--watermark-width: 200px;--watermark-height: 100px;z-index:1200;overflow:visible;min-height:100px;min-width:100px;width:var(--watermark-width);height:var(--watermark-height);box-sizing:border-box}.relation-graph .rg-watermark div{box-sizing:border-box}.relation-graph .rg-watermark.rg-watermark-top{left:calc((100% - var(--watermark-width)) / 2);top:10px}.relation-graph .rg-watermark.rg-watermark-bottom{left:calc((100% - var(--watermark-width)) / 2);bottom:10px}.relation-graph .rg-watermark.rg-watermark-left{left:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-right{right:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-tl{left:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-tr{right:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-bl{left:10px;bottom:10px}.relation-graph .rg-watermark.rg-watermark-br{right:10px;bottom:10px}.relation-graph .rg-lines-container svg{overflow:visible}.relation-graph .rg-lines-svg{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-lines-container{overflow:visible;position:absolute;z-index:40;width:100%;top:0px;left:0px;pointer-events:none}.relation-graph .rg-lines-container-el-lines{z-index:80;pointer-events:none}.relation-graph .rg-lines-container-el-lines .rg-line-bg{pointer-events:stroke}.relation-graph .rg-lines-container-el-lines .rg-line-text{pointer-events:all}.relation-graph .rg-lines-svg-el-lines{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-nodes-container-wrapper{position:absolute;width:100%;top:0px;left:0px;z-index:50}.relation-graph .rg-nodes-container{position:relative;overflow:visible}.relation-graph .rg-map{background-color:var(--rg-background-color);overflow:hidden;cursor:default;user-select:none;opacity:.01;transition:none;width:100%;height:100%;position:relative}.relation-graph.rg-move-mode .rg-map{cursor:grab}.relation-graph .rg-map-ready{opacity:1;transition:opacity .5s ease;will-change:opacity}.relation-graph .rg-map-background-norepeat{background-repeat:no-repeat;background-position:right bottom}.relation-graph .rg-map-canvas{position:relative;user-select:none;pointer-events:none;top:0;left:0;border:none;z-index:3;overflow:visible;white-space:nowrap;transform-origin:0 0;will-change:transform}.relation-graph .rg-map-canvas .rg-events-all{pointer-events:all}.relation-graph.rg-enable-node-xy-animation .rg-node-peel{transition:transform .15s ease}.relation-graph.rg-enable-node-xy-animation .rg-line-peel{transition:none}.relation-graph.rg-enable-canvas-animation .rg-map-canvas{transition:transform .5s ease}.relation-graph.rg-enable-canvas-animation .rg-editing-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-line-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-connect-ctrl{opacity:0}.relation-graph .rg-canvas-behind{z-index:2;position:absolute}.relation-graph .rg-canvas-above{z-index:5;position:absolute}.relation-graph .rg-canvas-slot{overflow:visible;position:absolute;margin-top:0;margin-left:0}.relation-graph .rg-canvas-slot-behind{z-index:30;overflow:visible}.relation-graph .rg-canvas-slot-above{z-index:70;overflow:visible}.relation-graph .rg-single-graph{position:relative;overflow:visible}.relation-graph .rg-map img{-webkit-user-drag:none;-webkit-user-select:none}.relation-graph .rg-line-text{fill:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);paint-order:stroke;pointer-events:all}.relation-graph .rg-linetext-container{position:absolute;pointer-events:none;user-select:none;overflow:visible;left:0;top:0;z-index:45;display:block}.relation-graph .rg-linetext-container .rg-line-peel{width:fit-content}.relation-graph .rg-linetext-container .rg-line-peel .rg-line-label{display:block;color:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);transform-origin:0 0;position:absolute;user-select:none;pointer-events:all;box-sizing:border-box;padding:2px 6px;border-radius:5px;white-space:nowrap}.relation-graph .rg-linetext-container .rg-line-peel .rg-line-label-on-path{background-color:#fff}.relation-graph .rg-linetext-container .rg-line-checked .rg-line-label{background-color:var(--rg-checked-line-text-bg-color);color:#0f172a}.relation-graph .rg-linetext-container .rg-line-checked .rg-line-label-on-path{background-color:var(--rg-line-color, #ffffff)}.relation-graph .rg-line-peel{pointer-events:none;cursor:default;transition:opacity .2s ease-in;opacity:var(--rg-line-opacity, 1)}.relation-graph .rg-line{fill-rule:nonzero;stroke-linecap:round;stroke:var(--rg-line-color);stroke-width:var(--rg-line-width);pointer-events:none;fill:none;marker-end:var(--rg-line-marker-end);marker-start:var(--rg-line-marker-start)}.relation-graph .rg-line-bg{stroke:#fff;opacity:.01;fill:none;fill-rule:nonzero;stroke-linecap:round;pointer-events:stroke;stroke-width:calc(var(--rg-line-width) + 6px)}.relation-graph .rg-line-bg:hover{opacity:.7;stroke:var(--rg-checked-item-bg-color)}.relation-graph .rg-line-checked .rg-line-bg{stroke:var(--rg-checked-item-bg-color);opacity:1}.relation-graph .rg-line-checked .rg-line{z-index:100}.relation-graph .rg-line-checked .rg-line-text{stroke:var(--rg-checked-item-bg-color);stroke-width:2}.relation-graph .rg-line-disable-events{pointer-events:none!important}.relation-graph .rg-line-disable-events .rg-line-bg,.relation-graph .rg-line-disable-events .rg-line-text,.relation-graph .rg-linetext-container .rg-line-disable-events .rg-line-bg,.relation-graph .rg-linetext-container .rg-line-disable-events .rg-line-label{pointer-events:none}.relation-graph .rg-line-dashtype-1{stroke-dasharray:2,2,2;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-2{stroke-dasharray:5,5,5;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-3{stroke-dasharray:9,9,9;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-4{stroke-dasharray:5,5,15;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}@keyframes ACTRGLineChecked{0%{stroke-dashoffset:352px;stroke-dasharray:5,5,5}50%{stroke-dasharray:5,5,5;stroke-dashoffset:3px}to{stroke-dashoffset:352px;stroke-dasharray:5,5,5}}@keyframes rg-line-anm1{0%{stroke-dashoffset:100px;stroke-dasharray:5,5,5}to{stroke-dasharray:5,5,5;stroke-dashoffset:3px}}@keyframes rg-line-anm2{0%{stroke-dashoffset:0;stroke-dasharray:4,4,4}to{stroke-dashoffset:10px;stroke-dasharray:20,20,20}}@keyframes rg-line-anm3{0%{stroke-opacity:1}50%{stroke-opacity:.2}to{stroke-opacity:1}}@keyframes rg-line-anm4{0%{stroke-dasharray:0,100%}to{stroke-dasharray:100%,0}}.relation-graph .rg-line-anm-1{animation:rg-line-anm1 10s infinite;animation-fill-mode:forwards;animation-timing-function:linear}.relation-graph .rg-line-anm-2{animation:rg-line-anm2 3s infinite}.relation-graph .rg-line-anm-3{animation:rg-line-anm3 1s infinite}.relation-graph .rg-line-anm-4{animation:rg-line-anm4 3s infinite}@keyframes deform1{0%{stroke-dashoffset:0}to{stroke-dashoffset:100%}}.relation-graph .rg-icon{width:19px;height:19px;vertical-align:0px;fill:currentColor;overflow:hidden}.relation-graph .rg-node-peel{padding:0;position:absolute;pointer-events:none;box-sizing:border-box;opacity:var(--rg-node-opacity);z-index:var(--rg-node-z-index);will-change:transform;transform-origin:0 0;cursor:default}.relation-graph .rg-node-peel .rg-node{pointer-events:all;text-align:center;border-style:solid;box-sizing:border-box;overflow:visible;transform-origin:0 0;font-size:var(--rg-node-font-size);color:var(--rg-node-font-color);background-color:var(--rg-node-color);border-color:var(--rg-node-border-color);border-width:var(--rg-node-border-width);width:var(--rg-node-width);height:var(--rg-node-height)}.relation-graph .rg-node-disable-events{pointer-events:none}.relation-graph .rg-node-shape-0>.rg-node{border-radius:50%}.relation-graph .rg-node-shape-1>.rg-node{border-radius:var(--rg-node-border-radius)}.relation-graph .rg-node-checked{z-index:800}.relation-graph .rg-node-checked>.rg-node{box-shadow:0 0 0 4px var(--rg-checked-item-bg-color)}.relation-graph .rg-node-selected>.rg-node{box-shadow:0 0 0 2px var(--editor-main-color)}.relation-graph img,.relation-graph svg,.relation-graph video,.relation-graph canvas,.relation-graph audio,.relation-graph iframe,.relation-graph embed,.relation-graph object{display:unset;vertical-align:unset}.relation-graph .rg-node-text{color:var(--rg-node-font-color);font-size:var(--rg-node-font-size);padding:var(--rg-node-text-py) var(--rg-node-text-px);height:100%;width:100%;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.relation-graph .rg-node-type-button{border-radius:25px;color:#00f;cursor:pointer}.relation-graph .rg-editing-referline{user-select:none;position:absolute;z-index:999;pointer-events:none;width:100%;height:100%;left:0px;top:0px}.relation-graph .rg-editing-referline .rg-referline{position:absolute;display:flex;place-items:center;justify-content:center;overflow:visible;transform-origin:0 0;--rg-refer-offset: -3px}.relation-graph .rg-editing-referline .rg-referline .referline{display:flex;place-items:center;justify-content:center}.relation-graph .rg-editing-referline .rg-referline .referline>div{background-color:var(--editor-main-color);font-size:8px;border-radius:3px;color:#fff;width:fit-content;height:fit-content;padding:2px 5px}.relation-graph .rg-editing-referline .rg-referline-v{top:0px;width:6px;height:100%}.relation-graph .rg-editing-referline .rg-referline-v .referline{width:1px;height:100%;background-color:var(--editor-main-color)}.relation-graph .rg-editing-referline .rg-referline-v:before{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;top:0;transform:translateY(-50%)}.relation-graph .rg-editing-referline .rg-referline-v:after{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;bottom:0;transform:translateY(50%)}.relation-graph .rg-editing-referline .rg-referline-h{left:0px;width:100%;height:6px}.relation-graph .rg-editing-referline .rg-referline-h .referline{width:100%;height:1px;background-color:var(--editor-main-color)}.relation-graph .rg-editing-referline .rg-referline-h:before{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;left:0;transform:translate(-50%)}.relation-graph .rg-editing-referline .rg-referline-h:after{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;right:0;transform:translate(50%)}.relation-graph .rg-editing-line-ctrl{position:absolute;left:0px;top:0px;z-index:500;pointer-events:none;user-select:none;width:100%;height:100%}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg{position:absolute;pointer-events:none;left:0px;top:0px;overflow:visible}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg path{stroke:var(--editor-main-color);stroke-width:1px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-dot{--rg-ctl-x: 0px;--rg-ctl-y: 0px;pointer-events:auto;user-select:none;width:10px;height:10px;background-color:#fff;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:50%;cursor:move;z-index:1;transform-origin:0 0}.relation-graph .rg-editing-line-ctrl .start-dot,.relation-graph .rg-editing-line-ctrl .end-dot,.relation-graph .rg-editing-line-ctrl .ctrl-dot{transform-origin:0 0;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split,.relation-graph .rg-editing-line-ctrl .ctrl-split-core{background-color:#fff}.relation-graph .rg-editing-line-ctrl .ctrl-split-h{width:12px;height:5px;border-radius:3px;cursor:row-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split-v{width:5px;height:12px;border-radius:3px;cursor:col-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text{--rg-ctl-x: 0px;--rg-ctl-y: 0px;--font-size: .8rem;pointer-events:auto;background-color:#fffc;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:3px;cursor:move;z-index:1;white-space:nowrap;color:#000;padding:3px 10px;display:flex;place-items:center;justify-content:center;box-sizing:border-box;text-shadow:none;font-size:var(--font-size, 12px);min-height:20px;max-height:30px;transform-origin:0 0;transform:translate(-50%,-50%) translate(10px,3px) translate(var(--rg-ctl-x),var(--rg-ctl-y));min-width:50px;max-width:220px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p{font-size:var(--font-size, 12px);color:#333}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p.empty-text{font-size:10px;color:#888}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text .rg-line-text-input{white-space:nowrap;pointer-events:auto;user-select:auto;background-color:transparent;color:#000;border-radius:3px;height:100%;padding:3px 0;width:100px;text-shadow:none;font-size:var(--font-size, 12px);text-align:center;box-sizing:border-box;border:none;outline:none}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text-editing{background-color:#faf191}.relation-graph .rg-editing-ctrl,.relation-graph .rg-editing-connect-ctrl{user-select:none;position:absolute;z-index:500;box-shadow:0 0 0 1px var(--editor-main-color);border-radius:0;pointer-events:none;transform-origin:0 0}.relation-graph .rg-editing-bar{user-select:none;pointer-events:none;position:absolute;border-radius:5px;padding:3px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;flex-wrap:wrap;gap:5px}.relation-graph .rg-editing-bar .rg-gee-icon{background-color:#d603f680;pointer-events:auto;min-width:20px;min-height:20px;border-radius:5px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;cursor:pointer}.relation-graph .rg-editing-bar .rg-gee-icon:hover{background-color:#d603f6;color:#fff}.relation-graph .rg-connect-source-handle{pointer-events:auto;width:fit-content;height:fit-content}.relation-graph .rg-editing-bar-top{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(-100%);top:-15px}.relation-graph .rg-editing-bar-bottom{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(100%);bottom:-15px}.relation-graph .rg-editing-bar-left{width:fit-content;height:fit-content;left:-15px;top:50%;transform:translate(-100%) translateY(-50%)}.relation-graph .rg-editing-bar-right{width:fit-content;height:fit-content;right:-15px;top:50%;transform:translate(100%) translateY(-50%)}.relation-graph .rg-editing-bar-tl{width:30px;height:30px;right:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-tr{width:30px;height:30px;left:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-bl{width:30px;height:30px;right:calc(100% + 10px);bottom:-40px}.relation-graph .rg-editing-bar-br{width:30px;height:30px;left:calc(100% + 10px);bottom:-40px}.relation-graph .rg-resize-ctl{user-select:none;position:relative;height:100%;width:100%;--resize-handler-size: 10px;--resize-handler-offset: -5px}.relation-graph .rg-resize-ctl .rg-resize-ctl-handler{pointer-events:auto;width:var(--resize-handler-size);height:var(--resize-handler-size);background-color:#fff;position:absolute;border-radius:2px;box-shadow:inset 0 0 0 1px var(--editor-main-color)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tl{cursor:nwse-resize;left:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tr{cursor:nesw-resize;right:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-bl{cursor:nesw-resize;left:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-br{cursor:nwse-resize;right:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-t{cursor:n-resize;top:var(--resize-handler-offset);left:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-b{cursor:s-resize;bottom:var(--resize-handler-offset);left:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-l{cursor:w-resize;left:var(--resize-handler-offset);top:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-r{cursor:e-resize;right:var(--resize-handler-offset);top:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-editing-connect-ctrl{position:absolute;user-select:none;pointer-events:none;left:0;top:0;z-index:1400;--hander-border-radius: 5px;border-radius:var(--hander-border-radius);--border-handler-width: 8px;--hv-handler-width: 10px;--center-handler-width: 10px;--border-point-width: 10px;--border-point-height: 10px;--hander-color: var(--editor-light2-color);--hander-border-color: var(--editor-main-color);--hander-shadow-color: rgba(57, 144, 216, .1);box-shadow:0 0 0 var(--border-handler-width) var(--hander-shadow-color)}.relation-graph .rg-connect-ctl{width:100%;height:100%;pointer-events:none;user-select:none;border:none;position:relative}.relation-graph .rg-connect-ctl-handler{pointer-events:auto;user-select:none;z-index:20;cursor:crosshair}.relation-graph .rg-connect-target{pointer-events:auto}.relation-graph .rg-connect-ctl-handler-style{background-color:var(--hander-color);border:var(--hander-border-color) solid 1px;position:absolute;border-radius:3px}.relation-graph .rg-connect-ctl-handler-style:hover{background-color:#fbe691}.relation-graph .rg-connect-ctl-center{width:var(--center-handler-width);height:var(--center-handler-width);border-radius:50%;top:calc((100% - var(--center-handler-width)) / 2);left:calc((100% - var(--center-handler-width)) / 2)}.relation-graph .rg-connect-ctl-t{width:var(--border-point-width);height:var(--border-point-height);top:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-b{width:var(--border-point-width);height:var(--border-point-height);bottom:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-l{width:var(--border-point-height);height:var(--border-point-width);left:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-r{width:var(--border-point-height);height:var(--border-point-width);right:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-lr{width:100%;height:var(--hv-handler-width);right:0px;top:calc((100% - var(--hv-handler-width)) / 2);z-index:11;opacity:.01}.relation-graph .rg-connect-ctl-lr:hover{opacity:1}.relation-graph .rg-connect-ctl-tb{width:var(--hv-handler-width);height:100%;top:0px;left:calc((100% - var(--hv-handler-width)) / 2);z-index:10;opacity:.01}.relation-graph .rg-connect-ctl-tb:hover{opacity:1}.relation-graph .rg-connect-ctl-bottom-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:100%;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-top-left-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-bottom-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-top-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:calc(var(--border-handler-width) * -1);z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-bottom-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-top-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-left-bar{border:0px;border:none;width:var(--border-handler-width);height:100%;left:calc(var(--border-handler-width) * -1);top:0;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-right-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-left-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-right-bar{border:0px;width:var(--border-handler-width);height:100%;right:calc(var(--border-handler-width) * -1);top:0px;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-top-left-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-right-bar:hover{opacity:1}.relation-graph .rg-miniview{pointer-events:all;position:absolute;user-select:none;overflow:hidden;z-index:1100;min-height:100px;min-width:100px;--miniview-width: 200px;--miniview-height: 120px;height:var(--miniview-height);width:var(--miniview-width);border-radius:3px;display:flex;place-items:center;justify-content:center;background-color:#fff;box-shadow:0 0 0 1px #ccc;border:none}.relation-graph .rg-miniview .rg-miniview-container{position:relative;width:100%;height:100%;display:flex;place-items:center;justify-content:center}.relation-graph .rg-miniview canvas{opacity:1}.relation-graph .rg-miniview .rg-mv-canvas-reset{cursor:pointer}.relation-graph .rg-miniview .rg-mv-canvas-reset:hover{background-color:#bbf54794}.relation-graph .rg-miniview .rg-mv-visible-area{z-index:2;position:absolute;left:0;top:0;cursor:move;transform-origin:0 0;box-shadow:0 0 0 9999px #0003;border:#888 solid 1px;border-radius:3px;display:grid;place-items:center;color:#fff;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.5)}.relation-graph .rg-miniview.rg-miniview-top{left:calc((100% - var(--miniview-width)) / 2);top:10px}.relation-graph .rg-miniview.rg-miniview-bottom{left:calc((100% - var(--miniview-width)) / 2);bottom:10px}.relation-graph .rg-miniview.rg-miniview-left{left:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-right{right:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-tl{left:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-tr{right:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-bl{left:10px;bottom:10px}.relation-graph .rg-miniview.rg-miniview-br{right:10px;bottom:10px}.relation-graph .rg-node-flashing{animation:ACTRGNodeFlashing 2s infinite}.relation-graph .rg-node-vtree-2{transform-origin:0 0;transform:rotate(30deg) translate(0)}.relation-graph .rg-node-vtree{width:130px;height:45px;text-align:left}.relation-graph .rg-node-expand-holder{position:absolute;height:fit-content;width:fit-content;display:flex;align-items:center;justify-content:center;user-select:none;pointer-events:none}.relation-graph .rg-node-expand-holder .rg-node-expand-button{width:16px;height:16px;border-radius:15px;cursor:pointer;pointer-events:all;border:#aaaaaa solid .5px;background-color:#fff;display:flex;align-items:center;justify-content:center}.relation-graph .rg-node-expand-holder .rg-icon{width:14px;height:14px}.relation-graph .c-expand-positon-hide{display:none}.relation-graph .c-expand-positon-left{transform:translate(-100%) translateY(-50%);left:-5px;top:50%}.relation-graph .c-expand-positon-right{transform:translate(5px) translateY(-50%);left:100%;top:50%}.relation-graph .c-expand-positon-bottom{transform:translate(-50%);left:50%;top:calc(100% + 5px)}.relation-graph .c-expand-positon-top{transform:translate(-50%) translateY(-100%);left:50%;top:-5px}.relation-graph .rg-setting-panel{--height: 300px;--width: 200px;width:300px;height:200px;position:absolute;left:10px;top:5px;font-size:12px;color:#3a5bb2;padding:60px 10px 10px;overflow:hidden;box-shadow:0 0 5px #999;border-radius:5px;z-index:1000;background-color:#fff;border:#999999 solid 1px}.relation-graph .rg-setting-panel-button{height:35px;width:35px;font-size:8px;line-height:35px;text-align:center;border-radius:50%;position:absolute;margin-left:25px;margin-top:20px;background-color:#3a5bb2;color:#fff;cursor:pointer;z-index:1001;box-shadow:0 0 8px #999}.relation-graph .rg-setting-panel-button:hover{box-shadow:0 0 20px #ffa20a;border:#ffffff solid 1px;color:#ffa20a;-moz-transform:rotate(-89deg) translateX(-190px);animation-timing-function:linear;animation:flashButton 2s infinite}@keyframes flashButton{0%{box-shadow:0 0 8px #2e4e8f}30%{box-shadow:0 0 20px #ffa20a}to{box-shadow:0 0 8px #2e4e8f}}.relation-graph .c-debug-tools-row{text-align:left}.relation-graph .rg-operate{pointer-events:none;user-select:none;position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:180}.relation-graph .rg-operate .rg-node{cursor:move}.relation-graph .rg-operate .rg-creating-container{pointer-events:none;position:relative}.relation-graph .rg-operate .rg-creating-container *{pointer-events:none!important}.relation-graph .rg-selection{pointer-events:none;position:absolute;user-select:none;background-color:var(--editor-light-opacity);border:var(--editor-main-color) solid 1px;transform-origin:0 0}.relation-graph .rg-graph-loading{position:absolute;z-index:1600;left:0px;top:0px;height:100%;width:100%;background-color:#ffffffe6}.relation-graph .rg-graph-loading .rg-graph-loading-icon{width:16px;height:16px;vertical-align:-3px;fill:currentColor;overflow:hidden;animation:turn 1s linear infinite}.relation-graph .rg-graph-loading .rg-graph-loading-message{position:absolute;padding:2px 15px;text-align:center;left:50%;top:50%;transform:translate(-50%,-50%);border-radius:5px;font-size:12px;background-color:#fff;border:#666 solid 1px;color:#666;display:flex;place-items:center;justify-content:center;gap:8px}.relation-graph .rg-graph-loading-hide{display:none}@keyframes slowHide{0%{opacity:1}to{opacity:0;display:none}}.relation-graph .rg-easy-view{overflow:visible;height:100%;width:100%;background-color:transparent;position:absolute;left:0px;top:0px;z-index:3;pointer-events:none}.relation-graph .rg-easy-view canvas{opacity:0;width:100%;height:100%}.relation-graph .rg-easy-view-active{pointer-events:all}.relation-graph .rg-easy-view-active canvas{opacity:1}.relation-graph .rg-move-operator{position:absolute;width:100%;height:100%;pointer-events:none;user-select:none;left:0px;top:0px;z-index:6666}.relation-graph .rg-move-operator .rg-move-touchpad{display:none;background-color:var(--edit-ctl-light2-color);height:100%;width:100%;pointer-events:all}.relation-graph .rg-move-operator.rg-move-operator-active{pointer-events:all;cursor:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMzJweCIgaGVpZ2h0PSIzMnB4Ij48aW1hZ2UgeGxpbms6aHJlZj0iZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFFQUFBQUJBQ0FZQUFBQ3FhWEhlQUFBQUFYTlNSMElBcnM0YzZRQUFDWlpKUkVGVWVGN3RXZ3RNVk5rWi9xYThabkZ4QkVIQWlCV3lFa0drUEcwRW1paWdGVVZzcFZxTmlsSmZRVEV4c2k2eDFqZHRMVnVEeGpoTlJDc0JzeHBOZktEV0J4Q05QTFFpaUNoRzBTQkxKZHBTYUFWNXlHaW4rOTNjdzQ2enVEc0Rkd1lUT01uSm5XRXU5NTcvKy8vLyt4L25xRERJaDJxUXk0OGhBSVlzWUpBak1PUUNnOXdBaGtod3lBV0dYR0NRSXpEa0FnTmtBQUo0UXdYbzViV0lxMVdXWm0wTDRQdCtCTUJHdnZJN0o0WG0vQitBZC9MVktrQllBd0FocEJEY3RyS3lNc3pYMTNlcG5aMWRvTDI5ZlhoM2QzZTVUcWVycnEydHpRc0pDYmtENEswUkVCWUR3NUlBR0dxYkdyY0ZZSGYvL3YxWkV5Wk0rTE90cmEyN3NZMi9mZnYybjQ4ZVBmcDgwcVJKZndPZ2s0RWdHTFFNVHNXQnNBUUFRdU1VMkxhc3JDekF6ODh2U2ExV0I2dlY2Z2doOUtWTGw4QjU0TUFCckYrL0huRnhjZElVUTZmVFBlN3M3THgyK1BEaFA2U2xwZjNieUNvVTR3ZExBRUJ0YzlxM3RMUnNkWFoyL3NKNHRRME5EUWdNRE1TclY2OTZmdEpvTktpdXJzYllzV1BmdTEybjB6MjRjZVBHNnRqWTJHb0EzUWF1b1FnSVNnUEE1OWxSZUsxVzY1T1NrbktQcXp4eTVBaU9IajJLMHRKU1RKMDZGY09HRGNQRml4ZXhZOGNPYk4rK0hUdDM3cFErejU0OUcrM3Q3YmgrL1RvaUl5T1JuSnlNRlN0V29MdTd1elkzTjNmK3FsV3I2bVFRaEZ2MEd3U2xBYURtSFFBNHZuang0azhlSGg2L29URFRwazNyZGFGNi9iY3VyVkwxdnBScjE2NUpvTDE4K2ZLdm5wNmV2d1hRQ2VDTjdCTDk1Z1dsQWFEMkhRRTR0YmEyWG5CeWN2cEpSRVFFYnQ2OCtSMXRFNUhlQURDMmlpbFRwcUNzckV3Q3NLT2o0MjVYVjFkNWZuNStWbkp5Y29OTWxDSnM5c2thbEFTQXo2TDJod0VZb2Rmcm4zSkZRck85Q2R1WHYvR1pPcDN1SC9YMTllbSt2cjc1QnRHQzFtRDJVQklBeG5rMXRRL0FSYS9YUDFRS2dISGp4cUcrdnY0N3ZKQ2Vudjd6ZmZ2Mk5SbndndGxoVWtrQTZQK2ZBQmdPWUtSZXJ5ZHJLMklCeG1vVnZORFkyTGh2ekpneHUyVmVFQkhDTEN0UUVnREdmZnEvUmdiZ3JsSUFmSWdYMnRyYWJnOGZQdnlYQU5vQWRNbnVZSFVBYVBvRTB0NElnTnRLQWZCOVhLRlNxWHdBTUtGb2wxM0JMRGZvandWUWNKSGYyeFFWRlFXTUh6OStiazFOemRkeGNYRVA5WHA5c1pVQThBUFFBdUMxYkFWbWtXRmZBYURnVXFwYlYxY1g3Kzd1L2l0SFI4ZjV2ZG1lMGxIQStIa3FsU29RUURPQVZwa0xHQlpOSG4wQlFBaHZYMUZSTVRVa0pPUVUyWjhzZmV2V0xYUjFkU0VoSVFFdUxpN1NJcXdBUUpBTUFOMmdRMDZWTFFZQUFaT3l2ZFRVMUZGNzkrNHR0TGUzOThuSnlVRnFhcXFVeG5Jd245KzBhWlAwTnlzQUVBS0F4WklBZ0dteXljTmNDNkQyU1hhZkZCY1h4MGRGUmVVMk5UVmg4dVRKVXB4ZXVIQWgzcjE3aDFPbmFCVEF5Wk1uc1dEQkF1bXpJWkd4NkhuOCtESG16Ly9XYTBTNnpCQW5oaW5ncVZTcVVBRE1CYXdDQUxYUFpPZlR1cnE2MzNsN2U2ZHF0VnFzVzdjT3k1Y3Zsd29lamtPSERtSE5talVZT1hJa21wdnBudThEWUtwNkJKQ0dRUFhDQVFTQUZ2QmYyUVVzYWdITTlhVmtwN2k0ZUZsVVZGVEdpUk1uc0dqUklrbjd4NDhmNzVHTkdtVWhKSWFoQlpnS2dDbWtLbHVBVlFGZ3JxODVkdXhZM09MRmkvOUMwdzhJQ0lDTmpRMEtDd3NSSGg3ZXMrNVpzMlpKVFErUnlQUkg4QSs1eFlBQkFNQzFvYUhob0plWDEwODNidHlJckt3c1RKOCtIVmV2WGxWQ3pnOCs0d011WURVT0VPa3U4MzNYN096c09TdFhydHoxK3ZWclJFZEhvN3k4SEZ1M2JzV3VYYnNzQnNKQUF5QklrQldmTTRCUnQyL2Yvanc4UER6K3lwVXJtRGx6cGlUNGhRc1hwTzZPMHFPcXFnckJ3Y0VZUFhvMEdoc2I4ZWJObTFkcXRacmRGcXVIUVJZOUkxajBCQVVGalNzb0tQalMxZFgxeDl1MmJjUHUzYnVsUmJLSm9WWXpZQ2czbUcrd1RSWWFHb283ZCs2Z3RiWDFhNDFHOHdzREFOZ3RzbWdVb0RTTUJHeDhTSFUvWFVHcjFjYWxwS1NrODBmMjhpaDhSa1lHdG16Wm9wejAzK1M1NmVucHlNek14TnExYTNIdzRFRTBOVFhkR3pWcVZKSkJKa2dBckpJS2k5WVhTMStDNEZaWldmbEZjSEJ3OUprelp6QnYzanhKOEljUEg4TFBqN1dLTW1QdTNMbkl6OC9IK2ZQbkVSOGZqOU9uVC84eE1USHhLNk5hd0NyRkVNbVFWdkNwY0lVTkd6Wk16c3pNM0dOblorZVFsSlNFdkx3OGFaRmNyQkpEY0F6OW44QTZPanAyUmtkSEx5Z3BLV0hyamRVZ2V3SnNsbG9GQU5IK1psTFU0d3FGaFlXclkySmlmczFVbDY3QTZFQ056Wmt6cDk4WWVIbDU0Zm56NXowNVJVMU56WldBZ0lDZEFQNGxaNEVzaDlrVnNtby9RR3FCaXk2UWs1T1RlMjF0YlphSGg4ZG5vdGRQeWZ1YkJTNWJ0Z3k1dWJtWU9IRWlDZ29LNE9ucGljMmJONi9mczJkUHFVeUFMSVZaQ1hJN3pheGhiakZrK0hCUkdZcEdLS09DSU1UTnZKRmNRRTVnVkNncEthSFptclU0M2h3Ykc0dWlvaUpKZUJaWC92Nyt1SGZ2WGtGUVVGQ0dYQVFaTmtQTUlrQSt2ejhBOFA5WkhmYlVCd3lMbktXbHBlc2pJaUlTZUFQMyt5NWZ2Z3huWjJka1oyY2pNVEhSSkJBWTh0TFMwdERTMHZLZThNM056UTJ1cnE1clpPRlphWWtxMEd6elZ3SUFQa1BzQmtrMWdnQ2hycTd1OTk3ZTNteFc5R3g5OFhOWVdCaVdMbDBLYm5pNHVibEprMXRsRHg0OGtHWk5UWTEwUFh2MnJBU1VvZWFsQmF0VWpQc1VYQlJBb2hWbVZ2d1hXdWl2QlFnUUdSV2tNbGxFQlliSGtwS1NsTWpJU0NrOUpDZWNPM2NPZCs5S3plSWZIR1Q3MWF0WFM1TSsvK3paczJvZkh4K1NIazJlOHo4eTh6UDIwL2ZOWW44bEFUQjJCVVlGa1IrTXlNdkxTMWl5Wk1rSzhVSUN3TWp3NU1rVFBIMzZWTHJTekNrd0JRMEtDcEtLcWhrelpraHV3L0ZONisxNldGallBWm50S1RocmYwRjhmZG9QVUJvQTRRcFN0MGkyQklKQVl0UmtabWIrTENZbVpvcS92MytvV3EwMmlRbDFPdDJicXFxcXYrZms1RnpWYXJYM1pZSHA3NXlNK1dSOUNrL1ROeXYwR1RQNUQ1cWppVGVJcUVBUWhEdlFHbGc1OGtyM1VPL2Z2ejh5SkNURTE4M056ZFhaMmRsVm85RzRPRGc0T0haMmRyWjFkSFMwdGJlM3R4VVhGNWRuWldXVlZWUlVNTWF6MFVpQk9hbDFmaGZDOTJ0alZDa1NOQVpVT2h3aHRzbmx6VklLVDVLa2RSQWNSZzd5aGpnc3hXZUlRMUxVS0RYTHJJNkNVbUF4K1owN1FJb2RsRkNDQkkwTlJGaUNTSmVaTEZGd0lUeS9Fd0FCQWtPcEFJQWFGUUJRVUU2U25EZ1RRRkFFNGZXSjlIcGJySWtXYnRadGhnZWtwQk1qOGhTZnBVMFZPWThRQVBBRkJJQ1RRbkpTWUdwYmZCY25RL3JzODlZQ1FMem52ZTB6c1p0a1lQcmlkMkVCRkV5QVFHSEZGTDZ1aU5ZdFJZTGZaeUxDSW9UQVlrTlZhSisvaThPU3ZSMllWRnh3UzRSQlUzMUU4STQ0VG1mOGY0WkFtUHJNUHQ5bkNSTHM4MklHNGgrSEFCZ0kxRCttZHc1WndNZWtqWUZZeTVBRkRBVHFIOU03QjcwRi9COEJrUXA5WU5iRzJRQUFBQUJKUlU1RXJrSmdnZz09IiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiLz48L3N2Zz4=) 16 16,auto!important;cursor:-webkit-image-set(url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 2x,url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 1x) 16 16,auto!important}.relation-graph .rg-move-operator.rg-move-operator-active .rg-move-touchpad{display:flex}.relation-graph.rg-creating-line .rg-connect-source-handle{pointer-events:none;opacity:.5}.rg-background{position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:0;pointer-events:none}.rg-toolbar{user-select:none;pointer-events:all;display:flex;position:absolute;z-index:300;background-color:#fff;color:#333;--rg-toolbar-hover-bg-color: rgba(220, 220, 220, .5);box-shadow:0 1px 3px #0003,0 0 1px #0006;box-sizing:border-box;border-radius:5px;width:fit-content;height:fit-content;place-items:center;justify-content:center;gap:3px;backdrop-filter:blur(5px)}.rg-toolbar .rg-icon{flex-grow:1;width:16px;height:16px;fill:currentColor;overflow:hidden}.rg-toolbar .rg-mb-button svg{margin:auto}.rg-toolbar .rg-mb-button:hover{background-color:var(--rg-toolbar-hover-bg-color)}.rg-toolbar .rg-loading-icon{animation:turn 1s linear infinite}@keyframes turn{0%{-webkit-transform:rotate(0deg)}25%{-webkit-transform:rotate(90deg)}50%{-webkit-transform:rotate(180deg)}75%{-webkit-transform:rotate(270deg)}to{-webkit-transform:rotate(360deg)}}.rg-toolbar .rg-current-zoom{margin-top:0;font-size:10px;text-align:center;border-radius:3px;cursor:pointer}.rg-toolbar .rg-current-zoom:hover{background-color:var(--rg-toolbar-hover-bg-color)}.rg-toolbar .rg-mb-button{width:35px;height:35px;margin-top:0;opacity:1;cursor:pointer;font-size:18px;box-sizing:border-box;display:flex;align-items:center;justify-items:center;border-radius:3px}.rg-toolbar.rg-toolbar-v{flex-flow:column;padding:10px 3px}.rg-toolbar.rg-toolbar-v .rg-current-zoom{width:35px;height:25px;line-height:25px}.rg-toolbar.rg-toolbar-h{padding:3px 10px}.rg-toolbar.rg-toolbar-h .rg-current-zoom{width:fit-content;padding:0 5px;height:35px;line-height:35px}.rg-toolbar.rg-toolbar-h-right{right:15px}.rg-toolbar.rg-toolbar-h-left{left:15px}.rg-toolbar.rg-toolbar-h-center{left:50%;transform:translate(-50%)}.rg-toolbar.rg-toolbar-v-top{top:15px}.rg-toolbar.rg-toolbar-v-bottom{bottom:15px}.rg-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}.rg-toolbar.rg-xs-toolbar .rg-mb-button{width:25px;height:25px}.rg-toolbar.rg-xs-toolbar .rg-icon{width:14px;height:14px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v{padding:3px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v .rg-current-zoom{width:30px;height:25px;line-height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h{padding:3px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h .rg-current-zoom{width:35px;height:25px;line-height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h .rg-mb-button{width:25px;height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-right{right:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-left{left:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-center{left:50%;transform:translate(-50%)}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-top{top:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-bottom{bottom:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();"use strict";var At=Object.defineProperty;var Vt=(s,o,e)=>o in s?At(s,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[o]=e;var _=(s,o,e)=>(Vt(s,typeof o!="symbol"?o+"":o,e),e);/*!
|
|
2
|
-
* relation-graph v3.0.
|
|
1
|
+
(function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("@charset \"UTF-8\";.relation-graph{box-sizing:border-box;position:relative;min-width:400px;min-height:300px;--editor-main-color: rgb(64, 165, 248);--editor-light-color: rgb(125, 192, 248);--editor-light2-color: rgb(168, 212, 248);--editor-light-opacity: rgba(57, 144, 216, .1);--rg-node-opacity: 1;--rg-node-font-size: 1rem;--rg-node-font-color: #000000;--rg-node-color: #eeeeee;--rg-node-border-color: #333333;--rg-node-border-width: 1px;--rg-node-border-radius: 3px;--rg-node-width: fit-content;--rg-node-height: fit-content;--rg-node-text-px: 10px;--rg-node-text-py: 3px;--rg-background-color: transparent;--rg-line-color: #888888;--rg-line-width: 1px;--rg-line-fontcolor: var(--rg-line-color, #666666);--rg-line-fontsize: 12px;--rg-line-opacity: 1;--rg-checked-item-bg-color: rgba(150, 150, 150, .2);--rg-checked-line-text-bg-color: rgb(234, 232, 232)}.relation-graph:focus{outline:none}.relation-graph .rg-graph-plugs{position:absolute;left:0px;top:0px;z-index:90;width:100%;height:100%;pointer-events:none;user-select:none}.relation-graph .rg-graph-plugs .rg-view-slot{position:relative;width:100%;height:100%}.relation-graph .rg-watermark{position:absolute;--watermark-width: 200px;--watermark-height: 100px;z-index:1200;overflow:visible;min-height:100px;min-width:100px;width:var(--watermark-width);height:var(--watermark-height);box-sizing:border-box}.relation-graph .rg-watermark div{box-sizing:border-box}.relation-graph .rg-watermark.rg-watermark-top{left:calc((100% - var(--watermark-width)) / 2);top:10px}.relation-graph .rg-watermark.rg-watermark-bottom{left:calc((100% - var(--watermark-width)) / 2);bottom:10px}.relation-graph .rg-watermark.rg-watermark-left{left:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-right{right:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-tl{left:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-tr{right:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-bl{left:10px;bottom:10px}.relation-graph .rg-watermark.rg-watermark-br{right:10px;bottom:10px}.relation-graph .rg-lines-container svg{overflow:visible}.relation-graph .rg-lines-svg{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-lines-container{overflow:visible;position:absolute;z-index:40;width:100%;top:0px;left:0px;pointer-events:none}.relation-graph .rg-lines-container-el-lines{z-index:80;pointer-events:none}.relation-graph .rg-lines-container-el-lines .rg-line-bg{pointer-events:stroke}.relation-graph .rg-lines-container-el-lines .rg-line-text{pointer-events:all}.relation-graph .rg-lines-svg-el-lines{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-nodes-container-wrapper{position:absolute;width:100%;top:0px;left:0px;z-index:50}.relation-graph .rg-nodes-container{position:relative;overflow:visible}.relation-graph .rg-map{background-color:var(--rg-background-color);overflow:hidden;cursor:default;user-select:none;opacity:.01;transition:none;width:100%;height:100%;position:relative}.relation-graph .rg-map-background{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none}.relation-graph.rg-move-mode .rg-map{cursor:grab}.relation-graph .rg-map-ready{opacity:1;transition:opacity .5s ease;will-change:opacity}.relation-graph .rg-map-background-norepeat{background-repeat:no-repeat;background-position:right bottom}.relation-graph .rg-map-canvas{position:relative;user-select:none;pointer-events:none;top:0;left:0;border:none;z-index:3;overflow:visible;white-space:nowrap;transform-origin:0 0;will-change:transform}.relation-graph .rg-map-canvas .rg-events-all{pointer-events:all}.relation-graph.rg-enable-node-xy-animation .rg-node-peel{transition:transform .15s ease}.relation-graph.rg-enable-node-xy-animation .rg-line-peel{transition:none}.relation-graph.rg-enable-canvas-animation .rg-map-canvas{transition:transform .5s ease}.relation-graph.rg-enable-canvas-animation .rg-editing-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-line-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-connect-ctrl{opacity:0}.relation-graph .rg-canvas-behind{z-index:2;position:absolute}.relation-graph .rg-canvas-above{z-index:5;position:absolute}.relation-graph .rg-canvas-slot{overflow:visible;position:absolute;margin-top:0;margin-left:0}.relation-graph .rg-canvas-slot-behind{z-index:30;overflow:visible}.relation-graph .rg-canvas-slot-above{z-index:70;overflow:visible}.relation-graph .rg-single-graph{position:relative;overflow:visible}.relation-graph .rg-map img{-webkit-user-drag:none;-webkit-user-select:none}.relation-graph .rg-line-text{fill:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);paint-order:stroke;pointer-events:all}.relation-graph .rg-linetext-container{position:absolute;pointer-events:none;user-select:none;overflow:visible;left:0;top:0;z-index:45;display:block}.relation-graph .rg-linetext-container .rg-line-peel{width:fit-content}.relation-graph .rg-linetext-container .rg-line-peel .rg-line-label{display:block;color:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);transform-origin:0 0;position:absolute;user-select:none;pointer-events:all;box-sizing:border-box;padding:2px 6px;border-radius:5px;white-space:nowrap}.relation-graph .rg-linetext-container .rg-line-peel .rg-line-label-on-path{background-color:#fff}.relation-graph .rg-linetext-container .rg-line-checked .rg-line-label{background-color:var(--rg-checked-line-text-bg-color);color:#0f172a}.relation-graph .rg-linetext-container .rg-line-checked .rg-line-label-on-path{background-color:var(--rg-line-color, #ffffff)}.relation-graph .rg-line-peel{pointer-events:none;cursor:default;transition:opacity .2s ease-in;opacity:var(--rg-line-opacity, 1)}.relation-graph .rg-line{fill-rule:nonzero;stroke-linecap:round;stroke:var(--rg-line-color);stroke-width:var(--rg-line-width);pointer-events:none;fill:none;marker-end:var(--rg-line-marker-end);marker-start:var(--rg-line-marker-start)}.relation-graph .rg-line-bg{stroke:#fff;opacity:.01;fill:none;fill-rule:nonzero;stroke-linecap:round;pointer-events:stroke;stroke-width:calc(var(--rg-line-width) + 6px)}.relation-graph .rg-line-bg:hover{opacity:.7;stroke:var(--rg-checked-item-bg-color)}.relation-graph .rg-line-checked .rg-line-bg{stroke:var(--rg-checked-item-bg-color);opacity:1}.relation-graph .rg-line-checked .rg-line{z-index:100}.relation-graph .rg-line-checked .rg-line-text{stroke:var(--rg-checked-item-bg-color);stroke-width:2}.relation-graph .rg-line-disable-events{pointer-events:none!important}.relation-graph .rg-line-disable-events .rg-line-bg,.relation-graph .rg-line-disable-events .rg-line-text,.relation-graph .rg-linetext-container .rg-line-disable-events .rg-line-bg,.relation-graph .rg-linetext-container .rg-line-disable-events .rg-line-label{pointer-events:none}.relation-graph .rg-line-dashtype-1{stroke-dasharray:2,2,2;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-2{stroke-dasharray:5,5,5;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-3{stroke-dasharray:9,9,9;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-4{stroke-dasharray:5,5,15;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}@keyframes ACTRGLineChecked{0%{stroke-dashoffset:352px;stroke-dasharray:5,5,5}50%{stroke-dasharray:5,5,5;stroke-dashoffset:3px}to{stroke-dashoffset:352px;stroke-dasharray:5,5,5}}@keyframes rg-line-anm1{0%{stroke-dashoffset:100px;stroke-dasharray:5,5,5}to{stroke-dasharray:5,5,5;stroke-dashoffset:3px}}@keyframes rg-line-anm2{0%{stroke-dashoffset:0;stroke-dasharray:4,4,4}to{stroke-dashoffset:10px;stroke-dasharray:20,20,20}}@keyframes rg-line-anm3{0%{stroke-opacity:1}50%{stroke-opacity:.2}to{stroke-opacity:1}}@keyframes rg-line-anm4{0%{stroke-dasharray:0,100%}to{stroke-dasharray:100%,0}}.relation-graph .rg-line-anm-1{animation:rg-line-anm1 10s infinite;animation-fill-mode:forwards;animation-timing-function:linear}.relation-graph .rg-line-anm-2{animation:rg-line-anm2 3s infinite}.relation-graph .rg-line-anm-3{animation:rg-line-anm3 1s infinite}.relation-graph .rg-line-anm-4{animation:rg-line-anm4 3s infinite}@keyframes deform1{0%{stroke-dashoffset:0}to{stroke-dashoffset:100%}}.relation-graph .rg-icon{width:19px;height:19px;vertical-align:0px;fill:currentColor;overflow:hidden}.relation-graph .rg-node-peel{padding:0;position:absolute;pointer-events:none;box-sizing:border-box;opacity:var(--rg-node-opacity);z-index:var(--rg-node-z-index);will-change:transform;transform-origin:0 0;cursor:default}.relation-graph .rg-node-peel .rg-node{pointer-events:all;text-align:center;border-style:solid;box-sizing:border-box;overflow:visible;transform-origin:0 0;font-size:var(--rg-node-font-size);color:var(--rg-node-font-color);background-color:var(--rg-node-color);border-color:var(--rg-node-border-color);border-width:var(--rg-node-border-width);width:var(--rg-node-width);height:var(--rg-node-height)}.relation-graph .rg-node-disable-events{pointer-events:none}.relation-graph .rg-node-shape-0>.rg-node{border-radius:50%}.relation-graph .rg-node-shape-1>.rg-node{border-radius:var(--rg-node-border-radius)}.relation-graph .rg-node-checked{z-index:800}.relation-graph .rg-node-checked>.rg-node{box-shadow:0 0 0 4px var(--rg-checked-item-bg-color)}.relation-graph .rg-node-selected>.rg-node{box-shadow:0 0 0 2px var(--editor-main-color)}.relation-graph img,.relation-graph svg,.relation-graph video,.relation-graph canvas,.relation-graph audio,.relation-graph iframe,.relation-graph embed,.relation-graph object{display:unset;vertical-align:unset}.relation-graph .rg-node-text{color:var(--rg-node-font-color);font-size:var(--rg-node-font-size);padding:var(--rg-node-text-py) var(--rg-node-text-px);height:100%;width:100%;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.relation-graph .rg-node-type-button{border-radius:25px;color:#00f;cursor:pointer}.relation-graph .rg-editing-referline{user-select:none;position:absolute;z-index:999;pointer-events:none;width:100%;height:100%;left:0px;top:0px}.relation-graph .rg-editing-referline .rg-referline{position:absolute;display:flex;place-items:center;justify-content:center;overflow:visible;transform-origin:0 0;--rg-refer-offset: -3px}.relation-graph .rg-editing-referline .rg-referline .referline{display:flex;place-items:center;justify-content:center}.relation-graph .rg-editing-referline .rg-referline .referline>div{background-color:var(--editor-main-color);font-size:8px;border-radius:3px;color:#fff;width:fit-content;height:fit-content;padding:2px 5px}.relation-graph .rg-editing-referline .rg-referline-v{top:0px;width:6px;height:100%}.relation-graph .rg-editing-referline .rg-referline-v .referline{width:1px;height:100%;background-color:var(--editor-main-color)}.relation-graph .rg-editing-referline .rg-referline-v:before{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;top:0;transform:translateY(-50%)}.relation-graph .rg-editing-referline .rg-referline-v:after{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;bottom:0;transform:translateY(50%)}.relation-graph .rg-editing-referline .rg-referline-h{left:0px;width:100%;height:6px}.relation-graph .rg-editing-referline .rg-referline-h .referline{width:100%;height:1px;background-color:var(--editor-main-color)}.relation-graph .rg-editing-referline .rg-referline-h:before{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;left:0;transform:translate(-50%)}.relation-graph .rg-editing-referline .rg-referline-h:after{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;right:0;transform:translate(50%)}.relation-graph .rg-editing-line-ctrl{position:absolute;left:0px;top:0px;z-index:500;pointer-events:none;user-select:none;width:100%;height:100%}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg{position:absolute;pointer-events:none;left:0px;top:0px;overflow:visible}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg path{stroke:var(--editor-main-color);stroke-width:1px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-dot{--rg-ctl-x: 0px;--rg-ctl-y: 0px;pointer-events:auto;user-select:none;width:10px;height:10px;background-color:#fff;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:50%;cursor:move;z-index:1;transform-origin:0 0}.relation-graph .rg-editing-line-ctrl .start-dot,.relation-graph .rg-editing-line-ctrl .end-dot,.relation-graph .rg-editing-line-ctrl .ctrl-dot{transform-origin:0 0;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split,.relation-graph .rg-editing-line-ctrl .ctrl-split-core{background-color:#fff}.relation-graph .rg-editing-line-ctrl .ctrl-split-h{width:12px;height:5px;border-radius:3px;cursor:row-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split-v{width:5px;height:12px;border-radius:3px;cursor:col-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text{--rg-ctl-x: 0px;--rg-ctl-y: 0px;--font-size: .8rem;pointer-events:auto;background-color:#fff;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:3px;cursor:move;z-index:1;white-space:nowrap;color:#000;padding:3px 10px;display:flex;place-items:center;justify-content:center;box-sizing:border-box;text-shadow:none;font-size:var(--font-size, 12px);min-height:20px;max-height:30px;transform-origin:0 0;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y));min-width:50px;max-width:220px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p{font-size:var(--font-size, 12px);color:#333}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p.empty-text{font-size:10px;color:#888}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text .rg-line-text-input{white-space:nowrap;pointer-events:auto;user-select:auto;background-color:transparent;color:#000;border-radius:3px;height:100%;padding:3px 0;width:100px;text-shadow:none;font-size:var(--font-size, 12px);text-align:center;box-sizing:border-box;border:none;outline:none}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text-editing{background-color:#faf191}.relation-graph .rg-editing-ctrl,.relation-graph .rg-editing-connect-ctrl{user-select:none;position:absolute;z-index:500;box-shadow:0 0 0 1px var(--editor-main-color);border-radius:0;pointer-events:none;transform-origin:0 0}.relation-graph .rg-editing-bar{user-select:none;pointer-events:none;position:absolute;border-radius:5px;padding:3px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;flex-wrap:wrap;gap:5px}.relation-graph .rg-editing-bar .rg-gee-icon{background-color:#d603f680;pointer-events:auto;min-width:20px;min-height:20px;border-radius:5px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;cursor:pointer}.relation-graph .rg-editing-bar .rg-gee-icon:hover{background-color:#d603f6;color:#fff}.relation-graph .rg-connect-source-handle{pointer-events:auto;width:fit-content;height:fit-content}.relation-graph .rg-editing-bar-top{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(-100%);top:-15px}.relation-graph .rg-editing-bar-bottom{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(100%);bottom:-15px}.relation-graph .rg-editing-bar-left{width:fit-content;height:fit-content;left:-15px;top:50%;transform:translate(-100%) translateY(-50%)}.relation-graph .rg-editing-bar-right{width:fit-content;height:fit-content;right:-15px;top:50%;transform:translate(100%) translateY(-50%)}.relation-graph .rg-editing-bar-tl{width:30px;height:30px;right:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-tr{width:30px;height:30px;left:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-bl{width:30px;height:30px;right:calc(100% + 10px);bottom:-40px}.relation-graph .rg-editing-bar-br{width:30px;height:30px;left:calc(100% + 10px);bottom:-40px}.relation-graph .rg-resize-ctl{user-select:none;position:relative;height:100%;width:100%;--resize-handler-size: 10px;--resize-handler-offset: -5px}.relation-graph .rg-resize-ctl .rg-resize-ctl-handler{pointer-events:auto;width:var(--resize-handler-size);height:var(--resize-handler-size);background-color:#fff;position:absolute;border-radius:2px;box-shadow:inset 0 0 0 1px var(--editor-main-color)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tl{cursor:nwse-resize;left:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tr{cursor:nesw-resize;right:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-bl{cursor:nesw-resize;left:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-br{cursor:nwse-resize;right:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-t{cursor:n-resize;top:var(--resize-handler-offset);left:50%;transform:translate(-50%)}.relation-graph .rg-resize-ctl .rg-resize-ctl-b{cursor:s-resize;bottom:var(--resize-handler-offset);left:50%;transform:translate(-50%)}.relation-graph .rg-resize-ctl .rg-resize-ctl-l{cursor:w-resize;left:var(--resize-handler-offset);top:50%;transform:translateY(-50%)}.relation-graph .rg-resize-ctl .rg-resize-ctl-r{cursor:e-resize;right:var(--resize-handler-offset);top:50%;transform:translateY(-50%)}.relation-graph .rg-editing-connect-ctrl{position:absolute;user-select:none;pointer-events:none;left:0;top:0;z-index:1400;--hander-border-radius: 5px;border-radius:var(--hander-border-radius);--border-handler-width: 8px;--hv-handler-width: 10px;--center-handler-width: 10px;--border-point-width: 10px;--border-point-height: 10px;--hander-color: var(--editor-light2-color);--hander-border-color: var(--editor-main-color);--hander-shadow-color: rgba(57, 144, 216, .1);box-shadow:0 0 0 var(--border-handler-width) var(--hander-shadow-color)}.relation-graph .rg-connect-ctl{width:100%;height:100%;pointer-events:none;user-select:none;border:none;position:relative}.relation-graph .rg-connect-ctl-handler{pointer-events:auto;user-select:none;z-index:20;cursor:crosshair}.relation-graph .rg-connect-target{pointer-events:auto}.relation-graph .rg-connect-ctl-handler-style{background-color:var(--hander-color);border:var(--hander-border-color) solid 1px;position:absolute;border-radius:3px}.relation-graph .rg-connect-ctl-handler-style:hover{background-color:#fbe691}.relation-graph .rg-connect-ctl-center{width:var(--center-handler-width);height:var(--center-handler-width);border-radius:50%;top:calc((100% - var(--center-handler-width)) / 2);left:calc((100% - var(--center-handler-width)) / 2)}.relation-graph .rg-connect-ctl-t{width:var(--border-point-width);height:var(--border-point-height);top:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-b{width:var(--border-point-width);height:var(--border-point-height);bottom:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-l{width:var(--border-point-height);height:var(--border-point-width);left:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-r{width:var(--border-point-height);height:var(--border-point-width);right:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-lr{width:100%;height:var(--hv-handler-width);right:0px;top:calc((100% - var(--hv-handler-width)) / 2);z-index:11;opacity:.01}.relation-graph .rg-connect-ctl-lr:hover{opacity:1}.relation-graph .rg-connect-ctl-tb{width:var(--hv-handler-width);height:100%;top:0px;left:calc((100% - var(--hv-handler-width)) / 2);z-index:10;opacity:.01}.relation-graph .rg-connect-ctl-tb:hover{opacity:1}.relation-graph .rg-connect-ctl-bottom-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:100%;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-top-left-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-bottom-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-top-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:calc(var(--border-handler-width) * -1);z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-bottom-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-top-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-left-bar{border:0px;border:none;width:var(--border-handler-width);height:100%;left:calc(var(--border-handler-width) * -1);top:0;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-right-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-left-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-right-bar{border:0px;width:var(--border-handler-width);height:100%;right:calc(var(--border-handler-width) * -1);top:0px;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-top-left-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-right-bar:hover{opacity:1}.relation-graph .rg-miniview{pointer-events:all;position:absolute;user-select:none;overflow:hidden;z-index:1100;min-height:100px;min-width:100px;--miniview-width: 200px;--miniview-height: 120px;height:var(--miniview-height);width:var(--miniview-width);border-radius:3px;display:flex;place-items:center;justify-content:center;background-color:#fff;box-shadow:0 0 0 1px #ccc;border:none}.relation-graph .rg-miniview .rg-miniview-container{position:relative;width:100%;height:100%;display:flex;place-items:center;justify-content:center}.relation-graph .rg-miniview canvas{opacity:1}.relation-graph .rg-miniview .rg-mv-canvas-reset{cursor:pointer}.relation-graph .rg-miniview .rg-mv-canvas-reset:hover{background-color:#bbf54794}.relation-graph .rg-miniview .rg-mv-visible-area{z-index:2;position:absolute;left:0;top:0;cursor:move;transform-origin:0 0;box-shadow:0 0 0 9999px #0003;border:#888 solid 1px;border-radius:3px;display:grid;place-items:center;color:#fff;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.5)}.relation-graph .rg-miniview.rg-miniview-top{left:calc((100% - var(--miniview-width)) / 2);top:10px}.relation-graph .rg-miniview.rg-miniview-bottom{left:calc((100% - var(--miniview-width)) / 2);bottom:10px}.relation-graph .rg-miniview.rg-miniview-left{left:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-right{right:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-tl{left:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-tr{right:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-bl{left:10px;bottom:10px}.relation-graph .rg-miniview.rg-miniview-br{right:10px;bottom:10px}.relation-graph .rg-node-flashing{animation:ACTRGNodeFlashing 2s infinite}.relation-graph .rg-node-vtree-2{transform-origin:0 0;transform:rotate(30deg) translate(0)}.relation-graph .rg-node-vtree{width:130px;height:45px;text-align:left}.relation-graph .rg-node-expand-holder{position:absolute;height:fit-content;width:fit-content;display:flex;align-items:center;justify-content:center;user-select:none;pointer-events:none}.relation-graph .rg-node-expand-holder .rg-node-expand-button{width:16px;height:16px;border-radius:15px;cursor:pointer;pointer-events:all;border:#666 solid 1px;background-color:#fff;display:flex;align-items:center;justify-content:center}.relation-graph .rg-node-expand-holder .rg-icon{width:14px;height:14px}.relation-graph .c-expand-positon-hide{display:none}.relation-graph .c-expand-positon-left{transform:translate(-100%) translateY(-50%);left:-5px;top:50%}.relation-graph .c-expand-positon-right{transform:translate(5px) translateY(-50%);left:100%;top:50%}.relation-graph .c-expand-positon-bottom{transform:translate(-50%);left:50%;top:calc(100% + 5px)}.relation-graph .c-expand-positon-top{transform:translate(-50%) translateY(-100%);left:50%;top:-5px}.relation-graph .rg-setting-panel{--height: 300px;--width: 200px;width:300px;height:200px;position:absolute;left:10px;top:5px;font-size:12px;color:#3a5bb2;padding:60px 10px 10px;overflow:hidden;box-shadow:0 0 5px #999;border-radius:5px;z-index:1000;background-color:#fff;border:#999999 solid 1px}.relation-graph .rg-setting-panel-button{height:35px;width:35px;font-size:8px;line-height:35px;text-align:center;border-radius:50%;position:absolute;margin-left:25px;margin-top:20px;background-color:#3a5bb2;color:#fff;cursor:pointer;z-index:1001;box-shadow:0 0 8px #999}.relation-graph .rg-setting-panel-button:hover{box-shadow:0 0 20px #ffa20a;border:#ffffff solid 1px;color:#ffa20a;-moz-transform:rotate(-89deg) translateX(-190px);animation-timing-function:linear;animation:flashButton 2s infinite}@keyframes flashButton{0%{box-shadow:0 0 8px #2e4e8f}30%{box-shadow:0 0 20px #ffa20a}to{box-shadow:0 0 8px #2e4e8f}}.relation-graph .c-debug-tools-row{text-align:left}.relation-graph .rg-operate{pointer-events:none;user-select:none;position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:180}.relation-graph .rg-operate .rg-node{cursor:move}.relation-graph .rg-operate .rg-creating-container{pointer-events:none;position:relative}.relation-graph .rg-operate .rg-creating-container *{pointer-events:none!important}.relation-graph .rg-selection{pointer-events:none;position:absolute;user-select:none;background-color:var(--editor-light-opacity);border:var(--editor-main-color) solid 1px;transform-origin:0 0}.relation-graph .rg-graph-loading{position:absolute;z-index:1600;left:0px;top:0px;height:100%;width:100%;background-color:#ffffffe6}.relation-graph .rg-graph-loading .rg-graph-loading-icon{width:16px;height:16px;vertical-align:-3px;fill:currentColor;overflow:hidden;animation:turn 1s linear infinite}.relation-graph .rg-graph-loading .rg-graph-loading-message{position:absolute;padding:2px 15px;text-align:center;left:50%;top:50%;transform:translate(-50%,-50%);border-radius:5px;font-size:12px;background-color:#fff;border:#666 solid 1px;color:#666;display:flex;place-items:center;justify-content:center;gap:8px}.relation-graph .rg-graph-loading-hide{display:none}@keyframes slowHide{0%{opacity:1}to{opacity:0;display:none}}.relation-graph .rg-easy-view{overflow:visible;height:100%;width:100%;background-color:transparent;position:absolute;left:0px;top:0px;z-index:3;pointer-events:none}.relation-graph .rg-easy-view canvas{opacity:0;width:100%;height:100%}.relation-graph .rg-easy-view-active{pointer-events:all}.relation-graph .rg-easy-view-active canvas{opacity:1}.relation-graph .rg-move-operator{position:absolute;width:100%;height:100%;pointer-events:none;user-select:none;left:0px;top:0px;z-index:6666}.relation-graph .rg-move-operator .rg-move-touchpad{display:none;background-color:var(--edit-ctl-light2-color);height:100%;width:100%;pointer-events:all}.relation-graph .rg-move-operator.rg-move-operator-active{pointer-events:all;cursor:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMzJweCIgaGVpZ2h0PSIzMnB4Ij48aW1hZ2UgeGxpbms6aHJlZj0iZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFFQUFBQUJBQ0FZQUFBQ3FhWEhlQUFBQUFYTlNSMElBcnM0YzZRQUFDWlpKUkVGVWVGN3RXZ3RNVk5rWi9xYThabkZ4QkVIQWlCV3lFa0drUEcwRW1paWdGVVZzcFZxTmlsSmZRVEV4c2k2eDFqZHRMVnVEeGpoTlJDc0JzeHBOZktEV0J4Q05QTFFpaUNoRzBTQkxKZHBTYUFWNXlHaW4rOTNjdzQ2enVEc0Rkd1lUT01uSm5XRXU5NTcvKy8vLyt4L25xRERJaDJxUXk0OGhBSVlzWUpBak1PUUNnOXdBaGtod3lBV0dYR0NRSXpEa0FnTmtBQUo0UXdYbzViV0lxMVdXWm0wTDRQdCtCTUJHdnZJN0o0WG0vQitBZC9MVktrQllBd0FocEJEY3RyS3lNc3pYMTNlcG5aMWRvTDI5ZlhoM2QzZTVUcWVycnEydHpRc0pDYmtENEswUkVCWUR3NUlBR0dxYkdyY0ZZSGYvL3YxWkV5Wk0rTE90cmEyN3NZMi9mZnYybjQ4ZVBmcDgwcVJKZndPZ2s0RWdHTFFNVHNXQnNBUUFRdU1VMkxhc3JDekF6ODh2U2ExV0I2dlY2Z2doOUtWTGw4QjU0TUFCckYrL0huRnhjZElVUTZmVFBlN3M3THgyK1BEaFA2U2xwZjNieUNvVTR3ZExBRUJ0YzlxM3RMUnNkWFoyL3NKNHRRME5EUWdNRE1TclY2OTZmdEpvTktpdXJzYllzV1BmdTEybjB6MjRjZVBHNnRqWTJHb0EzUWF1b1FnSVNnUEE1OWxSZUsxVzY1T1NrbktQcXp4eTVBaU9IajJLMHRKU1RKMDZGY09HRGNQRml4ZXhZOGNPYk4rK0hUdDM3cFErejU0OUcrM3Q3YmgrL1RvaUl5T1JuSnlNRlN0V29MdTd1elkzTjNmK3FsV3I2bVFRaEZ2MEd3U2xBYURtSFFBNHZuang0azhlSGg2L29URFRwazNyZGFGNi9iY3VyVkwxdnBScjE2NUpvTDE4K2ZLdm5wNmV2d1hRQ2VDTjdCTDk1Z1dsQWFEMkhRRTR0YmEyWG5CeWN2cEpSRVFFYnQ2OCtSMXRFNUhlQURDMmlpbFRwcUNzckV3Q3NLT2o0MjVYVjFkNWZuNStWbkp5Y29OTWxDSnM5c2thbEFTQXo2TDJod0VZb2Rmcm4zSkZRck85Q2R1WHYvR1pPcDN1SC9YMTllbSt2cjc1QnRHQzFtRDJVQklBeG5rMXRRL0FSYS9YUDFRS2dISGp4cUcrdnY0N3ZKQ2Vudjd6ZmZ2Mk5SbndndGxoVWtrQTZQK2ZBQmdPWUtSZXJ5ZHJLMklCeG1vVnZORFkyTGh2ekpneHUyVmVFQkhDTEN0UUVnREdmZnEvUmdiZ3JsSUFmSWdYMnRyYWJnOGZQdnlYQU5vQWRNbnVZSFVBYVBvRTB0NElnTnRLQWZCOVhLRlNxWHdBTUtGb2wxM0JMRGZvandWUWNKSGYyeFFWRlFXTUh6OStiazFOemRkeGNYRVA5WHA5c1pVQThBUFFBdUMxYkFWbWtXRmZBYURnVXFwYlYxY1g3Kzd1L2l0SFI4ZjV2ZG1lMGxIQStIa3FsU29RUURPQVZwa0xHQlpOSG4wQlFBaHZYMUZSTVRVa0pPUVUyWjhzZmV2V0xYUjFkU0VoSVFFdUxpN1NJcXdBUUpBTUFOMmdRMDZWTFFZQUFaT3l2ZFRVMUZGNzkrNHR0TGUzOThuSnlVRnFhcXFVeG5Jd245KzBhWlAwTnlzQUVBS0F4WklBZ0dteXljTmNDNkQyU1hhZkZCY1h4MGRGUmVVMk5UVmg4dVRKVXB4ZXVIQWgzcjE3aDFPbmFCVEF5Wk1uc1dEQkF1bXpJWkd4NkhuOCtESG16Ly9XYTBTNnpCQW5oaW5ncVZTcVVBRE1CYXdDQUxYUFpPZlR1cnE2MzNsN2U2ZHF0VnFzVzdjT3k1Y3Zsd29lamtPSERtSE5talVZT1hJa21wdnBudThEWUtwNkJKQ0dRUFhDQVFTQUZ2QmYyUVVzYWdITTlhVmtwN2k0ZUZsVVZGVEdpUk1uc0dqUklrbjd4NDhmNzVHTkdtVWhKSWFoQlpnS2dDbWtLbHVBVlFGZ3JxODVkdXhZM09MRmkvOUMwdzhJQ0lDTmpRMEtDd3NSSGg3ZXMrNVpzMlpKVFErUnlQUkg4QSs1eFlBQkFNQzFvYUhob0plWDEwODNidHlJckt3c1RKOCtIVmV2WGxWQ3pnOCs0d011WURVT0VPa3U4MzNYN096c09TdFhydHoxK3ZWclJFZEhvN3k4SEZ1M2JzV3VYYnNzQnNKQUF5QklrQldmTTRCUnQyL2Yvanc4UER6K3lwVXJtRGx6cGlUNGhRc1hwTzZPMHFPcXFnckJ3Y0VZUFhvMEdoc2I4ZWJObTFkcXRacmRGcXVIUVJZOUkxajBCQVVGalNzb0tQalMxZFgxeDl1MmJjUHUzYnVsUmJLSm9WWXpZQ2czbUcrd1RSWWFHb283ZCs2Z3RiWDFhNDFHOHdzREFOZ3RzbWdVb0RTTUJHeDhTSFUvWFVHcjFjYWxwS1NrODBmMjhpaDhSa1lHdG16Wm9wejAzK1M1NmVucHlNek14TnExYTNIdzRFRTBOVFhkR3pWcVZKSkJKa2dBckpJS2k5WVhTMStDNEZaWldmbEZjSEJ3OUprelp6QnYzanhKOEljUEg4TFBqN1dLTW1QdTNMbkl6OC9IK2ZQbkVSOGZqOU9uVC84eE1USHhLNk5hd0NyRkVNbVFWdkNwY0lVTkd6Wk16c3pNM0dOblorZVFsSlNFdkx3OGFaRmNyQkpEY0F6OW44QTZPanAyUmtkSEx5Z3BLV0hyamRVZ2V3SnNsbG9GQU5IK1psTFU0d3FGaFlXclkySmlmczFVbDY3QTZFQ056Wmt6cDk4WWVIbDU0Zm56NXowNVJVMU56WldBZ0lDZEFQNGxaNEVzaDlrVnNtby9RR3FCaXk2UWs1T1RlMjF0YlphSGg4ZG5vdGRQeWZ1YkJTNWJ0Z3k1dWJtWU9IRWlDZ29LNE9ucGljMmJONi9mczJkUHFVeUFMSVZaQ1hJN3pheGhiakZrK0hCUkdZcEdLS09DSU1UTnZKRmNRRTVnVkNncEthSFptclU0M2h3Ykc0dWlvaUpKZUJaWC92Nyt1SGZ2WGtGUVVGQ0dYQVFaTmtQTUlrQSt2ejhBOFA5WkhmYlVCd3lMbktXbHBlc2pJaUlTZUFQMyt5NWZ2Z3huWjJka1oyY2pNVEhSSkJBWTh0TFMwdERTMHZLZThNM056UTJ1cnE1clpPRlphWWtxMEd6elZ3SUFQa1BzQmtrMWdnQ2hycTd1OTk3ZTNteFc5R3g5OFhOWVdCaVdMbDBLYm5pNHVibEprMXRsRHg0OGtHWk5UWTEwUFh2MnJBU1VvZWFsQmF0VWpQc1VYQlJBb2hWbVZ2d1hXdWl2QlFnUUdSV2tNbGxFQlliSGtwS1NsTWpJU0NrOUpDZWNPM2NPZCs5S3plSWZIR1Q3MWF0WFM1TSsvK3paczJvZkh4K1NIazJlOHo4eTh6UDIwL2ZOWW44bEFUQjJCVVlGa1IrTXlNdkxTMWl5Wk1rSzhVSUN3TWp3NU1rVFBIMzZWTHJTekNrd0JRMEtDcEtLcWhrelpraHV3L0ZONisxNldGallBWm50S1RocmYwRjhmZG9QVUJvQTRRcFN0MGkyQklKQVl0UmtabWIrTENZbVpvcS92MytvV3EwMmlRbDFPdDJicXFxcXYrZms1RnpWYXJYM1pZSHA3NXlNK1dSOUNrL1ROeXYwR1RQNUQ1cWppVGVJcUVBUWhEdlFHbGc1OGtyM1VPL2Z2ejh5SkNURTE4M056ZFhaMmRsVm85RzRPRGc0T0haMmRyWjFkSFMwdGJlM3R4VVhGNWRuWldXVlZWUlVNTWF6MFVpQk9hbDFmaGZDOTJ0alZDa1NOQVpVT2h3aHRzbmx6VklLVDVLa2RSQWNSZzd5aGpnc3hXZUlRMUxVS0RYTHJJNkNVbUF4K1owN1FJb2RsRkNDQkkwTlJGaUNTSmVaTEZGd0lUeS9Fd0FCQWtPcEFJQWFGUUJRVUU2U25EZ1RRRkFFNGZXSjlIcGJySWtXYnRadGhnZWtwQk1qOGhTZnBVMFZPWThRQVBBRkJJQ1RRbkpTWUdwYmZCY25RL3JzODlZQ1FMem52ZTB6c1p0a1lQcmlkMkVCRkV5QVFHSEZGTDZ1aU5ZdFJZTGZaeUxDSW9UQVlrTlZhSisvaThPU3ZSMllWRnh3UzRSQlUzMUU4STQ0VG1mOGY0WkFtUHJNUHQ5bkNSTHM4MklHNGgrSEFCZ0kxRCttZHc1WndNZWtqWUZZeTVBRkRBVHFIOU03QjcwRi9COEJrUXA5WU5iRzJRQUFBQUJKUlU1RXJrSmdnZz09IiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiLz48L3N2Zz4=) 16 16,auto!important;cursor:-webkit-image-set(url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 2x,url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 1x) 16 16,auto!important}.relation-graph .rg-move-operator.rg-move-operator-active .rg-move-touchpad{display:flex}.relation-graph.rg-creating-line .rg-connect-source-handle{pointer-events:none;opacity:.5}.rg-background{position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:0;pointer-events:none}.rg-toolbar{user-select:none;pointer-events:all;display:flex;position:absolute;z-index:300;background-color:#fff;color:#333;--rg-toolbar-hover-bg-color: rgba(220, 220, 220, .5);box-shadow:0 1px 3px #0003,0 0 1px #0006;box-sizing:border-box;border-radius:5px;width:fit-content;height:fit-content;place-items:center;justify-content:center;gap:3px;backdrop-filter:blur(5px)}.rg-toolbar .rg-icon{flex-grow:1;width:16px;height:16px;fill:currentColor;overflow:hidden}.rg-toolbar .rg-mb-button svg{margin:auto}.rg-toolbar .rg-mb-button:hover{background-color:var(--rg-toolbar-hover-bg-color)}.rg-toolbar .rg-loading-icon{animation:turn 1s linear infinite}@keyframes turn{0%{-webkit-transform:rotate(0deg)}25%{-webkit-transform:rotate(90deg)}50%{-webkit-transform:rotate(180deg)}75%{-webkit-transform:rotate(270deg)}to{-webkit-transform:rotate(360deg)}}.rg-toolbar .rg-current-zoom{margin-top:0;font-size:10px;text-align:center;border-radius:3px;cursor:pointer}.rg-toolbar .rg-current-zoom:hover{background-color:var(--rg-toolbar-hover-bg-color)}.rg-toolbar .rg-mb-button{width:35px;height:35px;margin-top:0;opacity:1;cursor:pointer;font-size:18px;box-sizing:border-box;display:flex;align-items:center;justify-items:center;border-radius:3px}.rg-toolbar.rg-toolbar-v{flex-flow:column;padding:10px 3px}.rg-toolbar.rg-toolbar-v .rg-current-zoom{width:35px;height:25px;line-height:25px}.rg-toolbar.rg-toolbar-h{padding:3px 10px}.rg-toolbar.rg-toolbar-h .rg-current-zoom{width:fit-content;padding:0 5px;height:35px;line-height:35px}.rg-toolbar.rg-toolbar-h-right{right:15px}.rg-toolbar.rg-toolbar-h-left{left:15px}.rg-toolbar.rg-toolbar-h-center{left:50%;transform:translate(-50%)}.rg-toolbar.rg-toolbar-v-top{top:15px}.rg-toolbar.rg-toolbar-v-bottom{bottom:15px}.rg-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}.rg-toolbar.rg-xs-toolbar .rg-mb-button{width:25px;height:25px}.rg-toolbar.rg-xs-toolbar .rg-icon{width:14px;height:14px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v{padding:3px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v .rg-current-zoom{width:30px;height:25px;line-height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h{padding:3px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h .rg-current-zoom{width:35px;height:25px;line-height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h .rg-mb-button{width:25px;height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-right{right:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-left{left:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-center{left:50%;transform:translate(-50%)}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-top{top:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-bottom{bottom:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();"use strict";var Vt=Object.defineProperty;var Xt=(s,o,e)=>o in s?Vt(s,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[o]=e;var _=(s,o,e)=>(Xt(s,typeof o!="symbol"?o+"":o,e),e);/*!
|
|
2
|
+
* relation-graph v3.0.4
|
|
3
3
|
* (c) 2026 WanLian <seeksdream@qq.com>
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
* Repository: https://github.com/seeksdream/relation-graph
|
|
6
|
-
*/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("react/jsx-runtime"),I=require("react"),Xt=require("react-dom"),zt=s=>s&&typeof s=="object"&&"default"in s?s:{default:s},pe=zt(I),tt="3.0.3",ce=s=>{try{if("touches"in s&&s.touches||"targetTouches"in s&&s.targetTouches)return!0}catch{}return!1},Ce=s=>{if(ce(s)){const o=s.touches||s.targetTouches;if(!o)throw new Error("error targetTouches");return{clientX:o[0].clientX,clientY:o[0].clientY}}else return{clientX:s.clientX,clientY:s.clientY}},L=(...s)=>{typeof window<"u"&&window.relationGraphDebug&&console.log("[relation-graph:debug]",...s)},Le=(s,o,e)=>{if(!s)return null;if(s.classList){if(s.classList.contains(o))return s;if(s.classList.contains(e))return null}let t=null;if(s.assignedSlot?t=s.assignedSlot:t=s.parentElement,!t){const n=s.parentNode;n instanceof ShadowRoot&&(t=n.host)}return Le(t,o,e)},Xe=s=>new Promise(o=>setTimeout(o,s)),Bt=()=>{const s="l",o="o",e="g",t=new Date().getFullYear(),n=[];return t>1&&n.push(s),t>201&&n.push(o),t>1113&&n.push(e),n.join("")},Gt=()=>{const s="c",o="o",e="n",t="s",n="o",i="l",a="e",r=new Date().getFullYear(),l=[];return r>1&&l.push(s),r>21&&l.push(o),r>35&&l.push(e),r>55&&l.push(t),r>189&&l.push(n),r>231&&l.push(i),r>1234&&l.push(a),l.join("")},qe=s=>s.replace(/-/g,"").replace(/\*/g,"-"),nt=s=>{const o=Gt(),e=Bt(),t="r-e-l-a-t-i-o-n*g-r-a-p-h",n="h-t-t-p-s-:-/-/-g-i-t-h-u-b-.-c-o-m-/-s-e-e-k-s-d-r-e-a-m-/-r-e-l-a-t-i-o-n-*-g-r-a-p-h";window&&window[o]&&window[o][e](`%c ${qe(t)} %c Version v${tt}(${s}) %c More info: ${qe(n)} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#fff ; padding: 1px; border-radius: 0 3px 3px 0; color: #41b883","background:transparent")},Ft=(s,o)=>{typeof o=="string"&&(o=[o]);for(const t of o)if(s.classList.contains(t))return!0;let e=s.parentElement;for(;e;){for(const t of o)if(e.classList.contains(t))return!0;e=e.parentElement}return!1},we=s=>{const o=s.target;return Ft(o,"rel-text-editing")?!0:["input","textarea"].includes(document.activeElement.tagName.toLowerCase())},Be=(s=5)=>{const o="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let e="";const t=s>30?30:s;for(let n=0;n<t;n++)e+=o[Math.floor(Math.random()*o.length)];return e},Ge=s=>({onReady:s.onReady,onNodeClick:s.onNodeClick,onNodeExpand:s.onNodeExpand,onNodeCollapse:s.onNodeCollapse,onLineClick:s.onLineClick,onNodeDragStart:s.onNodeDragStart,onNodeDragEnd:s.onNodeDragEnd,onNodeDragging:s.onNodeDragging,onCanvasDragEnd:s.onCanvasDragEnd,onCanvasDragging:s.onCanvasDragging,onContextmenu:s.onContextmenu,onFullscreen:s.onFullscreen,onCanvasClick:s.onCanvasClick,onCanvasSelectionEnd:s.onCanvasSelectionEnd,beforeZoomStart:s.beforeZoomStart,onZoomEnd:s.onZoomEnd,onViewResize:s.onViewResize,onResizeStart:s.onResizeStart,beforeNodeResize:s.beforeNodeResize,onResizeEnd:s.onResizeEnd,onLineVertexDropped:s.onLineVertexDropped,beforeCreateLine:s.beforeCreateLine,onLineBeCreated:s.onLineBeCreated,beforeAddNodes:s.beforeAddNodes,beforeAddLines:s.beforeAddLines,onKeyboardDown:s.onKeyboardDown,onKeyboardUp:s.onKeyboardUp,onCanvasDragStart:s.onCanvasDragStart,onForceLayoutFinish:s.onForceLayoutFinish,beforeScrollStart:s.beforeScrollStart});var V=(s=>(s.Node="node",s.NodePoint="NodePoint",s.HTMLElementId="HTMLElementId",s.CanvasPoint="CanvasPoint",s.ViewPoint="ViewPoint",s))(V||{}),U=(s=>(s.border="border",s.ltrb="ltrb",s.tb="tb",s.lr="lr",s.left="left",s.right="right",s.top="top",s.bottom="bottom",s))(U||{}),Ne=(s=>(s[s.circle=0]="circle",s[s.rect=1]="rect",s))(Ne||{}),H=(s=>(s[s.StandardStraight=1]="StandardStraight",s[s.StandardCurve=6]="StandardCurve",s[s.Curve2=2]="Curve2",s[s.Curve3=3]="Curve3",s[s.Curve5=5]="Curve5",s[s.Curve7=7]="Curve7",s[s.Curve8=8]="Curve8",s[s.SimpleOrthogonal=4]="SimpleOrthogonal",s[s.StandardOrthogonal=44]="StandardOrthogonal",s[s.HardOrthogonal=49]="HardOrthogonal",s))(H||{}),it=(s=>(s.Left="left",s.Top="top",s.Right="right",s.Bottom="bottom",s))(it||{}),A=(s=>(s.onReady="onReady",s.onNodeClick="onNodeClick",s.onNodeExpand="onNodeExpand",s.onNodeCollapse="onNodeCollapse",s.onLineClick="onLineClick",s.onNodeDragStart="onNodeDragStart",s.onNodeDragEnd="onNodeDragEnd",s.onNodeDragging="onNodeDragging",s.onCanvasDragEnd="onCanvasDragEnd",s.onCanvasDragging="onCanvasDragging",s.onContextmenu="onContextmenu",s.onFullscreen="onFullscreen",s.onCanvasClick="onCanvasClick",s.onCanvasSelectionEnd="onCanvasSelectionEnd",s.beforeZoomStart="beforeZoomStart",s.onZoomEnd="onZoomEnd",s.onViewResize="onViewResize",s.onResizeStart="onResizeStart",s.beforeNodeResize="beforeNodeResize",s.onResizeEnd="onResizeEnd",s.onLineVertexDropped="onLineVertexDropped",s.beforeCreateLine="beforeCreateLine",s.onLineBeCreated="onLineBeCreated",s.beforeAddNodes="beforeAddNodes",s.beforeAddLines="beforeAddLines",s.onKeyboardDown="onKeyboardDown",s.onKeyboardUp="onKeyboardUp",s.onCanvasDragStart="onCanvasDragStart",s.onForceLayoutFinish="onForceLayoutFinish",s.beforeScrollStart="beforeScrollStart",s))(A||{});const he=(s,o)=>{if(s.from===void 0)throw console.log("error,line must has option[from](nodeId):",s),new Error("error,line must has option[from]:");if(s.to===void 0)throw console.log("error,line must has option[to](nodeId):",s),new Error("error,line must has option[to]:");if(typeof s.from!="string")throw console.log("error line from, must be string(nodeId):",s),new TypeError("error line from, must be string:");if(typeof s.to!="string")throw console.log("error line to, must be string(nodeId):",s),new TypeError("error line to, must be string:");return s.hidden===void 0&&s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.hidden===void 0&&s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead.")),{id:s.id,from:s.from,to:s.to,type:s.type!==void 0?s.type:"",isFakeLine:s.isFakeLine!==void 0?s.isFakeLine:!1,fromType:s.fromType!==void 0?s.fromType:s.isFakeLine?V.CanvasPoint:V.Node,toType:s.toType!==void 0?s.toType:s.isFakeLine?V.CanvasPoint:V.Node,selected:!1,text:s.text!==void 0?s.text:"",textOffsetX:s.textOffsetX!==void 0?s.textOffsetX:void 0,textOffsetY:s.textOffsetY!==void 0?s.textOffsetY:void 0,color:s.color!==void 0?s.color:void 0,opacity:s.opacity!==void 0?s.opacity:void 0,fontSize:s.fontSize!==void 0?s.fontSize:void 0,fontColor:s.fontColor!==void 0?s.fontColor:void 0,lineWidth:s.lineWidth!==void 0?s.lineWidth:void 0,lineShape:s.lineShape||o.defaultLineShape||1,className:s.className!==void 0?s.className:void 0,animation:s.animation!==void 0?s.animation:0,dashType:s.dashType!==void 0?s.dashType:0,disablePointEvent:s.disablePointEvent!==void 0?s.disablePointEvent:!1,showStartArrow:s.showStartArrow!==void 0?s.showStartArrow:!1,showEndArrow:s.showEndArrow!==void 0?s.showEndArrow:!0,useTextOnPath:s.useTextOnPath!==void 0?s.useTextOnPath:void 0,placeText:s.placeText!==void 0?s.placeText:void 0,startMarkerId:s.startMarkerId||"",endMarkerId:s.endMarkerId||"",textAnchor:s.textAnchor!==void 0?s.textAnchor:void 0,junctionOffset:s.junctionOffset,fromJunctionPoint:s.fromJunctionPoint,toJunctionPoint:s.toJunctionPoint,fromJunctionPointOffsetX:s.fromJunctionPointOffsetX||0,fromJunctionPointOffsetY:s.fromJunctionPointOffsetY||0,toJunctionPointOffsetX:s.toJunctionPointOffsetX||0,toJunctionPointOffsetY:s.toJunctionPointOffsetY||0,lineRadius:s.lineRadius,force_elastic:s.force_elastic,polyLineStartDistance:s.polyLineStartDistance,ctrlPointsFor49:s.ctrlPointsFor49,ctrlPointsFor44:s.ctrlPointsFor44,ctrlPoints:s.ctrlPoints,lineDirection:s.lineDirection!==void 0?s.lineDirection:void 0,forDisplayOnly:s.forDisplayOnly||s.from===s.to,hidden:s.hidden!==void 0?s.hidden:!1,cssVars:s.cssVars!==void 0?s.cssVars:void 0,data:s.data!==void 0?s.data:{}}},Yt=["arrow","isReverse","selected","shouldRender","rgCalcedVisibility"],Re=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!Yt.includes(e)){const t=s[e];t!==void 0&&(e==="isFakeLine"&&t===!1||e==="fromType"&&t===V.Node||e==="toType"&&t===V.Node||e==="animation"&&t===0||e==="text"&&t===""||e==="dashType"&&t===0||e==="disablePointEvent"&&t===!1||e==="showStartArrow"&&t===!1||e==="showEndArrow"&&t===!0||e==="startMarkerId"&&t===""||e==="endMarkerId"&&t===""||e==="forDisplayOnly"&&t===!1||e==="fromJunctionPointOffsetX"&&t===0||e==="fromJunctionPointOffsetY"&&t===0||e==="toJunctionPointOffsetX"&&t===0||e==="toJunctionPointOffsetY"&&t===0||e==="opacity"&&t===1||e==="hidden"&&t===!1||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=s[e]))}}),o},Fe=s=>{if(!!s)return Re(s.line)},Ht={json2Line:he,transLinkToJson:Fe},jt=Object.freeze(Object.defineProperty({__proto__:null,json2Line:he,transLineToJson:Re,transLinkToJson:Fe,default:Ht},Symbol.toStringTag,{value:"Module"})),z={getDescendantNodes(s,o=[]){return s.lot&&s.lot.childs&&s.lot.childs.forEach(e=>{o.push(e),z.getDescendantNodes(e,o)}),o},isVisibleNode(s,o=0){return typeof o!="number"&&(o=0),o>18?!0:s.hidden?!1:s.lot&&s.lot.parent?s.lot.parent.expanded===!1?!1:z.isVisibleNode(s.lot.parent,o+1):!0},isAllowShowNode(s,o=0){return z.isVisibleNode(s,o=0)},getNodeWidth(s){return s.el_W||s.width||50},getNodeHeight(s){return s.el_H||s.height||50},getNodeXByLotX(s,o){const e=o.lot.x||0;return s.alignItemsX==="end"?e-z.getNodeWidth(o):s.alignItemsX==="start"?e:e-z.getNodeWidth(o)/2},getNodeYByLotY(s,o){const e=o.lot.y||0;return s.alignItemsY==="end"?e-z.getNodeHeight(o):s.alignItemsY==="start"?e:e-z.getNodeHeight(o)/2},getNodeLotXY(s,o){let e=o.x||0,t=o.y||0;return s.alignItemsX==="end"?e=e+z.getNodeWidth(o):s.alignItemsX==="start"||(e=e+z.getNodeWidth(o)/2),s.alignItemsY==="end"?t=t+z.getNodeHeight(o):s.alignItemsY==="start"||(t=t+z.getNodeHeight(o)/2),{x:e,y:t}},isRectangleOverlap(s,o){const e=s.x,t=o.x,n=s.el_W,i=o.el_W,a=s.y,r=o.y,l=s.el_H,c=o.el_H;return!(t>=e+n||t+i<=e||r>=a+l||r+c<=a)},isXOverlap(s,o,e,t){return!(o>=s+e||o+t<=s)},isYOverlap(s,o,e,t){return!(o>=s+e||o+t<=s)},shapesOverlap(s,o,e=1,t=1){return this.isRectangleOverlap(s,o)},getNoOverlapLimitedPosition(s,o,e,t){const n=s.x,i=s.y,a=o,r=t.x,l=s.el_W,c=t.el_W,d=e,h=t.y,f=s.el_H,p=t.el_H;let u=s.x,g=s.y;const m=this.isXOverlap(n,r,l,c),y=this.isYOverlap(i,h,f,p);return m?d<h?(u=o,g=h-f):d>h&&(u=o,g=h+p):y&&(a<r?(u=r-l,g=e):a>r&&(u=r+c,g=e)),{x:u,y:g}},flatNodeData(s,o,e,t){s.forEach(n=>{e.push(n),o&&t.push({from:o.id,to:n.id});const i=n.children||n.childs;i&&i.length>0&&this.flatNodeData(i,n,e,t)})}},_e=(s,o)=>s||s===0?s:o,Ye={id:"rg-newNodeTemplate",x:0,y:0,text:""},be=(s,o,e)=>{if(s.id===void 0)throw console.log("node must has id:",s),new Error("node must has option[id]:");s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead."));const t=s.width||s.width===0?s.width:o==null?void 0:o.defaultNodeWidth,n=s.height||s.height===0?s.height:o==null?void 0:o.defaultNodeHeight,i={id:s.id,text:s.text!==void 0?s.text:"",type:s.type!==void 0?s.type:"",targetType:s.targetType!==void 0?s.targetType:V.Node,expanded:s.expanded!==void 0?s.expanded:!0,selected:s.selected!==void 0?s.selected:!1,className:s.className!==void 0?s.className:"",nodeShape:_e(s.nodeShape,o==null?void 0:o.defaultNodeShape),borderWidth:s.borderWidth!==void 0?s.borderWidth:void 0,borderRadius:s.borderRadius!==void 0?s.borderRadius:void 0,borderColor:s.borderColor!==void 0?s.borderColor:void 0,fontColor:s.fontColor!==void 0?s.fontColor:void 0,fontSize:s.fontSize!==void 0?s.fontSize:void 0,color:s.color!==void 0?s.color:void 0,opacity:s.opacity!==void 0?s.opacity:void 0,fixed:s.fixed!==void 0?s.fixed:!1,width:t,height:n,force_weight:s.force_weight,x:s.x!==void 0?s.x:0,y:s.y!==void 0?s.y:0,expandHolderPosition:s.expandHolderPosition!==void 0?s.expandHolderPosition:void 0,disablePointEvent:s.disablePointEvent!==void 0?s.disablePointEvent:void 0,disableDrag:s.disableDrag!==void 0?s.disableDrag:!1,hidden:s.hidden!==void 0?s.hidden:!1,rgCalcedVisibility:!0,rgShouldRender:!0,rgChildrenSize:0,zIndex:s.zIndex||0,el_W:s.el_W||t||0,el_H:s.el_H||n||0,data:s.data!==void 0?s.data:{}};if(e&&e.has&&e.has(i.id)){const a=e.get(i.id);i.el_W||a&&(i.el_W=a[0]),i.el_H||a&&(i.el_H=a[1])}return i.lot={childs:[],parent:void 0,eached:!1,strength:0},i.width&&(i.el_W=i.width),i.height&&(i.el_H=i.height),i},Wt=["Fx","Fy","appended","dragging","el","el_W","el_H","targetFrom","targetNodes","targetTo","lot","seeks_id","shouldRender","rgCalcedVisibility","rgShouldRender","rgChildrenSize","origin_x","origin_y","selected"],Se=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!Wt.includes(e)){const t=s[e];t!==void 0&&(e==="offset_x"&&t===0||e==="nodeShape"&&t===1||e==="offset_y"&&t===0||e==="zIndex"&&t===0||e==="width"&&!t||e==="height"&&!t||e==="fixed"&&t===!1||e==="className"&&t===""||e==="hidden"&&t===!1||e==="disableDrag"&&t===!1||e==="expanded"&&t===!0||e==="opacity"&&t===1||e==="type"&&t==="node"||e==="targetType"&&t===V.Node||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=t))}}),o},$t={json2Node:be,transNodeToJson:Se},Ut=Object.freeze(Object.defineProperty({__proto__:null,newNodeTemplate:Ye,json2Node:be,transNodeToJson:Se,default:$t},Symbol.toStringTag,{value:"Module"})),Oe=(s={})=>{const o={definitelyNoDataProviderNeeded:!1,instanceId:"",debug:!0,graphLoading:!1,graphLoadingText:"",showToolBar:!0,backgroundColor:"transparent",checkedItemBackgroundColor:void 0,selectionMode:!1,disableWheelEvent:!1,wheelEventAction:"zoom",dragEventAction:"move",fullscreenElementXPath:"",disableDragNode:!1,disableDragLine:!0,canvasMoveMode:!1,disableNodePointEvent:!1,disableLinePointEvent:!1,enableNodeXYAnimation:!1,enableCanvasTransformAnimation:!1,reLayoutWhenExpandedOrCollapsed:!1,defaultExpandHolderPosition:"hide",toolBarDirection:"h",toolBarPositionH:"left",toolBarPositionV:"bottom",defaultNodeColor:"#ffffff",defaultNodeBorderColor:"#666666",defaultNodeBorderWidth:1,defaultNodeBorderRadius:4,defaultNodeShape:Ne.rect,defaultNodeWidth:void 0,defaultNodeHeight:void 0,defaultLineColor:"#cccccc",defaultLineWidth:2,defaultLineShape:H.StandardStraight,defaultLineTextOffsetX:void 0,defaultLineTextOffsetY:void 0,defaultJunctionPoint:U.border,defaultLineJunctionOffset:3,defaultPolyLineRadius:5,placeOtherGroup:!0,defaultLineTextOnPath:!1,lineTextMaxLength:66,multiLineDistance:30,defaultLineMarker:{viewBox:"0 0 12 12",markerWidth:20,markerHeight:20,refX:3,refY:3,data:"M 0 0, V 6, L 4 3, Z"},viewSize:{width:300,height:300},canvasSize:{width:300,height:300},canvasOffset:{x:25,y:27},fullscreen:!1,checkedNodeId:"",checkedLineId:"",draggingNodeId:"",layout:{layoutName:"center"},canvasZoom:100,mouseWheelSpeed:10,minCanvasZoom:5,maxCanvasZoom:500,showEasyView:!1,performanceMode:!1,viewHeight:"100%",canvasOpacity:1,creatingSelection:!1,selectionView:{x:25,y:27,width:0,height:0},creatingNodePlot:!1,showTemplateNode:!0,newNodeTemplate:be(JSON.parse(JSON.stringify(Ye)),{}),creatingLinePlot:!1,newLineTemplate:{from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:"new line"},newLinkTemplate:{fromNode:null,toNodeObject:null,toNode:{nothing:!0,x:400,y:400,el_W:30,el_H:30},totalLinesBetweenNodes:1,currentLineIndex:0,line:{}},data:{},editingLineController:{show:!1,line:null,startPoint:{x:0,y:0},endPoint:{x:0,y:0},text:{show:!0,x:0,y:0,width:10,height:10},ctrlPoints:[],selectedLines:[],line44Splits:[],line49Points:[],ctrlPoint1:{x:0,y:0},ctrlPoint2:{x:0,y:0},toolbar:{x:0,y:0}},editingController:{show:!1,nodes:[],x:0,y:0,width:100,height:100},nodeConnectController:{show:!1,node:void 0,x:0,y:0,width:100,height:100},showReferenceLine:!1,referenceLineAdsorption:!1,editingReferenceLine:{show:!1,directionV:!1,directionH:!1,v_x:0,v_y:0,v_height:0,h_x:0,h_y:0,h_width:0},showMiniView:!1,miniViewVisibleHandle:{x:0,y:0,width:100,height:100,emptyContent:!1},snapshotting:!1};o.newLineTemplate=he(o.newLineTemplate,o);const e=Object.keys(o);return s&&Object.keys(s).forEach(t=>{const n=s[t];if(!e.includes(t)){L("RGOptions: unknow option key:",t);return}if(typeof n=="object"){L("RGOptions:user setting object:",t,n);const i=o[t];if(t==="layout")o[t]=JSON.parse(JSON.stringify(n));else if(i&&!Array.isArray(i)&&n)Object.keys(i).forEach(a=>{i[a]=n[a]});else if(Array.isArray(i)){const a=[];n.forEach(r=>{r&&typeof r=="object"?a.push(JSON.parse(JSON.stringify(r))):a.push(r)}),o[t]=a}else o[t]=n}else o[t]=n}),o},He=(s,o)=>{L("applyDefaultOptionsByLayout",s.layoutName,o);const e=s.layoutName||"";e==="center"||e.includes("tree")&&(s.from==="top"||s.from,s.from==="left"||s.from)},je=s=>{const o=s.layoutName||"";if(o==="center"){const e=s;e.layoutDirection=void 0}else if(o.includes("tree")){const e=s;e.from===void 0&&(e.from="left"),e.levelGaps===void 0&&(e.levelGaps=[]),(e.from==="top"||e.from==="bottom")&&(e.layoutDirection===void 0&&(e.layoutDirection="v"),L("set layoutDirection=v"),L("set defaultJunctionPoint=tb")),(e.from==="left"||e.from==="right")&&(e.layoutDirection===void 0&&(e.layoutDirection="h"),L("set defaultJunctionPoint=lr"))}else(o==="fixed"||o==="force")&&(s.layoutDirection=void 0)},qt={createDefaultConfig:Oe,applyDefaultOptionsByLayout:He},Jt=Object.freeze(Object.defineProperty({__proto__:null,createDefaultConfig:Oe,applyDefaultOptionsByLayout:He,appendDefaultOptions4Layout:je,default:qt},Symbol.toStringTag,{value:"Module"})),ye=I.createContext(null),ot=I.createContext(null),Ee=I.createContext(0),re=I.createContext({shouldRenderLines:[],shouldRenderNodes:[],shouldRenderFakeLines:[],options:Oe({})});function W(){const s=I.useContext(ye);if(!s)throw new Error("'useGraphInstance' must be used within 'RGProvider'");return s}function se(){const s=I.useContext(Ee);if(s===void 0)throw new Error("'useAutoUpdateView' must be used within 'RGProvider'");return s}function J(){const s=I.useContext(re);if(s===void 0)throw new Error("'useGraphStore' must be used within 'RGProvider'");return s}function Zt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCreatingLine' must be used within 'RGProvider'");const o=W();return I.useMemo(()=>{if(!s.options||!s.options.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=o.generateCreatingLineConfig(s.options);return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}},[s.options.creatingLinePlot,s.options.newLinkTemplate,s.options.newLineTemplate])}function Qt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCreatingLine' must be used within 'RGProvider'");return I.useMemo(()=>!s.options||!s.options.creatingNodePlot?{creating:!1}:{creating:!0,nodeJson:s.options.newNodeTemplate},[s.options.creatingNodePlot,s.options.newNodeTemplate])}function Kt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useEditingNodes' must be used within 'RGProvider'");return I.useMemo(()=>s.options.editingController,[s.options.editingController])}function en(){const s=I.useContext(re);if(s===void 0)throw new Error("'useEditingLine' must be used within 'RGProvider'");return I.useMemo(()=>s.options.editingLineController,[s.options.editingLineController])}function tn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useConnectingNode' must be used within 'RGProvider'");return I.useMemo(()=>s.options.nodeConnectController,[s.options.nodeConnectController])}function nn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useViewInformation' must be used within 'RGProvider'");return I.useMemo(()=>{const{viewSize:o,canvasSize:e,canvasOffset:t,canvasZoom:n,fullscreen:i,showEasyView:a}=s.options;return{viewSize:o,canvasSize:e,canvasOffset:t,canvasZoom:n,fullscreen:i,showEasyView:a}},[s.options.viewSize,s.options.canvasSize,s.options.canvasOffset,s.options.canvasZoom,s.options.fullscreen,s.options.showEasyView])}function on(){const s=I.useContext(re);if(s===void 0)throw new Error("'useSelection' must be used within 'RGProvider'");return I.useMemo(()=>({...s.options.selectionView,show:s.options.creatingSelection}),[s.options.selectionView,s.options.creatingSelection])}function sn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCheckedItem' must be used within 'RGProvider'");return I.useMemo(()=>({checkedLineId:s.options.checkedLineId,checkedNodeId:s.options.checkedNodeId,draggingNodeId:s.options.draggingNodeId}),[s.options.checkedLineId,s.options.checkedNodeId,s.options.draggingNodeId])}const st=({forElementLines:s})=>{const{options:o}=J();return x.jsxs("defs",{children:[x.jsx("marker",{id:`${o.instanceId}-arrow-default`,markerWidth:o.defaultLineMarker.markerWidth,markerHeight:o.defaultLineMarker.markerHeight,refX:o.defaultLineMarker.refX,refY:o.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto",viewBox:o.defaultLineMarker.viewBox,children:x.jsx("path",{style:{fill:"context-stroke"},d:o.defaultLineMarker.data})}),x.jsx("marker",{id:`${o.instanceId}-start-arrow-default`,markerWidth:o.defaultLineMarker.markerWidth,markerHeight:o.defaultLineMarker.markerHeight,refX:o.defaultLineMarker.refX,refY:o.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",viewBox:o.defaultLineMarker.viewBox,children:x.jsx("path",{style:{fill:"context-stroke"},d:o.defaultLineMarker.data})})]})},at=({children:s,lineConfig:o,checked:e})=>{const t=W();if(!t)return null;const n=t.getLineTextContainer(o==null?void 0:o.line);if(!n)return null;const i=o.line,a=i.selected;return Xt.createPortal(x.jsx("div",{className:["rg-line-peel",i.className,e&&"rg-line-checked",(i.disablePointEvent||i.opacity===0)&&"rg-line-disable-events",a&&"rg-line-selected"].filter(Boolean).join(" "),"data-id":i.id,style:{"--rg-line-color":i.color,"--rg-line-fontsize":o.line.fontSize?`${o.line.fontSize}px`:void 0,"--rg-line-opacity":i.opacity,"--rg-line-fontcolor":i.fontColor,...i.cssVars||{}},children:s}),n)},rt=({lineConfig:s,linePathInfo:o,useTextOnPath:e,checked:t,graphInstanceId:n,onLineClick:i,children:a})=>{const r=W(),l=s.line,c=l.selected,d=r.getArrowMarkerId(l,!0),h=r.getArrowMarkerId(l,!1),f=l.lineWidth?l.lineWidth+"px":void 0,p=e?r.generateLineTextStyle4TextOnPath(s):null,u=n+"-"+l.id;return x.jsxs("g",{className:["rg-line-peel",l.className,t&&"rg-line-checked",c&&"rg-line-selected",(l.disablePointEvent||l.opacity===0)&&"rg-line-disable-events"].filter(Boolean).join(" "),"data-id":l.id,style:{"--rg-line-width":f,"--rg-line-color":l.color,"--rg-line-opacity":l.opacity,"--rg-line-fontcolor":l.fontColor,"--rg-line-marker-end":h,"--rg-line-marker-start":d,...l.cssVars||{}},children:[x.jsx("path",{d:o.pathData,className:"rg-line-bg",onTouchStart:i,onClick:i}),x.jsx("path",{id:u,d:o.pathData,className:["rg-line",l.dashType?"rg-line-dashtype-"+l.dashType:void 0,l.animation?"rg-line-anm-"+l.animation:void 0].filter(Boolean).join(" ")}),p&&x.jsx("g",{children:x.jsx("text",{className:"rg-line-text rg-line-text-on-path",dx:p.textOffset.x+"px",dy:p.textOffset.y+"px",onTouchStart:i,onClick:i,children:x.jsx("textPath",{xlinkHref:`#${u}`,startOffset:p.onPathStartOffset,textAnchor:p.textAnchor,method:"align",spacing:"auto",children:p.text})})}),a]})},lt=({lineConfig:s,defaultLineTextOnPath:o,graphInstanceId:e,checked:t})=>{const n=W(),i=I.useMemo(()=>n.generateLinePath(s),[s]),a=h=>{n.onLineClick(s.line,h.nativeEvent)},r=s.line.useTextOnPath||o,l=r&&s.line.lineShape!==H.StandardStraight,c=!l,d=n.generateLineTextStyle(s,i);return x.jsxs(x.Fragment,{children:[x.jsx(rt,{lineConfig:s,linePathInfo:i,onLineClick:a,useTextOnPath:l,checked:t,graphInstanceId:e}),s.line.text&&c&&x.jsx(at,{lineConfig:s,linePathInfo:i,checked:t,children:x.jsx("div",{className:`rg-line-label ${r?"rg-line-label-on-path":""}`,style:{...d.cssStyles},onTouchStart:a,onClick:a,children:d.text})})]})},dt=({line:s,defaultLineTextOnPath:o,graphInstanceId:e,checked:t,lineSlot:n})=>{const i=W();se();const a=s.isFakeLine?i.generateFakeLineConfig(s):i.generateLineConfig(s);return x.jsx(x.Fragment,{children:a&&(n?n({lineConfig:a,defaultLineTextOnPath:o,graphInstanceId:e,checked:t}):x.jsx(lt,{lineConfig:a,defaultLineTextOnPath:o,graphInstanceId:e,checked:t}))})},ct=({showEasyView:s,lineSlot:o,defaultLineTextOnPath:e,checkedLineId:t,graphInstanceId:n,allLineConfigList:i})=>x.jsxs("div",{className:"rg-lines-container rg-lines-container-normal-lines",children:[x.jsxs("svg",{className:"rg-lines-svg",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx(st,{}),!s&&i.map(a=>a.hidden!==!0&&x.jsx(dt,{line:a,lineSlot:o,defaultLineTextOnPath:e,checked:a.id===t,graphInstanceId:n},a.id))]}),x.jsx("div",{className:"rg-linetext-container"})]});pe.default.memo(ct,(s,o)=>s.allLineConfigList!==o.allLineConfigList||s.graphInstanceId!==o.graphInstanceId||s.checkedLineId!==o.checkedLineId||s.lineSlot!==o.lineSlot?!1:s.defaultLineTextOnPath===o.defaultLineTextOnPath);const an={"icon-quanping":{data:`
|
|
6
|
+
*/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("react/jsx-runtime"),I=require("react"),Bt=require("react-dom"),zt=s=>s&&typeof s=="object"&&"default"in s?s:{default:s},pe=zt(I),et="3.0.4",ce=s=>{try{if("touches"in s&&s.touches||"targetTouches"in s&&s.targetTouches)return!0}catch{}return!1},Ce=s=>{if(ce(s)){const o=s.touches||s.targetTouches;if(!o)throw new Error("error targetTouches");return{clientX:o[0].clientX,clientY:o[0].clientY}}else return{clientX:s.clientX,clientY:s.clientY}},w=(...s)=>{typeof window<"u"&&window.relationGraphDebug&&console.log("[relation-graph:debug]",...s)},we=(s,o,e)=>{if(!s)return null;if(s.classList){if(s.classList.contains(o))return s;if(s.classList.contains(e))return null}let t=null;if(s.assignedSlot?t=s.assignedSlot:t=s.parentElement,!t){const n=s.parentNode;n instanceof ShadowRoot&&(t=n.host)}return we(t,o,e)},Xe=s=>new Promise(o=>setTimeout(o,s)),Gt=()=>{const s="l",o="o",e="g",t=new Date().getFullYear(),n=[];return t>1&&n.push(s),t>201&&n.push(o),t>1113&&n.push(e),n.join("")},Ft=()=>{const s="c",o="o",e="n",t="s",n="o",i="l",a="e",r=new Date().getFullYear(),l=[];return r>1&&l.push(s),r>21&&l.push(o),r>35&&l.push(e),r>55&&l.push(t),r>189&&l.push(n),r>231&&l.push(i),r>1234&&l.push(a),l.join("")},$e=s=>s.replace(/-/g,"").replace(/\*/g,"-"),tt=s=>{const o=Ft(),e=Gt(),t="r-e-l-a-t-i-o-n*g-r-a-p-h",n="h-t-t-p-s-:-/-/-g-i-t-h-u-b-.-c-o-m-/-s-e-e-k-s-d-r-e-a-m-/-r-e-l-a-t-i-o-n-*-g-r-a-p-h";window&&window[o]&&window[o][e](`%c ${$e(t)} %c Version v${et}(${s}) %c More info: ${$e(n)} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#fff ; padding: 1px; border-radius: 0 3px 3px 0; color: #41b883","background:transparent")},Yt=(s,o)=>{typeof o=="string"&&(o=[o]);for(const t of o)if(s.classList.contains(t))return!0;let e=s.parentElement;for(;e;){for(const t of o)if(e.classList.contains(t))return!0;e=e.parentElement}return!1},_e=s=>{const o=s.target;return Yt(o,"rel-text-editing")?!0:["input","textarea"].includes(document.activeElement.tagName.toLowerCase())},ze=(s=5)=>{const o="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let e="";const t=s>30?30:s;for(let n=0;n<t;n++)e+=o[Math.floor(Math.random()*o.length)];return e},Ge=s=>({onReady:s.onReady,onNodeClick:s.onNodeClick,onNodeExpand:s.onNodeExpand,onNodeCollapse:s.onNodeCollapse,onLineClick:s.onLineClick,onNodeDragStart:s.onNodeDragStart,onNodeDragEnd:s.onNodeDragEnd,onNodeDragging:s.onNodeDragging,onCanvasDragEnd:s.onCanvasDragEnd,onCanvasDragging:s.onCanvasDragging,onContextmenu:s.onContextmenu,onFullscreen:s.onFullscreen,onCanvasClick:s.onCanvasClick,onCanvasSelectionEnd:s.onCanvasSelectionEnd,beforeZoomStart:s.beforeZoomStart,onZoomEnd:s.onZoomEnd,onViewResize:s.onViewResize,onResizeStart:s.onResizeStart,beforeNodeResize:s.beforeNodeResize,onResizeEnd:s.onResizeEnd,onLineVertexDropped:s.onLineVertexDropped,beforeCreateLine:s.beforeCreateLine,onLineBeCreated:s.onLineBeCreated,beforeAddNodes:s.beforeAddNodes,beforeAddLines:s.beforeAddLines,onKeyboardDown:s.onKeyboardDown,onKeyboardUp:s.onKeyboardUp,onCanvasDragStart:s.onCanvasDragStart,onForceLayoutFinish:s.onForceLayoutFinish,beforeScrollStart:s.beforeScrollStart});var V=(s=>(s.Node="node",s.NodePoint="NodePoint",s.HTMLElementId="HTMLElementId",s.CanvasPoint="CanvasPoint",s.ViewPoint="ViewPoint",s))(V||{}),U=(s=>(s.border="border",s.ltrb="ltrb",s.tb="tb",s.lr="lr",s.left="left",s.right="right",s.top="top",s.bottom="bottom",s))(U||{}),be=(s=>(s[s.circle=0]="circle",s[s.rect=1]="rect",s))(be||{}),H=(s=>(s[s.StandardStraight=1]="StandardStraight",s[s.StandardCurve=6]="StandardCurve",s[s.Curve2=2]="Curve2",s[s.Curve3=3]="Curve3",s[s.Curve5=5]="Curve5",s[s.Curve7=7]="Curve7",s[s.Curve8=8]="Curve8",s[s.SimpleOrthogonal=4]="SimpleOrthogonal",s[s.StandardOrthogonal=44]="StandardOrthogonal",s[s.HardOrthogonal=49]="HardOrthogonal",s))(H||{}),nt=(s=>(s.Left="left",s.Top="top",s.Right="right",s.Bottom="bottom",s))(nt||{}),A=(s=>(s.onReady="onReady",s.onNodeClick="onNodeClick",s.onNodeExpand="onNodeExpand",s.onNodeCollapse="onNodeCollapse",s.onLineClick="onLineClick",s.onNodeDragStart="onNodeDragStart",s.onNodeDragEnd="onNodeDragEnd",s.onNodeDragging="onNodeDragging",s.onCanvasDragEnd="onCanvasDragEnd",s.onCanvasDragging="onCanvasDragging",s.onContextmenu="onContextmenu",s.onFullscreen="onFullscreen",s.onCanvasClick="onCanvasClick",s.onCanvasSelectionEnd="onCanvasSelectionEnd",s.beforeZoomStart="beforeZoomStart",s.onZoomEnd="onZoomEnd",s.onViewResize="onViewResize",s.onResizeStart="onResizeStart",s.beforeNodeResize="beforeNodeResize",s.onResizeEnd="onResizeEnd",s.onLineVertexDropped="onLineVertexDropped",s.beforeCreateLine="beforeCreateLine",s.onLineBeCreated="onLineBeCreated",s.beforeAddNodes="beforeAddNodes",s.beforeAddLines="beforeAddLines",s.onKeyboardDown="onKeyboardDown",s.onKeyboardUp="onKeyboardUp",s.onCanvasDragStart="onCanvasDragStart",s.onForceLayoutFinish="onForceLayoutFinish",s.beforeScrollStart="beforeScrollStart",s))(A||{});const ue=(s,o)=>{if(s.from===void 0)throw console.log("error,line must has option[from](nodeId):",s),new Error("error,line must has option[from]:");if(s.to===void 0)throw console.log("error,line must has option[to](nodeId):",s),new Error("error,line must has option[to]:");if(typeof s.from!="string")throw console.log("error line from, must be string(nodeId):",s),new TypeError("error line from, must be string:");if(typeof s.to!="string")throw console.log("error line to, must be string(nodeId):",s),new TypeError("error line to, must be string:");return s.hidden===void 0&&s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.hidden===void 0&&s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead.")),{id:s.id,from:s.from,to:s.to,type:s.type!==void 0?s.type:"",isFakeLine:s.isFakeLine!==void 0?s.isFakeLine:!1,fromType:s.fromType!==void 0?s.fromType:s.isFakeLine?V.CanvasPoint:V.Node,toType:s.toType!==void 0?s.toType:s.isFakeLine?V.CanvasPoint:V.Node,selected:!1,text:s.text!==void 0?s.text:"",textOffsetX:s.textOffsetX!==void 0?s.textOffsetX:void 0,textOffsetY:s.textOffsetY!==void 0?s.textOffsetY:void 0,color:s.color!==void 0?s.color:void 0,opacity:s.opacity!==void 0?s.opacity:void 0,fontSize:s.fontSize!==void 0?s.fontSize:void 0,fontColor:s.fontColor!==void 0?s.fontColor:void 0,lineWidth:s.lineWidth!==void 0?s.lineWidth:void 0,lineShape:s.lineShape||o.defaultLineShape||1,className:s.className!==void 0?s.className:void 0,animation:s.animation!==void 0?s.animation:0,dashType:s.dashType!==void 0?s.dashType:0,disablePointEvent:s.disablePointEvent!==void 0?s.disablePointEvent:!1,showStartArrow:s.showStartArrow!==void 0?s.showStartArrow:!1,showEndArrow:s.showEndArrow!==void 0?s.showEndArrow:!0,useTextOnPath:s.useTextOnPath!==void 0?s.useTextOnPath:void 0,placeText:s.placeText!==void 0?s.placeText:void 0,startMarkerId:s.startMarkerId||"",endMarkerId:s.endMarkerId||"",textAnchor:s.textAnchor!==void 0?s.textAnchor:void 0,junctionOffset:s.junctionOffset,fromJunctionPoint:s.fromJunctionPoint,toJunctionPoint:s.toJunctionPoint,fromJunctionPointOffsetX:s.fromJunctionPointOffsetX||0,fromJunctionPointOffsetY:s.fromJunctionPointOffsetY||0,toJunctionPointOffsetX:s.toJunctionPointOffsetX||0,toJunctionPointOffsetY:s.toJunctionPointOffsetY||0,lineRadius:s.lineRadius,force_elastic:s.force_elastic,polyLineStartDistance:s.polyLineStartDistance,ctrlPointsFor49:s.ctrlPointsFor49,ctrlPointsFor44:s.ctrlPointsFor44,ctrlPoints:s.ctrlPoints,lineDirection:s.lineDirection!==void 0?s.lineDirection:void 0,forDisplayOnly:s.forDisplayOnly||s.from===s.to,hidden:s.hidden!==void 0?s.hidden:!1,cssVars:s.cssVars!==void 0?s.cssVars:void 0,data:s.data!==void 0?s.data:{}}},Ht=["arrow","isReverse","selected","shouldRender","rgCalcedVisibility"],Le=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!Ht.includes(e)){const t=s[e];t!==void 0&&(e==="isFakeLine"&&t===!1||e==="fromType"&&t===V.Node||e==="toType"&&t===V.Node||e==="animation"&&t===0||e==="text"&&t===""||e==="dashType"&&t===0||e==="disablePointEvent"&&t===!1||e==="showStartArrow"&&t===!1||e==="showEndArrow"&&t===!0||e==="startMarkerId"&&t===""||e==="endMarkerId"&&t===""||e==="forDisplayOnly"&&t===!1||e==="fromJunctionPointOffsetX"&&t===0||e==="fromJunctionPointOffsetY"&&t===0||e==="toJunctionPointOffsetX"&&t===0||e==="toJunctionPointOffsetY"&&t===0||e==="opacity"&&t===1||e==="hidden"&&t===!1||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=s[e]))}}),o},Fe=s=>{if(!!s)return Le(s.line)},jt={json2Line:ue,transLinkToJson:Fe},Wt=Object.freeze(Object.defineProperty({__proto__:null,json2Line:ue,transLineToJson:Le,transLinkToJson:Fe,default:jt},Symbol.toStringTag,{value:"Module"})),B={getDescendantNodes(s,o=[]){return s.lot&&s.lot.childs&&s.lot.childs.forEach(e=>{o.push(e),B.getDescendantNodes(e,o)}),o},isVisibleNode(s,o=0){return typeof o!="number"&&(o=0),o>18?!0:s.hidden?!1:s.lot&&s.lot.parent?s.lot.parent.expanded===!1?!1:B.isVisibleNode(s.lot.parent,o+1):!0},isAllowShowNode(s,o=0){return B.isVisibleNode(s,o=0)},getNodeWidth(s){return s.el_W||s.width||50},getNodeHeight(s){return s.el_H||s.height||50},getNodeXByLotX(s,o){const e=o.lot.x||0;return s.alignItemsX==="end"?e-B.getNodeWidth(o):s.alignItemsX==="start"?e:e-B.getNodeWidth(o)/2},getNodeYByLotY(s,o){const e=o.lot.y||0;return s.alignItemsY==="end"?e-B.getNodeHeight(o):s.alignItemsY==="start"?e:e-B.getNodeHeight(o)/2},getNodeLotXY(s,o){let e=o.x||0,t=o.y||0;return s.alignItemsX==="end"?e=e+B.getNodeWidth(o):s.alignItemsX==="start"||(e=e+B.getNodeWidth(o)/2),s.alignItemsY==="end"?t=t+B.getNodeHeight(o):s.alignItemsY==="start"||(t=t+B.getNodeHeight(o)/2),{x:e,y:t}},isRectangleOverlap(s,o){const e=s.x,t=o.x,n=s.el_W,i=o.el_W,a=s.y,r=o.y,l=s.el_H,c=o.el_H;return!(t>=e+n||t+i<=e||r>=a+l||r+c<=a)},isXOverlap(s,o,e,t){return!(o>=s+e||o+t<=s)},isYOverlap(s,o,e,t){return!(o>=s+e||o+t<=s)},shapesOverlap(s,o,e=1,t=1){return this.isRectangleOverlap(s,o)},getNoOverlapLimitedPosition(s,o,e,t){const n=s.x,i=s.y,a=o,r=t.x,l=s.el_W,c=t.el_W,d=e,h=t.y,f=s.el_H,p=t.el_H;let u=s.x,g=s.y;const y=this.isXOverlap(n,r,l,c),m=this.isYOverlap(i,h,f,p);return y?d<h?(u=o,g=h-f):d>h&&(u=o,g=h+p):m&&(a<r?(u=r-l,g=e):a>r&&(u=r+c,g=e)),{x:u,y:g}},flatNodeData(s,o,e,t){s.forEach(n=>{e.push(n),o&&t.push({from:o.id,to:n.id});const i=n.children||n.childs;i&&i.length>0&&this.flatNodeData(i,n,e,t)})}},Ne=(s,o)=>s||s===0?s:o,Ye={id:"rg-newNodeTemplate",x:0,y:0,text:""},Oe=(s,o,e)=>{if(s.id===void 0)throw console.log("node must has id:",s),new Error("node must has option[id]:");s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead."));const t=s.width||s.width===0?s.width:o==null?void 0:o.defaultNodeWidth,n=s.height||s.height===0?s.height:o==null?void 0:o.defaultNodeHeight,i={id:s.id,text:s.text!==void 0?s.text:"",type:s.type!==void 0?s.type:"",targetType:s.targetType!==void 0?s.targetType:V.Node,expanded:s.expanded!==void 0?s.expanded:!0,selected:s.selected!==void 0?s.selected:!1,className:s.className!==void 0?s.className:"",nodeShape:Ne(s.nodeShape,o==null?void 0:o.defaultNodeShape),borderWidth:s.borderWidth!==void 0?s.borderWidth:void 0,borderRadius:s.borderRadius!==void 0?s.borderRadius:void 0,borderColor:s.borderColor!==void 0?s.borderColor:void 0,fontColor:s.fontColor!==void 0?s.fontColor:void 0,fontSize:s.fontSize!==void 0?s.fontSize:void 0,color:s.color!==void 0?s.color:void 0,opacity:s.opacity!==void 0?s.opacity:void 0,fixed:s.fixed!==void 0?s.fixed:!1,width:t,height:n,force_weight:s.force_weight,x:s.x!==void 0?s.x:0,y:s.y!==void 0?s.y:0,expandHolderPosition:s.expandHolderPosition!==void 0?s.expandHolderPosition:void 0,disablePointEvent:s.disablePointEvent!==void 0?s.disablePointEvent:void 0,disableDrag:s.disableDrag!==void 0?s.disableDrag:!1,hidden:s.hidden!==void 0?s.hidden:!1,rgCalcedVisibility:!0,rgShouldRender:!0,rgChildrenSize:0,zIndex:s.zIndex||0,el_W:s.el_W||t||0,el_H:s.el_H||n||0,data:s.data!==void 0?s.data:{}};if(e&&e.has&&e.has(i.id)){const a=e.get(i.id);i.el_W||a&&(i.el_W=a[0]),i.el_H||a&&(i.el_H=a[1])}return i.lot={childs:[],parent:void 0,eached:!1,strength:0},i.width&&(i.el_W=i.width),i.height&&(i.el_H=i.height),i},$t=["Fx","Fy","appended","dragging","el","el_W","el_H","targetFrom","targetNodes","targetTo","lot","seeks_id","shouldRender","rgCalcedVisibility","rgShouldRender","rgChildrenSize","origin_x","origin_y","selected"],Pe=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!$t.includes(e)){const t=s[e];t!==void 0&&(e==="offset_x"&&t===0||e==="nodeShape"&&t===1||e==="offset_y"&&t===0||e==="zIndex"&&t===0||e==="width"&&!t||e==="height"&&!t||e==="fixed"&&t===!1||e==="className"&&t===""||e==="hidden"&&t===!1||e==="disableDrag"&&t===!1||e==="expanded"&&t===!0||e==="opacity"&&t===1||e==="type"&&t==="node"||e==="targetType"&&t===V.Node||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=t))}}),o},Ut={json2Node:Oe,transNodeToJson:Pe},qt=Object.freeze(Object.defineProperty({__proto__:null,newNodeTemplate:Ye,json2Node:Oe,transNodeToJson:Pe,default:Ut},Symbol.toStringTag,{value:"Module"})),Te=(s={})=>{const o={definitelyNoDataProviderNeeded:!1,instanceId:"",debug:!0,graphLoading:!1,graphLoadingText:"",showToolBar:!0,backgroundColor:"transparent",checkedItemBackgroundColor:void 0,selectionMode:!1,disableWheelEvent:!1,wheelEventAction:"zoom",dragEventAction:"move",fullscreenElementXPath:"",disableDragNode:!1,disableDragLine:!0,canvasMoveMode:!1,disableNodePointEvent:!1,disableLinePointEvent:!1,enableNodeXYAnimation:!1,enableCanvasTransformAnimation:!1,reLayoutWhenExpandedOrCollapsed:!1,defaultExpandHolderPosition:"hide",toolBarDirection:"h",toolBarPositionH:"left",toolBarPositionV:"bottom",defaultNodeColor:"#ffffff",defaultNodeBorderColor:"#666666",defaultNodeBorderWidth:1,defaultNodeBorderRadius:4,defaultNodeShape:be.rect,defaultNodeWidth:void 0,defaultNodeHeight:void 0,defaultLineColor:"#cccccc",defaultLineWidth:2,defaultLineShape:H.StandardStraight,defaultLineTextOffsetX:void 0,defaultLineTextOffsetY:void 0,defaultJunctionPoint:U.border,defaultLineJunctionOffset:3,defaultPolyLineRadius:5,placeOtherGroup:!0,defaultLineTextOnPath:!1,lineTextMaxLength:66,multiLineDistance:30,defaultLineMarker:{viewBox:"0 0 12 12",markerWidth:20,markerHeight:20,refX:3,refY:3,data:"M 0 0, V 6, L 4 3, Z"},viewSize:{width:300,height:300},canvasSize:{width:300,height:300},canvasOffset:{x:25,y:27},fullscreen:!1,checkedNodeId:"",checkedLineId:"",draggingNodeId:"",layout:{layoutName:"center"},canvasZoom:100,mouseWheelSpeed:10,minCanvasZoom:5,maxCanvasZoom:500,showEasyView:!1,performanceMode:!1,viewHeight:"100%",canvasOpacity:1,creatingSelection:!1,selectionView:{x:25,y:27,width:0,height:0},creatingNodePlot:!1,showTemplateNode:!0,newNodeTemplate:Oe(JSON.parse(JSON.stringify(Ye)),{}),creatingLinePlot:!1,newLineTemplate:{from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:""},newLinkTemplate:{fromNode:null,toNodeObject:null,toNode:{nothing:!0,x:400,y:400,el_W:30,el_H:30},totalLinesBetweenNodes:1,currentLineIndex:0,line:{}},data:{},editingLineController:{show:!1,line:null,startPoint:{x:0,y:0},endPoint:{x:0,y:0},text:{show:!0,x:0,y:0,width:10,height:10},ctrlPoints:[],selectedLines:[],line44Splits:[],line49Points:[],ctrlPoint1:{x:0,y:0},ctrlPoint2:{x:0,y:0},toolbar:{x:0,y:0}},editingController:{show:!1,nodes:[],x:0,y:0,width:100,height:100},nodeConnectController:{show:!1,node:void 0,x:0,y:0,width:100,height:100},showReferenceLine:!1,referenceLineAdsorption:!1,editingReferenceLine:{show:!1,directionV:!1,directionH:!1,v_x:0,v_y:0,v_height:0,h_x:0,h_y:0,h_width:0},showMiniView:!1,miniViewVisibleHandle:{x:0,y:0,width:100,height:100,emptyContent:!1},snapshotting:!1};o.newLineTemplate=ue(o.newLineTemplate,o);const e=Object.keys(o);return s&&Object.keys(s).forEach(t=>{const n=s[t];if(!e.includes(t)){w("RGOptions: unknow option key:",t);return}if(typeof n=="object"){w("RGOptions:user setting object:",t,n);const i=o[t];if(t==="layout")o[t]=JSON.parse(JSON.stringify(n));else if(i&&!Array.isArray(i)&&n)Object.keys(i).forEach(a=>{i[a]=n[a]});else if(Array.isArray(i)){const a=[];n.forEach(r=>{r&&typeof r=="object"?a.push(JSON.parse(JSON.stringify(r))):a.push(r)}),o[t]=a}else o[t]=n}else o[t]=n}),o},it=s=>{const o=s.layoutName||"";if(o==="center"){const e=s;e.layoutDirection=void 0}else if(o.includes("tree")){const e=s;e.from===void 0&&(e.from="left"),e.levelGaps===void 0&&(e.levelGaps=[]),(e.from==="top"||e.from==="bottom")&&(e.layoutDirection===void 0&&(e.layoutDirection="v"),w("set layoutDirection=v"),w("set defaultJunctionPoint=tb")),(e.from==="left"||e.from==="right")&&(e.layoutDirection===void 0&&(e.layoutDirection="h"),w("set defaultJunctionPoint=lr"))}else(o==="fixed"||o==="force")&&(s.layoutDirection=void 0)},Jt={createDefaultConfig:Te},Zt=Object.freeze(Object.defineProperty({__proto__:null,createDefaultConfig:Te,appendDefaultOptions4Layout:it,default:Jt},Symbol.toStringTag,{value:"Module"})),ye=I.createContext(null),ot=I.createContext(null),Ee=I.createContext(0),re=I.createContext({shouldRenderLines:[],shouldRenderNodes:[],shouldRenderFakeLines:[],options:Te({})});function W(){const s=I.useContext(ye);if(!s)throw new Error("'useGraphInstance' must be used within 'RGProvider'");return s}function se(){const s=I.useContext(Ee);if(s===void 0)throw new Error("'useAutoUpdateView' must be used within 'RGProvider'");return s}function J(){const s=I.useContext(re);if(s===void 0)throw new Error("'useGraphStore' must be used within 'RGProvider'");return s}function Qt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCreatingLine' must be used within 'RGProvider'");const o=W();return I.useMemo(()=>{if(!s.options||!s.options.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=o.generateCreatingLineConfig(s.options);return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}},[s.options.creatingLinePlot,s.options.newLinkTemplate,s.options.newLineTemplate])}function Kt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCreatingLine' must be used within 'RGProvider'");return I.useMemo(()=>!s.options||!s.options.creatingNodePlot?{creating:!1}:{creating:!0,nodeJson:s.options.newNodeTemplate},[s.options.creatingNodePlot,s.options.newNodeTemplate])}function en(){const s=I.useContext(re);if(s===void 0)throw new Error("'useEditingNodes' must be used within 'RGProvider'");return I.useMemo(()=>s.options.editingController,[s.options.editingController])}function tn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useEditingLine' must be used within 'RGProvider'");return I.useMemo(()=>s.options.editingLineController,[s.options.editingLineController])}function nn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useConnectingNode' must be used within 'RGProvider'");return I.useMemo(()=>s.options.nodeConnectController,[s.options.nodeConnectController])}function on(){const s=I.useContext(re);if(s===void 0)throw new Error("'useViewInformation' must be used within 'RGProvider'");return I.useMemo(()=>{const{viewSize:o,canvasSize:e,canvasOffset:t,canvasZoom:n,fullscreen:i,showEasyView:a}=s.options;return{viewSize:o,canvasSize:e,canvasOffset:t,canvasZoom:n,fullscreen:i,showEasyView:a}},[s.options.viewSize,s.options.canvasSize,s.options.canvasOffset,s.options.canvasZoom,s.options.fullscreen,s.options.showEasyView])}function sn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useSelection' must be used within 'RGProvider'");return I.useMemo(()=>({...s.options.selectionView,show:s.options.creatingSelection}),[s.options.selectionView,s.options.creatingSelection])}function an(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCheckedItem' must be used within 'RGProvider'");return I.useMemo(()=>({checkedLineId:s.options.checkedLineId,checkedNodeId:s.options.checkedNodeId,draggingNodeId:s.options.draggingNodeId}),[s.options.checkedLineId,s.options.checkedNodeId,s.options.draggingNodeId])}const st=({forElementLines:s})=>{const{options:o}=J();return x.jsxs("defs",{children:[x.jsx("marker",{id:`${o.instanceId}-arrow-default`,markerWidth:o.defaultLineMarker.markerWidth,markerHeight:o.defaultLineMarker.markerHeight,refX:o.defaultLineMarker.refX,refY:o.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto",viewBox:o.defaultLineMarker.viewBox,children:x.jsx("path",{style:{fill:"context-stroke"},d:o.defaultLineMarker.data})}),x.jsx("marker",{id:`${o.instanceId}-start-arrow-default`,markerWidth:o.defaultLineMarker.markerWidth,markerHeight:o.defaultLineMarker.markerHeight,refX:o.defaultLineMarker.refX,refY:o.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",viewBox:o.defaultLineMarker.viewBox,children:x.jsx("path",{style:{fill:"context-stroke"},d:o.defaultLineMarker.data})})]})},at=({children:s,lineConfig:o,checked:e})=>{const t=W();if(!t)return null;const n=t.getLineTextContainer(o==null?void 0:o.line);if(!n)return null;const i=o.line,a=i.selected;return Bt.createPortal(x.jsx("div",{className:["rg-line-peel",i.className,e&&"rg-line-checked",(i.disablePointEvent||i.opacity===0)&&"rg-line-disable-events",a&&"rg-line-selected"].filter(Boolean).join(" "),"data-id":i.id,style:{"--rg-line-color":i.color,"--rg-line-fontsize":o.line.fontSize?`${o.line.fontSize}px`:void 0,"--rg-line-opacity":i.opacity,"--rg-line-fontcolor":i.fontColor,...i.cssVars||{}},children:s}),n)},rt=({lineConfig:s,linePathInfo:o,useTextOnPath:e,checked:t,graphInstanceId:n,onLineClick:i,children:a})=>{const r=W(),l=s.line,c=l.selected,d=r.getArrowMarkerId(l,!0),h=r.getArrowMarkerId(l,!1),f=l.lineWidth?l.lineWidth+"px":void 0,p=e?r.generateLineTextStyle4TextOnPath(s):null,u=n+"-"+l.id;return x.jsxs("g",{className:["rg-line-peel",l.className,t&&"rg-line-checked",c&&"rg-line-selected",(l.disablePointEvent||l.opacity===0)&&"rg-line-disable-events"].filter(Boolean).join(" "),"data-id":l.id,style:{"--rg-line-width":f,"--rg-line-color":l.color,"--rg-line-opacity":l.opacity,"--rg-line-fontcolor":l.fontColor,"--rg-line-marker-end":h,"--rg-line-marker-start":d,...l.cssVars||{}},children:[x.jsx("path",{d:o.pathData,className:"rg-line-bg",onTouchStart:i,onClick:i}),x.jsx("path",{id:u,d:o.pathData,className:["rg-line",l.dashType?"rg-line-dashtype-"+l.dashType:void 0,l.animation?"rg-line-anm-"+l.animation:void 0].filter(Boolean).join(" ")}),p&&x.jsx("g",{children:x.jsx("text",{className:"rg-line-text rg-line-text-on-path",dx:p.textOffset.x+"px",dy:p.textOffset.y+"px",onTouchStart:i,onClick:i,children:x.jsx("textPath",{xlinkHref:`#${u}`,startOffset:p.onPathStartOffset,textAnchor:p.textAnchor,method:"align",spacing:"auto",children:p.text})})}),a]})},lt=({lineConfig:s,defaultLineTextOnPath:o,graphInstanceId:e,checked:t})=>{const n=W(),i=I.useMemo(()=>n.generateLinePath(s),[s]),a=h=>{n.onLineClick(s.line,h.nativeEvent)},r=s.line.useTextOnPath||o,l=r&&s.line.lineShape!==H.StandardStraight,c=!l,d=n.generateLineTextStyle(s,i);return x.jsxs(x.Fragment,{children:[x.jsx(rt,{lineConfig:s,linePathInfo:i,onLineClick:a,useTextOnPath:l,checked:t,graphInstanceId:e}),s.line.text&&c&&x.jsx(at,{lineConfig:s,linePathInfo:i,checked:t,children:x.jsx("div",{className:`rg-line-label ${r?"rg-line-label-on-path":""}`,style:{...d.cssStyles},onTouchStart:a,onClick:a,children:d.text})})]})},dt=({line:s,defaultLineTextOnPath:o,graphInstanceId:e,checked:t,lineSlot:n})=>{const i=W();se();const a=s.isFakeLine?i.generateFakeLineConfig(s):i.generateLineConfig(s);return x.jsx(x.Fragment,{children:a&&(n?n({lineConfig:a,defaultLineTextOnPath:o,graphInstanceId:e,checked:t}):x.jsx(lt,{lineConfig:a,defaultLineTextOnPath:o,graphInstanceId:e,checked:t}))})},ct=({showEasyView:s,lineSlot:o,defaultLineTextOnPath:e,checkedLineId:t,graphInstanceId:n,allLineConfigList:i})=>x.jsxs("div",{className:"rg-lines-container rg-lines-container-normal-lines",children:[x.jsxs("svg",{className:"rg-lines-svg",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx(st,{}),!s&&i.map(a=>a.hidden!==!0&&x.jsx(dt,{line:a,lineSlot:o,defaultLineTextOnPath:e,checked:a.id===t,graphInstanceId:n},a.id))]}),x.jsx("div",{className:"rg-linetext-container"})]});pe.default.memo(ct,(s,o)=>s.allLineConfigList!==o.allLineConfigList||s.graphInstanceId!==o.graphInstanceId||s.checkedLineId!==o.checkedLineId||s.lineSlot!==o.lineSlot?!1:s.defaultLineTextOnPath===o.defaultLineTextOnPath);const rn={"icon-quanping":{data:`
|
|
7
7
|
<path d="M921.6 358.4h-76.8V179.2h-179.2V102.4h256v256zM102.4 358.4h76.8V179.2h179.2V102.4H102.4v256z m0 307.2h76.8v179.2h179.2v76.8H102.4V665.6z m819.2 0h-76.8v179.2h-179.2v76.8h256V665.6z"></path>`},"icon-fangda":{data:`
|
|
8
8
|
<path d="M853.333333 480H544V170.666667c0-17.066667-14.933333-32-32-32s-32 14.933333-32 32v309.333333H170.666667c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h309.333333V853.333333c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V544H853.333333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z"></path>
|
|
9
9
|
`},"icon-suoxiao":{data:`
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
`},"icon-lianjiezhong":{data:`
|
|
40
40
|
<path d="M512 907c-24.852 0-45-20.148-45-45s20.148-45 45-45c168.446 0 305-136.554 305-305S680.446 207 512 207 207 343.554 207 512c0 24.852-20.148 45-45 45S117 536.852 117 512c0-218.152 176.848-395 395-395S907 293.848 907 512 730.152 907 512 907z"></path>
|
|
41
41
|
|
|
42
|
-
`}},ee=({iconName:s,className:o})=>{const e=an[s];return x.jsx("svg",{className:`rg-icon ${o||""}`,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",dangerouslySetInnerHTML:{__html:e.data}})},ht=({node:s,expandOrCollapseNode:o,expandHolderPosition:e})=>{const t=s.expanded===!1?"rg-node-expand-button c-expanded":"rg-node-expand-button c-collapsed";return x.jsx("div",{className:`rg-node-expand-holder c-expand-positon-${e}`,children:x.jsx("div",{className:t,onClickCapture:o,onTouchEnd:o,children:s.expanded===!1?x.jsx(ee,{iconName:"icon-fangda"}):x.jsx(ee,{iconName:"icon-suoxiao"})})})},ut=({nodeProps:s,nodeSlot:o,nodeExpandButtonSlot:e,defaultExpandHolderPosition:t,dragging:n,checked:i})=>{const a=W(),r=I.useRef();I.useEffect(()=>(a.addNodeResizeListener(r.current,s),()=>{r.current&&a.removeNodeResizeListener(r.current)}),[]);const l=async v=>{a.expandOrCollapseNode(s,v.nativeEvent)},c=v=>{v.type==="mousedown"&&v.button!==0||(v.stopPropagation(),a.onNodeDragStart(s,v.nativeEvent))},d=s.width?s.width+"px":void 0,h=s.height?s.height+"px":void 0,f=s.borderWidth===void 0?void 0:s.borderWidth+"px",p=s.borderColor,u=s.opacity,g=s.rgCalcedVisibility,m=s.expandHolderPosition||t||"hide",y=s.expandHolderPosition&&s.expandHolderPosition!=="hide"||t!=="hide"&&s.rgChildrenSize>0;return x.jsxs("div",{ref:r,style:{display:g?void 0:"none","--rg-node-z-index":s.zIndex?s.zIndex:void 0,pointerEvents:u===0?"none":void 0,transform:`translate(${s.x}px, ${s.y}px)`,"--rg-node-color":s.color,"--rg-node-font-color":s.fontColor,"--rg-node-font-size":s.fontSize?s.fontSize+"px":void 0,"--rg-node-border-width":f,"--rg-node-border-radius":s.borderRadius&&s.borderRadius+"px","--rg-node-border-color":p,"--rg-node-width":d,"--rg-node-height":h,"--rg-node-opacity":s.opacity===void 0?void 0:s.opacity},className:["rg-node-peel",s.selected&&"rg-node-selected",n&&"rg-node-dragging",i&&"rg-node-checked",`rg-node-shape-${s.nodeShape===void 0?1:s.nodeShape}`,`rg-node-type-${s.type}`,s.className,(s.disablePointEvent||s.opacity===0)&&"rg-node-disable-events"].filter(Boolean).join(" "),"data-id":s.id,children:[y&&(e?e({node:s,expandOrCollapseNode:l,expandHolderPosition:m}):x.jsx(ht,{node:s,expandOrCollapseNode:l,expandHolderPosition:m})),x.jsx("div",{className:"rg-node",onMouseDown:v=>{c(v)},onTouchStart:v=>{c(v)},children:o?o({node:s,defaultExpandHolderPosition:t,checked:i,dragging:n}):x.jsx("div",{className:"rg-node-text",children:x.jsx("span",{children:s.text})})})]})},ft=({nodeSlot:s,nodeExpandButtonSlot:o,defaultExpandHolderPosition:e,draggingNodeId:t,checkedNodeId:n,allNodeConfigList:i})=>x.jsx("div",{className:"rg-nodes-container",children:i.map(a=>x.jsx(ut,{nodeProps:a,nodeSlot:s,nodeExpandButtonSlot:o,defaultExpandHolderPosition:e,dragging:a.id===t,checked:a.id===n},a.id))});pe.default.memo(ft,(s,o)=>s.allNodeConfigList!==o.allNodeConfigList||s.draggingNodeId!==o.draggingNodeId||s.checkedNodeId!==o.checkedNodeId||s.nodeSlot!==o.nodeSlot||s.nodeExpandButtonSlot!==o.nodeExpandButtonSlot?!1:s.defaultExpandHolderPosition===o.defaultExpandHolderPosition);const rn=({showEasyView:s,lineSlot:o,defaultLineTextOnPath:e,checkedLineId:t,graphInstanceId:n})=>{const i=W(),{shouldRenderFakeLines:a}=J(),r=s?[]:i.getShouldRenderFakeLines(a);return x.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[x.jsx("div",{className:"rg-linetext-container"}),x.jsxs("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx(st,{forElementLines:!0}),!s&&r.map(l=>l.hidden!==!0&&x.jsx(dt,{line:l,lineSlot:o,defaultLineTextOnPath:e,checked:l.id===t,graphInstanceId:n},l.id))]})]})},ln=({lineSlot:s,defaultLineTextOnPath:o,graphInstanceId:e})=>{const t=W(),{options:n}=J(),i=t.generateCreatingLineConfig(n);return x.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[x.jsx("div",{className:"rg-linetext-container"}),x.jsx("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:s?s({lineConfig:i}):x.jsx(lt,{lineConfig:i,defaultLineTextOnPath:o,graphInstanceId:e})})]})},dn=({nodeSlot:s,lineSlot:o,nodeExpandButtonSlot:e,showEasyView:t,creatingLine:n,defaultExpandHolderPosition:i,draggingNodeId:a,checkedNodeId:r,checkedLineId:l,graphInstanceId:c,defaultLineTextOnPath:d})=>{const h=W(),{shouldRenderNodes:f,shouldRenderLines:p}=J(),u=I.useMemo(()=>t?[]:h.getShouldRenderNodes(f),[h,f,t]),g=I.useMemo(()=>t?[]:h.getShouldRenderLines(p),[h,p,t]);return x.jsxs("div",{className:"rg-single-graph",children:[x.jsx(ct,{graphInstanceId:c,showEasyView:t,defaultLineTextOnPath:d,checkedLineId:l,lineSlot:o,allLineConfigList:g}),x.jsx("div",{className:"rg-nodes-container-wrapper",children:!t&&x.jsx(ft,{defaultExpandHolderPosition:i,draggingNodeId:a,checkedNodeId:r,nodeSlot:s,nodeExpandButtonSlot:e,allNodeConfigList:u})}),x.jsx(rn,{graphInstanceId:c,showEasyView:t,defaultLineTextOnPath:d,checkedLineId:l,lineSlot:o}),n&&x.jsx(ln,{defaultLineTextOnPath:d,checkedLineId:l,lineSlot:o})]})},cn=s=>{const o=W(),{options:e}=J(),t=I.useRef();return I.useEffect(()=>(L("[RGEasyView mounted]"),o.setEasyViewCanvas(t.current),()=>{L("[RGEasyView UnMounted]")}),[]),x.jsx("div",{className:`rg-easy-view ${e.showEasyView?"rg-easy-view-active":""}`,children:x.jsx("canvas",{ref:t})})},hn=s=>{const o=W(),{options:e}=J();se();const t=I.useRef(),n=I.useRef(),i=I.useMemo(()=>e.canvasSize,[e.canvasSize]),a=I.useMemo(()=>e.canvasOffset,[e.canvasOffset]),r=I.useMemo(()=>e.canvasZoom/100,[e.canvasZoom]),l={width:`${i.width}px`,height:`${i.height}px`,backgroundColor:"transparent",transform:`translate(${a.x}px, ${a.y}px) scale(${r},${r})`};I.useEffect(()=>(L("[RGCanvas mounted]"),o.setCanvasDom(t.current),()=>{L("[RGCanvas UnMounted]")}),[]);const c=h=>{h.type==="mousedown"&&h.button!==0||o.onCanvasDragStart(h.nativeEvent)},d=h=>{h.preventDefault(),o.onContextmenu(h.nativeEvent)};return x.jsxs("div",{ref:n,className:["rg-map",e.canvasOpacity===1?"rg-map-ready":""].join(" "),onContextMenu:h=>{d(h)},onMouseDown:h=>{c(h)},onTouchStart:h=>{c(h)},children:[x.jsx(cn,{}),x.jsx("div",{style:l,className:"rg-map-canvas rg-canvas-behind",children:x.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-behind",children:s.canvasPlugSlot&&(typeof s.canvasPlugSlot=="function"?x.jsx(s.canvasPlugSlot,{}):s.canvasPlugSlot)})}),x.jsx("div",{ref:t,style:l,className:"rg-map-canvas",children:x.jsx(dn,{nodeSlot:s.nodeSlot,lineSlot:s.lineSlot,nodeExpandButtonSlot:s.nodeExpandButtonSlot,showEasyView:e.showEasyView,creatingLine:e.creatingLinePlot&&e.newLinkTemplate.fromNode,defaultExpandHolderPosition:e.defaultExpandHolderPosition,draggingNodeId:e.draggingNodeId,checkedNodeId:e.checkedNodeId,defaultLineTextOnPath:e.defaultLineTextOnPath,checkedLineId:e.checkedLineId,graphInstanceId:e.instanceId})}),x.jsx("div",{style:l,className:"rg-map-canvas rg-canvas-above",children:x.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-above",children:s.canvasPlugAboveSlot})})]})},un=()=>{const s=W(),o=(s==null?void 0:s.options.canvasMoveMode)||!1,e=t=>{s&&s.startMoveCanvas(t.nativeEvent,!0)};return x.jsx("div",{className:`rg-move-operator ${o?"rg-move-operator-active":""}`,children:x.jsx("div",{className:"rg-move-touchpad",onMouseDown:e,onTouchStart:e})})},fn=()=>{const s=W(),{options:o}=J(),e=t=>{s.clearLoading()};return x.jsx(x.Fragment,{children:o&&x.jsx("div",{className:`rg-graph-loading ${o.graphLoading?"":"rg-graph-loading-hide"}`,onClick:t=>{e()},children:x.jsxs("div",{className:"rg-graph-loading-message",children:[x.jsx(ee,{iconName:"icon-lianjiezhong",className:"rg-graph-loading-icon"}),o.graphLoadingText||"Loading..."]})})})},gn=({nodeSlot:s})=>{W();const{options:o}=J();return o&&x.jsxs("div",{className:"rg-operate",children:[x.jsxs("div",{className:"rg-creating-container",children:[o.creatingNodePlot&&o.showTemplateNode&&x.jsx(ut,{nodeProps:o.newNodeTemplate,nodeSlot:s}),o.creatingSelection&&x.jsx("div",{className:"rg-selection",style:{transform:`translate(${o.selectionView.x}px, ${o.selectionView.y}px)`,width:o.selectionView.width+"px",height:o.selectionView.height+"px"}})]}),x.jsx(un,{}),x.jsx(fn,{})]})},gt=({direction:s="",positionH:o="",positionV:e="",children:t})=>{const n=W();se();const{options:i}=J(),a=()=>{n==null||n.toggleAutoLayout()},r=async()=>{n&&(n.enableCanvasAnimation(),n.setZoom(100),n.moveToCenter(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300))},l=async d=>{await(n==null?void 0:n.zoom(d))},c=async()=>{await(n==null?void 0:n.fullscreen())};return I.useEffect(()=>{},[]),x.jsxs("div",{className:`rg-toolbar rg-xs-toolbar rg-toolbar-h-${o||i.toolBarPositionH||"left"} rg-toolbar-v-${e||i.toolBarPositionV||"bottom"} rg-toolbar-${s||i.toolBarDirection||"h"}`,children:[x.jsx("div",{title:"Full Screen",className:"rg-mb-button",style:{marginTop:0},onClick:c,children:x.jsx(ee,{iconName:"icon-quanping"})}),x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>l(20),children:x.jsx(ee,{iconName:"icon-fangda"})}),x.jsx("div",{className:"rg-current-zoom",onClick:r,children:`${Math.round(i.canvasZoom)}%`}),x.jsx("div",{className:"rg-mb-button",style:{marginTop:0},onClick:()=>l(-20),children:x.jsx(ee,{iconName:"icon-suoxiao"})})]}),i.layout.supportAutoLayout&&x.jsx("div",{title:i.layout.autoLayouting?"Stop Force Layout":"Start Force Layout",className:`rg-mb-button ${i.layout.autoLayouting?"rg-mb-button-on":""}`,onClick:a,children:i.layout.autoLayouting?x.jsx(ee,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):x.jsx(ee,{iconName:"icon-zidong"})}),t]})},pt=({children:s})=>x.jsx(x.Fragment,{}),We=({children:s})=>x.jsx(x.Fragment,{}),yt=({children:s})=>x.jsx(x.Fragment,{}),mt=({children:s})=>x.jsx(x.Fragment,{}),vt=s=>{const o=W();se();const e=I.useRef(),[t,n]=I.useState(!1);I.useEffect(()=>{L("<RelationGraph> Dom Mounted!"),o.setDom(e.current),n(!0);const v=w=>{o.onMouseWheel(w)};return e.current.addEventListener("wheel",v,{passive:!1}),()=>{var w;L("<RelationGraph> Dom UnMounted!"),(w=e.current)==null||w.removeEventListener("wheel",v),o.beforeUnmount()}},[]);const{options:i}=J();let a,r;const l=[],c=[],d=[],h=pe.default.Children.toArray(s.children).filter(v=>{if(v&&pe.default.isValidElement(v))if(v.type===Et){const w=v.props.children;if(typeof w=="function")a=w;else throw new Error("RGSlotOnNode children must be a function, e.g. <RGSlotOnNode>{ (node: RGNode) => <div>{node.text}</div> }</RGSlotOnNode>")}else if(v.type===pt){const w=v.props.children;if(typeof w=="function")r=w;else throw new Error("RGSlotOnLine children must be a function, e.g. <RGSlotOnLine>{ (lineConfig: RGGenerateLineConfig) => <RGLineContent lineConfig={lineConfig} /> }</RGSlotOnLine>")}else{if(v.type===We)return l.push(v.props.children),!1;if(v.type===yt)return c.push(v.props.children),!1;if(v.type===mt)return d.push(v.props.children),!1}return!0}),f=l,p=d,u=c.concat(...h);if(a&&s.nodeSlot)throw new Error("You can only provide nodeSlot or RGSlotOnNode, but not both.");if(r&&s.lineSlot)throw new Error("You can only provide lineSlot or RGSlotOnLine, but not both.");const g=a||s.nodeSlot,m=r||s.lineSlot,y=s.nodeExpandButtonSlot;return x.jsx("div",{ref:e,id:`relation-graph-ins-${i==null?void 0:i.instanceId}`,className:["relation-graph",(i==null?void 0:i.creatingLinePlot)&&"rg-creating-line",(i==null?void 0:i.dragEventAction)==="move"?"rg-move-mode":"",i!=null&&i.enableNodeXYAnimation?"rg-enable-node-xy-animation":"",(i==null?void 0:i.enableCanvasTransformAnimation)&&"rg-enable-canvas-animation"].filter(Boolean).join(" "),tabIndex:1,style:{width:"100%",height:i!=null&&i.viewHeight?i==null?void 0:i.viewHeight:"100%",opacity:t?1:0,"--rg-checked-item-bg-color":i==null?void 0:i.checkedItemBackgroundColor,"--rg-background-color":i==null?void 0:i.backgroundColor,"--rg-node-color":i==null?void 0:i.defaultNodeColor,"--rg-node-border-color":i==null?void 0:i.defaultNodeBorderColor,"--rg-node-border-width":(i==null?void 0:i.defaultNodeBorderWidth)+"px","--rg-node-border-radius":(i==null?void 0:i.defaultNodeBorderRadius)+"px","--rg-line-color":i==null?void 0:i.defaultLineColor,"--rg-line-width":(i==null?void 0:i.defaultLineWidth)+"px"},children:i&&x.jsxs(x.Fragment,{children:[i.showToolBar&&x.jsx(gt,{}),x.jsx(hn,{nodeSlot:g,lineSlot:m,canvasPlugSlot:u,canvasPlugAboveSlot:p,nodeExpandButtonSlot:y}),x.jsx(gn,{nodeSlot:g}),x.jsx("div",{className:"rg-graph-plugs",children:x.jsx("div",{className:"rg-view-slot",children:f})})]})})},xt=s=>{const o=W();return I.useEffect(()=>{nt("React"),o.setOptions(s.options);const e=Ge(s);L("[RelationGraph]mounted:listeners:",e),o.setListeners(e),o.ready(),o.dataUpdated(),s.initialData&&(L("[RelationGraph] apply data"),o.applyInitialData(s.initialData))},[]),x.jsx(vt,{...s})};class pn{constructor(o){_(this,"$evCanvasCtx");_(this,"viewScale",1);_(this,"offset",{x:0,y:0});const e=o.getContext("2d");if(!e)throw new Error("\u65E0\u6CD5\u83B7\u53D6 Canvas 2D \u4E0A\u4E0B\u6587");this.$evCanvasCtx=e}setSize(o,e){const t=this.$evCanvasCtx.canvas;t.width=o*window.devicePixelRatio,t.height=e*window.devicePixelRatio,t.style.width=`${o}px`,t.style.height=`${e}px`,this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.applyCurrentViewTransform()}setScale(o){this.viewScale=o,this.applyCurrentViewTransform()}applyCurrentViewTransform(){this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$evCanvasCtx.scale(this.viewScale,this.viewScale)}setViewOffset(o,e){this.offset.x=o/this.viewScale,this.offset.y=e/this.viewScale}beforeDraw(){}evDrawNode4Rect(o,e,t,n,i,a,r=5,l){const c=this.$evCanvasCtx,d=this.offset.x+o,h=this.offset.y+e;let f=Math.max(0,r);t<2*f&&(f=t/2),n<2*f&&(f=n/2),c.beginPath(),c.globalAlpha=a,f===0?c.rect(d,h,t,n):(c.moveTo(d+f,h),c.arcTo(d+t,h,d+t,h+f,f),c.arcTo(d+t,h+n,d+t-f,h+n,f),c.arcTo(d,h+n,d,h+n-f,f),c.arcTo(d,h,d+f,h,f),c.closePath()),c.fillStyle=i,c.fill(),c.globalAlpha=1,c.strokeStyle=l,c.lineWidth=1,c.stroke()}evDrawNode4Circle(o,e,t,n,i,a,r){const l=this.$evCanvasCtx,c=this.offset.x+o+t/2,d=this.offset.y+e+n/2;l.beginPath(),l.globalAlpha=a,l.ellipse(c,d,t/2,n/2,0,0,2*Math.PI),l.fillStyle=i,l.fill(),l.strokeStyle=r,l.lineWidth=1,l.stroke(),l.globalAlpha=1}evDrawLine(o,e,t,n){const i=this.$evCanvasCtx;i.beginPath(),i.globalAlpha=n,this.evDrawSvgPathOnCanvas(i,o),i.strokeStyle=t,i.lineWidth=e*this.viewScale<.5?.5:e,i.stroke(),i.globalAlpha=1}getPointValue(o,e,t){return t?o+parseFloat(e):parseFloat(e)}evDrawSvgPathOnCanvas(o,e){const t=e.match(/[a-zA-Z][^a-zA-Z]*/g);if(!t)return;let n=0,i=0,a=0,r=0,l=0,c=0,d=0,h=0,f="";o.beginPath(),t.forEach(p=>{const u=p.trim(),g=u.charAt(0),y=u.substring(1).trim().split(/[ ,]+/).filter(C=>C!=="").map(parseFloat);let v=0,w=0,N=0,O=0,b=0,T=0,P=0,S=0,k=0,R=0,M=0;switch(g){case"M":n=y[0],i=y[1],a=n,r=i,o.moveTo(n+this.offset.x,i+this.offset.y);for(let C=2;C<y.length;C+=2)n=y[C],i=y[C+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"L":for(let C=0;C<y.length;C+=2)n=y[C],i=y[C+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"l":for(let C=0;C<y.length;C+=2)n+=y[C],i+=y[C+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"H":for(let C=0;C<y.length;C++)n=y[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"h":for(let C=0;C<y.length;C++)n+=y[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"V":for(let C=0;C<y.length;C++)i=y[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"v":for(let C=0;C<y.length;C++)i+=y[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"C":for(let C=0;C<y.length;C+=6)N=y[C],O=y[C+1],b=y[C+2],T=y[C+3],v=y[C+4],w=y[C+5],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,w+this.offset.y),n=v,i=w,l=b,c=T;break;case"c":for(let C=0;C<y.length;C+=6)N=n+y[C],O=i+y[C+1],b=n+y[C+2],T=i+y[C+3],v=n+y[C+4],w=i+y[C+5],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,w+this.offset.y),l=b,c=T,n=v,i=w;break;case"S":for(let C=0;C<y.length;C+=4)f.match(/[CS]/i)?(N=2*n-l,O=2*i-c):(N=n,O=i),b=y[C],T=y[C+1],v=y[C+2],w=y[C+3],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,w+this.offset.y),n=v,i=w,l=b,c=T;break;case"s":for(let C=0;C<y.length;C+=4)f.match(/[CS]/i)?(N=2*n-l,O=2*i-c):(N=n,O=i),b=n+y[C],T=i+y[C+1],v=n+y[C+2],w=i+y[C+3],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,w+this.offset.y),l=b,c=T,n=v,i=w;break;case"Q":for(let C=0;C<y.length;C+=4)N=y[C],O=y[C+1],v=y[C+2],w=y[C+3],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,w+this.offset.y),n=v,i=w,d=N,h=O;break;case"q":for(let C=0;C<y.length;C+=4)N=n+y[C],O=i+y[C+1],v=n+y[C+2],w=i+y[C+3],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,w+this.offset.y),d=N,h=O,n=v,i=w;break;case"T":for(let C=0;C<y.length;C+=2)f.match(/[QT]/i)?(N=2*n-d,O=2*i-h):(N=n,O=i),v=y[C],w=y[C+1],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,w+this.offset.y),n=v,i=w,d=N,h=O;break;case"t":for(let C=0;C<y.length;C+=2)f.match(/[QT]/i)?(N=2*n-d,O=2*i-h):(N=n,O=i),v=n+y[C],w=i+y[C+1],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,w+this.offset.y),d=N,h=O,n=v,i=w;break;case"A":for(let C=0;C<y.length;C+=7)P=y[C],S=y[C+1],k=y[C+2],R=y[C+3],M=y[C+4],v=y[C+5],w=y[C+6],this.drawArc(o,n,i,P,S,k,R,M,v,w),n=v,i=w;break;case"a":for(let C=0;C<y.length;C+=7)P=y[C],S=y[C+1],k=y[C+2],R=y[C+3],M=y[C+4],v=n+y[C+5],w=i+y[C+6],this.drawArc(o,n,i,P,S,k,R,M,v,w),n=v,i=w;break;case"Z":case"z":o.closePath(),n=a,i=r;break;default:console.warn(`\u672A\u652F\u6301\u7684SVG\u547D\u4EE4\u5B57\u7B26: ${g}`)}g.match(/[CSQT]/i)?f=g:f=""})}drawArc(o,e,t,n,i,a,r,l,c,d){if(n=Math.abs(n),i=Math.abs(i),n===0||i===0){o.lineTo(c+this.offset.x,d+this.offset.y);return}const h=a%360*Math.PI/180,f=Math.sin(h),p=Math.cos(h),u=p*(e-c)/2+f*(t-d)/2,g=-f*(e-c)/2+p*(t-d)/2,m=u*u/(n*n)+g*g/(i*i);m>1&&(n*=Math.sqrt(m),i*=Math.sqrt(m));let y=(r===l?-1:1)*Math.sqrt(Math.max(0,(n*n*i*i-n*n*g*g-i*i*u*u)/(n*n*g*g+i*i*u*u)));isNaN(y)&&(y=0);const v=y*n*g/i,w=y*-i*u/n,N=p*v-f*w+(e+c)/2,O=f*v+p*w+(t+d)/2,b=(u-v)/n,T=(g-w)/i,P=(-u-v)/n,S=(-g-w)/i;let k=Math.atan2(T,b),R=Math.atan2(T*P-b*S,b*P+T*S);l===0&&R>0?R-=2*Math.PI:l===1&&R<0&&(R+=2*Math.PI);const M=k+R;o.ellipse?o.ellipse(N+this.offset.x,O+this.offset.y,n,i,h,k,M,l===0):(console.warn("ctx.ellipse is not supported. Arc will be drawn as a line."),o.lineTo(c+this.offset.x,d+this.offset.y))}}let me={x:0,y:0};const ve={x:0,y:0},le={x:0,y:0};let De,Ae;const Ve=s=>{const o={clientX:0,clientY:0};if(ce(s)){const e=s.touches||s.targetTouches;if(!e)throw new Error("error targetTouches");o.clientX=e[0].clientX,o.clientY=e[0].clientY}else o.clientX=s.clientX,o.clientY=s.clientY;return o},Z={startDrag(s,o,e,t){t?De=(n,i,a)=>{const r=n-le.x,l=i-le.y;t(r,l,ve,le,a)}:De=(n,i)=>{me.x=ve.x+(n-le.x),me.y=ve.y+(i-le.y)},Ae=e,me=o,ve.x=me.x,ve.y=me.y;try{const n=Ve(s);le.x=n.clientX,le.y=n.clientY,ce(s)?(document.body.addEventListener("touchmove",Z.onNodeMove),document.body.addEventListener("touchend",Z.onNodeDragend),document.body.addEventListener("mousemove",Z.onNodeMove),document.body.addEventListener("mouseup",Z.onNodeDragend),s.preventDefault()):(document.body.addEventListener("mousemove",Z.onNodeMove),document.body.addEventListener("mouseup",Z.onNodeDragend))}catch(n){console.error(n.message)}},onNodeMove(s){const o=Ve(s);De(o.clientX,o.clientY,s)},onNodeDragend(s){if(ce(s)?(document.body.removeEventListener("touchmove",Z.onNodeMove),document.body.removeEventListener("touchend",Z.onNodeDragend),document.body.removeEventListener("mousemove",Z.onNodeMove),document.body.removeEventListener("mouseup",Z.onNodeDragend)):(document.body.removeEventListener("mousemove",Z.onNodeMove),document.body.removeEventListener("mouseup",Z.onNodeDragend)),Ae){const o=Ve(s),e=o.clientX,t=o.clientY,n=e-le.x,i=t-le.y;Ae(n,i,s)}}};function yn(s,o,e,t,n,i,a,r,l){const c=n-s,d=i-o,h=Math.sqrt(c*c+d*d);if(h===0)return{x:s,y:o};const f=l*d/h,p=-(l*c)/h,u=s+f,g=o+p,m=s-e/2,y=s+e/2,v=o-t/2,w=o+t/2;let N=[];if(c!==0){let T=(m-u)/c,P=g+T*d;P>=v&&P<=w&&N.push({x:m,y:P});let S=(y-u)/c,k=g+S*d;k>=v&&k<=w&&N.push({x:y,y:k})}if(d!==0){let T=(v-g)/d,P=u+T*c;P>=m&&P<=y&&N.push({x:P,y:v});let S=(w-g)/d,k=u+S*c;k>=m&&k<=y&&N.push({x:k,y:w})}if(N.length===0&&c===0&&d===0)return{x:u,y:g};let O=null,b=1/0;return N.forEach(T=>{const P=Math.sqrt((T.x-n)**2+(T.y-i)**2);P<b&&(b=P,O=T)}),O}const q={getRectPoint(s,o,e,t,n,i,a,r,l=!1,c=1,d=0,h=14,f=!1){const p=s+n/2,u=o+i/2,g=e+a/2,m=t+r/2;if(c>1){const S=Math.min(h,n,i),k=-S/2,R=S/(c-1),M=l&&f||!l&&!f?k*-1-d*R:k+d*R,C=yn(p,u,n,i,g,m,a,r,M);if(C)return C}const y=p<g?1:-1,v=u<m?1:-1;if(m===u)return{x:p+y*n/2,y:u};const w=Math.abs((g-p)/(m-u)),N=n/i;let O=0,b=0;w<N?(O=y*i/2*w,b=v*i/2):(O=y*n/2,b=v*n/2/w);const T=p+O,P=u+b;return{x:T,y:P}},getRectPointBasic(s,o,e,t,n,i,a,r){const l=s+n/2,c=o+i/2,d=e+a/2,h=t+r/2;let f=h===c?0:(d-l)/(h-c);f===0&&h===c&&d===l?f=1:f===0&&(f=(d-l)/(h-c+(h>c?-1:1)*1e-4));const p=n/i;let u=0,g=0,m="1";return Math.abs(f)<p?(m="2",c<=h?(g=i/2,u=g*f):(g=-i/2,u=g*f)):(m="3",l<=d?(u=n/2,g=f===0&&d===l?0:u/f):(u=-n/2,g=f===0&&d===l?0:u/f)),{x:l+u,y:c+g,_case:m}},getRectJoinPoint(s){const{from_x:o,from_y:e,to_x:t,to_y:n,f_W:i,f_H:a,t_W:r,t_H:l}=s,c=o+i/2,d=e+a/2,h=t+r/2,f=n+l/2,p=h-c,u=f-d,g=p/(i/2),m=u/(a/2);return Math.abs(g)>Math.abs(m)?g>0?{x:o+i,y:d}:{x:o,y:d}:m>0?{x:c,y:e+a}:{x:c,y:e}},getRectHJoinPoint(s){const{from_x:o,from_y:e,to_x:t,f_W:n,f_H:i,t_W:a}=s,r=i/2;return o+n<t?{x:o+n,y:e+r}:{x:o,y:e+r}},getRectLeftJoinPoint(s){const{from_x:o,from_y:e,f_H:t}=s;return{x:o,y:e+t/2}},getRectRightJoinPoint(s){const{from_x:o,from_y:e,f_W:t,f_H:n}=s;return{x:o+t,y:e+n/2}},getRectTopJoinPoint(s){const{from_x:o,from_y:e,f_W:t}=s;return{x:o+t/2,y:e}},getRectBottomJoinPoint(s){const{from_x:o,from_y:e,f_W:t,f_H:n}=s;return{x:o+t/2,y:e+n}},getRectHorizontalLineJoinPoint(s){return this.getRectVJoinPoint(s)},getRectVerticalLineLineJoinPoint(s){return this.getRectHJoinPoint(s)},getRectVJoinPoint(s){const{from_x:o,from_y:e,to_y:t,f_W:n,f_H:i,t_H:a}=s,r=n/2;return e+i<t?{y:e+i,x:o+r}:{y:e,x:o+r}},getBorderPoint(s,o,e,t,n,i,a,r,l){return l===0?this.getCirclePoint(s,o,e,t,n,i,a,r):this.getRectPoint(s,o,e,t,n,i,a,r)},getBorderPoint4MultiLine(s){const{from_x:o,from_y:e,to_x:t,to_y:n,f_W:i,f_H:a,t_W:r,t_H:l,nodeShape:c,isReverse:d=!1,isEndPoint:h,totalLinesBetweenNodes:f=1,currentLineIndex:p=0,lineDistance:u=50}=s;return c===0?this.getCirclePoint4MultiLine(o,e,t,n,i,a,r,l,d,f,p,u,h):this.getRectPoint(o,e,t,n,i,a,r,l,d,f,p,u,h)},getCirclePoint(s,o,e,t,n,i,a,r){const l=e+a/2,c=t+r/2,d=s+n/2,h=o+i/2,f=l-d;if(f===0)return{x:d,y:h-i/2*(c<h?1:-1)};const u=(c-h)/f,g=Math.sqrt(1/(1/(n/2)**2+u**2/(i/2)**2))*(l<d?1:-1),m=u*g;return{x:d-g,y:h-m}},getCirclePoint4MultiLine(s,o,e,t,n,i,a,r,l,c,d,h,f){let p=e+a/2;const u=t+r/2;let g=s+n/2;const m=o+i/2;let y=p-g;y>-1&&y<1&&(p=p-.5,g=g+.5,y=-1);let w=0;if(c>1){const M=Math.min(h,n,i),C=-M/2,D=M/(c-1);w=l&&f||!l&&!f?C*-1-d*D:C+d*D}const N=u-m,O=Math.sqrt(y**2+N**2)*w/y,b=N/y,T=n/2,P=i/2,S=g<p?-1:1,k=(-1*T**2*b*O+T*P*Math.sqrt(Math.abs(P**2+b**2*T**2-O**2))/S)/(P**2+T**2*b**2),R=b*k+O;return{x:g-k,y:m-R}},getCirclePointBasic(s,o,e,t,n,i,a,r,l){const c=s+n/2,d=o+i/2,h=e+a/2,f=t+r/2,p=h-c,u=f-d,g=Math.sqrt(p*p+u*u),m=g-l,y=m*p/g*-1,v=m*u/g*-1;return{x:h+y,y:f+v}},getCirclePointPlus(s,o,e,t,n,i,a,r){const l=s+n/2,c=o+i/2,d=e+a/2,h=t+r/2,f=d-l,p=h-c,u=Math.sqrt(f*f+p*p),g=(u-n/2)*f/u*-1,m=(u-i/2)*p/u*-1;return{x:d+g,y:h+m}},getOvalPoint(s,o,e,t,n,i=180){const a=t*(360/n),r=(180-i+a)*Math.PI/180;return{x:s+e*Math.sin(r),y:o+e*Math.cos(r)*-1}},getRotatedPoint(s,o,e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=(s-e)*a-(o-t)*r+e,c=(s-e)*r+(o-t)*a+t;return{x:l,y:c}},getFlippedX(s,o){return o-(s-o)},getFlippedY(s,o){return o-(s-o)},getAngleType(s,o){if(s>=0&&o>=0)return 1;if(s<0&&o>=0)return 2;if(s<0&&o<0)return 3;if(s>=0&&o<0)return 4},getTextAngle(s,o,e,t){let n=Math.atan2(t-o,e-s)*180/Math.PI;return n<0&&(n+=360),n>90&&n<=270&&(n+=180),n>=360&&(n-=360),Math.round(n)}},ge=(s,o,e,t)=>{const n=s-e,i=o-t;return Math.sqrt(n**2+i**2)};function Je(s,o,e,t,n=0,i=0){let a=1,r=n,l=i,c=0;for(let d of e){const h=d.width,f=d.height;f>c&&(c=f),t(d,r,l),r+=h+o,a>s?(l+=c+o,a=1,r=0,c=0):a++}}class mn{constructor(o){_(this,"graphInstance");_(this,"initialized",!1);_(this,"isFolderLayout",!1);this.graphInstance=o}analyzeNetwork(o,e,t=!1,n=!1){this.initialized||(this.initialized=!0),o.forEach(u=>{u.lot||(u.lot={}),u.lot.eached=!1,u.lot.index_of_level=0,u.lot.index_of_p_childs=0,u.lot.index_of_parent=0,u.lot.strength=0,u.lot.strengthWithChilds_from=0,u.lot.strengthWithChilds=0,u.lot.childrenSizeVisible=0,u.lot.childrenSize=0,u.lot.childs=[],u.lot.subling=void 0,u.lot.parent=void 0}),e.lot.parent=void 0;const i=this.markNodeParent(e);L("groupNodes:marked-tree-node:",i.networkNodes.length);const a=[],r={direct:1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},l={direct:-1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},c=[e];this.expandLevelNodesWithDirection(a,c,0,t,n,r,l),this.calcStrengthWithChildsValue(a),this.calcStrengthFromValue(e,1),t&&this.calcStrengthFromValue(e,-1);const d=a.filter(u=>u.lot.level===1),h=d.length===0?1:d.map(u=>u.lot.strengthWithChilds).reduce((u,g)=>u+g,0);r.max_strength=h;const f=a.filter(u=>u.lot.level>=0);L("groupNodes:tree-nodes:",f.length,r);const p={tree:{networkNodes:f,analyticResult:r},reverseTree:{networkNodes:[],analyticResult:l}};if(t){const u=a.filter(y=>y.lot.level===-1),g=u.length===0?1:u.map(y=>y.lot.strengthWithChilds).reduce((y,v)=>y+v,0);l.max_strength=g;const m=a.filter(y=>y.lot.level<=0);L("groupNodes:reverse-tree-nodes:",m.length,l),p.reverseTree.networkNodes=m}for(const u of o)this.graphInstance.updateNode(u,{rgChildrenSize:u.lot.childrenSize});return p}markNodeParent(o){let e=[];return this._markNodeParent(e,[o],0),{networkNodes:e}}_markNodeParent(o,e,t){t===0&&e.forEach(i=>{i.lot.parent=void 0});const n=[];for(const i of e){o.includes(i)||o.push(i);for(const a of this.graphInstance.getNodeRelatedNodes(i))o.includes(a)||(o.push(a),a.lot.parent=i,n.push(a))}n.length>0&&this._markNodeParent(o,n,t+1)}expandLevelNodesWithDirection(o,e,t,n,i,a,r){const l=n&&t<0?r:a;L(`bothWay:${n}(deep:${i}) level ${t} size: ${e.length}`,l.direct),e.length>l.max_length&&(l.max_length=e.length),t>l.max_deep&&(l.max_deep=t),t<l.min_deep&&(l.min_deep=t),l.levels.has(t)||l.levels.set(t,{level:t,all_size:e.length,all_strength:0});const c=l.levels.get(t);e.forEach(u=>{u.lot.eached=!0,u.lot.subling=c,u.lot.level=t,o.push(u)});const d=[],h=[];let f=1,p=0;e.forEach(u=>{let g=[],m=[];n?i||t===0?(g=this.graphInstance.getNodeIncomingNodes(u),m=this.graphInstance.getNodeOutgoingNodes(u)):(t<0&&(f=-1),m=this.graphInstance.getNodeRelatedNodes(u)):m=this.graphInstance.getNodeRelatedNodes(u),this._appendNodeChildrenToNextLevelNodes(u,m,h,c,n,1),this._appendNodeChildrenToNextLevelNodes(u,g,d,c,n,-1),u.lot.index_of_level=p,p++}),c.all_strength>l.max_strength&&(l.max_strength=c.all_strength),h.length>0&&this.expandLevelNodesWithDirection(o,h,t+f,n,i,a,r),d.length>0&&this.expandLevelNodesWithDirection(o,d,t-1,n,i,a,r)}_appendNodeChildrenToNextLevelNodes(o,e,t,n,i,a){let r=0,l=0,c=0;if(e.forEach(d=>{d.lot||(d.lot={eached:!1,childs:[]}),d.lot.eached||(l++,d.lot.parent=o,z.isVisibleNode(d)&&(d.lot.eached=!0,d.lot.index_of_parent=c++,t.push(d),r++),o.lot.childs.push(d))}),a===1){const d=r>0?r:1;o.lot.strength=d,n.all_strength+=d,o.lot.strength_of_level=n.all_strength,o.lot.childrenSizeVisible=r,o.lot.childrenSize=l}}calcStrengthWithChildsValue(o){this.isFolderLayout?o.forEach(e=>{e.lot.strengthWithChilds=1,this.conductStrengthToParents(e)}):(o.forEach(e=>{e.lot.childrenSizeVisible>0&&(e.lot.strengthWithChilds=0)}),o.forEach(e=>{e.lot.childrenSizeVisible===0&&(e.lot.strengthWithChilds=1,this.conductStrengthToParents(e))}))}calcStrengthFromValue(o,e=1){this._calcStrengthFromValue([o],0,e===-1?-1:1)}_calcStrengthFromValue(o,e,t=1){const n=[];let i=0;o.forEach(a=>{if(a.lot.level===0||t===(a.lot.level<0?-1:1)){a.lot.childs.forEach(l=>{n.push(l)}),a.lot.parent&&i<a.lot.parent.lot.strengthWithChilds_from&&(i=a.lot.parent.lot.strengthWithChilds_from);const r=this.isFolderLayout?1:0;a.lot.strengthWithChilds_from=i+r,i+=a.lot.strengthWithChilds}}),n.length>0&&this._calcStrengthFromValue(n,e+(t<0?-1:1),t)}conductStrengthToParents(o){if(o.lot.parent){const e=Math.abs(o.lot.level)-1===Math.abs(o.lot.parent.lot.level);(this.isFolderLayout||e)&&(o.lot.parent.lot.strengthWithChilds+=1,this.conductStrengthToParents(o.lot.parent))}}}class ue{constructor(o,e,t){_(this,"graphOptions");_(this,"layoutOptions");_(this,"graphInstance");_(this,"networkAnalyzer");_(this,"allNodes",[]);_(this,"isMainLayouer",!0);_(this,"requireLinks",!1);_(this,"allLinks",[]);_(this,"rootNode");this.layoutOptions=o,this.graphOptions=e,this.graphInstance=t,this.networkAnalyzer=new mn(t)}setLinks(o){L("setLinks:",o.length),this.allLinks=o}generateCalcNodes(o){const e=[],t=new Map;for(const n of o){const i={rgNode:n,x:n.x,y:n.y,width:n.el_W,height:n.el_H};e.push(i),t.set(n.id,i)}return{calcNodes:e,calcNodeMap:t}}generateLevels(o){const e=[],t=new Map;for(const n of o){if(!n.lot||typeof n.lot.level!="number")continue;const i=n.lot.level;e.includes(i)||(e.push(i),t.set(i,[])),t.get(i).push(n)}return e.sort((n,i)=>n-i),{levels:e,levelNodesMap:t}}adjustNodePositions(o,e,t){if(!o||o.length===0)return[];for(let n=1;n<o.length;n++){const i=o[n],a=o[n-1];switch(e){case"right":i.x<a.x+a.width+t&&(i.x=a.x+a.width+t);break;case"left":i.x+i.width>a.x-t&&(i.x=a.x-i.width-t);break;case"bottom":i.y<a.y+a.height+t&&(i.y=a.y+a.height+t);break;case"top":i.y+i.height>a.y-t&&(i.y=a.y-i.height-t);break}}return o}getReverseAlignItems(o){return vn[o]}updateNodePosition(o,e,t){this.graphInstance.updateNode(typeof o=="string"?o:o.id,{x:e,y:t})}layoutEnd(){this.graphInstance&&(this.graphInstance.dataProvider.updateShouldRenderGraphData(),this.graphInstance._dataUpdated())}}const vn={start:"end",end:"start",center:"center"};class Te extends ue{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");_(this,"fastStart",!1);_(this,"skipInitLayout",!1);_(this,"maxLayoutTimes",300);_(this,"byNode",!0);_(this,"byLine",!0);_(this,"lockX",!1);_(this,"lockY",!1);_(this,"force_node_repulsion",1);_(this,"force_line_elastic",1);_(this,"disableLiveChanges",!1);_(this,"force_x_coefficient",1);_(this,"force_y_coefficient",1);_(this,"instanceId","");_(this,"calcNodes",[]);_(this,"_graphEventHandler");_(this,"layoutTimes",0);_(this,"prev10",[]);_(this,"visibleNodes",[]);_(this,"_onFinishCallback");_(this,"_onTickCallback");_(this,"calcNodeMap",new WeakMap);_(this,"forCalcNodes",[]);_(this,"recentGraphVelocity",[]);_(this,"graphVelocityBalancedValue",.1);_(this,"prevLogTime",0);_(this,"animationFrameTimer",0);_(this,"prevNodeLevel1Index",0);_(this,"prevNodeLevel2Index",0);_(this,"stoped",!1);_(this,"maxTractionLength",400);_(this,"zeroForceLength",40);_(this,"maxRepulsionDistance",600);_(this,"nodeCollisionRadius",40);_(this,"maxMoveSpeed",100);_(this,"n2nMaxForce",50);this.layoutOptions=e,this.updateOptions(e),this.requireLinks=!0,this.instanceId=n?n.generateNewUUID(5):"error-id"}updateOptions(e){e.fastStart!==void 0&&(this.fastStart=e.fastStart),e.maxLayoutTimes!==void 0&&(this.maxLayoutTimes=e.maxLayoutTimes),e.byNode!==void 0&&(this.byNode=e.byNode),e.byLine!==void 0&&(this.byLine=e.byLine),e.force_node_repulsion!==void 0&&(this.force_node_repulsion=e.force_node_repulsion),e.force_line_elastic!==void 0&&(this.force_line_elastic=e.force_line_elastic),e.force_x_coefficient!==void 0&&(this.force_x_coefficient=e.force_x_coefficient),e.force_y_coefficient!==void 0&&(this.force_y_coefficient=e.force_y_coefficient),e.disableLiveChanges!==void 0&&(this.disableLiveChanges=e.disableLiveChanges),e.skipInitLayout!==void 0&&(this.skipInitLayout=e.skipInitLayout),e.maxTractionLength!==void 0&&(this.maxTractionLength=e.maxTractionLength),e.zeroForceLength!==void 0&&(this.zeroForceLength=e.zeroForceLength),e.maxRepulsionDistance!==void 0&&(this.maxRepulsionDistance=e.maxRepulsionDistance),e.nodeCollisionRadius!==void 0&&(this.nodeCollisionRadius=e.nodeCollisionRadius)}placeNodes(e,t){if(L("RGForceLayout["+this.instanceId+"].placeNodes"),this.calcNodes=e,this.allNodes.length===0&&(this.allNodes=e),this.rootNode=t,this.fastStart)L("RGForceLayout["+this.instanceId+"] fastStart"),this.calcNodes.forEach(n=>{if(n.fixed===!0)return;let i=n.x,a=n.y,r=!1;(Number.isNaN(i)||i===void 0)&&(i=Math.floor(Math.random()*200)-100,r=!0),(Number.isNaN(a)||a===void 0)&&(a=Math.floor(Math.random()*200)-100,r=!0),i===0&&a===0&&(i=Math.floor(Math.random()*200)-100,a=Math.floor(Math.random()*200)-100,r=!0),r&&this.updateNodePosition(n,i,a)});else if(!this.skipInitLayout){if(L("!!!initNodesPosition....."),t){L("layout by root:",t),(Number.isNaN(t.x)||t.x===void 0)&&this.updateNodePosition(t,0,0);const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,t),{networkNodes:i,analyticResult:a}=n;t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const r=z.getNodeLotXY({alignItemsX:"center",alignItemsY:"center"},t);t.lot.x=r.x,t.lot.y=r.y,this.placeRelativePosition(t,i,a,1,[]),L("!!!initNodesPosition fixedRootNode:2:",t.x,t.y),i.forEach(l=>{if(l.fixed===!0||!l.rgCalcedVisibility||l===t)return;const c=l.lot.x-z.getNodeWidth(l)/2,d=l.lot.y-z.getNodeHeight(l)/2;this.updateNodePosition(l,c,d)})}}this.allNodes.forEach(n=>{let i=n.x,a=n.y,r=!1;(Number.isNaN(i)||i===void 0)&&(i=0,r=!0),(Number.isNaN(a)||a===void 0)&&(a=0,r=!0),r&&this.updateNodePosition(n,i,a)}),L("["+this.instanceId+"]Start Auto Layout....."),this.start()}getLevelR(e,t){if(e.length===0)return;let n=0;for(let i=0;i<t;i++)n+=e[i]||e[e.length-1];return n}placeRelativePosition(e,t,n,i,a){L("analyticResult:",this.layoutOptions,n,i,a);const r={x:e.lot.x,y:e.lot.y},l=t.filter(c=>c.lot.level===1);this.placeNodesInFanRegion(l,0,360,r,1,n.max_strength,a,1,i,0)}calculateMinimumRadius(e,t=0){if(e.length===0||e.length===1)return 0;const n=e.map(d=>{const h=d.width||d.el_W,f=d.height||d.el_H;return Math.sqrt(h*h+f*f)/2+t/2}),i=[];for(let d=0;d<n.length;d++){const h=(d+1)%n.length;i.push(n[d]+n[h])}let a=Math.max(...i)/2,r=i.reduce((d,h)=>d+h,0);const l=100;let c=r;for(let d=0;d<l;d++){const h=(a+r)/2;let f=0;for(const p of i){const u=p/(2*h);if(u>1){f=10;break}f+=2*Math.asin(u)}f>2*Math.PI?a=h:(r=h,c=h)}return c}placeNodesInFanRegion(e,t,n,i,a,r,l,c,d,h){var m,y;let f=t;const p=n-t,u=200;let g=this.getLevelR(l,a)||h+u*d;a===1&&d===1&&(!this.layoutOptions.levelGaps||this.layoutOptions.levelGaps.length===0)&&(g=this.calculateMinimumRadius(e,10),g=Math.min(Math.max(g,200),500));for(const v of e){const w=((m=v.lot)==null?void 0:m.strengthWithChilds)/r,N=i.x+g,O=i.y,b=w*p,T=f+b/2,P=q.getRotatedPoint(N,O,i.x,i.y,T);v.lot.x=P.x,v.lot.y=P.y,v.lot.childs&&v.lot.childs.length>0&&this.placeNodesInFanRegion(v.lot.childs,f,f+b,i,a+1,(y=v.lot)==null?void 0:y.strengthWithChilds,l,c+1,d,g),f+=b}}graphEventHandle(e,...t){if(e===A.onNodeDragStart){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!0)}else if(e===A.onNodeDragging){const n=t[0],i=t[1],a=t[2],r=this.calcNodeMap.get(n);console.log("[force]onNodeDragging:",n.id,r),r&&(r.x=i,r.y=a)}else if(e===A.onNodeDragEnd){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!1)}}connectToGraphInstance(){this._graphEventHandler=this.graphEventHandle.bind(this),this.graphInstance&&this.graphInstance.addEventHandler(this._graphEventHandler)}disConnectToGraphInstance(){this.graphInstance&&this.graphInstance.removeEventHandler(this._graphEventHandler)}updateVisibleNodes(e){this.visibleNodes=[],e&&(this.allNodes=e),this.allNodes.forEach(t=>{t.lot||(L("node miss lot:",t.text),t.lot={x:t.x,y:t.y,childs:[]}),this.visibleNodes.push(t)}),this.resetCalcNodes(),L("visibleNodes:",this.visibleNodes.length)}viewUpdate(){this._onTickCallback&&this._onTickCallback(),this.graphInstance&&this.graphInstance.forceLayoutTickCallback()}autoLayout(e=!1){if(this.updateVisibleNodes(),this.isMainLayouer){const t=this.graphInstance.dataProvider.getOptions();this.graphInstance.dataProvider.updateOptions({layout:{...t.layout,autoLayouting:!0}})}this.doForceLayout(0)}onFinish(e){this._onFinishCallback=e}onTick(e){this._onTickCallback=e}applyFBuffToNodes(){for(const e of this.forCalcNodes)this.applyToNodePosition(e)}applyPositionToNodes(){this.visibleNodes.forEach(e=>{if(e.fixed)return;const t=this.calcNodeMap.get(e);t&&(e.x=t.x,e.y=t.y)}),this.viewUpdate()}layoutFinished(){if(cancelAnimationFrame(this.animationFrameTimer),this.isMainLayouer){const e=this.graphInstance.dataProvider.getOptions();this.graphInstance.dataProvider.updateOptions({layout:{...e.layout,autoLayouting:!1}})}console.warn("Force Layout["+this.instanceId+"] finished on:",this.layoutTimes,"of",this.maxLayoutTimes),L("Force Layout["+this.instanceId+"] finished"),this.applyFBuffToNodes(),this.applyPositionToNodes(),this.disConnectToGraphInstance();try{this._onFinishCallback&&this._onFinishCallback()}catch(e){console.error(e)}}resetCalcNodes(){this.forCalcNodes=[],this.calcNodeMap=new WeakMap,this.visibleNodes.forEach(e=>{const t={rgNode:e,Fx:0,Fy:0,x:e.x,y:e.y,dragging:!1,force_weight:e.force_weight||1,forceCenterOffset_X:(e.width||e.el_W||60)/2,forceCenterOffset_Y:(e.height||e.el_H||60)/2,fixed:e.fixed||!1};this.forCalcNodes.push(t),this.calcNodeMap.set(e,t)}),this.allLinks=this.graphInstance.getLinksBetweenNodes(this.visibleNodes)}start(){this.stoped&&this.layoutTimes===0||(this.stoped=!1,this.layoutTimes=0,this.updateVisibleNodes(),this.connectToGraphInstance(),this.autoLayout(!0))}doForceLayout(e){if(this.graphInstance.viewComponentUnmounted){L("["+this.instanceId+"]stop layout:viewComponentUnmounted"),this.layoutFinished();return}let t="0";e>0?(this.prev10.length>=10&&(this.prev10.splice(0,1),t=(1e3/((this.prev10[this.prev10.length-1]-this.prev10[0])/10)).toFixed(1)),this.prev10.push(e)):this.visibleNodes.length===0&&this.updateVisibleNodes(),this.layoutTimes++,this.calcNodesPosition(),this.applyFBuffToNodes(),this.disableLiveChanges||this.layoutTimes%2===0&&this.applyPositionToNodes(),this.layoutTimes<=this.maxLayoutTimes?(Date.now()-this.prevLogTime>3e3&&(L("Force Layout["+this.instanceId+"] Is Working...layoutTimes:",this.layoutTimes,"of",this.maxLayoutTimes,t,"Hz",this.visibleNodes.length),this.prevLogTime=Date.now()),this.animationFrameTimer=requestAnimationFrame(this.doForceLayout.bind(this))):this.layoutFinished()}syncNodePosition(e,t,n){const i=this.allNodes.find(r=>r.id===e),a=this.calcNodeMap.get(i);a&&(a.x=t,a.y=n)}calcNodesPosition(){if(this.byNode)for(let e=this.prevNodeLevel1Index;e<this.forCalcNodes.length;e++){const t=this.forCalcNodes[e];if(!t.dragging&&!t.fixed){for(let n=this.prevNodeLevel2Index;n<this.forCalcNodes.length;n++)if(e!==n){const i=this.forCalcNodes[n];if(i.dragging)continue;this.addGravityByNode(t,i)}}}if(this.byLine){if(this.allLinks&&this.allLinks.length>0){for(const e of this.allLinks)if(!e.line.forDisplayOnly){let t=e.line.force_elastic===void 0?1:e.line.force_elastic;if(this.visibleNodes.includes(e.fromNode)&&this.visibleNodes.includes(e.toNode)){const n=this.calcNodeMap.get(e.fromNode),i=this.calcNodeMap.get(e.toNode);this.addElasticByLine(n,i,t)}}}else for(const e of this.visibleNodes)if(e.lot&&e.lot.parent){const t=this.calcNodeMap.get(e.lot.parent),n=this.calcNodeMap.get(e);this.addElasticByLine(t,n,1)}}return!0}stop(){if(this.stoped=!0,this.layoutTimes===0)return;const e=this.graphInstance.dataProvider.getOptions();cancelAnimationFrame(this.animationFrameTimer),L("[RGForceLayout]["+this.instanceId+"]stop:",e.layout.autoLayouting,this.layoutTimes),this.layoutTimes=Number.MAX_VALUE,this.layoutFinished()}addElasticByLine(e,t,n=1){const i=e.x,a=e.y,r=t.x,l=t.y;let c=Math.sqrt((a-l)**2+(i-r)**2);if(c<this.zeroForceLength)return;c>this.maxTractionLength&&(c=this.maxTractionLength);const d=(c-this.zeroForceLength)*.02*this.force_line_elastic*n,h=d,f=d,p=(i-r)/c,u=(a-l)/c;this.addFtoNode(e,p*h*-1,u*h*-1),this.addFtoNode(t,p*f,u*f)}addGravityByNode(e,t,n=1){const i=e.x,a=e.y,r=t.x,l=t.y;if(n===1&&(Math.abs(i-r)>this.maxRepulsionDistance||Math.abs(a-l)>this.maxRepulsionDistance))return;const c=Math.sqrt((a-l)**2+(i-r)**2);if(n===1&&c>this.maxRepulsionDistance)return;let d=(this.maxRepulsionDistance-c)*.02*this.force_node_repulsion*n;c<this.nodeCollisionRadius&&(d=d*2);const h=(i-r)/c,f=(a-l)/c;this.addFtoNode(e,h*d,f*d)}addFtoNode(e,t,n){if(e.fixed||e.dragging||Number.isNaN(t)||Number.isNaN(n))return;t>this.n2nMaxForce&&(t=this.n2nMaxForce),n>this.n2nMaxForce&&(n=this.n2nMaxForce),t<-this.n2nMaxForce&&(t=-this.n2nMaxForce),n<-this.n2nMaxForce&&(n=-this.n2nMaxForce);const i=e.force_weight||1;this.lockX||(e.Fx+=t*(1/i)),this.lockY||(e.Fy+=n*(1/i))}applyToNodePosition(e){if(e.fixed)return 0;if(e.dragging){const i=e.rgNode;return this.updateNodePosition(i,e.x,e.y),0}if(this.calcNodes!==this.allNodes&&!this.calcNodes.includes(e.rgNode))return 0;let t=e.Fx,n=e.Fy;if(t>this.maxMoveSpeed&&(t=this.maxMoveSpeed),n>this.maxMoveSpeed&&(n=this.maxMoveSpeed),t<-this.maxMoveSpeed&&(t=-this.maxMoveSpeed),n<-this.maxMoveSpeed&&(n=-this.maxMoveSpeed),e.x=e.x+t*this.force_x_coefficient,e.y=e.y+n*this.force_y_coefficient,!this.disableLiveChanges){const i=e.rgNode;this.updateNodePosition(i,e.x,e.y)}e.Fx=0,e.Fy=0}}class Ct extends ue{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,L("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="start"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const a=this.layoutOptions.layoutExpansionDirection,r=a==="start"||a==="left"||a==="top"?"start":a==="end"||a==="right"||a==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps or treeNodeGapH,treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes,this.layoutOptions.rotate||(this.layoutOptions.rotate=0)}placeNodes(e,t){if(console.log("tree:placeNodes:rootNode",t.id,t),L("RGTreeLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}L("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};this.rootNode=t,this.allNodes=e,t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=z.getNodeLotXY(n,t);t.lot.x=a.x,t.lot.y=a.y;const r=e;if(L("groupNodes:2:",r.length,r.map(d=>d.text).join(",")),this.layoutOptions.simpleTree===!0){const{tree:d}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!1);this.placeNodesPosition(this.rootNode,d.networkNodes,d.analyticResult)}else{const{tree:d,reverseTree:h}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!0);this.placeNodesPosition(this.rootNode,d.networkNodes,d.analyticResult),this.placeNodesPosition(this.rootNode,h.networkNodes,h.analyticResult)}const l=this.layoutOptions.rotate||0;console.log("rotate:",l);const c={x:t.x,y:t.y};this.allNodes.forEach(d=>{if(d.fixed!==!0&&!!z.isVisibleNode(d)&&(Number.isNaN(d.lot.x)&&(L("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(L("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==t)){if(l){const u=q.getRotatedPoint(d.lot.x,d.lot.y,c.x,c.y,l);d.lot.x=u.x,d.lot.y=u.y}const h=d.lot.level<0?i:n,f=z.getNodeXByLotX(h,d),p=z.getNodeYByLotY(h,d);this.updateNodePosition(d,f,p)}}),L("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t,n){this.placeRelativePosition(e,t,n)}placeRelativePosition(e,t,n){const i=this.layoutOptions.layoutExpansionDirection,{levels:a,levelNodesMap:r}=this.generateLevels(t),l=n.max_strength;if(this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"){const c=this.layoutOptions.treeNodeGapH||20,d=this.layoutOptions.treeNodeGapV||20,h=new Map;for(const m of a){const y=r.get(m);h.set(m,Math.max(...y.map(v=>v.el_H)))}let f=0,p=0;for(const m of t){const y=m.el_W;f+=y,p++}const g=f/p+c;t.forEach(m=>{m.fixed!==!0&&m!==e&&(this.layoutOptions.from==="bottom"?m.lot.y=e.lot.y-this.getLevelDistance(m.lot.level,h,d+10):m.lot.y=e.lot.y+this.getLevelDistance(m.lot.level,h,d+10))}),t.forEach(m=>{m.fixed!==!0&&m.lot.level!==0&&(i==="start"?m.lot.x=e.lot.x-g*m.lot.strengthWithChilds_from:i==="end"?m.lot.x=e.lot.x+g*m.lot.strengthWithChilds_from:m.lot.x=e.lot.x+g*(l/-2+m.lot.strengthWithChilds_from+m.lot.strengthWithChilds/2))}),this.applyNodesGap(t,"v"),this.gatherNodes(t,"v",g)}else{const c=this.layoutOptions.treeNodeGapH||20,d=this.layoutOptions.treeNodeGapV||20;console.log("levelNodesMap:",r);const h=new Map;for(const m of a){const y=r.get(m);h.set(m,Math.max(...y.map(v=>v.el_W||v.width)))}let f=0,p=0;for(const m of t){const y=m.el_H;f+=y,p++}if(p===0)return;const g=f/p+d;t.forEach(m=>{m.fixed!==!0&&m!==e&&(this.layoutOptions.from==="right"?m.lot.x=e.lot.x-this.getLevelDistance(m.lot.level,h,c+50):m.lot.x=e.lot.x+this.getLevelDistance(m.lot.level,h,c+50))}),t.forEach(m=>{m.fixed!==!0&&m.lot.level!==0&&(i==="start"?m.lot.y=e.lot.y-g*m.lot.strengthWithChilds_from:i==="end"?m.lot.y=e.lot.y+g*m.lot.strengthWithChilds_from:m.lot.y=e.lot.y+g*(l/-2+m.lot.strengthWithChilds_from+m.lot.strengthWithChilds/2))}),console.log("levelMaxWidthMap:",e.id,h),this.applyNodesGap(t,"h"),this.gatherNodes(t,"h",g)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return i}else{let i=0;for(let a=0;a>e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return-i}}getLevelGap(e,t,n,i){let a=t+(i===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(a=r)}return a}applyNodesGap(e,t){if(this.layoutOptions.ignoreNodeSize)return;const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},a=this.layoutOptions.layoutExpansionDirection,{levels:r,levelNodesMap:l}=this.generateLevels(e),c=new Map;for(const f of r){const p=l.get(f);c.set(f,Math.max(...p.map(u=>u.el_W)))}const{calcNodes:d,calcNodeMap:h}=this.generateCalcNodes(e);d.forEach(f=>{const p=f.rgNode.lot.level<0?i:n;f.x=z.getNodeXByLotX(p,f.rgNode),f.y=z.getNodeYByLotY(p,f.rgNode),f.width=f.rgNode.el_W,f.height=f.rgNode.el_H,f.buffY=0});for(const f of r){const p=l.get(f)||[];if(t==="h")if(a==="end"){p.sort((g,m)=>g.lot.y-m.lot.y);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"bottom",this.layoutOptions.treeNodeGapV);for(const g of u){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.y=z.getNodeLotXY(m,g).y}}else{p.sort((g,m)=>m.lot.y-g.lot.y);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"top",this.layoutOptions.treeNodeGapV);for(const g of u){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.y=z.getNodeLotXY(m,g).y}}else if(a==="end"){p.sort((g,m)=>g.lot.x-m.lot.x);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"right",this.layoutOptions.treeNodeGapH);for(const g of u){const m=g.rgNode.lot.level<0?i:n,y=z.getNodeLotXY(m,g);g.rgNode.lot.x=y.x}}else{p.sort((g,m)=>m.lot.x-g.lot.x);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"left",this.layoutOptions.treeNodeGapH);for(const g of u){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.x=z.getNodeLotXY(m,g).x}}console.log("levelNodes:",f,p)}if(t==="h"){const f=new Map,p=new Map;for(const w of r){const O=l.get(w).map(b=>h.get(b.id));f.set(w,Math.max(...O.map(b=>b.width))),p.set(w,Math.min(...O.map(b=>b.x)))}const u=this.layoutOptions.treeNodeGapH;let g=r.filter(w=>w>0).sort((w,N)=>w-N),m=r.filter(w=>w<0).sort((w,N)=>N-w),y=1;this.layoutOptions.from==="right"&&([m,g]=[g,m],y=-1);let v=0;for(const w of g){const N=w-y,O=p.get(N),b=f.get(N),T=p.get(w)+v;f.get(w);const P=O+b+u;if(P>T){const S=P-T;console.log("[xxxxx]move",N,w,P,T,S),v=S;const k=l.get(w);for(const R of k)R.lot.x+=v;p.set(w,T+S)}else p.set(w,T)}v=0;for(const w of m){const N=w+y,O=p.get(N);f.get(N);const b=p.get(w)+v,T=f.get(w),P=O-u;if(b+T>P){const S=P-(b+T);v=S;const k=l.get(w);for(const R of k)R.lot.x+=v;p.set(w,b+S)}else p.set(w,b)}}else{const f=new Map,p=new Map;for(const w of r){const O=l.get(w).map(b=>h.get(b.id));f.set(w,Math.max(...O.map(b=>b.height))),p.set(w,Math.min(...O.map(b=>b.y)))}const u=this.layoutOptions.treeNodeGapV;let g=r.filter(w=>w>0).sort((w,N)=>w-N),m=r.filter(w=>w<0).sort((w,N)=>N-w),y=1;this.layoutOptions.from==="bottom"&&([m,g]=[g,m],y=-1);let v=0;for(const w of g){const N=w-y,O=p.get(N),b=f.get(N),T=p.get(w)+v;f.get(w);const P=O+b+u;if(P>T){const S=P-T;console.log("[xxxxx]move",N,w,P,T,S),v=S;const k=l.get(w);for(const R of k)R.lot.y+=v;p.set(w,T+S)}else p.set(w,T)}v=0;for(const w of m){const N=w+y,O=p.get(N);f.get(N);const b=p.get(w)+v,T=f.get(w),P=O-u;if(b+T>P){const S=P-(b+T);v=S;const k=l.get(w);for(const R of k)R.lot.y+=v;p.set(w,b+S)}else p.set(w,b)}}}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const{calcNodes:i,calcNodeMap:a}=this.generateCalcNodes(e);i.forEach(l=>{l.movedNodeSizeBefore=1,l.movedNodeSizeAfter=1});const{levelNodesMap:r}=this.generateLevels(e);e.forEach(l=>{if(l.fixed!==!0&&l.lot.level!==0){const c=r.get(l.lot.level)||[];if(l.lot.strengthWithChilds===1&&l.lot.childrenSizeVisible<=1){const d=this.getBloomingNearByParent(l,l.lot.parent,c,t);if(d){const h=a.get(l.id);t==="h"?l.lot.y-d.lot.y>0?(l.lot.y=d.lot.y+n*h.movedNodeSizeAfter,h.movedNodeSizeAfter++):(l.lot.y=d.lot.y-n*h.movedNodeSizeBefore,h.movedNodeSizeBefore++):l.lot.x-d.lot.x>0?(l.lot.x=d.lot.x+n*h.movedNodeSizeAfter,h.movedNodeSizeAfter++):(l.lot.x=d.lot.x-n*h.movedNodeSizeBefore,h.movedNodeSizeBefore++)}}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const l of n)if(l.lot.childrenSizeVisible>1&&l.lot.parent===t){const c=i==="h"?l.lot.y-t.lot.y:l.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=l)}if(r&&r!==e)return r}}class Lt extends Te{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");this.layoutOptions=e,this.layoutOptions.distanceCoefficient||(this.layoutOptions.distanceCoefficient=1),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps option in layoutOptions")}placeNodes(e,t){if(L("RGCenterLayout:placeNodes"),!t){L("root is null:",t);return}L("layout by root:",t),this.allNodes=e,this.calcNodes=e,this.rootNode=t;const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode),{networkNodes:i,analyticResult:a}=n;if(this.layoutOptions.genLotInfoOnly){L("only gen lot info, return");return}t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const r={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},l=z.getNodeLotXY(r,t);t.lot.x=l.x,t.lot.y=l.y;const c=this.layoutOptions.rotate||0;L("root position:",t.lot.x,t.lot.y);const d=this.layoutOptions.distanceCoefficient||1,h=this.getLevelDistanceArr();this.placeRelativePosition(this.rootNode,i,a,d,h);const f={x:t.x,y:t.y};i.forEach(p=>{if(p.fixed!==!0&&!!p.rgCalcedVisibility&&p!==t){if(c){const y=q.getRotatedPoint(p.lot.x,p.lot.y,f.x,f.y,c);p.lot.x=y.x,p.lot.y=y.y}const u=r,g=z.getNodeXByLotX(u,p),m=z.getNodeYByLotY(u,p);this.updateNodePosition(p,g,m)}}),this.layoutEnd()}getLevelDistanceArr(){let e=[];if(this.layoutOptions.levelGaps){if(Array.isArray(this.layoutOptions.levelGaps))e=this.layoutOptions.levelGaps;else return console.error("Error levelDistance, levelDistance must is Array"),new Array(10).fill(200);if(e.length>0&&e.length<10)for(let t=e.length;t<10;t++)e.push(e[e.length-1])}return e}}class wt extends Te{constructor(o,e,t){super(o,e,t)}placeNodes(o,e){if(e)L("layout by root:",e);else{L("root is null:",e);return}this.allNodes=o,this.rootNode=e,e.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(e,0,0);const t={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},n=this.layoutOptions.rotate||0,i=z.getNodeLotXY(t,e);e.lot.x=i.x,e.lot.y=i.y;const a=this.allNodes.filter(c=>c.rgCalcedVisibility),r=a.length;let l=r*90/Math.PI/2;l<200&&(l=200),l>800&&(l=800),a.forEach((c,d)=>{const h=q.getOvalPoint(e.lot.x,e.lot.y,l,d,r);c.lot.x=h.x,c.lot.y=h.y,console.log("xxxxxxxxxxxxxx:",c.id,c.lot.x,c.lot.y)}),a.forEach(c=>{if(c===e||c.fixed===!0||!c.rgCalcedVisibility)return;if(n){const p=q.getRotatedPoint(c.lot.x,c.lot.y,e.lot.x,e.lot.y,n);c.lot.x=p.x,c.lot.y=p.y}const d=t,h=z.getNodeXByLotX(d,c),f=z.getNodeYByLotY(d,c);this.updateNodePosition(c,h,f)}),this.layoutEnd()}}class _t extends ue{constructor(e,t,n){super(e,t,n);_(this,"graphOptions");_(this,"layoutOptions");_(this,"allNodes",[]);this.layoutOptions=e,this.graphOptions=t}placeNodes(e,t){if(t)L("layout by root:",t);else{L("root is null:",t);return}L("allNodes:",e.length),this.networkAnalyzer.analyzeNetwork(e,t,!1,!1),L("[Fixed layout canvasOffset]",this.graphOptions.viewSize,this.graphOptions.canvasSize),this.layoutEnd()}}class xn extends ue{constructor(e,t,n){super(e,t,n);_(this,"graphInstance");_(this,"layoutOptions");_(this,"levelGaps",[]);this.layoutOptions=e,L("new RGSmartTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps&&(Array.isArray(this.layoutOptions.levelGaps)?this.levelGaps=this.layoutOptions.levelGaps:console.error("Error levelDistance, levelDistance must is Array"));const i=this.layoutOptions.from;i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=30),this.layoutOptions.treeNodeGapV<30&&(this.layoutOptions.treeNodeGapV=30)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=30),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.treeNodeGapH<30&&(this.layoutOptions.treeNodeGapH=30)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX,this.layoutOptions.alignItemsY),this.requireLinks=!0,this.graphInstance=n}placeNodes(e,t){if(L("RGSmartTreeLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,L("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},{tree:a,reverseTree:r}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode,!0,!0);t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const l=z.getNodeLotXY(n,t);t.lot.x=l.x,t.lot.y=l.y,this.placeRelativePosition(t,[...a.networkNodes].concat(r.networkNodes),Math.max(a.analyticResult.max_strength,r.analyticResult.max_strength)),L("allNodes:",e.length);const c={left:0,top:90,right:180,bottom:270}[this.layoutOptions.from],d={x:t.x,y:t.y};this.allNodes.forEach(p=>{if(p.fixed===!0||!p.rgCalcedVisibility)return;if(Number.isNaN(p.lot.x)&&(L("bad lot x:",p.text,p.lot.x),p.lot.x=0),Number.isNaN(p.lot.y)&&(L("bad lot y:",p.text,p.lot.y),p.lot.y=0),c){const y=q.getRotatedPoint(p.lot.x,p.lot.y,d.x,d.y,c);p.lot.x=y.x,p.lot.y=y.y}const u=p.lot.level<0?i:n,g=z.getNodeXByLotX(u,p),m=z.getNodeYByLotY(u,p);this.updateNodePosition(p,g,m)}),L("create rootNode coordinates:1",t.x,t.y);const h=new Te({layoutName:"force",maxLayoutTimes:30,force_node_repulsion:.1,force_line_elastic:1,fixedRootNode:!0,disableLiveChanges:!0},this.graphOptions,this.graphInstance);h.isMainLayouer=!1,h.requireLinks=!0,this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?h.lockY=!0:h.lockX=!0;const f=t.fixed;t.fixed=!0,h.skipInitLayout=!0,h.resetCalcNodes(),setTimeout(()=>{t.fixed=f},800),h.onFinish(()=>{t.fixed=f,this.graphInstance&&(this.graphInstance.enableNodeXYAnimation(),this.graphInstance._dataUpdated()),this.applyNodesGap(this.allNodes),this.graphInstance&&(this.graphInstance._dataUpdated(),setTimeout(()=>{this.graphInstance.disableNodeXYAnimation(),this.graphInstance._dataUpdated()},300))}),h.placeNodes(this.allNodes,t),this.layoutEnd()}placeRelativePosition(e,t,n){const i=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h";let a=this.layoutOptions.treeNodeGapH||300,r=this.layoutOptions.treeNodeGapV||10;i==="v"&&([a,r]=[r,a]);const{levels:l,levelNodesMap:c}=this.generateLevels(t),d=new Map;for(const g of l){const m=c.get(g);d.set(g,Math.max(...m.map(y=>y.el_W)))}let h=0,f=0;for(const g of t){const m=g.el_H;h+=m,f++}if(f===0)return;const u=h/f+r;t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.x=e.lot.x+this.getLevelDistance(g.lot.level,d,a))}),t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.level===0?g.lot.y=e.lot.y+u*g.lot.index_of_level:g.lot.y=e.lot.y+u*(n/-2+g.lot.strengthWithChilds_from+g.lot.strengthWithChilds/2))})}applyNodesGap(e){const t=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h",{levels:n,levelNodesMap:i}=this.generateLevels(e),a=new Map;for(const c of n){const d=i.get(c);a.set(c,Math.max(...d.map(h=>h.el_W)))}const{calcNodes:r,calcNodeMap:l}=this.generateCalcNodes(e);r.forEach(c=>{c.x=c.rgNode.x,c.y=c.rgNode.y,c.width=c.rgNode.el_W,c.height=c.rgNode.el_H,c.buffY=0});for(const c of n){const d=i.get(c)||[];if(t==="h"){const h=d.map(u=>l.get(u.id)),f=h.filter(u=>u.y<this.rootNode.y).sort((u,g)=>g.y-u.y),p=h.filter(u=>u.y>=this.rootNode.y).sort((u,g)=>u.y-g.y);this.adjustNodePositions(f,"top",5),this.adjustNodePositions(p,"bottom",5);for(const u of h)u.rgNode.y=u.y}else{const h=d.map(u=>l.get(u.id)),f=h.filter(u=>u.x<this.rootNode.x).sort((u,g)=>g.x-u.x),p=h.filter(u=>u.x>=this.rootNode.x).sort((u,g)=>u.x-g.x);this.adjustNodePositions(f,"left",5),this.adjustNodePositions(p,"right",5);for(const u of h)u.rgNode.x=u.x}console.log("levelNodes:",c,d)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=1;a<=e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r)}return i}else{let i=0;for(let a=-1;a>=e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r)}return-i}}getLevelGap(e,t,n){var a;let i=t+(e===-1?n/2:0);if(((a=this.layoutOptions.levelGaps)==null?void 0:a.length)>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(i=r)}return i}}class Nt extends ue{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,L("new RGFolderLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.bottomJunctionPointOffsetX===void 0&&(this.layoutOptions.bottomJunctionPointOffsetX=-50);const i=this.layoutOptions.from;i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps, treeNodeGapH, treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes}placeNodes(e,t){if(L("RGFolderLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,console.log("fixedRootNode:",this.layoutOptions.fixedRootNode);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=z.getNodeLotXY(n,t);t.lot.x=a.x,t.lot.y=a.y,L("allNodes:",e.length),this.networkAnalyzer.isFolderLayout=!0;const{tree:r}=this.networkAnalyzer.analyzeNetwork(e,t,!1,!1);this.placeRelativePosition(t,r.networkNodes,r.analyticResult),L("networkNodes:",r.networkNodes.length),this.allNodes.forEach(l=>{if(l.fixed!==!0&&(Number.isNaN(l.lot.x)&&(L("bad lot x:",l.text,l.lot.x),l.lot.x=0),Number.isNaN(l.lot.y)&&(L("bad lot y:",l.text,l.lot.y),l.lot.y=0),l!==t)){const c=l.lot.level<0?i:n,d=z.getNodeXByLotX(c,l),h=z.getNodeYByLotY(c,l);this.updateNodePosition(l,d,h)}}),L("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeRelativePosition(e,t,n){const i=this.layoutOptions.treeNodeGapH||20,a=this.layoutOptions.treeNodeGapV||20,r=new Map;let l=0,c=0;for(const f of t){const p=f.lot.level,u=f.el_W,g=f.el_H;l+=g,c++;const m=r.get(p);m===void 0?r.set(p,u):u>m&&r.set(p,m)}if(c===0)return;console.log("levelMaxWidthMap:",r);const h=l/c+a;t.forEach(f=>{f.fixed!==!0&&f!==e&&(this.layoutOptions.from==="right"?f.lot.x=e.lot.x-this.getLevelDistance(f.lot.level,r,i+50):f.lot.x=e.lot.x+this.getLevelDistance(f.lot.level,r,i+50))}),t.forEach(f=>{f.fixed!==!0&&f!==e&&f.lot.level!==0&&(f.lot.y=e.lot.y+h*f.lot.strengthWithChilds_from)}),this.gatherNodes(t,"h",h)}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const i={};e.forEach(a=>{if(a.lot.level!==0)return;const r=a.lot.level+"";i[r]||(i[r]=[]),i[r].push(a),a.lot.movedNodeSizeBefore=1,a.lot.movedNodeSizeAfter=1}),e.forEach(a=>{if(a.fixed!==!0&&a.lot.level!==0){const r=a.lot.level+"",l=i[r];if(a.lot.strengthWithChilds===1&&a.lot.childrenSizeVisible<=1){const c=this.getBloomingNearByParent(a,a.lot.parent,l,t);c&&(t==="h"?a.lot.y-c.lot.y>0?(a.lot.y=c.lot.y+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(a.lot.y=c.lot.y-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++):a.lot.x-c.lot.x>0?(a.lot.x=c.lot.x+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(a.lot.x=c.lot.x-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++))}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const l of n)if(l.lot.childrenSizeVisible>1&&l.lot.parent===t){const c=i==="h"?l.lot.y-t.lot.y:l.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=l)}if(r&&r!==e)return r}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++)i+=t.get(a)+this.getLevelGap(a,n);return i}else{let i=e<-1?0:-t.get(e)/2;for(let a=e;a<0;a++)i+=t.get(a)+this.getLevelGap(a,n)+50;return-i}}getLevelGap(e,t){var i;let n=t;if(((i=this.layoutOptions.levelGaps)==null?void 0:i.length)>0){const a=this.layoutOptions.levelGaps[Math.abs(e)];a&&(n=a)}return n}}const fe=s=>!s||s.length===0?"":s.map(o=>{switch(o.type){case"M":return`${o.type} ${o.x} ${o.y}`;case"l":return`${o.type} ${o.dx} ${o.dy}`;case"L":return`${o.type} ${o.x} ${o.y}`;case"h":return`${o.type} ${o.dx}`;case"v":return`${o.type} ${o.dy}`;case"c":return`${o.type} ${o.dx1} ${o.dy1} ${o.dx2} ${o.dy2} ${o.dx} ${o.dy}`;case"s":return`${o.type} ${o.dx2} ${o.dy2} ${o.dx} ${o.dy}`;case"q":return`${o.type} ${o.dx1} ${o.dy1} ${o.dx} ${o.dy}`;case"Q":return`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`;case"t":return`${o.type} ${o.dx} ${o.dy}`;case"a":return`${o.type} ${o.rx} ${o.ry} ${o.xAxisRotation} ${o.largeArcFlag} ${o.sweepFlag} ${o.dx} ${o.dy}`;case"Z":return o.type;default:return console.warn("\u672A\u77E5\u7684\u8DEF\u5F84\u547D\u4EE4\u7C7B\u578B:",o),""}}).join(" ").trim(),Ze=s=>{const o=s.match(/[a-zA-Z][^a-zA-Z]*/g);let e=0,t=0,n=0,i=0,a=0,r=0,l=0,c=0;const d={x:0,y:0},h={x:0,y:0},f=[];for(const p of o){const u=p.trim().split(/[ ,]+/),g=u[0].toUpperCase(),m=u[0]===u[0].toLowerCase();switch(g){case"M":e=j(n,u[1],m),t=j(i,u[2],m),n=e,i=t;break;case"L":e=j(n,u[1],m),t=j(i,u[2],m),f.push({x:e,y:t});break;case"C":a=j(n,u[1],m),r=j(i,u[2],m),l=j(n,u[3],m),c=j(i,u[4],m),e=j(n,u[5],m),t=j(i,u[6],m),n=e,i=t;break;case"Q":a=j(n,u[1],m),r=j(i,u[2],m),e=j(n,u[3],m),t=j(i,u[4],m),n=e,i=t;break;case"V":t=j(i,u[1],m),i=t;break;case"H":e=j(n,u[1],m),n=e;break;case"Z":break;default:console.log(`Unsupported command: ${g}`)}p===o[0]&&(d.x=e,d.y=t),p===o[o.length-1]&&(h.x=e,h.y=t)}return{startPoint:d,ctrl1:{x:a,y:r},ctrl2:{x:l,y:c},endPoint:h,lines:f}},j=(s,o,e)=>e?s+parseFloat(o):parseFloat(o),Cn=(s,o,e,t,n,i,a)=>{const r=JSON.parse(JSON.stringify(s));let l=!1;if(e<0||e>=s.length-1)return{newPoints:r,pointsChanged:l};r[e-1];const c=r[e],d=r[e+1];o[e-1];const h=o[e];o[e+1];let f=i,p=a;if(t.direction==="v"){const u=o[e-2],g=o[e+2],m=h.x+f;let y=3e3;if(u){const v=Math.abs(u.x-m);v<10&&v<y&&(y=v,f=u.x-h.x)}if(g){const v=Math.abs(g.x-m);v<10&&v<y&&(y=v,f=g.x-h.x)}}else{const u=o[e-2],g=o[e+2],m=h.y+p;let y=3e3;if(u){const v=Math.abs(u.y-m);v<10&&v<y&&(y=v,p=u.y-h.y)}if(g){const v=Math.abs(g.y-m);v<10&&v<y&&(y=v,p=g.y-h.y)}}if(t.direction==="v")if(e===0){const u=c.y<d.y?1:-1,g={x:c.x,y:c.y},m={x:c.x,y:c.y+20*u};c.x=m.x+f,c.y=m.y,r.splice(e,0,g,m),n.indexOffset+=2,l=!0}else if(e===s.length-2){const u=c.y<d.y?1:-1,g={x:h.x+f,y:d.y-20*u},m={x:d.x,y:d.y-20*u};r.splice(e+1,0,g,m),l=!0}else c.x=h.x+f,d.x=h.x+f;else if(e===0){const u=c.x<d.x?1:-1,g={x:c.x,y:c.y},m={x:c.x+20*u,y:c.y};c.x=m.x,c.y=h.y+p,r.splice(e,0,g,m),n.indexOffset+=2,l=!0}else if(e===s.length-2){const u=c.x<d.x?1:-1,g={x:d.x-20*u,y:h.y+p},m={x:d.x-20*u,y:d.y};r.splice(e+1,0,g,m),l=!0}else c.y=h.y+p,d.y=h.y+p;return{newPoints:r,pointsChanged:l}},Ln=(s,o={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:i}=s;o.rotate=q.getTextAngle(e,t,n,i),o.x=e+(n-e)/2,o.y=t+(i-t)/2,Number.isNaN(o.rotate)&&(o.rotate=0);const a=n-e,r=i-t,l=[{type:"M",x:e,y:t},{type:"l",dx:a,dy:r}],c=fe(l);return{pathCommands:l,pathData:c,textPosition:o,points:[]}},wn=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fx:n,fy:i,fcx:a,fcy:r,f_W:l,f_H:c,tx:d,ty:h,tcx:f,tcy:p,t_W:u,t_H:g}=s,m=d-n,y=h-i,v=n-a,w=i-r,N=d-f,O=h-p,b=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0;let T=Math.min(b,Math.abs(m))*(n<d?1:-1),P=Math.min(b,Math.abs(y))*(i<h?1:-1);const S=t.fromJunctionPoint||e.defaultJunctionPoint||U.border,k=t.toJunctionPoint||e.defaultJunctionPoint||U.border,R=t.lineDirection||(S===U.tb||S===U.top||S===U.bottom?"v":"h")||(Math.abs(v)>=l/2?"h":"v"),M=t.lineDirection||(k===U.tb||k===U.top||k===U.bottom?"v":"h")||(Math.abs(N)>=u/2?"h":"v"),C=[];let D=0,X=0;if(R==="v"){const B=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(h-i)/2),15),E=w>0?B:-B;if(t.placeText==="start"?(D=n,X=i+(w>0?20:-5)):t.placeText==="center"||t.placeText==="middle"?(D=n+(d-n)/2,X=i+E):(D=d,X=h-(w>0?20:-5)),C.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"v",dy:Math.round(E-P)},{type:"c",dx1:0,dy1:Math.round(P),dx2:Math.round(T),dy2:Math.round(P),dx:Math.round(T),dy:Math.round(P)}),M==="v")C.push({type:"h",dx:Math.round(d-n-T*2)},{type:"c",dx1:Math.round(T),dy1:0,dx2:Math.round(T),dy2:Math.round(P),dx:Math.round(T),dy:Math.round(P)},{type:"v",dy:Math.round(h-i-E-P)});else{const F=Math.min(30,Math.abs(d-n)/2),$=N>0?-F:F;C.push({type:"h",dx:Math.round(d-n+$-T)},{type:"c",dx1:Math.round(T),dy1:0,dx2:Math.round(T),dy2:Math.round(P),dx:Math.round(T),dy:Math.round(P)},{type:"v",dy:Math.round(h-i-E-P)},{type:"h",dx:Math.round($-T)})}}else{const B=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(d-n)/2),15),E=v>0?B:-B;if(t.placeText==="start"?(D=n+(v>0?10:-50),X=i):t.placeText==="center"||t.placeText==="middle"?(D=n+E,X=i+(h-i)/2):(D=d-(v>0?10:-50),X=h),T=Math.min(b,Math.abs(m))*(n>a?1:-1),P=Math.min(b,Math.abs(y))*(i<h?1:-1),C.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"h",dx:Math.round(E-T)},{type:"c",dx1:Math.round(T),dy1:0,dx2:Math.round(T),dy2:Math.round(P),dx:Math.round(T),dy:Math.round(P)}),M==="v"){T=Math.min(b,Math.abs(m))*(h<p?1:-1),P=Math.min(b,Math.abs(y))*(h<p?1:-1);const F=Math.min(30,Math.abs(h-i)/2),$=O>0?-F:F;C.push({type:"v",dy:Math.round(h-i+$-P)},{type:"h",dx:Math.round(d-n-E-T)},{type:"c",dx1:0,dy1:Math.round(P),dx2:Math.round(T),dy2:Math.round(P),dx:Math.round(T),dy:Math.round(P)},{type:"v",dy:Math.round($-P)})}else T=Math.min(b,Math.abs(m))*(n+E<d?1:-1),P=Math.min(b,Math.abs(y))*(h>i?1:-1),C.push({type:"v",dy:Math.round(h-i-P*2)},{type:"c",dx1:0,dy1:Math.round(P),dx2:Math.round(T),dy2:Math.round(P),dx:Math.round(T),dy:Math.round(P)},{type:"h",dx:Math.round(d-n-E-T)})}o.x=D,o.y=X;const G=fe(C);return{pathCommands:C,pathData:G,textPosition:o,points:[]}},Me={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},_n=({source:s,sourcePosition:o="bottom",target:e})=>o==="left"||o==="right"?s.x<e.x?{x:1,y:0}:{x:-1,y:0}:s.y<e.y?{x:0,y:1}:{x:0,y:-1},Qe=(s,o)=>Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));function ze({source:s,sourcePosition:o="bottom",target:e,targetPosition:t="top",center:n,sourceOffset:i,targetOffset:a}){const r=Me[o],l=Me[t],c={x:s.x+r.x*i,y:s.y+r.y*i},d={x:e.x+l.x*a,y:e.y+l.y*a},h=_n({source:c,sourcePosition:o,target:d}),f=h.x!==0?"x":"y",p=h[f];let u=[],g,m;const y={x:0,y:0},v={x:0,y:0};let w=0;if(r[f]*l[f]===-1){g=n.x,m=n.y;const O=[{x:g,y:c.y},{x:g,y:d.y}],b=[{x:c.x,y:m},{x:d.x,y:m}];r[f]===p?(w=1.1,u=f==="x"?O:b):(w=1.2,u=f==="x"?b:O)}else{const O=[{x:c.x,y:d.y}],b=[{x:d.x,y:c.y}];if(f==="x"?u=r.x===p?b:O:u=r.y===p?O:b,o===t){w=2.1;const R=Math.abs(s[f]-e[f]),M=r[f]===p?i:a;if(R<=M){const C=Math.min(M-1,M-R);r[f]===p?y[f]=(c[f]>s[f]?-1:1)*C:v[f]=(d[f]>e[f]?-1:1)*C}}if(o!==t){w=2.2;const R=f==="x"?"y":"x",M=r[f]===l[R],C=c[R]>d[R],D=c[R]<d[R];(r[f]===1&&(!M&&C||M&&D)||r[f]!==1&&(!M&&D||M&&C))&&(u=f==="x"?O:b)}const T={x:c.x+y.x,y:c.y+y.y},P={x:d.x+v.x,y:d.y+v.y},S=Math.max(Math.abs(T.x-u[0].x),Math.abs(P.x-u[0].x)),k=Math.max(Math.abs(T.y-u[0].y),Math.abs(P.y-u[0].y));S>=k?(g=(T.x+P.x)/2,m=u[0].y):(g=u[0].x,m=(T.y+P.y)/2)}return[[s,{x:c.x+y.x,y:c.y+y.y},...u,{x:d.x+v.x,y:d.y+v.y},e],g,m,0,0,w]}const ke=s=>{const o=[];for(let e=0;e<s.length;e++){const t=s[e];if(t.x=Math.round(t.x),t.y=Math.round(t.y),e===0||e===s.length-1)o.push(t);else{const n=o[o.length-1];t.x===n.x&&t.y===n.y||o.push(t)}}for(let e=2;e<o.length;e++){const t=o[e-2],n=o[e-1],i=o[e],a=t.x===n.x?"v":"h",r=n.x===i.x?"v":"h";a===r&&(n.merged=!0)}return o.filter(e=>e.merged!==!0)};function Nn(s,o,e,t){const n=Math.min(Qe(s,o)/2,Qe(o,e)/2,t),{x:i,y:a}=o;if(s.x===i&&i===e.x||s.y===a&&a===e.y)return[{type:"L",x:i,y:a}];if(s.y===a){const c=s.x<e.x?-1:1,d=s.y<e.y?1:-1;return[{type:"L",x:i+n*c,y:a},{type:"Q",x1:i,y1:a,x:i,y:a+n*d}]}const r=s.x<e.x?1:-1,l=s.y<e.y?-1:1;return[{type:"L",x:i,y:a+n*l},{type:"Q",x1:i,y1:a,x:i+n*r,y:a}]}const bt=(s,o)=>{const e=[];return s.forEach((t,n)=>{if(n===0)e.push({type:"M",x:Math.round(t.x),y:Math.round(t.y)});else if(n===s.length-1){const i=s[n-1];let a=i.x===t.x?0:i.x<t.x?-1:1,r=i.y===t.y?0:i.y<t.y?-1:1;s.length===2&&(a=0,r=0),e.push({type:"l",dx:Math.round(t.x-i.x+o*a),dy:Math.round(t.y-i.y+o*r)})}else{const i=Nn(s[n-1],t,s[n+1],o);e.push(...i)}}),e};var de=(s=>(s.border="border",s.ltrb="ltrb",s.tb="tb",s.lr="lr",s.left="left",s.right="right",s.top="top",s.bottom="bottom",s))(de||{});const Ie=(s,o,e,t,n,i,a,r)=>s==="left"?"left":s==="right"?"right":s==="top"?"top":s==="bottom"?"bottom":s==="horizontalLine"?t?i>r?"bottom":"top":i<r?"bottom":"top":s==="verticalLine"?t?n>a?"right":"left":n<a?"right":"left":o===1?"right":o===-1?"left":e===1?"bottom":e===-1?"top":"left",Ke=s=>s==="left"?"right":s==="right"?"left":s==="top"?"bottom":s==="bottom"?"top":"left",Ot=s=>{if(s.length<2)throw new Error("At least two points are required to form a polyline.");let o=0;const e=[];for(let i=1;i<s.length;i++){const a=s[i].x-s[i-1].x,r=s[i].y-s[i-1].y,l=Math.sqrt(a*a+r*r);e.push(l),o+=l}const t=o/2;let n=0;for(let i=0;i<e.length;i++)if(n+=e[i],n>=t){const a=s[i],r=s[i+1],l=e[i],d=(t-(n-l))/l,h=a.x+(r.x-a.x)*d,f=a.y+(r.y-a.y)*d;return{x:h,y:f}}return{x:0,y:0}},bn=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:l,fy:c,fcx:d,fcy:h,f_W:f,f_H:p,tx:u,ty:g,tcx:m,tcy:y,t_W:v,t_H:w}=s,N=l-d,O=c-h;let b=N>1?1:N<-1?-1:0,T=O>1?1:O<-1?-1:0;Math.abs(b)===1&&Math.abs(T)===1&&(Math.abs(N)>Math.abs(O)?T=0:b=0),b===0&&T===0&&(b=1);const P=u-m,S=g-y;let k=P>1?1:P<-1?-1:0,R=S>1?1:S<-1?-1:0;Math.abs(k)===1&&Math.abs(R)===1&&(Math.abs(P)>Math.abs(S)?R=0:k=0),k===0&&R===0&&(b=-1);const M=Ie(n,b,T,!1,l,c,u,g),C=Ie(i,k,R,!0,l,c,u,g),D=M,X=C,G=l+(u-l)/2,B=c+(g-c)/2;let E={x:0,y:0},F=20,$=20;t.ctrlOptionsFor44&&(E={x:t.ctrlOptionsFor44.cx,y:t.ctrlOptionsFor44.cy},F+=t.ctrlOptionsFor44.fd,$+=t.ctrlOptionsFor44.td);const te=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,[Q]=ze({source:{x:l,y:c},sourcePosition:D,target:{x:u,y:g},targetPosition:X,center:{x:G+E.x,y:B+E.y},sourceOffset:F,targetOffset:$}),oe=ke(Q),ie=bt(oe,te),ne=fe(ie),ae=Ot(Q);if(o.x=ae.x,o.y=ae.y,a==="v"){const K=O>1?1:O<-1?-1:0,Y=S>1?1:S<-1?-1:0;t.placeText==="start"?(o.x=l,o.y=c+K*10):t.placeText==="end"&&(o.x=u,o.y=g+Y*10)}else{const K=N>1?1:N<-1?-1:0,Y=P>1?1:P<-1?-1:0;t.placeText==="start"?(o.x=l+K*10,o.y=c):t.placeText==="end"&&(o.x=u+Y*10,o.y=g)}return{pathCommands:ie,pathData:ne,textPosition:o,points:oe,startDirection:D,endDirection:X}},On=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:l,fy:c,fcx:d,fcy:h,f_W:f,f_H:p,tx:u,ty:g,tcx:m,tcy:y,t_W:v,t_H:w}=s,N=l-d,O=c-h;let b=N>3?1:N<-3?-1:0,T=O>3?1:O<-3?-1:0;Math.abs(b)===1&&Math.abs(T)===1&&(Math.abs(N)>Math.abs(O)?T=0:b=0),b===0&&T===0&&(b=1);const P=u-m,S=g-y;let k=P>3?1:P<-3?-1:0,R=S>3?1:S<-3?-1:0;Math.abs(k)===1&&Math.abs(R)===1&&(Math.abs(P)>Math.abs(S)?R=0:k=0),k===0&&R===0&&(b=-1);let M=Ie(n,b,T,!1,l,c,u,g),C=Ie(i,k,R,!0,l,c,u,g);const D=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,X=t.ctrlPointsFor49;let G={x:Math.round(l),y:Math.round(c)},B={x:Math.round(u),y:Math.round(g)},E={x:Math.round(X[0].x),y:Math.round(X[0].y)},F={x:Math.round(X[X.length-1].x),y:Math.round(X[X.length-1].y)},$=[...X];if(t.isReverse&&([M,C]=[C,M]),Math.abs(G.x-E.x)>3||Math.abs(G.y-E.y)>3){const ne=G.x+(E.x-G.x)/2,ae=G.y+(E.y-G.y)/2,K=Ke(M),[Y]=ze({source:G,sourcePosition:M,target:E,targetPosition:K,center:{x:ne,y:ae},sourceOffset:20,targetOffset:5});$=ke([...Y,...$])}if(Math.abs(B.x-F.x)>3||Math.abs(B.y-F.y)>3){const ne=F.x+(B.x-F.x)/2,ae=F.y+(B.y-F.y)/2,K=Ke(C),[Y]=ze({source:F,sourcePosition:K,target:B,targetPosition:C,center:{x:ne,y:ae},sourceOffset:5,targetOffset:20});$=ke([...$,...Y])}const te=$,Q=bt(te,D),oe=fe(Q),ie=Ot(X);return o.x=ie.x,o.y=ie.y,{pathCommands:[],pathData:oe,textPosition:o,points:te,startDirection:M,endDirection:C}},Tn=(s,o={x:0,y:0,rotate:0})=>{const{line:e,lineShape:t,fx:n,fy:i,fcx:a,fcy:r,tx:l,ty:c,tcx:d,tcy:h}=s,f=l-n,p=c-i;let u=n-a,g=i-r,m=l-d,y=c-h,{fromJunctionPoint:v,toJunctionPoint:w}=e;e.isReverse&&([v,w]=[w,v]),(v===U.left||v===U.right)&&(g=0),(v===U.top||v===U.bottom)&&(u=0),(w===U.left||w===U.right)&&(y=0),(w===U.top||w===U.bottom)&&(m=0);const N=Math.min(200,Math.max(100,Math.abs(f/2))),O=Math.min(200,Math.max(100,Math.abs(p/2))),b=u/(Math.abs(u)+Math.abs(g))*N,T=g/(Math.abs(u)+Math.abs(g))*O;let P={x:b,y:T};const S=m/(Math.abs(m)+Math.abs(y))*N+f,k=y/(Math.abs(m)+Math.abs(y))*O+p;let R={x:S,y:k};e.ctrlPoints&&e.ctrlPoints.length>0&&(e.isReverse?(P.x+=e.ctrlPoints[1].x,P.y+=e.ctrlPoints[1].y,R.x+=e.ctrlPoints[0].x,R.y+=e.ctrlPoints[0].y):(P.x+=e.ctrlPoints[0].x,P.y+=e.ctrlPoints[0].y,R.x+=e.ctrlPoints[1].x,R.y+=e.ctrlPoints[1].y));const M={x:n+P.x,y:i+P.y},C={x:n+R.x,y:i+R.y},D={x:n+f,y:i+p},X=[{type:"M",x:n,y:i},{type:"c",dx1:P.x,dy1:P.y,dx2:R.x,dy2:R.y,dx:f,dy:p}];t===8&&X.push({type:"Z"});const G=Tt({x:n,y:i},M,C,D,t<6?.8:.5);o.x=G.x,o.y=G.y;const B=fe(X);return{pathCommands:X,pathData:B,textPosition:o,points:[]}},Tt=(s,o,e,t,n=.5)=>{const i={x:(1-n)*s.x+n*o.x,y:(1-n)*s.y+n*o.y},a={x:(1-n)*o.x+n*e.x,y:(1-n)*o.y+n*e.y},r={x:(1-n)*e.x+n*t.x,y:(1-n)*e.y+n*t.y},l={x:(1-n)*i.x+n*a.x,y:(1-n)*i.y+n*a.y},c={x:(1-n)*a.x+n*r.x,y:(1-n)*a.y+n*r.y};return{x:(1-n)*l.x+n*c.x,y:(1-n)*l.y+n*c.y}},Pn=(s,o={x:0,y:0,rotate:0})=>{const{line:e,totalLinesBetweenNodes:t,currentLineIndex:n,lineDirection:i,lineShape:a,fx:r,fy:l,fcx:c,fcy:d,f_W:h,f_H:f,tx:p,ty:u,tcx:g,tcy:m,t_W:y,t_H:v}=s,w=p-r,N=u-l,O=p>r?1:-1,b=u>l?1:-1,T=i==="v"?b:O,P=r-c,S=l-d,k=p-g,R=u-m,M=1/(t+1)*(n+1);let C={x:0,y:0},D={x:0,y:0};if(a===H.Curve2)C=i==="v"?{x:0,y:T*30}:{x:T*30,y:0},D=i==="v"?{x:w*M,y:T*-10}:{x:T*-10,y:N*M};else if(a===H.Curve3)C=i==="v"?{x:0,y:N*M}:{x:T*30,y:0},D=i==="v"?{x:0,y:0}:{x:T*-10,y:N*M};else if(a===H.Curve5)C={x:0,y:0},D=i==="v"?{x:0,y:N*M}:{x:w*M,y:0};else if(a===H.Curve7||a===H.Curve8){const oe=P/(Math.abs(P)+Math.abs(S))*30,ie=S/(Math.abs(P)+Math.abs(S))*30;C={x:oe,y:ie};const ne=k/(Math.abs(k)+Math.abs(R))*30+w,ae=R/(Math.abs(k)+Math.abs(R))*30+N;D={x:ne,y:ae}}const X={x:r+C.x,y:l+C.y},G={x:r+D.x,y:l+D.y},B={x:r+w,y:l+N},E=[{type:"M",x:r,y:l},{type:"c",dx1:C.x,dy1:C.y,dx2:D.x,dy2:D.y,dx:w,dy:N}];a===8&&E.push({type:"Z"});const F=Tt({x:r,y:l},X,G,B,a<6?.8:.5);o.x=F.x,o.y=F.y;const $=fe(E);return{pathCommands:E,pathData:$,textPosition:o,points:[]}};class Rn{constructor(){_(this,"graphData",{rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]});_(this,"options",{});_(this,"runtimeDATA4NodeMap",new Map);_(this,"runtimeDATA4Links",[]);_(this,"runtimeDATA4LinkMap",new Map);_(this,"runtimeDATA4ConnectTargets",[]);_(this,"runtimeDATA4ElLineTargets",[]);_(this,"runtimeDATA4ShouldRenderItems",{nodes:[],lines:[],fakeLines:[]})}}class Sn extends Rn{constructor(){super()}getOptions(){return this.options}getNodeById(o){return this.runtimeDATA4NodeMap.get(o)}getLineById(o){var e;return(e=this.runtimeDATA4LinkMap.get(o))==null?void 0:e.line}getLinkByLineId(o){return this.runtimeDATA4LinkMap.get(o)}getFakeLineById(o){return this.graphData.fakeLines.find(e=>e.id===o)}getNodes(){return this.graphData.nodes}getLinks(){return this.runtimeDATA4Links}getFakeLines(){return this.graphData.fakeLines}getLines(){return this.runtimeDATA4Links.map(o=>o.line)}getRootNode(){return this.graphData.rootNode}getShouldRenderNodes(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.nodes:this.graphData.nodes}getShouldRenderLines(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.lines:this.graphData.normalLines}getShouldRenderFakeLines(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.fakeLines:this.graphData.fakeLines}isPerformanceMode(){return this.options.performanceMode}getCanvasScale(){return this.options.canvasZoom/100}getConnectTargets(){return this.runtimeDATA4ConnectTargets}getConnectTargetById(o){if(!o)throw new Error("[getConnectTargetById]targetId is empty");for(let e=0;e<this.runtimeDATA4ConnectTargets.length;e++){const t=this.runtimeDATA4ConnectTargets[e];if(t.targetId===o)return t}}getElLineTargets(){return this.runtimeDATA4ElLineTargets}getElLineTargetById(o){return this.runtimeDATA4ElLineTargets.find(e=>e.id===o)}calcShouldRenderNodes(){const o=[];return this.graphData.nodes.forEach(e=>{e.rgShouldRender!==!1&&e.rgCalcedVisibility!==!1&&o.push(e)}),o}calcShouldRenderLines(){const o=[];return this.runtimeDATA4Links.forEach(e=>{e.rgShouldRender!==!1&&e.line.hidden!==!0&&e.rgCalcedVisibility!==!1&&o.push(e.line)}),o}calcShouldRenderFakeLines(){return this.graphData.fakeLines}findNodeByXy(o){const e=this.graphData.nodes;for(let t=e.length-1;t>=0;t--){const n=e[t],i=n.x,a=n.y,r=n.el_W||n.width||50,l=n.el_H||n.height||50;if(o.x>i&&o.x<i+r&&o.y>a&&o.y<a+l)return n}return null}}class Mn{constructor(){_(this,"map");this.map=new Map}_key(o,e){return o<=e?`${o}${e}`:`${e}${o}`}addEdge(o,e){const t=this._key(o,e),n=this.map.get(t)||0;return this.map.set(t,n+1),n}getCount(o,e){const t=this._key(o,e);return this.map.get(t)||0}clear(){this.map.clear()}}class Pe extends Sn{constructor(){super();_(this,"commits");_(this,"updateViewHook",e=>{});this.options=Oe({}),this.commits=this.resetCommints()}clearReactiveData(){this.graphData.nodes=[],this.graphData.normalLines=[],this.graphData.fakeLines=[],this.runtimeDATA4Links.splice(0,this.runtimeDATA4Links.length),this.runtimeDATA4ElLineTargets.splice(0,this.runtimeDATA4ElLineTargets.length),this.runtimeDATA4NodeMap.clear(),this.runtimeDATA4LinkMap.clear(),this.graphData.rootNode=void 0,this.updateShouldRenderGraphData(),this.commits.optionsChanged=!0,this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0,this.commits.fakeLinesListChanged=!0}resetCommints(){return{optionsChanged:!1,changedNodes:[],nodesListChanged:!1,changedLines:[],linesListChanged:!1,changedFakeLines:[],fakeLinesListChanged:!1,changedConnectTargets:[],connectTargetsListChanged:!1}}commitLine(e){this.commits.linesListChanged=!0}commitNode(e){this.commits.changedNodes.includes(e)||this.commits.changedNodes.push(e),this.commits.linesListChanged=!0,this.commits.fakeLinesListChanged=!0}commitFakeLine(e){this.commits.fakeLinesListChanged=!0}commitConnectTarget(e){this.commits.changedConnectTargets.includes(e)||this.commits.changedConnectTargets.push(e),this.commits.fakeLinesListChanged=!0}dataUpdated(){const e=this.commits;this.commits=this.resetCommints(),this.updateViewHook(e)}updateOptions(e){var t;if(e.layout&&console.log("RGDataProvider:updateOptions:layout:",(t=e.layout)==null?void 0:t.layoutName,e.layout),Object.assign(this.options,e),this.isPerformanceMode()&&!this.options.showEasyView){const n=Object.keys(e);console.log("changedKeys:",n.join(",")),n.includes("canvasZoom")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0),n.includes("viewSize")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0),n.includes("canvasOffset")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0)}this.commits.optionsChanged=!0}clearChecked(){this.updateOptions({checkedNodeId:"",checkedLineId:""})}setCanvasOffset(e,t){this.updateOptions({canvasOffset:{x:e,y:t}}),this.commits.optionsChanged=!0}setCanvasZoom(e){this.updateOptions({canvasZoom:e})}setEditingLine(e){if(e){const t=this.getLineById(e.id)||this.getFakeLineById(e.id);t&&this.updateOptions({editingLineController:{...this.options.editingLineController,line:t,show:!0},checkedLineId:e.id})}else this.updateOptions({editingLineController:{...this.options.editingLineController,line:null,show:!1},checkedLineId:""})}setEditingNodes(e){for(const n of e)if(!n||!this.getNodeById(n.id)){console.error("setEditingNodes Error: node not found:",n);return}this.getNodes().filter(n=>n.selected).forEach(n=>this.updateNode(n.id,{selected:!1})),this.updateOptions({editingController:{...this.options.editingController,nodes:e,show:e.length>0}}),e.length>1&&this.options.editingController.nodes.forEach(n=>this.updateNode(n.id,{selected:!0}))}setCanvasCenter(e,t){const n=this.options.viewSize.width/2,i=this.options.viewSize.height/2,a=this.options.canvasZoom/100;this.setCanvasOffset(n-e*a,i-t*a)}removeNodeById(e){this.beforeNodeBeRemove(e),L("Removed Node line/connect-arget\uFF1A",e);let t=0;for(let n=0;n<this.graphData.nodes.length;n++)e.includes(this.graphData.nodes[n].id)&&(this.graphData.nodes.splice(n,1),n--,t++);for(const n of e)this.runtimeDATA4NodeMap.delete(n);L("Removed node\uFF1A",e,t),this.commits.nodesListChanged=!0}removeLineByIds(e){L("_removeLineByIds:",e.length,e),this.removeFakeLineByIds(e);let t=0;for(let n=0;n<this.graphData.normalLines.length;n++){const i=this.graphData.normalLines[n];e.includes(i.id)&&(this.graphData.normalLines.splice(n,1),n--,t++)}L("_removeLineByIds:",t),this.removeLinkByLineIds(e),this.updateLinks(),this.commits.linesListChanged=!0}removeFakeLineByIds(e){L("_removeFakeLineByIds:",e.length,e);let t=0;for(let n=0;n<this.graphData.fakeLines.length;n++){const i=this.graphData.fakeLines[n];e.includes(i.id)&&(this.graphData.fakeLines.splice(n,1),n--,t++)}this.commits.fakeLinesListChanged=!0,L("_removeFakeLineByIds:",t)}removeLinkByLineIds(e){L("_removeLinkByLineIds:",e.length,e);let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const i=this.runtimeDATA4Links[n];e.includes(i.lineId)&&(this.runtimeDATA4Links.splice(n,1),this.runtimeDATA4LinkMap.delete(i.lineId),n--,t++)}this.commits.fakeLinesListChanged=!0,L("_removeLinkByLineIds:",t)}removeConnectTarget(e){const t=this.runtimeDATA4ConnectTargets.findIndex(n=>n.targetId===e);if(t!==-1){const n=this.runtimeDATA4ConnectTargets[t];(n.targetType===V.NodePoint||n.targetType===V.CanvasPoint)&&this.runtimeDATA4ConnectTargets.splice(t,1)}this.commits.connectTargetsListChanged=!0}updateLinks(e=[]){const t=new Mn;for(const n of this.runtimeDATA4Links){const{from:i,to:a}=n.line,r=t.addEdge(i,a);r!==n.currentLineIndex&&(n.currentLineIndex=r,this.commitLine(n.lineId))}for(const n of this.runtimeDATA4Links){const{from:i,to:a}=n.line,r=t.getCount(i,a);r!==n.totalLinesBetweenNodes&&(n.totalLinesBetweenNodes=r,this.commitLine(n.lineId))}t.clear()}beforeNodeBeRemove(e){let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const i=this.runtimeDATA4Links[n];(e.includes(i.fromNode.id)||e.includes(i.toNode.id))&&(this.removeLinkByLineIds([i.lineId]),n--,t++)}L("Removed Node link\uFF1A",e,t);for(let n=0;n<this.graphData.fakeLines.length;n++){const i=this.graphData.fakeLines[n];let a=!1;if(i.fromType===V.Node&&e.includes(i.from))a=!0;else if(i.fromType===V.CanvasPoint||i.fromType===V.NodePoint){const r=this.getConnectTargetById(i.from);r&&r.nodeId&&e.includes(r.nodeId)&&(a=!0)}else if(i.toType===V.CanvasPoint||i.toType===V.NodePoint){const r=this.getConnectTargetById(i.to);r&&r.nodeId&&e.includes(r.nodeId)&&(a=!0)}a&&(this.graphData.fakeLines.splice(n,1),n--,this.commits.fakeLinesListChanged=!0)}for(let n=0;n<this.runtimeDATA4ConnectTargets.length;n++){const i=this.runtimeDATA4ConnectTargets[n];i.nodeId&&e.includes(i.nodeId)&&(this.runtimeDATA4ConnectTargets.splice(n,1),this.commitConnectTarget(i.targetId),n--)}}addFakeLines(e){for(const t of e)if(t.id||console.warn("[relation-graph]Must have id for fake line:",t),this.graphData.fakeLines.some(n=>n.id===t.id))console.log("[relation-graph]Ignore duplicate fake line id:",t.id);else{t.isFakeLine=!0;const n=he(t,this.options);n.id||(n.id=Be(6)),this.graphData.fakeLines.push(n)}this.commits.fakeLinesListChanged=!0}clearFakeLines(){this.graphData.fakeLines.splice(0,this.graphData.fakeLines.length),this.commits.fakeLinesListChanged=!0}addNodes(e){for(const t of e)this.runtimeDATA4NodeMap.set(t.id,t);this.graphData.nodes.push(...e.map(t=>this.runtimeDATA4NodeMap.get(t.id))),this.commits.nodesListChanged=!0}addLines(e){this.graphData.normalLines.push(...e);const t=[];for(const n of e){const i=this.getNodeById(n.from),a=this.getNodeById(n.to),r={lineId:n.id,line:n,fromNode:i,toNode:a,currentLineIndex:0,totalLinesBetweenNodes:1,rgShouldRender:!0,rgCalcedVisibility:!0};this.runtimeDATA4LinkMap.set(r.lineId,r),t.push(r)}this.runtimeDATA4Links.push(...t.map(n=>this.runtimeDATA4LinkMap.get(n.lineId))),this.updateLinks(),this.commits.linesListChanged=!0}updateNode(e,t){const n=this.getNodeById(e);if(!n){console.error("Cannot find node to update:",e,t);return}const i=t.hidden!==void 0&&n.hidden!==t.hidden;if(Object.assign(n,t,{id:e}),i){const a=z.getDescendantNodes(n);this.updateNodesVisibleProperty([n].concat(a))}this.commitNode(e)}updateNodeData(e,t){const n=this.getNodeById(e);if(!n){console.error("Cannot find node to update:",e);return}this.updateNode(e,{data:Object.assign(n.data||{},t)})}updateLine(e,t){const n=this.getLineById(e);if(!n){this.updateFakeLine(e,t);return}Object.assign(n,t,{id:e}),this.commitLine(e)}updateLineData(e,t){const n=this.getLineById(e);if(!n){console.error("Cannot find line to update:",e);return}this.updateLine(e,{data:Object.assign(n.data||{},t)})}updateFakeLine(e,t){const n=this.getFakeLineById(e);if(!n){console.error("Cannot find fakeLine to update:",e,t);return}Object.assign(n,t,{id:e}),this.commitFakeLine(e)}updateConnectTarget(e,t){const n=this.getConnectTargetById(e);!n||(Object.assign(n,t,{targetId:e}),this.commitConnectTarget(e))}updateElLineTarget(e,t){const n=this.getElLineTargetById(e);!n||Object.assign(n,t,{id:e})}updateNodesVisibleProperty(e){let t=!1;e||(e=this.getNodes(),t=!0);for(const n of e){const i=z.isVisibleNode(n);n.rgCalcedVisibility!==i&&(n.rgCalcedVisibility=i,this.commitNode(n.id))}for(const n of this.runtimeDATA4Links)if(t||e.includes(n.fromNode)||e.includes(n.toNode)){const a=this.calcLinkVisibility(n);n.rgCalcedVisibility=a,this.commitLine(n.lineId)}}calcLinkVisibility(e){return e.fromNode.rgCalcedVisibility&&e.toNode.rgCalcedVisibility}updateShouldRenderGraphData(){const e=this.options,t=e.canvasZoom/100,n={x:-e.canvasOffset.x/t,y:-e.canvasOffset.y/t},i={x:n.x+e.viewSize.width/t,y:n.y+e.viewSize.height/t},a=e.snapshotting;for(const r of this.getNodes()){let l=!0;a||r.alwaysRender?l=!0:((r.x>i.x||r.y>i.y)&&(l=!1),(r.x+r.el_W<n.x||r.y+r.el_H<n.y)&&(l=!1)),r.rgShouldRender=l}for(const r of this.runtimeDATA4Links){if(a){r.rgShouldRender=!0;continue}r.rgShouldRender=r.fromNode.rgShouldRender||r.toNode.rgShouldRender}this.options.showEasyView?(this.runtimeDATA4ShouldRenderItems.nodes=[],this.runtimeDATA4ShouldRenderItems.lines=[],this.runtimeDATA4ShouldRenderItems.fakeLines=[]):(this.runtimeDATA4ShouldRenderItems.nodes=this.calcShouldRenderNodes(),this.runtimeDATA4ShouldRenderItems.lines=this.calcShouldRenderLines(),this.runtimeDATA4ShouldRenderItems.fakeLines=this.calcShouldRenderFakeLines())}addConnectTarget(e){return this.runtimeDATA4ConnectTargets.push(e),this.commits.connectTargetsListChanged=!0,this.commits.fakeLinesListChanged=!0,this.getConnectTargetById(e.targetId)}addElLineTarget(e){this.runtimeDATA4ElLineTargets.push(e),this.commits.fakeLinesListChanged=!0}setRootNodeId(e){if(this.graphData.rootNode=this.graphData.nodes.find(t=>t.id===e),!this.graphData.rootNode)throw new Error("The root node [rootId] is not set! Or cannot get the root node:"+e+", If you don't have any nodes to display, you can simply set an invisible node: {id:'root', opacity:0}")}}class kn{constructor(){_(this,"listeners");_(this,"useReactiveDataToAutoUpdateView",!1);_(this,"instanceId");_(this,"dataProvider");_(this,"options");_(this,"_dataUpdatedRequested",!1);_(this,"eventHandlers",[]);_(this,"_emitHook");this.dataProvider=new Pe,this.options=this.dataProvider.getOptions(),this.listeners={},this.instanceId="RG-"+this.generateNewUUID(5)}generateNewUUID(o=5){return Be(o)}enableDebugLog(o){this.dataProvider.updateOptions({debug:o}),window&&(window.relationGraphDebug=o)}_dataUpdated(){this._requestDataUpdate()}_requestDataUpdate(){!window||!window.requestAnimationFrame||this._dataUpdatedRequested||(this._dataUpdatedRequested=!0,requestAnimationFrame(this._doSomethingAfterDataUpdated.bind(this)))}_doSomethingAfterDataUpdated(){try{!this.useReactiveDataToAutoUpdateView||this.dataProvider.isPerformanceMode()?(this._previousUpdateTime=Date.now(),this.updateShouldRenderGraphData(),this.updateEasyView(),this.dataProvider&&this.dataProvider.dataUpdated()):this.updateMiniView()}catch(o){console.error("[relation-graph]Error:",o)}finally{this._dataUpdatedRequested=!1}}addEventHandler(o){this.eventHandlers.includes(o)||this.eventHandlers.push(o)}removeEventHandler(o){const e=this.eventHandlers.indexOf(o);e!==-1&&this.eventHandlers.splice(e,1)}setEventEmitHook(o){this._emitHook=o,console.warn("[setEventEmitHook]",this._emitHook)}emitEvent(o,...e){let{result:t,handled:n}=this.defaultEventHandler(o,...e);for(const i of this.eventHandlers){const a=i(o,...e);a!==void 0&&(t=a,n=!0)}if(n||this._emitHook&&this._emitHook(o,...e,i=>{i!==void 0&&(t=i)}),t!==void 0)return L("[custom event hook]Event:",o," => returnValue:",t),t}defaultEventHandler(o,...e){let t,n=!1;if(o===A.onReady)this.listeners.onReady&&(n=!0,this.listeners.onReady(this));else if(o===A.onNodeDragStart)this.listeners.onNodeDragStart&&(n=!0,this.listeners.onNodeDragStart(e[0],e[1]));else if(o===A.onNodeDragging){if(this.listeners.onNodeDragging){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3],c=e[4],d=e[5];t=this.listeners.onNodeDragging(i,a,r,l,c,d)}}else if(o===A.onCanvasDragging){if(this.listeners.onCanvasDragging){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3];t=this.listeners.onCanvasDragging(i,a,r,l)}}else if(o===A.onNodeDragEnd){const i=e[0],a=e[1],r=e[2],l=e[3];this.listeners.onNodeDragEnd&&(n=!0,this.listeners.onNodeDragEnd(i,a,r,l))}else if(o===A.onZoomEnd)this.listeners.onZoomEnd&&(n=!0,this.listeners.onZoomEnd());else if(o===A.onNodeClick){if(this.listeners.onNodeClick){n=!0;const i=e[0],a=e[1];this.listeners.onNodeClick(i,a)}}else if(o===A.onLineClick){if(this.listeners.onLineClick){n=!0;const i=e[0],a=e[1],r=e[2];this.listeners.onLineClick(i,a,r)}}else if(o===A.onNodeExpand){if(this.listeners.onNodeExpand){n=!0;const i=e[0],a=e[1];this.listeners.onNodeExpand(i,a)}}else if(o===A.onNodeCollapse){if(this.listeners.onNodeCollapse){n=!0;const i=e[0],a=e[1];this.listeners.onNodeCollapse(i,a)}}else if(o===A.onCanvasDragEnd){if(this.listeners.onCanvasDragEnd){n=!0;const i=e[0];this.listeners.onCanvasDragEnd(i)}}else if(o===A.onCanvasClick){if(this.listeners.onCanvasClick){n=!0;const i=e[0];this.listeners.onCanvasClick(i)}}else if(o===A.onCanvasSelectionEnd){if(this.listeners.onCanvasSelectionEnd){n=!0;const i=e[0],a=e[1];this.listeners.onCanvasSelectionEnd(i,a)}}else if(o===A.onContextmenu){if(this.listeners.onContextmenu){n=!0;const i=e[0],a=e[1],r=e[2];this.listeners.onContextmenu(i,a,r)}}else if(o===A.onFullscreen){if(this.listeners.onFullscreen){n=!0;const i=e[0],a=e[1];t=this.listeners.onFullscreen(i,a)}}else if(o===A.beforeAddNodes){if(this.listeners.beforeAddNodes){n=!0;const i=e[0];t=this.listeners.beforeAddNodes(i)}}else if(o===A.beforeAddLines){if(this.listeners.beforeAddLines){n=!0;const i=e[0];t=this.listeners.beforeAddLines(i)}}else if(o===A.onKeyboardDown){if(this.listeners.onKeyboardDown){n=!0;const i=e[0];t=this.listeners.onKeyboardDown(i)}}else if(o===A.onKeyboardUp){if(this.listeners.onKeyboardUp){n=!0;const i=e[0];t=this.listeners.onKeyboardUp(i)}}else if(o===A.onLineBeCreated){if(this.listeners.onLineBeCreated){n=!0;const i=e[0];t=this.listeners.onLineBeCreated(i)}}else if(o===A.onCanvasDragStart){if(this.listeners.onCanvasDragStart){n=!0;const i=e[0],a=e[1],r=e[2];t=this.listeners.onCanvasDragStart(i,a,r)}}else if(o===A.onResizeEnd){if(this.listeners.onResizeEnd){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3];t=this.listeners.onResizeEnd(i,a,r,l)}}else if(o===A.onResizeStart){if(this.listeners.onResizeStart){n=!0;const i=e[0],a=e[1];t=this.listeners.onResizeStart(i,a)}}else if(o===A.beforeNodeResize&&this.listeners.beforeNodeResize){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3],c=e[4];t=this.listeners.beforeNodeResize(i,a,r,l,c)}return{result:t,handled:n}}setEventListener(o){Object.assign(this.listeners,o)}}class In extends kn{constructor(){super(...arguments);_(this,"$dom");_(this,"$canvasDom");_(this,"_rgAsConnectArea",!1);_(this,"$lineTextContainer4NormalLine");_(this,"$lineTextContainer4FakeLine")}getLineTextContainer(e){if(!(!e||!this.$canvasDom))return e.isFakeLine?(this.$lineTextContainer4NormalLine||(this.$lineTextContainer4NormalLine=this.$canvasDom.querySelector(".rg-lines-container-el-lines .rg-linetext-container")),this.$lineTextContainer4NormalLine):(this.$lineTextContainer4FakeLine||(this.$lineTextContainer4FakeLine=this.$canvasDom.querySelector(".rg-lines-container-normal-lines .rg-linetext-container")),this.$lineTextContainer4FakeLine)}getViewBoundingClientRect(){var e;return this.$dom?(e=this.$dom)==null?void 0:e.getBoundingClientRect():(console.error("[getViewBoundingClientRect] RelationGraph DOM is not set yet!"),null)}getBoundingClientRect(){return console.warn("Please use getViewBoundingClientRect instead of getBoundingClientRect, this method is compatible with older api versions."),this.getViewBoundingClientRect()}_getEventPoint(e){return this.getViewXyByEvent(e)}getViewXyByEvent(e){const t={x:e.clientX,y:e.clientY};if(ce(e)){const i=e.touches||e.targetTouches;if(!i)throw new Error("error targetTouches");t.x=i[0].clientX,t.x=i[0].clientY}const n=this.getViewBoundingClientRect();return{x:t.x-n.x,y:t.y-n.y}}getCanvasXyByClientXy(e){const t=this.getViewBoundingClientRect(),n={x:e.x-t.left,y:e.y-t.top};return this.getCanvasXyByViewXy(n)}getCanvasXyByViewXy(e){if(this._rgAsConnectArea)return e;const t=this.dataProvider.getOptions(),n=t.canvasZoom/100,i={x:e.x-t.canvasOffset.x,y:e.y-t.canvasOffset.y};return{x:i.x/n,y:i.y/n}}getViewXyByCanvasXy(e){const t=this.dataProvider.getOptions(),n=t.canvasZoom/100;return{x:e.x*n+t.canvasOffset.x,y:e.y*n+t.canvasOffset.y}}getCanvasCoordinateByClientCoordinate(e){return console.warn("Please use getCanvasXyByClientXy instead of getCanvasCoordinateByClientCoordinate, this method is compatible with older api versions."),this.getCanvasXyByClientXy(e)}isNode(e){const t=Le(e,"rg-node-peel","rg-map");if(!!t)return this.dataProvider.getNodeById(t.dataset.id)}isLine(e){const t=Le(e,"rg-line-peel","relation-graph");if(!!t)return this.dataProvider.getLineById(t.dataset.id)}isLink(e){throw new Error("Please use isLine")}}class En extends Pe{constructor(e,t,n,i){super();_(this,"dataStores");this.dataStores=e;const a=Object.assign({},this.options,n);this.options=n,Object.assign(this.options,a),this.graphData=t,this.runtimeDATA4Links=i.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=i.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=i.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=i.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=i.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=i.runtimeDATA4ElLineTargets,this.updateViewHook=r=>{if(console.log("###########updateViewHook"),r.optionsChanged&&(this.dataStores.store4Options.set(this.getOptions()),console.log("[updateViewHook]optionsChanged")),r.nodesListChanged&&(this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),console.log("[updateViewHook]nodesListChanged")),r.linesListChanged){const l=this.getShouldRenderLines();this.dataStores.store4ShouldRenderLines.set(l),console.log("[updateViewHook]linesListChanged")}if(r.fakeLinesListChanged){const l=this.getShouldRenderFakeLines();this.dataStores.store4ShouldRenderFakeLines.set(l),console.log("[updateViewHook]fakeLinesListChanged")}}}}class Dn extends Pe{constructor(o,e,t){super(),this.graphData=o,this.runtimeDATA4Links=t.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=t.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=t.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=t.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=t.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=t.runtimeDATA4ElLineTargets;const n=Object.assign({},this.options,e);this.options=e,Object.assign(this.options,n)}}class An extends Pe{constructor(e,t){super();_(this,"dataStores");this.dataStores=e,this.updateViewHook=n=>{n.optionsChanged&&this.dataStores.store4Options.set(this.getOptions()),(n.nodesListChanged||n.changedNodes.length>0)&&(this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),console.log("[updateViewHook]nodesListChanged")),(n.linesListChanged||n.changedLines.length>0)&&(this.dataStores.store4ShouldRenderLines.set(this.getShouldRenderLines()),console.log("[updateViewHook]linesListChanged")),(n.fakeLinesListChanged||n.changedFakeLines.length>0)&&this.dataStores.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()])}}}class Vn extends Pe{constructor(o,e){super(),e(),this.updateViewHook=t=>{if(t.optionsChanged&&o.store4Options.set(this.getOptions()),t.linesListChanged||t.changedLines.length>0||t.nodesListChanged||t.changedNodes.length>0){const n=this.getShouldRenderNodes();o.store4ShouldRenderNodes.set([...n])}if(t.linesListChanged||t.changedLines.length>0){const n=this.getShouldRenderLines();o.store4ShouldRenderLines.set(n)}t.fakeLinesListChanged?o.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()]):t.changedFakeLines.length>0&&o.store4ShouldRenderFakeLines.set(this.getShouldRenderFakeLines())}}}class Xn extends In{constructor(){super();_(this,"_initRawPropertyFn",(e,t,n)=>{});_(this,"dataStores")}setReactiveData4Vue2(e,t,n,i){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new Dn(e,t,n),this._initRawPropertyFn=i,this.options=this.dataProvider.options,this.dataStores={shouldRenderNodesStore:n.runtimeDATA4ShouldRenderItems.nodes,shouldRenderLinesStore:n.runtimeDATA4ShouldRenderItems.lines,shouldRenderFakeLinesStore:n.runtimeDATA4ShouldRenderItems.fakeLines}}setReactiveData4Vue3(e,t,n,i,a){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new En(e,t,n,i),this._initRawPropertyFn=a,this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines,optionsRef:e.optionsRef,shouldRenderNodesRef:e.shouldRenderNodesRef,shouldRenderLinesRef:e.shouldRenderLinesRef,shouldRenderFakeLinesRef:e.shouldRenderFakeLinesRef},console.error("[RelationGraphWith2Data] setReactiveData4Vue3:",this.options)}setReactiveData4React(e,t){this.dataProvider=new Vn(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines}}setReactiveData4Svelte(e,t){this.dataProvider=new An(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines},console.log("[RelationGraphWith2Data] setReactiveData4Svelte:",this.options)}generateNewNodeId(e=5){const t=Be(e);return this.dataProvider.getNodeById(t)?this.generateNewNodeId(e+1):t}}class zn extends Xn{constructor(){super()}getOptions(){return this.dataProvider.getOptions()}getNodeById(o){return this.dataProvider.getNodeById(o)}getLineById(o){return this.dataProvider.getLineById(o)}getLinkByLineId(o){return this.dataProvider.getLinkByLineId(o)}getLinkByLine(o){return this.getLinkByLineId(o.id)}getLines(){return this.dataProvider.getLines()}getElementLineById(o){return this.getFakeLineById(o)}getElementLines(){return this.getFakeLines()}getFakeLines(){return this.dataProvider.getFakeLines()}getFakeLineById(o){return this.dataProvider.getFakeLineById(o)}getNodes(){return this.dataProvider.getNodes()}getLinks(){return this.dataProvider.getLinks()}_getAllLinks(){const o=this.getLinks();return this._getFakeLineLinks().concat(o)}getNodeByTargetId(o){const e=this.dataProvider.getConnectTargetById(o);if(e&&e.nodeId)return this.getNodeById(e.nodeId)}_getFakeLineLinks(){const o=[];for(const e of this.getFakeLines())if(!e.forDisplayOnly&&(e.fromType===V.Node||e.fromType===V.NodePoint||e.fromType===V.CanvasPoint)&&(e.toType===V.Node||e.toType===V.NodePoint||e.toType===V.CanvasPoint)){let t=null,n=null;e.fromType===V.Node?t=this.getNodeById(e.from):(e.fromType===V.NodePoint||e.fromType===V.CanvasPoint)&&(t=this.getNodeByTargetId(e.from)),e.toType===V.Node?n=this.getNodeById(e.to):(e.toType===V.NodePoint||e.toType===V.CanvasPoint)&&(n=this.getNodeByTargetId(e.to)),t&&n&&o.push({lineId:e.id,line:e,fromNode:t,toNode:n,totalLinesBetweenNodes:1,currentLineIndex:0,rgShouldRender:!0,rgCalcedVisibility:!0})}return o}getConnectTargets(){return this.dataProvider.getConnectTargets()}getConnectTargetById(o){return this.dataProvider.getConnectTargetById(o)}}class Bn extends zn{constructor(){super()}getRelatedLinesByNode(o){const e=[];for(const t of this._getAllLinks())(o===t.fromNode||o===t.toNode)&&e.push(t.line);return e}getLinksBetweenNodes(o){const e=[],t=this._getAllLinks();for(const n of t)o.includes(n.fromNode)&&o.includes(n.toNode)&&e.push(n);return e}getLinesBetweenNodes(o){return this.getLinksBetweenNodes(o).map(e=>e.line)}getNodeRelatedNodes(o,e={incoming:!0,outgoing:!0}){const t=[];for(const n of this.getLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:i,toNode:a}=n;e.outgoing&&i===o&&(t.includes(a)||t.push(a)),e.incoming&&a===o&&(t.includes(i)||t.push(i))}for(const n of this._getFakeLineLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:i,toNode:a}=n;e.outgoing&&i===o&&(t.includes(a)||t.push(a)),e.incoming&&a===o&&(t.includes(i)||t.push(i))}return t}getNodeIncomingNodes(o){return this.getNodeRelatedNodes(o,{incoming:!0,outgoing:!1})}getNodeOutgoingNodes(o){return this.getNodeRelatedNodes(o,{incoming:!1,outgoing:!0})}findGroupNodes(o,e=[]){return this._getNetworkNodesByNode(o,e)}getGroupNodesByNode(o,e=[]){return this._getNetworkNodesByNode(o,e)}getNetworkNodesByNode(o){return this._getNetworkNodesByNode(o)}_getNetworkNodesByNode(o,e=[]){if(!o)throw new Error("Call graphInstance.getNetworkNodesByNode:error: node is undefined");e.includes(o)||e.push(o);for(const t of this.getNodeRelatedNodes(o))e.includes(t)||this._getNetworkNodesByNode(t,e);return e}getStuffSize(o){return console.warn("Please use getNodesRectBox instead of getStuffSize, this method is compatible with older api versions."),this.getNodesRectBox(o)}getNodesViewInfo(o){return console.warn("Please use getNodesRectBox instead of getNodesViewInfo, this method is compatible with older api versions."),this.getNodesRectBox(o)}getNodesRectBox(o){const t=(o||this.getNodes()).filter(d=>d.rgCalcedVisibility!==!1);if(t.length===0)return{width:10,height:10,minX:0,minY:0,maxX:0,maxY:0};let n=9999999,i=9999999,a=-9999999,r=-9999999;t.forEach(d=>{d.x<n&&(n=d.x),d.x+(d.width||d.el_W)>a&&(a=d.x+(d.width||d.el_W)),d.y<i&&(i=d.y);const f=d.y+(d.height||d.el_H);f>r&&(r=f)});const l=a-n,c=r-i;return{width:l<0?0:l,height:c<0?0:c,minX:n===9999999?0:n,minY:i===9999999?0:i,maxX:a===-9999999?0:a,maxY:r===-9999999?0:r}}getNodesCenter(o){const e=this.getNodesRectBox(o);L("getNodesCenter:",e);const t=e.minX+(e.maxX-e.minX)/2,n=e.minY+(e.maxY-e.minY)/2;return{x:t,y:n}}getDescendantNodes(o){return z.getDescendantNodes(o)}getNodesInSelectionView(o){const e=this.getCanvasXyByViewXy({x:o.x,y:o.y}),t=this.getCanvasXyByViewXy({x:o.x+o.width,y:o.y+o.height}),n=[];return this.getNodes().forEach(i=>{const a=i.x+i.el_W/2,r=i.y+i.el_H/2;a>e.x&&r>e.y&&a<t.x&&r<t.y&&n.push(i)}),n}getShouldRenderNodes(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderNodes()}getShouldRenderLines(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderLines()}getShouldRenderFakeLines(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderFakeLines()}}class Gn extends Bn{constructor(){super();_(this,"_elLineUpdateTimer");_(this,"_canvasCurrentInfo",{x:0,y:0,scale:1});_(this,"_nodeResizeEffectTimer");_(this,"prevAddNodeTimestamp",0);_(this,"_nodesElSizeMap",new Map)}removeLine(e){this.removeLines([e])}removeLines(e){this.removeLineByIds(e.map(t=>t.id))}removeLineById(e){this.removeLineByIds([e])}removeLineByIds(e){this.dataProvider.removeLineByIds(e),this._dataUpdated()}removeFakeLine(e){this.removeFakeLineById(e.id)}removeFakeLineById(e){L("removeLineById:",e),this.dataProvider.removeFakeLineByIds([e]),this._dataUpdated()}removeLink(e){L("removeLink:",e),this.removeLinkByLineId(e.lineId)}removeLinkByLineId(e){this.dataProvider.removeLineByIds([e]),this._dataUpdated()}removeNodeById(e){this.dataProvider.removeNodeById([e]),this._dataUpdated()}removeNodesByIds(e){e.forEach(t=>this.dataProvider.removeNodeById(e)),this._dataUpdated()}removeNodes(e){this.dataProvider.removeNodeById(e.map(t=>t.id)),this._dataUpdated()}removeNode(e){this.dataProvider.removeNodeById([e.id]),this._dataUpdated()}removeELementLineById(e){L("removeELementLineById:",e),this.removeFakeLineById(e)}addNode(e){if(L("addNode:",e),e&&Array.isArray(e)){console.error("addNode: node is array:",e);return}this._addNodes([e]),this._dataUpdated()}addNodes(e){if(L("addNodes:",e),e&&!Array.isArray(e)){console.error("addNodes: nodes is not array:",e);return}this._addNodes(e),this._dataUpdated()}addLine(e){if(L("addLine:",e),e&&Array.isArray(e)){console.error("addLine: line is array:",e);return}this.addLines([e])}addLines(e){if(L("addLines:",e),e&&!Array.isArray(e)){console.error("addLines: lines is not array:",e);return}if(e.length===0)return;const t=e.filter(i=>!i.isFakeLine);this._addLines(t);const n=e.filter(i=>i.isFakeLine);this.addFakeLines(n),this._dataUpdated()}_addFakeLines(e){this.dataProvider.addFakeLines(e)}addFakeLines(e){L("addFakeLines:",e),this._addFakeLines(e),this._dataUpdated()}updateElementLines(){this.dataProvider.getElLineTargets().length!==0&&(L("updateElementLines:runtimeDATA4ElLineTargets:",this.dataProvider.getElLineTargets().length),this._elLineUpdateTimer&&clearTimeout(this._elLineUpdateTimer),this._elLineUpdateTimer=setTimeout(()=>{this._updateElementLines(),this._dataUpdated()},100))}_updateElementLines(){this._updateCanvasBoxInfo();for(const e of this.dataProvider.getElLineTargets())this.updateElementTarget(e)}_updateCanvasBoxInfo(){const e=this.$canvasDom.getBoundingClientRect();this._canvasCurrentInfo.x=e.x,this._canvasCurrentInfo.y=e.y,this._canvasCurrentInfo.scale=this.dataProvider.getOptions().canvasZoom/100}updateElementTarget(e){const t=this._getElementTargetPosition(document.getElementById(e.id),e);t?this.dataProvider.updateElLineTarget(e.id,{hidden:!1,...t}):this.dataProvider.updateElLineTarget(e.id,{hidden:!0})}_getElementTargetPosition(e){if(!e)return null;const t=e.getBoundingClientRect(),n=(t.x-this._canvasCurrentInfo.x)/this._canvasCurrentInfo.scale,i=(t.y-this._canvasCurrentInfo.y)/this._canvasCurrentInfo.scale,a=t.width/this._canvasCurrentInfo.scale,r=t.height/this._canvasCurrentInfo.scale;return{x:n,y:i,el_W:a,el_H:r}}addElementLines(e){L("addElementLines:",e),e.forEach(t=>{t.fromType=V.HTMLElementId,t.toType=V.HTMLElementId,t.isFakeLine=!0,t.id||(t.id=this.generateNewUUID(6)),t.forDisplayOnly=!0}),this.addFakeLines(e),console.log("addElementLines:",e.length,e),this.updateElementLines()}updateNodeOffsetSize(e,t,n){const i=this.getNodeById(e);if(!i)return;const a=i.el_W,r=i.el_H;(a!==t||r!==n)&&(this.dataProvider.updateNode(e,{el_W:t,el_H:n}),this._nodeResizeEffectTimer&&clearTimeout(this._nodeResizeEffectTimer),this._nodeResizeEffectTimer=setTimeout(()=>{this._dataUpdated()},100))}clearFakeLines(){this.dataProvider.clearFakeLines(),this._dataUpdated()}clearElementLines(){const e=[];for(const t of this.getFakeLines())(t.fromType===V.HTMLElementId||t.toType===V.HTMLElementId)&&e.push(t.id);this.dataProvider.removeFakeLineByIds(e),this._dataUpdated()}_addNodes(e){this.emitEvent(A.beforeAddNodes,e);const t={};this.getNodes().forEach(a=>{t[a.id]=a});const n=[],i=this.getOptions();e.forEach(a=>{let r=t[a.id];if(!r){let{text:l,id:c}=a;!l&&a.label&&(l=a.label,console.warn('Use "label" as "text":',a.label)),l===void 0&&c&&(l=c,console.warn('Use "id" as "text":',c)),r=be(Object.assign({},a,{text:l}),i,this._nodesElSizeMap),this._initRawPropertyFn&&this._initRawPropertyFn(r,"lot",r.lot),r&&(t[r.id]=r,n.push(r))}}),this.dataProvider.addNodes(n),n.length>0&&(this.prevAddNodeTimestamp=Date.now())}_addLines(e){this.emitEvent(A.beforeAddLines,e);const t=[];e.forEach(n=>{let{from:i,to:a,text:r}=n;if(!i)if(n.source)i=n.source,console.warn('Use "source" as "from":',n.source);else{console.error('JsonLine Must have field:"from"',n);return}if(!a)if(n.target)a=n.target,console.warn('Use "target" as "to":',n.target);else{console.error('JsonLine Must have field:"to"',n);return}if(r||n.label&&(r=n.label,console.warn('Use "label" as "text":',n.label)),!this.getNodeById(i)){console.error("Can not found from node:",n);return}if(!this.getNodeById(a)){console.error("Can not found to node:",n);return}if(n.id){if(this.getLineById(n.id)){console.warn("_addLines:skip duplicate line id:",n.id);return}else if(t.some(f=>f.id===n.id)){console.warn("Duplicate line id in new lines:",n.id);return}}else n.id="L-"+this.generateNewUUID(6);const d=he(Object.assign({},n,{from:i,to:a,text:r}),this.getOptions());t.push(d)}),this.dataProvider.addLines(t)}updateNode(e,t){this.dataProvider.updateNode(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateNodePosition(e,t,n){var a;const i=typeof e=="string"?e:e.id;this.dataProvider.updateNode(i,{x:t,y:n}),this.getOptions().layout.autoLayouting&&((a=this.layoutor)==null||a.syncNodePosition(i,t,n)),this._dataUpdated()}updateNodeData(e,t){this.dataProvider.updateNodeData(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateLine(e,t){this.dataProvider.updateLine(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateLineData(e,t){this.dataProvider.updateLineData(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateFakeLine(e,t){this.dataProvider.updateFakeLine(typeof e=="string"?e:e.id,t),this._dataUpdated()}flatNodeData(e,t,n,i){z.flatNodeData(e,t,n,i)}backupNodesElSize(){for(const e of this.getNodes())this._nodesElSizeMap.set(e.id,[e.el_W,e.el_H])}loadGraphJsonData(e){e.lines||(e.lines=e.relations,e.lines&&console.warn("[relation-graph] For compatibility with older version, Use jsonData.relations as jsonData.lines, It is recommended that you define your data using")),e.lines||(e.lines=e.links||e.edges,e.lines&&console.warn("[relation-graph] For compatibility with older version, Use jsonData.links/jsonData.edges as jsonData.lines, It is recommended that you define your data using"));const t=e.nodes||[],n=e.lines||[],i=[],a=[];this.flatNodeData(t,null,i,a),n.forEach(r=>{a.push(r)}),this._addNodes(i),L("Nodes is initialized"),this._addLines(a),this._dataUpdated(),e.fakeLines&&this.addFakeLines(e.fakeLines),setTimeout(()=>{e.elementLines&&(console.warn("elementLines is deprecated, please use fakeLines with isFakeLine and fromType/toType = RGInnerConnectTargetType.HTMLElementId instead:",e.elementLines),this.addElementLines(e.elementLines)),this._dataUpdated()},500)}updateShouldRenderGraphData(e=!1){!e&&!this.dataProvider.isPerformanceMode()||this.dataProvider.updateShouldRenderGraphData()}updateNodesVisibleProperty(e){this.dataProvider.updateNodesVisibleProperty(e)}updateVisibleNodesSize(){for(const e of this.getShouldRenderNodes()){const t=this.getNodeElByNodeId(e.id);t&&this._onNodeDomResize(t,t.clientWidth,t.clientHeight)}}_clearGraph(){this.backupNodesElSize(),this.dataProvider.clearReactiveData(),this.dataProvider.clearChecked(),this.dataProvider.setEditingLine(null),this.dataProvider.setEditingNodes([])}_setJsonData(e,t=!1){this._clearGraph(),this.loadGraphJsonData(e)}}class Fn extends Gn{constructor(){super();_(this,"canvasConnectTargetsMap",new Map);_(this,"nodeConnectTargetsMap",new Map);_(this,"connectTargetElementMap",new Map);_(this,"_connectTargetUpdateRequestedSet",new Map);_(this,"_updateTimer");_(this,"_removedConnectTargetMap",new Map)}updateConnectTargetsOnCanvas(e,t){if(!t)return;console.warn(`updateConnectTargetsOnCanvas:[${e}]:`);const n=t.classList.contains("rg-canvas-slot-above")?"above":"behind",i=this.canvasConnectTargetsMap.get(n);i&&i.length>0&&this.updateConnectTargetList(e,t,i)}updateConnectTargetsByNodeId(e){const t=this.getNodeElByNodeId(e);this.updateConnectTargetsOnNode("API",e,t)}getNodeElByNodeId(e){return this.$dom.querySelector(`[data-id="${e}"]`)}updateConnectTargetsOnNode(e,t,n){const i=this.nodeConnectTargetsMap.get(t)||[];i.length!==0&&this.updateConnectTargetList(e,n,i)}updateConnectTargetList(e,t,n){const i=this.dataProvider.getCanvasScale();for(const a of n){const r=this.connectTargetElementMap.get(a.targetId);if(!r){console.error("Can not find el for connectTarget:",a.targetId,a);continue}this._requestUpdateConnectTargetOffset(e,a,r,t,i)}}_requestUpdateConnectTargetOffset(e,t,n,i,a){this._connectTargetUpdateRequestedSet.set(t.targetId,{stableTimes:0,connectTarget:t,by:e,connectTargetEl:n,relativeEl:i}),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(this._connectTargetUpdateRequestedSet.size+10,50))}_updateAllRequestedConnectTargetOffsets(){let e=0,t=0;for(const n of this._connectTargetUpdateRequestedSet.values()){const{by:i,connectTargetEl:a,relativeEl:r,connectTarget:l}=n;if(this.dataProvider.isPerformanceMode()&&l.nodeId){const h=this.getNodeById(l.nodeId);if(!h||!h.rgShouldRender||!h.rgCalcedVisibility){t++;continue}}const c=this.dataProvider.getCanvasScale();this._updateConnectTargetOffset(i,l,a,r,c)?e++:n.stableTimes++,n.stableTimes>2&&this._connectTargetUpdateRequestedSet.delete(l.targetId)}e>0?(console.warn(`_updateAllRequestedConnectTargetOffsets: ${e} of ${this._connectTargetUpdateRequestedSet.size} changed, ${t} Skipped!`),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(e/2+10,50)),this._dataUpdated()):(console.warn("_updateAllRequestedConnectTargetOffsets:::::::OK",this._connectTargetUpdateRequestedSet.size),this._connectTargetUpdateRequestedSet.clear(),this._dataUpdated())}_updateConnectTargetOffset(e,t,n,i,a){const r=i.getBoundingClientRect(),l=n.getBoundingClientRect(),c=Math.round(l.x-r.x),d=Math.round(l.y-r.y),h=this.dataProvider.getCanvasScale(),f=c/h,p=d/h,u=l.width/h,g=l.height/h;return t.offsetX!==f||t.offsetY!==p||t.width!==u||t.height!==g?(this.dataProvider.updateConnectTarget(t.targetId,{offsetX:f,offsetY:p,width:l.width/h,height:l.height/h}),!0):!1}_onConnectTargetMounted(e,t,n,i){const a=this.dataProvider.getCanvasScale();this._requestUpdateConnectTargetOffset(e,t,n,i,a)}getNodeElByChildrenTarget(e){return Le(e,"rg-node-peel","rg-map")}registerConnectTarget(e,t,n,i,a={}){if(n!==V.NodePoint&&n!==V.CanvasPoint)return;if(!e){console.error(`[registerConnectTarget]Can not find CanvasPoint target DOM: ${t}`);return}const r=this.getNodeElByChildrenTarget(e),l=r==null?void 0:r.dataset.id;if(l==="rg-newNodeTemplate")return;let c=this.dataProvider.getConnectTargetById(t);if(!c){const h={targetId:t,targetType:n,junctionPoint:i,nodeId:"",width:20,height:20,offsetX:0,offsetY:0,offsetPercentX:0,offsetPercentY:0,targetData:a||{}};this.reuseConnectTarget(h),c=this.dataProvider.addConnectTarget(h)}return this.connectTargetElementMap.set(c.targetId,e),(l?this.getNodeById(l):null)?this._addConnectTargetToNodeMap(l,c,e,r):this._addConnectTargetToCanvasMap(c,e),c}_addConnectTargetToNodeMap(e,t,n,i){this.dataProvider.updateConnectTarget(t.targetId,{junctionPoint:t.junctionPoint,targetType:V.NodePoint,nodeId:e,targetData:Object.assign({},t.targetData||{},{nodeId:e})});let a=this.nodeConnectTargetsMap.get(e);a?a.some(r=>r.targetId===t.targetId)||a.push(t):this.nodeConnectTargetsMap.set(e,[t]),this._onConnectTargetMounted("NT-Mounted",t,n,i)}_addConnectTargetToCanvasMap(e,t){let n=Le(t,"rg-canvas-slot","rg-map");if(!n){console.error(`Can not find CanvasPoint target DOM's parent(.rg-canvas-slot) : ${e.targetId}`,t);return}if(n){const i=n.classList.contains("rg-canvas-slot-above")?"above":"behind";this.dataProvider.updateConnectTarget(e.targetId,{junctionPoint:e.junctionPoint,targetType:V.CanvasPoint,targetData:Object.assign({},e.targetData||{})});const a=this.canvasConnectTargetsMap.get(i);a?a.some(r=>r.targetId===e.targetId)||a.push(e):this.canvasConnectTargetsMap.set(i,[e]),console.error("ConnectTarget On Canvas:",e),this._onConnectTargetMounted("CT-Mounted",e,t,n)}}unregisterConnectTarget(e){const t=this.dataProvider.getConnectTargetById(e);if(!t)return;let n;if(t.nodeId&&this.nodeConnectTargetsMap.has(t.nodeId))n=this.nodeConnectTargetsMap.get(t.nodeId);else{let i=this.canvasConnectTargetsMap.get("behind").findIndex(a=>a.targetId===e);i!==-1?n=this.canvasConnectTargetsMap.get("behind"):(i=this.canvasConnectTargetsMap.get("above").findIndex(a=>a.targetId===e),i!==-1&&(n=this.canvasConnectTargetsMap.get("above")))}if(n){const i=n.findIndex(a=>a.targetId===e);i!==-1&&n.splice(i,1)}this.dataProvider.removeConnectTarget(e),this.connectTargetElementMap.delete(e),this._removedConnectTargetMap.set(t.targetId,t)}reuseConnectTarget(e){if(this._removedConnectTargetMap.has(e.targetId)){const t=this._removedConnectTargetMap.get(e.targetId);e.offsetX=t.offsetX,e.offsetY=t.offsetY,e.width=t.width,e.height=t.height,e.offsetPercentX=t.offsetPercentX,e.offsetPercentY=t.offsetPercentY,this._removedConnectTargetMap.delete(e.targetId)}}}class Yn extends Fn{constructor(){super();_(this,"fakeLineTargetRender")}generateCreatingLineConfig(e){e||(e=this.dataProvider.getOptions());const{newLinkTemplate:t,newLineTemplate:n}=e,i=t.fromNode;if(!i)return{line:n,from:null,to:null,totalLinesBetweenNodes:1,currentLineIndex:0};const a=t.toNode,r=a.targetType===V.Node?t.toNode:this.getFakeLineTarget(a.targetType,a.id,n);return{line:Object.assign({},n,{isFakeLine:!1}),from:this.getFakeLineTarget(i.targetType,i.id,n),to:r,totalLinesBetweenNodes:1,currentLineIndex:0}}generateLineConfig(e){const t=this.getLinkByLine(e);return!t||!t.rgCalcedVisibility?!1:{line:t.line,from:t.fromNode,to:t.toNode,totalLinesBetweenNodes:t.totalLinesBetweenNodes,currentLineIndex:t.currentLineIndex}}generateFakeLineConfig(e){let t=1,n=0;if(e.fromType===V.HTMLElementId&&e.toType===V.HTMLElementId){const r=this.dataProvider.getFakeLines().filter(l=>l.from===e.from&&l.to===e.to);r.length>1&&(console.warn("sameTargetLines element-line:",e),t=r.length,n=r.indexOf(e))}let i=this.getFakeLineTarget(e.fromType,e.from,e),a=this.getFakeLineTarget(e.toType,e.to,e);return!i&&e.fromType===V.Node?(console.error("[generateFakeLineConfig]error fakeLine from:",e.fromType,e.from,e),!1):!a&&e.fromType===V.Node?(console.error("[generateFakeLineConfig]error fakeLine to:",e.toType,e.to,e),!1):{line:e,from:i,to:a,totalLinesBetweenNodes:t,currentLineIndex:n}}setFakeLineTargetRender(e){this.fakeLineTargetRender=e}getFakeLineTarget(e,t,n){if(e===V.HTMLElementId){let i=this.dataProvider.getElLineTargets().find(a=>a.id===t);return i||(i={x:300,y:300,targetType:V.HTMLElementId,nodeShape:1,id:t,el_W:40,el_H:40,hidden:!0},this.dataProvider.addElLineTarget(i),this.updateElementLines()),i.hidden?null:i}else{if(e===V.Node)return this.getNodeById(t);if(e===V.NodePoint||e===V.CanvasPoint){const i=this.dataProvider.getConnectTargetById(t);if(!i)return;if(i.nodeId){const a=this.getNodeById(i.nodeId);if(!a){console.error("[getFakeLineTarget]Can not find NodePoint-s Node:",`${i.targetId}@${i.nodeId}`);return}return{x:a.x+i.offsetPercentX*a.el_W+i.offsetX,y:a.y+i.offsetPercentY*a.el_H+i.offsetY,targetType:V.NodePoint,targetData:i.targetData,nodeShape:0,id:t,el_W:i.width,el_H:i.height,hidden:!1}}else return{x:i.offsetX,y:i.offsetY,targetType:V.CanvasPoint,targetData:i.targetData,nodeShape:0,id:t,el_W:i.width,el_H:i.height,hidden:!1}}}if(this.fakeLineTargetRender)return this.fakeLineTargetRender(e,t,n)}}class Hn extends Yn{constructor(){super()}_updateOptions(o){!o.instanceId&&this.getOptions().instanceId!==o.instanceId&&(o.instanceId=this.instanceId);const e=Object.assign({},o);if(e.layouts)throw new Error('Graph options do not support setting layouts properties, Please use "layout"!');if(e.lineUseTextPath)throw new Error('Graph options do not support setting layouts properties, Please use "defaultLineTextOnPath"!');if(e.defaultPloyLineRadius&&(e.defaultPolyLineRadius=e.defaultPloyLineRadius),e.debug!==void 0){const t=e.debug===!0;t&&L("RGOptions:user instance options:",e),window&&(window.relationGraphDebug=t)}e.layout?(je(e.layout),He(e.layout,e),this.dataProvider.updateOptions({...e,layout:{...this.getOptions().layout,...e.layout}}),this.layoutor&&this.layoutor.updateOptions&&this.layoutor.updateOptions(e.layout)):this.dataProvider.updateOptions(e)}resetViewSize(o=!1){const e=this.getViewBoundingClientRect(),t={};t.viewSize={width:e.width,height:e.height},this._rgAsConnectArea?(t.canvasZoom=100,t.canvasOffset={x:0,y:0}):o&&(t.canvasZoom=100,t.canvasOffset={x:t.viewSize.width/2,y:t.viewSize.height/2}),this.dataProvider.updateOptions(t),L("resetViewSize:1:",t),this._dataUpdated()}loading(o=""){this.dataProvider.updateOptions({graphLoading:!0,graphLoadingText:o}),this._dataUpdated()}clearLoading(){this.dataProvider.updateOptions({graphLoading:!1,graphLoadingText:""}),this._dataUpdated()}setCheckedNode(o){this.dataProvider.updateOptions({checkedNodeId:o?typeof o=="string"?o:o.id:""}),this._dataUpdated()}setCheckedLine(o){this.dataProvider.updateOptions({checkedLineId:o?typeof o=="string"?o:o.id:""})}clearChecked(){this.dataProvider.clearChecked(),this._dataUpdated()}clearSelected(){const o=this.getNodes().filter(n=>n.selected),e=this.getLines().filter(n=>n.selected),t=this.getFakeLines().filter(n=>n.selected);o.forEach(n=>this.dataProvider.updateNode(n.id,{selected:!1})),e.forEach(n=>this.dataProvider.updateLine(n.id,{selected:!1})),t.forEach(n=>this.dataProvider.updateFakeLine(n.id,{selected:!1})),this._dataUpdated()}setCanvasOffset(o,e){this.dataProvider.setCanvasOffset(o,e),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}setCanvasMoveMode(o){this.dataProvider.updateOptions({canvasMoveMode:o}),this._dataUpdated()}onMiniViewMounted(){this.dataProvider.updateOptions({showMiniView:!0}),this._dataUpdated()}onMiniViewUnMounted(){this.dataProvider.updateOptions({showMiniView:!1})}onReferenceLineMounted(o){this.dataProvider.updateOptions({referenceLineAdsorption:o||!1,showReferenceLine:!0})}onReferenceLineUnMounted(){this.dataProvider.updateOptions({referenceLineAdsorption:!1,showReferenceLine:!1})}}class jn extends Hn{constructor(){super()}getCreatingLine(o){if(o||(o=this.getOptions()),!o.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=this.generateCreatingLineConfig();return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}}getCreatingNode(o){return o||(o=this.getOptions()),o.creatingNodePlot?{creating:o.creatingNodePlot,nodeJson:o.newNodeTemplate}:{creating:!1}}}class Wn extends jn{constructor(){super()}_getJunctionPoint(o,e){return o===U.border?q.getBorderPoint4MultiLine(e):o===U.ltrb?q.getRectJoinPoint(e):o===U.tb?q.getRectVJoinPoint(e):o===U.lr?q.getRectHJoinPoint(e):o===U.left?q.getRectLeftJoinPoint(e):o===U.right?q.getRectRightJoinPoint(e):o===U.top?q.getRectTopJoinPoint(e):o===U.bottom?q.getRectBottomJoinPoint(e):o==="horizontalLine"?q.getRectHorizontalLineJoinPoint(e):o==="verticalLine"?q.getRectVerticalLineLineJoinPoint(e):q.getBorderPoint4MultiLine(e)}createLinePath(o,e,t){throw new Error("createLinePath() is deprecated, please use createLineDrawInfo() instead.")}createLineDrawInfo(o,e){let t,n,i=1,a=0;if(o&&(a=o.currentLineIndex,i=o.totalLinesBetweenNodes),o)t=o.fromNode,n=o.toNode;else{const r=e;if(t=this.getFakeLineTarget(r.fromType,r.from,r),n=this.getFakeLineTarget(r.toType,r.to,r),!t){console.error("Invalid line configuration:error from:",e);return}if(!n){console.error("Invalid line configuration:error to:",e);return}}return this.generateLinePath({line:e,from:t,to:n,totalLinesBetweenNodes:i,currentLineIndex:a})}_getLineDefaultOptions(){const o=this.getOptions();return{layoutDirection:o.layout.layoutDirection,multiLineDistance:o.multiLineDistance,defaultJunctionPoint:o.defaultJunctionPoint,lineRadius:o.defaultPolyLineRadius,defaultLineJunctionOffset:o.defaultLineJunctionOffset,defaultNodeShape:o.defaultNodeShape}}generateLinePath(o){o.totalLinesBetweenNodes===void 0&&(o.totalLinesBetweenNodes=1),o.currentLineIndex===void 0&&(o.currentLineIndex=0),o.defaultOptions===void 0&&(o.defaultOptions=this._getLineDefaultOptions());try{const e=this.withLineJunctionPoints(o);return this.createLinePathData(e)}catch(e){if(e.rgError)return this.createErrorLineValue(e.errorCode,e.x,e.y);throw e}}throwLineError(o,e,t){return{rgError:!0,errorCode:o,x:e,y:t}}createErrorLineValue(o,e,t){const n={x:0,y:0,rotate:0},i=[{type:"M",x:0,y:0},{type:"l",dx:e,dy:t}];return{pathCommands:i,pathData:fe(i),textPosition:n,points:[]}}withLineJunctionPoints({line:o,from:e,to:t,totalLinesBetweenNodes:n,currentLineIndex:i,defaultOptions:a}){if(!e||!t)throw L("error from-to:",e,t),this.throwLineError("F",-10,0);let r=o.lineShape||1;const l=o.lineDirection||a.layoutDirection||"h";let c=e.x||0,d=e.y||0,h=t.x||0,f=t.y||0;if(Number.isNaN(c)||Number.isNaN(d))throw L("error start node:",e.text,e.x,e.y),this.throwLineError("A",-10,-10);if(Number.isNaN(h)||Number.isNaN(f))throw L("error end point:",t.text,t.x,t.y),this.throwLineError("B",10,-10);let p=e.el_W||60,u=e.el_H||60;if(Number.isNaN(p)||Number.isNaN(u))throw this.throwLineError("C",-10,10);let g=t.el_W||60,m=t.el_H||60;if(Number.isNaN(g)||Number.isNaN(m))throw this.throwLineError("D",10,10);if(c===0&&h===0&&d===0&&f===0)throw this.throwLineError("D",10,10);const y=h-c+(f-d)>0,v=o.isReverse?t:e,w=o.isReverse?e:t,N=_e(v.nodeShape,a.defaultNodeShape),O=o.junctionOffset||a.defaultLineJunctionOffset||0;c-=O,d-=O,h-=O,f-=O,p+=O*2,u+=O*2,g+=O*2,m+=O*2;const b={from_x:c,from_y:d,to_x:h,to_y:f,f_W:p,f_H:u,t_W:g,t_H:m,nodeShape:N,isReverse:y,isEndPoint:!1,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||30},T=_e(w.nodeShape,a.defaultNodeShape),P={from_x:h,from_y:f,to_x:c,to_y:d,f_W:g,f_H:m,t_W:p,t_H:u,nodeShape:T,isReverse:y,isEndPoint:!0,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||50},S=a.defaultJunctionPoint||U.border;let k=o.fromJunctionPoint||S,R=o.toJunctionPoint||S,M=o.fromJunctionPointOffsetX||0,C=o.fromJunctionPointOffsetY||0,D=o.toJunctionPointOffsetX||0,X=o.toJunctionPointOffsetY||0;o.isReverse&&([k,R]=[R,k],[M,C,D,X]=[D,X,M,C]),(e===t||c===0&&h===0&&d===0&&f===0)&&M===0&&C===0&&D===0&&X===0&&((r===H.StandardStraight||r===H.Curve2||r===H.Curve3||r===H.SimpleOrthogonal||r===H.Curve5)&&(r=H.StandardCurve),X=20);const G=this._getJunctionPoint(k,b);G.x+=M,G.y+=C;const B=this._getJunctionPoint(R,P);if(B.x+=D,B.y+=X,!G||!B)throw this.throwLineError("E",-20,-20);const E=c+p/2,F=d+u/2,$=h+g/2,te=f+m/2;k==="horizontalLine"?(G.x=B.x,(r===44||r===49)&&(G.x+=(B.x>$?1:-1)*30)):k==="verticalLine"&&(G.y=B.y,(r===44||r===49)&&(G.y+=(B.y>te?1:-1)*30)),R==="horizontalLine"?(B.x=G.x,(r===44||r===49)&&(B.x+=(G.x>E?1:-1)*30)):R==="verticalLine"&&(B.y=G.y,(r===44||r===49)&&(B.y+=(G.y>F?1:-1)*30));const Q=G.x,oe=G.y,ie=B.x,ne=B.y;if(Number.isNaN(Q)||Number.isNaN(oe))throw L("error start point:",e.text),this.throwLineError("F",-10,0);if(Number.isNaN(ie)||Number.isNaN(ne))throw L("error end point:",t.text),this.throwLineError("G",10,0);return{line:o,totalLinesBetweenNodes:n,currentLineIndex:i,lineDirection:l==="v"?"v":"h",lineShape:r,lineRadius:a.lineRadius||0,fromJunctionPoint:k,toJunctionPoint:R,fx:Q,fy:oe,fcx:E,fcy:F,f_W:p,f_H:u,tx:ie,ty:ne,tcx:$,tcy:te,t_W:g,t_H:m}}createLinePathData(o){const{lineShape:e}=o;let t;return e===H.SimpleOrthogonal?t=wn(o,void 0,this._getLineDefaultOptions()):e===H.StandardOrthogonal?t=bn(o,void 0,this._getLineDefaultOptions()):e===H.HardOrthogonal?t=On(o,void 0,this._getLineDefaultOptions()):e===H.StandardCurve?t=Tn(o):e===H.Curve2||e===H.Curve3||e===H.Curve5||e===H.Curve7||e===H.Curve8?t=Pn(o):t=Ln(o),t}getArrowMarkerId(o,e=!1){let t=o.showStartArrow===!0,n=o.showEndArrow!==!1;if(o.isReverse&&([t,n]=[n,t]),e){if(!t)return;if(o.startMarkerId)return`url('#${o.startMarkerId}')`}else{if(!n)return;if(o.endMarkerId)return`url('#${o.endMarkerId}')`}return`url('#${this.getLineArrow(o.color,e,!1)}')`}getLineArrow(o,e=!1,t=!1){const n=e?"start-":"";return`${this.getOptions().instanceId}-${n}arrow-default`}getTextTransform(o,e){if(!o||!e)return"translate(0,0)";const{x:t,y:n,rotate:i}=e;if(Number.isNaN(t)||Number.isNaN(n))return"translate(0,0)";const a=this.getOptions(),r=o.textOffsetX||a.defaultLineTextOffsetX||0,l=o.textOffsetY||a.defaultLineTextOffsetY||0,c=o.lineShape||1;return c===H.StandardStraight||c===H.SimpleOrthogonal?`translate(-50%, -50%) translate(${t+r}px,${n+l}px) rotate(${i||0}deg)`:`translate(-50%, -50%) translate(${t+r}px,${n+l}px)`}generateLineTextStyle(o,e){const t=this.getOptions(),n={transform:"",transformOrigin:""};if(!o||!e)return{cssStyles:n};const{line:i}=o,{textPosition:a}=e;if(!i||!a)return{cssStyles:n};let r=i.text||"";r.length>t.lineTextMaxLength&&(r=r.substring(0,t.lineTextMaxLength||15)+"...");const{x:l,y:c,rotate:d}=a;if(Number.isNaN(l)||Number.isNaN(c))return{text:r,cssStyles:n};const h=[],f=i.textAnchor||"center";f==="start"?h.push("translate(0%, -50%)"):f==="end"?h.push("translate(-100%, -50%)"):h.push("translate(-50%, -50%)"),h.push(`translate(${l}px,${c}px)`);const p=i.textOffsetX||t.defaultLineTextOffsetX||0,u=i.textOffsetY||t.defaultLineTextOffsetY||0,g=i.lineShape||1;return(i.useTextOnPath||t.defaultLineTextOnPath)&&g===1&&d&&h.push(`rotate(${d||0}deg)`),g===H.StandardStraight?(n.transformOrigin="50% 50%",h.push(`translate(${p}px,${u}px)`)):h.push(`translate(${p}px,${u}px)`),n.transform=h.join(" "),{text:r,cssStyles:n}}generateLineTextStyle4TextOnPath(o){const{line:e,from:t,to:n}=o;let i=e.text;if(!i||!n||!t)return null;let a=0;const r=this.getOptions();i.length>r.lineTextMaxLength&&(i=i.substring(0,r.lineTextMaxLength||15)+"...");const l=e.textOffsetX||r.defaultLineTextOffsetX||0,c=e.textOffsetY||r.defaultLineTextOffsetY||0,d={x:l,y:c-6};let h="50%";e.placeText==="start"?(h="0%",d.x+=20):e.placeText==="end"?(h="100%",d.x-=20):e.placeText==="center"?h="50%":e.placeText&&(h=e.placeText);let f="middle";return e.textAnchor&&(f=e.textAnchor),{text:i,textOffset:d,textAnchor:f,onPathStartOffset:h,textRotate:a}}}class $n extends Wn{constructor(){super()}zoom(o,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions();try{const i=this.emitEvent(A.beforeZoomStart,n.canvasZoom,o,t);if(L("[zoom]","abortZoom:",i),i===!0)return;if(n.canvasZoom+o<n.minCanvasZoom){if(L("zoom:minCanvasZoom"),o=n.minCanvasZoom-n.canvasZoom,o===0)return}else if(n.canvasZoom+o>n.maxCanvasZoom&&(L("zoom:maxCanvasZoom"),o=n.maxCanvasZoom-n.canvasZoom,o===0))return;const a=o/100,r=this.getViewBoundingClientRect(),l=n.canvasZoom/100,c=Math.max(.01,Math.min(10,l+a));e||(e={x:r.x+r.width/2,y:r.y+r.height/2});const d=e.x-r.left,h=e.y-r.top,f=d-(d-n.canvasOffset.x)*(c/l),p=h-(h-n.canvasOffset.y)*(c/l),u=n.canvasZoom,g=c*100;this._performanceModeLogicHook(u,g),this.dataProvider.updateOptions({canvasOffset:{x:f,y:p},canvasZoom:g}),this.emitEvent(A.onZoomEnd,g,u)}finally{this._updateEditingControllerView(),this._dataUpdated()}}_performanceModeLogicHook(o,e){const t=this.getOptions();o<=40?e>40&&(t.performanceMode&&this.updateShouldRenderGraphData(!0),this.dataProvider.updateOptions({showEasyView:!1}),L("zoom:hide:showEasyView",o,e),this.updateElementLines()):o>40&&e<=40&&(L("zoom:show:showEasyView",o,e),t.performanceMode&&this.dataProvider.updateOptions({showEasyView:!0}))}setZoom(o,e){const t=this.getOptions(),n=Math.round(o-t.canvasZoom);this.zoom(n,e)}}class Un extends $n{constructor(){super()}fitContentHeight(o=20){this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated();const e=this.getOptions(),t=this.getNodesRectBox(),n=t.height,i=t.width,a=e.viewSize.width-o*2,r=t.minX+t.width/2,l=t.minY+t.height/2;console.warn("[fitContentHeight]nodesCenter:",r,l),this.dataProvider.setCanvasCenter(r,l);const c=Math.min(1,a/i),d=n*c+o*2;this.dataProvider.updateOptions({viewSize:{...e.viewSize,height:d},viewHeight:d+"px"}),setTimeout(()=>{this.setZoom(c*100),this._moveToCenter(),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()},200)}_moveToCenter(o){const e=this.getNodesCenter(o);this.dataProvider.setCanvasCenter(e.x,e.y),this._dataUpdated()}setCanvasCenter(o,e){this.dataProvider.setCanvasCenter(o,e),this._dataUpdated()}zoomToFit(o){const e=this.getOptions(),t=this.getCanvasSlotRectItems();console.error("rectItems:",t);const n=t.length>0?[...t,...o||this.getNodes()]:o,i=this.getNodesRectBox(n),a=50,r=e.viewSize.width/(i.width+a*2),l=e.viewSize.height/(i.height+a*2),c=Math.min(r,l,1);L("zoomToFit:",{stuffSize:i,zoomPercent:c,zoomPercentX:r,zoomPercentY:l,viewSize:e.viewSize}),this._moveToCenter(n),this.setZoom(c*100),this._dataUpdated()}enableNodeXYAnimation(){this.dataProvider.updateOptions({enableNodeXYAnimation:!0}),this._dataUpdated()}disableNodeXYAnimation(){this.dataProvider.updateOptions({enableNodeXYAnimation:!1}),this._dataUpdated()}enableCanvasAnimation(){this.dataProvider.updateOptions({enableCanvasTransformAnimation:!0}),this._dataUpdated()}disableCanvasAnimation(){this.dataProvider.updateOptions({enableCanvasTransformAnimation:!1}),this._dataUpdated()}focusNodeById(o){const e=this.getNodeById(o);e&&this.focusNode(e)}focusRootNode(){throw new Error("focusRootNode is deprecated, please use focusNodeById instead.")}focusNode(o){L("checked:",o);const e=this.getOptions();this.setZoom(100);const t=o.width||50,n=o.height||50,i=o.x*-1+e.viewSize.width/2-t/2,a=o.y*-1+e.viewSize.height/2-n/2;this.dataProvider.setCanvasOffset(i,a),this.dataProvider.updateOptions({checkedNodeId:o.id})}}class qn extends ue{constructor(e,t,n){super(e,t,n);_(this,"rotate",0);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,L("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;console.log("this.layoutOptions.alignItemsX:1:",this.layoutOptions.alignItemsX),i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="start"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const a=this.layoutOptions.layoutExpansionDirection,r=a==="start"||a==="left"||a==="top"?"start":a==="end"||a==="right"||a==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.treeNodeGapH<100&&(this.layoutOptions.treeNodeGapH=100),this.layoutOptions.treeNodeGapV<10&&(this.layoutOptions.treeNodeGapV=10),(this.layoutOptions.from==="bottom"||this.layoutOptions.from==="right")&&(this.rotate=180),this.layoutOptions.changeNodeSizeDuringLayout===void 0&&(this.layoutOptions.changeNodeSizeDuringLayout=!1)}placeNodes(e,t){if(console.log("tree:placeNodes:rootNode",t.id,t),L("RGTreeLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}L("allNodes:",e.length),this.layoutOptions.alignItemsX,this.layoutOptions.alignItemsY,this.layoutOptions.alignParentItemsX,this.layoutOptions.alignParentItemsY,this.rootNode=t,this.allNodes=e,t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0),t.lot.x=t.x,t.lot.y=t.y;const n=e;L("groupNodes:2:",n.length,n.map(r=>r.text).join(","));const i=this.rotate;console.log("rotate:",i),this.networkAnalyzer.analyzeNetwork(n,this.rootNode,!1),this.placeNodesPosition(t,n);const a={x:t.x,y:t.y};this.allNodes.forEach(r=>{if(r.fixed!==!0&&!!z.isVisibleNode(r)&&(Number.isNaN(r.lot.x)&&(L("bad lot x:",r.text,r.lot.x),r.lot.x=0),Number.isNaN(r.lot.y)&&(L("bad lot y:",r.text,r.lot.y),r.lot.y=0),r!==t)){this.layoutOptions.from==="right"&&(r.lot.x=q.getFlippedX(r.lot.x,a.x)),this.layoutOptions.from==="bottom"&&(r.lot.y=q.getFlippedY(r.lot.y,a.y));const l=this.layoutOptions.from==="right"?z.getNodeXByLotX({alignItemsX:"end"},r):r.lot.x,c=this.layoutOptions.from==="bottom"?z.getNodeYByLotY({alignItemsY:"end"},r):r.lot.y;this.updateNodePosition(r,l,c)}});for(const r of this.allNodes)this.graphInstance.updateNode(r,{rgChildrenSize:r.lot.childs.length});L("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t){this.placeRelativePosition(e,t)}placeRelativePosition(e,t){e.lot.parent=void 0,e.lot.level=0;const n=[];this.buildNetwork([e],n,0);const i=Math.max(...n.map(c=>c.lot.level)),a=this.layoutOptions.from==="left"||this.layoutOptions.from==="right";this.reduceNodeRect(n,i,a),a?this.placeNodeChildrenH(n,0):this.placeNodeChildrenV(n,0);let r=e.lot.x-e.x,l=e.lot.y-e.y;this.layoutOptions.from==="right"&&(r+=e.lot.width),this.layoutOptions.from==="bottom"&&(l+=e.lot.height),n.forEach(c=>{c.fixed!==!0&&(c.lot.x-=r,c.lot.y-=l)}),console.log("levelMaxWidthMap:",e.id)}buildNetwork(e,t,n){n===0&&t.push(...e);const i=[];e.forEach(a=>{if(!z.isVisibleNode(a))return;const r=this.graphInstance.getNodeIncomingNodes(a).filter(z.isVisibleNode),c=this.graphInstance.getNodeOutgoingNodes(a).filter(z.isVisibleNode).filter(h=>!t.includes(h));t.push(...c);const d=r.filter(h=>!t.includes(h));t.push(...d),a.lot.level=n,a.lot.toNodes=c,a.lot.fromNodes=d;for(const h of d.concat(c))h.lot.parent=a,i.includes(h)||i.push(h)}),i.length>0&&this.buildNetwork(i,t,n+1)}reduceNodeRect(e,t,n=!1){let i=this.layoutOptions.treeNodeGapH,a=this.layoutOptions.treeNodeGapV;const r=i,l=a,c=e.filter(d=>d.lot.level===t);console.log("reduceNodeRect:level:",t,c.length);for(const d of c){if(!z.isVisibleNode(d))continue;let h=d.width||d.el_W||50,f=d.height||d.el_H||50;if(d.lot.width=h,d.lot.height=f,d.lot.toNodes.length===0&&d.lot.fromNodes.length===0)d.lot.width_with_childs=h,d.lot.height_with_childs=f;else if(n){let p=0,u=0;for(const y of d.lot.fromNodes)y.lot.height_with_childs>u&&(u=y.lot.height_with_childs),p+=y.lot.width_with_childs+l;let g=0,m=0;for(const y of d.lot.toNodes)y.lot.height_with_childs>m&&(m=y.lot.height_with_childs),g+=y.lot.width_with_childs+l;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),f=Math.max(u+r/2,f/2)+Math.max(m+r/2,f/2),d.lot.width_with_childs=h+Math.max(p,g)+l,d.lot.height_with_childs=f}else{let p=0,u=0;for(const y of d.lot.fromNodes)y.lot.width_with_childs>p&&(p=y.lot.width_with_childs),u+=y.lot.height_with_childs+l;let g=0,m=0;for(const y of d.lot.toNodes)y.lot.width_with_childs>g&&(g=y.lot.width_with_childs),m+=y.lot.height_with_childs+l;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),h=Math.max(p+r/2,h/2)+Math.max(g+r/2,h/2),d.lot.width_with_childs=h,d.lot.height_with_childs=f+Math.max(u,m)+l}}t>=0&&this.reduceNodeRect(e,t-1,n)}placeNodeChildrenV(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let l=0;const c=e.filter(d=>d.lot.level===t);console.log("placeNodeChildren:level:",t,c.length);for(const d of c){l++;let h=d.lot.width;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),t===0&&(d.lot.groupStartX=d.lot.x+h/2-d.lot.width_with_childs/2);const f=d.lot.groupStartX,p=d.lot.y;let u=0,g=0;for(const y of d.lot.fromNodes)y.lot.width_with_childs>u&&(u=y.lot.width_with_childs);for(const y of d.lot.toNodes)y.lot.width_with_childs>g&&(g=y.lot.width_with_childs);const m=f+Math.max(u+a/2,h/2);if(d.lot.fromNodes.length>0){let y=d.lot.height+r;for(const v of d.lot.fromNodes)v.lot.groupStartX=m-v.lot.width_with_childs-a/2,v.lot.y=p+y+r,y+=v.lot.height_with_childs+r}if(d.lot.toNodes.length>0){let y=d.lot.height+r;for(const v of d.lot.toNodes)v.lot.groupStartX=m+a/2,v.lot.y=p+y+r,y+=v.lot.height_with_childs+r}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(d.lot.x=f,d.width=d.lot.width_with_childs):d.lot.x=m-d.lot.width/2:d.lot.x=f}l>0&&this.placeNodeChildrenV(e,t+1)}placeNodeChildrenH(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let l=0;const c=e.filter(d=>d.lot.level===t);console.log("placeNodeChildren:level:",t,c.length);for(const d of c){l++;let h=d.lot.height;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),t===0&&(d.lot.groupStartY=d.lot.y+h/2-d.lot.height_with_childs/2);const f=d.lot.groupStartY,p=d.lot.x;let u=0,g=0;for(const y of d.lot.fromNodes)y.lot.height_with_childs>u&&(u=y.lot.height_with_childs);for(const y of d.lot.toNodes)y.lot.height_with_childs>g&&(g=y.lot.height_with_childs);const m=f+Math.max(u+a/2,h/2);if(d.lot.fromNodes.length>0){let y=d.lot.width+r;for(const v of d.lot.fromNodes)v.lot.groupStartY=m-v.lot.height_with_childs-a/2,v.lot.x=p+y+r,y+=v.lot.width_with_childs+r}if(d.lot.toNodes.length>0){let y=d.lot.width+r;for(const v of d.lot.toNodes)v.lot.groupStartY=m+a/2,v.lot.x=p+y+r,y+=v.lot.width_with_childs+r}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(d.lot.y=f,d.height=d.lot.height_with_childs):d.lot.y=m-d.lot.height/2:d.lot.y=f}l>0&&this.placeNodeChildrenH(e,t+1)}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return i}else{let i=0;for(let a=0;a>e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return-i}}getLevelGap(e,t,n,i){let a=t+(i===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(a=r)}return a}}class Jn extends Un{constructor(){super();_(this,"_layoutTimer",null);_(this,"_layoutPromise",null);_(this,"_layoutResolve",null);_(this,"layoutor")}async doLayout(e){const t=Date.now()-this.prevAddNodeTimestamp;return t<300&&(this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated(),await Xe(300-t)),this._layoutPromise||(this._layoutPromise=new Promise(n=>{this._layoutResolve=n})),clearTimeout(this._layoutTimer),this._layoutTimer=setTimeout(async()=>{var n;try{await this._doLayout(e),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()}finally{(n=this._layoutResolve)==null||n.call(this),this._layoutResolve=null,this._layoutPromise=null}},50),this._layoutPromise}async _doLayout(e){this.updateNodesVisibleProperty();const t=this.getNodes();L("node size\uFF1A",t.length);let n=this.dataProvider.getRootNode();if(e&&(n=typeof e=="string"?this.getNodeById(e):e),n||(n=t[0],this._rgAsConnectArea||(L("[relation-graph]No root node, use first node as root:",n),L("[relation-graph]You can set rootNode call doLayout(rootNode | nodeId) with a node id"))),!n)throw new Error("custom rootNode not found, id:"+e);const i=this.getOptions();this.dataProvider.setRootNodeId(n?n.id:""),this.stopAutoLayout();const a=this.createLayout(i.layout,!0);if(a.layoutOptions.layoutName==="force")a.isMainLayouer=!0,a.onFinish(()=>{this.emitEvent(A.onForceLayoutFinish)}),await Xe(100),L("doLayout:start force:",t.length),a.placeNodes(t,n);else{this.enableNodeXYAnimation();let r=[];n&&(r=this.getNetworkNodesByNode(n),a.placeNodes(r,n)),L("doLayout:placeOtherNodes:all:",t.length,"mainGroupNodes:",r.length),this.placeOtherNodes(r),setTimeout(()=>{this.disableNodeXYAnimation()},300),L("doLayout:placeOtherNodes ok!")}t.forEach(r=>this.dataProvider.updateNode(r.id,{x:r.x||0,y:r.y||0,rgChildrenSize:r.rgChildrenSize||0})),this.updateElementLines()}async refresh(e=!0){this.resetViewSize(!0),this._dataUpdated(),e&&await this.doLayout(),this.updateElementLines(),this._dataUpdated()}placeOtherNodes(e=[]){const t=this.getOptions();if(t.layout.layoutName==="fixed"||!t.placeOtherGroup)return;const i=[],a=[],r=this.getNodes();r.forEach(c=>{if(c.fixed===!0||e.includes(c))return;this.getNodeRelatedNodes(c).length===0?a.push(c):i.push(c)}),L("doLayout:allNodes:",r.length),L("doLayout:mainGroupNodes:",e.length),L("doLayout:notInMainGroupNodes:",i.length),L("doLayout:singleNodes:",a.length);const l=[{nodes:e}];this.placeNextNetwork(i,[...e],l),this.placeSingleNodes(a),l.push({nodes:a}),this.sortGroups(l),this._dataUpdated()}placeSingleNodes(e){if(e.length>0){const t=Math.ceil(Math.sqrt(e.length));Je(t,30,e.map(i=>({width:i.el_W,height:i.el_H,node:i})),(i,a,r)=>{const l=i.node;l.x=a,l.y=r,l.lot||(l.lot={childs:[]})}),L("[placeSingleNodes]Single nodes:",e.length)}}sortGroups(e){L("[placeSingleNodes]sortGroups groupList:",e.length,e.map(a=>a.nodes.length));const t=e.map(a=>{const r=this.getNodesRectBox(a.nodes);return{width:r.width,height:r.height,nodes:a.nodes,orignX:r.minX,orignY:r.minY}});if(t.length===0)return;const n=Math.floor(Math.sqrt(t.length))||1;Je(n,100,t,(a,r,l)=>{const c=r-a.orignX,d=l-a.orignY;L(`[placeNextNetwork]Move ${a.nodes.length} Nodes :`,c,d,a," > ");for(const h of a.nodes)this.updateNodePosition(h,h.x+c,h.y+d)},t[0].orignX,t[0].orignY)}placeNextNetwork(e,t,n){if(e.length>0){const i=this.getOptions();L("[placeNextNetwork]notPlacedNodes nodes:",e.length);const a=JSON.parse(JSON.stringify(i.layout)),r=e[0],l=this.createLayout(a);if(l.isMainLayouer=!1,L("[placeNextNetwork]layoutName:",l.layoutOptions.layoutName,"root:",r.text),l.layoutOptions.layoutName==="force"){const h=l;h.maxLayoutTimes=0}r.fixed?L("[placeNextNetwork]fixed root x,y:",r.x,r.y,r.text):(this.updateNodePosition(r,0,0),L("[placeNextNetwork]set root x,y:",r.x,r.y,r.text)),l.layoutOptions.fixedRootNode=!0;const c=this.getNetworkNodesByNode(r);L("[placeNextNetwork]thisNetworkNodes:",e.length),l.placeNodes(c,r),t.push(...c),n.push({nodes:c});const d=[];e.forEach(h=>{t.includes(h)||d.push(h)}),i.placeOtherGroup&&this.placeNextNetwork(d,t,n),this._dataUpdated()}else L("[placeOtherGroup]thisGroupNodes:all is OK!")}toggleAutoLayout(){const e=this.getOptions();L("toggleAutoLayout:to:",e.layout.autoLayouting),e.layout.autoLayouting?this.stopAutoLayout():this.startAutoLayout()}startAutoLayout(){var e;(e=this.layoutor)!=null&&e.start&&(L("Start force layout:"+this.layoutor.instanceId),this.layoutor.start())}stopAutoLayout(){var e;(e=this.layoutor)!=null&&e.stop&&(L("Stop force layout:"+this.layoutor.instanceId),this.layoutor.stop())}createLayout(e,t=!1){L("########createLayout:",e);const n=this.getOptions();je(e);let i=null;if(e.layoutName==="tree"?i=new Ct(e,n,this):e.layoutName==="center"?i=new Lt(e,n,this):e.layoutName==="circle"?i=new wt(e,n,this):e.layoutName==="force"?i=new Te(e,n,this):e.layoutName==="fixed"?i=new _t(e,n,this):e.layoutName==="smart-tree"?i=new xn(e,n,this):e.layoutName==="io-tree"?i=new qn(e,n,this):e.layoutName==="folder"&&(i=new Nt(e,n,this)),!i)throw new Error("unknown layout: "+e.layoutName);return L("########supportAutoLayout:",i.autoLayout!==void 0,e.disableAsForceLayout),this.setLayoutor(i,t,i.autoLayout!==void 0&&e.disableAsForceLayout!==!0),i}setLayoutor(e,t,n=!1){e.isMainLayouer=t,e.layoutOptions.fixedRootNode=!0,t&&(this.layoutor=e,this._updateOptions({layout:{supportAutoLayout:n}}))}}const Zn=async(s,o)=>{const e=s||document.documentElement;o?await Qn(e):await Kn()},Qn=async s=>{s.requestFullscreen?await s.requestFullscreen():s.mozRequestFullScreen?await s.mozRequestFullScreen():s.webkitRequestFullscreen?await s.webkitRequestFullscreen():s.msRequestFullscreen&&await s.msRequestFullscreen()},Kn=async()=>{document.exitFullscreen?await document.exitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()};class ei extends Jn{constructor(){super();_(this,"_prevClickNodeTime",0);_(this,"_nodeXYMappingBeforeDrag",{});_(this,"canvasAutoMoving",e=>{const t=this.getOptions(),n=t.viewSize,i=40;let a=0,r=0;e.x<i?a=i-e.x:n.width-i<e.x&&(a=n.width-i-e.x),e.y<i?r=i-e.y:n.height-i<e.y&&(r=n.height-i-e.y);const l=a!==0||r!==0;l&&(a=Math.max(Math.min(a/5,30),-30),r=Math.max(Math.min(r/5,30),-30));const c=t.canvasOffset.x+a,d=t.canvasOffset.y+r;return this.onCanvasDragging(c,d,a,r),l});_(this,"_canvasMovingTimer");_(this,"_relayoutTaskTimer");_(this,"_onMovingWhenCreatingLine");_(this,"_step1EventTime",0);_(this,"_onCreateLineCallback");_(this,"_mouseWheelTimer");_(this,"_mouseWheelEventPrevApplyTime",0);_(this,"_mouseWheelForce",{x:0,y:0});_(this,"_fullscreenchangeHandler")}onNodeClick(e,t){if(Date.now()-this._prevClickNodeTime<200){L("[node]click abort : time < 200");return}this._prevClickNodeTime=Date.now();const n=this.getOptions();if(n.creatingLinePlot){this.onNodeClickWhenCreatingLinePlot(e);return}const i=e.disablePointEvent===void 0?n.disableNodePointEvent:e.disablePointEvent;L("[node]node click",e.text,n.creatingLinePlot,i),!t.shiftKey&&!i&&(n.checkedLineId="",this.dataProvider.updateOptions({checkedLineId:"",checkedNodeId:e.id})),this.emitEvent(A.onNodeClick,e,t),this._prevClickNodeTime=Date.now()}onNodeDragStart(e,t){if(!e||we(t))return;const n=this.getOptions();if((e.disableDrag||n.disableDragNode)&&!(t.target&&t.target.closest(".rg-node-drag-handler"))){const g=m=>{this.onNodeClick(e,m),document.body.removeEventListener("mouseup",g)};document.body.addEventListener("mouseup",g);return}isNaN(e.x)&&(e.x=0),isNaN(e.y)&&(e.y=0),this.dataProvider.setEditingLine(null),this.dataProvider.updateOptions({checkedLineId:""});let a=!1;const r=(u,g,m)=>{m.stopPropagation(),a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.dataProvider.updateOptions({draggingNodeId:"",editingReferenceLine:{...n.editingReferenceLine,show:!1}}),this._onNodeDragEnd(e,u,g,m),d?this.emitEvent(A.onNodeDragEnd,e,m,u,g):this.onNodeClick(e,t),this._dataUpdated()};this._nodeXYMappingBeforeDrag={},this._nodeXYMappingBeforeDrag[e.id]={x:e.x,y:e.y};for(const u of n.editingController.nodes)this._nodeXYMappingBeforeDrag[u.id]={x:u.x,y:u.y};const l=this.getCanvasXyByViewXy(this.getViewXyByEvent(t)),c={x:e.x,y:e.y};let d=!1;this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer);let h;const f=()=>{if(!h||a)return;const u=this.getViewXyByEvent(h),g=this.getCanvasXyByViewXy(u),m=g.x-l.x,y=g.y-l.y;let v=m+c.x,w=y+c.y,N=v-c.x,O=w-c.y;const b=this.emitEvent(A.onNodeDragging,e,v,w,N,O,h);b&&(typeof b.x=="number"&&(v=b.x,N=v-c.x),typeof b.y=="number"&&(w=b.y,O=w-c.y)),this.canvasAutoMoving(u),this.draggingSelectedNodes(e,v,w,N,O),this._dataUpdated()},p=()=>{f(),this._canvasMovingTimer=requestAnimationFrame(p)};Z.startDrag(t,c,r,(u,g,m,y,v)=>{d?h=v:Math.abs(u)+Math.abs(g)>4&&(L("[node]onNodeDragStart...",ce(h),h),this.emitEvent(A.onNodeDragStart,e,h),d=!0,this.dataProvider.updateOptions({draggingNodeId:e.id}),this._canvasMovingTimer=requestAnimationFrame(p)),this.updateElementLines(),this._dataUpdated()})}_onNodeDragEnd(e,t,n,i){this.updateElementLines()}onLineClick(e,t){const n=this.getLinkByLineId(e.id);L("onLineClick:","line:",e,"link:",n);const i=this.getOptions();(e.disablePointEvent===void 0?i.disableLinePointEvent:e.disablePointEvent)||(this.setCheckedNode(""),this.setCheckedLine(e)),this.emitEvent(A.onLineClick,e,n,t),this._dataUpdated()}expandOrCollapseNode(e,t){t.stopPropagation(),e.expanded===!1?this.expandNode(e,t):this.collapseNode(e,t)}expandNode(e,t){L("onNodeExpand:",e),this.dataProvider.updateNode(e.id,{expanded:!0}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(A.onNodeExpand,e,t)}collapseNode(e,t){L("onNodeCollapse:",e),this.dataProvider.updateNode(e.id,{expanded:!1}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(A.onNodeCollapse,e,t)}_effectWhenExpandedOrCollapsed(e){const t=this.getDescendantNodes(e);this.updateNodesVisibleProperty([e].concat(t)),this._relayoutTaskTimer&&clearTimeout(this._relayoutTaskTimer),this._relayoutTaskTimer=setTimeout(()=>{this.updateElementLines(),this._dataUpdated();const n=this.getOptions();n.reLayoutWhenExpandedOrCollapsed&&(n.layout.layoutName==="force"?this.startAutoLayout():this.doLayout())},100)}onCanvasDragEnd(e){this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated(),this.emitEvent(A.onCanvasDragEnd,e)}onCanvasClick(e){if(this.getOptions().creatingLinePlot)this.onCanvasClickWhenCreatingLinePlot(e);else{if(this.dataProvider.isPerformanceMode()){const n=this.getNodeAtEvent(e);if(n){this.emitEvent(A.onNodeClick,n,e);return}}this.emitEvent(A.onCanvasClick,e)}}getNodeAtEvent(e){const t=this.getCanvasXyByClientXy(e);return this.dataProvider.findNodeByXy(t)}onCanvasSelectionEnd(e,t){this.emitEvent(A.onCanvasSelectionEnd,e,t),L("[canvas]onCanvasSelectionEnd:",e),this._dataUpdated()}startCreatingNodePlot(e,t){if(!t)throw new Error("startCreatingNodePlot need setting param");if(!t.onCreateNode)throw new Error("startCreatingNodePlot need setting.onCreateNode param as callback");const n=be(JSON.parse(JSON.stringify(Ye)),this.getOptions()),i=ce(e);this.dataProvider.updateOptions({newNodeTemplate:Object.assign({},n,t.templateNode),creatingNodePlot:!0,showTemplateNode:!i});let a=(u,g)=>{const m=this.getOptions().newNodeTemplate,y={width:m.width||50,height:m.height||50};this.dataProvider.updateOptions({newNodeTemplate:{...m,x:u-y.width/2,y:g-y.height/2}}),this._dataUpdated()};const r=this.getViewBoundingClientRect();L("[CreatingNodePlot]startCreatingNodePlot:");const l=Ce(e),c=l.clientX-r.x+10,d=l.clientY-r.y+10;i||a(c,d);const h=u=>{L("[CreatingNodePlot]objectTemplateMove");const g=this.getViewXyByEvent(u);t.templateMove&&t.templateMove(g.x,g.y),a(g.x,g.y)},f=u=>{L("[CreatingNodePlot]user abort!"),this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("click",p),this.$dom.removeEventListener("contextmenu",f),this.dataProvider.updateOptions({creatingNodePlot:!1})},p=u=>{let g=!1;if(this.getOptions().creatingNodePlot||(g=!0),this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("click",p),this.$dom.removeEventListener("contextmenu",f),this.dataProvider.updateOptions({creatingNodePlot:!1}),g){L("[CreatingNodePlot]action be abort!");return}const m=Ce(u),y=m.clientX-r.x+10,v=m.clientY-r.y+10;if(Math.abs(c-y)<30&&Math.abs(d-v)<30){L("[CreatingNodePlot]create node be abort!");return}const w=this.getCanvasXyByClientXy({x:m.clientX,y:m.clientY});L("[CreatingNodePlot]objectBePlaced:",w),t.onCreateNode(w.x,w.y,this.getOptions().newNodeTemplate),this._dataUpdated()};setTimeout(()=>{this.$dom.addEventListener("click",p),this.$dom.addEventListener("contextmenu",f)},300),i||this.$dom.addEventListener("mousemove",h)}startCreatingLinePlot(e,t){const n=ce(e);t&&t.onCreateLine&&(this._onCreateLineCallback=t.onCreateLine);const i=he({from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:"new line"},this.getOptions());t&&t.template&&Object.assign(i,t.template),this.dataProvider.updateOptions({newLineTemplate:Object.assign(i,{isReverse:t.isReverse||!1})}),this.dataProvider.updateOptions({newLineTemplate:Object.assign(i,{isReverse:t.isReverse||!1,disablePointEvent:!0}),creatingLinePlot:!0});const a=Object.assign({},this.getOptions().newLinkTemplate,{fromNode:null,toNode:{id:"",targetType:V.Node,x:0,y:0,el_W:2,el_H:2},toNodeObject:null});t&&t.fromNode&&(a.toNode.x=t.fromNode.x+50,a.toNode.y=t.fromNode.y+50,a.fromNode=t.fromNode,this._step1EventTime=Date.now()),this.dataProvider.updateOptions({newLinkTemplate:a}),L("[CreatingLinePlot]startCreatingLinePlot:isTouchEvent:",n),n||(L("[CreatingLinePlot]Listener move"),this._onMovingWhenCreatingLine&&this.$dom.removeEventListener("mousemove",this._onMovingWhenCreatingLine),this._onMovingWhenCreatingLine=this.onMovingWhenCreatingLinePlot.bind(this),this.$dom.addEventListener("mousemove",this._onMovingWhenCreatingLine)),this._dataUpdated()}stopCreatingLinePlot(){L("[CreatingLinePlot]stop CreatingLinePlot!"),this.dataProvider.updateOptions({creatingLinePlot:!1,newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:null,toNodeObject:null},nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}),this._onCreateLineCallback=void 0,this.$dom.removeEventListener("mousemove",this._onMovingWhenCreatingLine),this._onMovingWhenCreatingLine=void 0,this._dataUpdated()}onMovingWhenCreatingLinePlot(e){L("[CreatingLinePlot]mousemove");const t=this.getCanvasXyByClientXy({x:e.clientX,y:e.clientY}),n=this.getOptions(),i=e.target;let a="",r=V.Node;const l=this.isNode(i);let c=!1,d={x:0,y:0,el_W:5,el_H:5,nodeShape:0};l&&(a=l.id,l===this.getOptions().newLinkTemplate.fromNode?this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}):(this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:l,show:!0}}),this._updateEditingConnectControllerView()));const h=i.closest(".rg-connect-ctl-handler");if(h){let f=this.getOptions().nodeConnectController.node;L("[CreatingLinePlot]content point:",h.dataset.point);let p=h.dataset.point||"border";if(h.classList.contains("rg-connect-target")){const{width:u,height:g,x:m,y}=h.getBoundingClientRect(),v=this.getCanvasXyByClientXy({x:m,y}),w=this.dataProvider.getCanvasScale(),N={x:v.x,y:v.y,el_W:u/w,el_H:g/w,nodeShape:1,id:h.dataset.targetId,targetData:JSON.parse(h.dataset.targetData||"{}"),targetType:h.dataset.targetType};c=!0,d.x=N.x,d.y=N.y,d.el_W=N.el_W,d.el_H=N.el_H,d.nodeShape=N.nodeShape,console.log("[CreatingLinePlot]fakeNode:",JSON.stringify(N)),this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:N,show:!1}}),p=h.dataset.point,n.newLinkTemplate.toNode&&(a=N.id,r=N.targetType,this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,nodeShape:N.nodeShape}}})),this._updateEditingConnectControllerView()}else f&&(r=V.Node,c=!0,d.x=f.x,d.y=f.y,d.el_W=f.el_W,d.el_H=f.el_H,d.nodeShape=f.nodeShape,i.dataset.innode==="true"&&(d.x=t.x,d.y=t.y,d.el_W=2,d.el_H=2,d.nodeShape=1));n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:p}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:p}})}else L("[CreatingLinePlot]point:",i.dataset.point),n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:U.border}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:U.border}}),n.newLinkTemplate.toNode&&(r=V.Node);n.newLinkTemplate.toNode&&(a&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,id:a}}}),this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,targetType:r}}})),n.newLinkTemplate.fromNode&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,x:c?d.x:t.x,y:c?d.y:t.y,el_W:d.el_W,el_H:d.el_H,nodeShape:d.nodeShape}}}),this._dataUpdated()}onCanvasClickWhenCreatingLinePlot(e){if(Date.now()-this._step1EventTime<500){L("[CreatingLinePlot]step1EventTime:",this._step1EventTime);return}const t=this.getOptions();if(!t.newLinkTemplate.fromNode){L("[CreatingLinePlot]CreatingLinePlot:fromNode not set!");return}let n=!1;if(!t.newLinkTemplate.toNodeObject){L("[CreatingLinePlot]CreatingLinePlot:toNodeObject not set!");const i=Ce(e),a=this.getCanvasXyByClientXy({x:i.clientX,y:i.clientY});n=this.onReadyToCreateLine(t.newLinkTemplate.fromNode,a)}n!==!0&&this.stopCreatingLinePlot()}onNodeClickWhenCreatingLinePlot(e){const t=this.getOptions();t.newLinkTemplate.fromNode?(L("[CreatingLinePlot]step 2: set toNodeObjecct:",t.newLinkTemplate.fromNode,e),this.dataProvider.updateOptions({newLinkTemplate:{...t.newLinkTemplate,toNodeObject:e}}),this.onReadyToCreateLine(t.newLinkTemplate.fromNode,e)!==!0&&this.stopCreatingLinePlot()):(L("[CreatingLinePlot]step 1: set fromNode:",e),this.dataProvider.updateOptions({newLinkTemplate:{...t.newLinkTemplate,fromNode:e,toNode:{...t.newLinkTemplate.toNode,x:e.x+50,y:e.y+50}}}),this._step1EventTime=Date.now())}onReadyToCreateLine(e,t){L("[CreatingLinePlot][fire-event]onCreateLine:",e,t);const n=this.getOptions(),i=he(n.newLineTemplate,this.getOptions());n.newLineTemplate.isReverse?(i.from=t?t.id:"",i.to=e?e.id:"",i.isReverse=void 0,[e,t]=[t,e]):(i.from=e?e.id:"",i.to=t?t.id:""),i.disablePointEvent=!1;const a=this.emitEvent(A.beforeCreateLine,{lineJson:i,fromNode:e,toNode:t});if(L("[CreatingLinePlot]onCreateLine:abort-flag:",a),a===!0){L("[CreatingLinePlot]onCreateLine:abort!");return}if(this._onCreateLineCallback){L("[CreatingLinePlot]onCreateLine:callback");try{this._onCreateLineCallback(e,t,i)}catch(l){return console.warn("[Custom Reject Connect By Throw Error:",l),!1}}return L("[CreatingLinePlot]onCreateLine:emitEvent"),this.emitEvent(A.onLineBeCreated,{lineJson:i,fromNode:e,toNode:t})}onContextmenu(e){e.stopPropagation(),e.preventDefault(),this.stopCreatingLinePlot();let t="canvas",n=this.isNode(e.target);n?t="node":(n=this.isLine(e.target),n&&(t="line")),L("contextmenu:objectType",t,n);const i=Ce(e),a=this.getCanvasXyByClientXy({x:i.clientX,y:i.clientY}),r=this.getViewXyByCanvasXy(a);this.emitEvent(A.onContextmenu,e,t,n,a,r)}async fullscreen(e){const t=this.getOptions();if(e!==void 0&&e===t.fullscreen)return;L("fullscreen:newValue:",e),console.log("fullscreen:newValue:",e),e===void 0&&(e=!t.fullscreen);let n=this.$dom;t.fullscreenElementXPath&&(n=document.querySelector(t.fullscreenElementXPath)||this.$dom),await Zn(n,e),this.dataProvider.updateOptions({fullscreen:e}),this.emitEvent(A.onFullscreen,e),this._dataUpdated()}onMouseWheel(e){const t=this.getOptions();if(!e.ctrlKey&&!e.metaKey&&(t.disableWheelEvent||t.wheelEventAction==="none"))return!0;try{e.preventDefault(),e.stopPropagation()}catch{}let{deltaX:n,deltaY:i,deltaMode:a}=e;a===1?(n*=40,i*=40):a===2&&(n*=800,i*=800),this._mouseWheelForce.x+=n,this._mouseWheelForce.y+=i,this._applyWheelEvent(e)}_applyWheelEvent(e){clearTimeout(this._mouseWheelTimer),this._mouseWheelTimer=setTimeout(()=>{const t=this._mouseWheelForce.x,n=this._mouseWheelForce.y;this._onMouseWheel(e,t,n),this._mouseWheelForce.x-=t,this._mouseWheelForce.y-=n,this._mouseWheelEventPrevApplyTime=Date.now(),(Math.abs(this._mouseWheelForce.x)>1||Math.abs(this._mouseWheelForce.y)>1)&&this._applyWheelEvent(e)},Date.now()-this._mouseWheelEventPrevApplyTime>50?0:50)}_onMouseWheel(e,t,n){const i=e.ctrlKey||e.metaKey,a=this.getOptions();if(!i&&a.wheelEventAction==="scroll"){let r=Math.max(Math.abs(t),Math.abs(n));const l=t/r,c=n/r;r>200&&(r=200);const d=a.mouseWheelSpeed/10*-l*r,h=a.mouseWheelSpeed/10*-c*r,f=this.emitEvent(A.beforeScrollStart,d,h,e);if(L("[scroll]","abortScroll:",f),f===!0)return;this.scrollView(d,h)}else if(!(!i&&a.wheelEventAction==="none")){const r={x:e.clientX,y:e.clientY};let l=a.mouseWheelSpeed/20*-n;l=Math.max(Math.min(l,20),-20),this.zoom(l,r,e)}}scrollView(e,t){const n=this.getOptions();this.dataProvider.setCanvasOffset(n.canvasOffset.x+e,n.canvasOffset.y+t),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}onLineDragStart(e,t){L("onLineDragStart...");const n=this.getLinkByLine(e),i={x:n.fromNode.x,y:n.fromNode.y},a={x:n.toNode.x,y:n.toNode.y},r=(l,c,d,h,f)=>{const p=this.dataProvider.getCanvasScale();n.fromNode.x=i.x+l/p,n.fromNode.y=i.y+c/p,n.toNode.x=a.x+l/p,n.toNode.y=a.y+c/p,this._updateEditingControllerView(),this._dataUpdated()};Z.startDrag(t,{x:0,y:0},(...l)=>{this.onLineDragEnd(...l)},r)}onLineDragEnd(e,t,n){L("onLineDragEnd"),this.updateElementLines()}onCanvasDragStart(e){if(we(e)||e.target&&e.target.closest(".rg-line-peel"))return;const t=this.getOptions();if(this.dataProvider.isPerformanceMode()&&t.editingController.nodes.length>0){const n=this.getNodeAtEvent(e);if(n){this.onNodeDragStart(n,e);return}}if(t.dragEventAction==="none"){this.onCanvasClick(e);return}if(t.dragEventAction==="selection"||e.shiftKey){this.startCreateSelection(e);return}if(!t.disableDragLine){const n=this.isLine(e.target);if(n){this.onLineDragStart(n,e);return}}this.startMoveCanvas(e)}startMoveCanvas(e,t=!1){let n;if(ce(e)){let l,c=1;n=(d,h,f,p,u)=>{const g=u.touches||u.targetTouches,m=g[0];if(g&&g.length>1){u.preventDefault();const y=g[1],v=this.getOptions();l||(l={x:y.clientX,y:y.clientY},c=v.canvasZoom);const w={x:m.clientX,y:m.clientY},N={x:y.clientX,y:y.clientY},O=Math.hypot(l.x-p.x,l.y-p.y),T=Math.hypot(N.x-w.x,N.y-w.y)/O,P=v.mouseWheelSpeed*T,S=c*P;this.setZoom(S,p),this._dataUpdated()}else{const y=m.clientX,v=m.clientY,w=y-p.x,N=v-p.y,O=f.x+w,b=f.y+N;this.onCanvasDragging(O,b,N,w),this._updateEditingControllerView(),this._dataUpdated()}}}else n=(l,c,d,h,f)=>{const p=d.x+l,u=d.y+c;this.onCanvasDragging(p,u,l,c),this._updateEditingControllerView(),this._dataUpdated()};const i=this.getOptions(),a={x:i.canvasOffset.x,y:i.canvasOffset.y};let r=t;Z.startDrag(e,a,(l,c,d)=>{this.onCanvasDragStop(l,c,d)},(l,c,d,h,f)=>{r?n(l,c,d,h,f):Math.abs(l)+Math.abs(c)>4&&(this.emitEvent(A.onCanvasDragStart,d,h,f),r=!0)})}onCanvasDragging(e,t,n,i){const a=this.emitEvent(A.onCanvasDragging,e,t,n,i);a!==!1&&(a&&(typeof a.x=="number"&&(e=a.x),typeof a.y=="number"&&(t=a.y)),this.dataProvider.setCanvasOffset(e,t))}onCanvasDragStop(e,t,n){const i=this.getOptions();if(i.creatingSelection){this.dataProvider.updateOptions({creatingSelection:!1}),this.onCanvasSelectionEnd(i.selectionView,n);return}if(Math.abs(e)+Math.abs(t)<4){L("[canvas]onDragEnd as click2"),this._dataUpdated(),this.onCanvasClick(n);return}else L("[canvas]onDragEnd"),this.onCanvasDragEnd(n)}startCreateSelection(e){const t=()=>{if(!n||a)return;const d=this.getViewXyByEvent(n);this.canvasAutoMoving(d)&&this._updateEditingControllerView();const f=this.getViewXyByCanvasXy(r),p=d.x-f.x,u=d.y-f.y;p<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:f.x+p,width:Math.abs(p)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:f.x,width:Math.abs(p)}}),u<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:f.y+u,height:Math.abs(u)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:f.y,height:u}}),this._dataUpdated()};let n,i=!1,a=!0;const r=this.getCanvasXyByViewXy(this.getViewXyByEvent(e)),l=()=>{t(),this._canvasMovingTimer=requestAnimationFrame(l)},c=(d,h,f,p,u)=>{n=u,i?n=u:Math.abs(d)+Math.abs(h)>6&&(i=!0,a=!1,this.dataProvider.updateOptions({creatingSelection:!0}),this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this._canvasMovingTimer=requestAnimationFrame(l)),this._dataUpdated()};Z.startDrag(e,{x:0,y:0},(...d)=>{a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.onCanvasDragStop(...d)},c)}addFullscreenListener(){this._fullscreenchangeHandler=()=>{let e=!1;document.fullscreenElement?(L("div entered fullscreen mode",document.fullscreenElement),this.$dom===document.fullscreenElement&&(L("relation-graph is fullscreen!"),e=!0)):L("div exited fullscreen mode"),e!==this.getOptions().fullscreen&&(this.dataProvider.updateOptions({fullscreen:e}),this._dataUpdated(),setTimeout(async()=>{this.resetViewSize(),this._moveToCenter(),this.zoomToFit(),L("relation-graph reset complete!")},500))},document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}removeFullscreenListener(){document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}defaultLineConnectEndHandler(e,t,n){L("defaultLineConnectEndHandler:",e,t,n)}defaultLineVertexBeChangedHandler(e,t,n){L("defaultLineVertexBeChangedHandler:",n&&n.isReverse)}async sleep(e){await Xe(e)}forceLayoutTickCallback(){this._updateEditingControllerView(),this.dataProvider.updateShouldRenderGraphData(),this._dataUpdated()}}class ti extends ei{constructor(){super();_(this,"$easyViewCanvas");_(this,"$rgWebglPainter");_(this,"_updateEasyViewRequested",!1);_(this,"_easyViewOffset",{x:0,y:0})}setEasyViewCanvas(e){this.$easyViewCanvas=e,this.$rgWebglPainter=new pn(e)}updateEasyView(){this.updateMiniView(),this.dataProvider.isPerformanceMode()&&(!this.getOptions().showEasyView||this._updateEasyViewRequested||(this._updateEasyViewRequested=!0,requestAnimationFrame(this._updateEasyView.bind(this))))}_updateEasyView(e){try{const t=Date.now();if(!this.$easyViewCanvas)return;this.updateShouldRenderGraphData(),this.evDosomethingBeforeDraw(),this.evDrawAllLines(),this.evDrawAllNodes()}catch(t){console.error(t)}finally{this._updateEasyViewRequested=!1}}evDosomethingBeforeDraw(){const e=this.getOptions(),t=e.viewSize.width,n=e.viewSize.height;this.$easyViewCanvas.width=t,this.$easyViewCanvas.height=n,this.$rgWebglPainter.setSize(t,n);const i=this.dataProvider.getCanvasScale();this.$rgWebglPainter.setScale(i),this._easyViewOffset.x=e.canvasOffset.x,this._easyViewOffset.y=e.canvasOffset.y,this.$rgWebglPainter.setViewOffset(this._easyViewOffset.x,this._easyViewOffset.y),this.$rgWebglPainter.beforeDraw()}evDrawAllNodes(){const e=this.getOptions().defaultNodeShape;for(const t of this.getNodes()){if(!(t.rgShouldRender!==!1&&t.rgCalcedVisibility&&t.opacity!==0))continue;const i=_e(t.nodeShape,e);this.evDrawNode(t,i)}}evDrawNode(e,t){t===Ne.circle?this.evDrawNode4Circle(e):this.evDrawNode4Rect(e)}getNodeColor(e){const t=e.color||this.getOptions().defaultNodeColor||"#dddddd";return t==="transparent"?"rgba(204,204,204,0.2)":t}evDrawNode4Rect(e){const t=e.el_W,n=e.el_H,i=e.opacity||.8,a=this.getNodeColor(e),r=e.borderRadius===void 0?3:e.borderRadius,l=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Rect(e.x,e.y,t,n,a,i,r,l)}evDrawNode4Circle(e){const t=e.el_W,n=e.el_H,i=e.opacity||.8,a=this.getNodeColor(e),r=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Circle(e.x,e.y,t,n,a,i,r)}evDrawAllLines(){for(const e of this.getLinks()){const t=e.fromNode.rgShouldRender!==!1&&e.fromNode.opacity!==0&&e.fromNode.rgCalcedVisibility,n=e.toNode.rgShouldRender!==!1&&e.toNode.opacity!==0&&e.toNode.rgCalcedVisibility;!t&&!n||this.evDrawLine(e,e.line)}}evDrawLine(e,t){const n=this.createLineDrawInfo(e,t),i=t.opacity||1,a=this.getOptions(),r=t.color||a.defaultLineColor||"#888888",l=t.lineWidth||a.defaultLineWidth||1;this.$rgWebglPainter.evDrawLine(n.pathData,l,r,i)}}class ni extends ti{constructor(){super();_(this,"_onResizing");_(this,"_onResizeEnd");_(this,"_startPoint",{x:0,y:0});_(this,"_startEventCanvasXy",{x:0,y:0});_(this,"_startSizeCanvasXy",{x:0,y:0});_(this,"_startSize",{x:0,y:0,width:0,height:0,widthOnCanvas:0,heightOnCanvas:0});_(this,"_resizeType","l");_(this,"_nodeStartSizeMap",new WeakMap);_(this,"resizeMinLimit",{width:10,height:10});_(this,"_resizeDraggingTimer");_(this,"_resizeDraggingEvent");_(this,"_resizeDraggingStoped",!0);_(this,"_startCreateLineFromNodeTime",0)}setEditingNodes(e){if(e===null||e.length===0)this.dataProvider.setEditingNodes([]);else{const t=e.map(i=>i.id),n=this.getNodes().filter(i=>t.includes(i.id));this.dataProvider.setEditingNodes(n)}this._updateEditingControllerView(),this._dataUpdated()}addEditingNode(e){if(!this.getNodeById(e.id))throw new Error("Node not found: "+e.id);this.dataProvider.setEditingNodes(this.getOptions().editingController.nodes.concat(e)),this._updateEditingControllerView(),this._dataUpdated()}removeEditingNode(e){this.dataProvider.setEditingNodes(this.getOptions().editingController.nodes.filter(t=>t.id!==e.id)),this._updateEditingControllerView(),this._dataUpdated()}toggleEditingNode(e){this.getOptions().editingController.nodes.findIndex(n=>n.id===e.id)===-1?this.addEditingNode(e):this.removeEditingNode(e)}updateEditingControllerView(){this._updateEditingControllerView(),this._dataUpdated()}_updateEditingControllerView(){this._updateEditingLineView(),this._updateEditingConnectControllerView();const e=this.getOptions();if(!e.editingController.show)return;const{minX:t,minY:n,maxX:i,maxY:a}=this.getNodesRectBox(e.editingController.nodes),r=e.editingController.nodes.length>1?5:0,l=this.dataProvider.getCanvasScale();let c=i-t,d=a-n;if(c<0&&(c=0),d<0&&(d=0),c>0&&d>0){const h=this.getViewXyByCanvasXy({x:t,y:n}),f=h.x-r*l,p=h.y-r*l,u=c*l+r*2*l,g=d*l+r*2*l;this.dataProvider.updateOptions({editingController:{...e.editingController,x:f,y:p,width:u,height:g}})}else this.dataProvider.updateOptions({editingController:{...e.editingController,show:!1}})}onResizeStart(e,t){this._resizeType=e,this._startPoint=this.getViewXyByEvent(t),this._startEventCanvasXy=this.getCanvasXyByViewXy(this._startPoint);const n=this.getOptions();this._startSize.x=n.editingController.x,this._startSize.y=n.editingController.y,this._startSizeCanvasXy=this.getCanvasXyByViewXy(this._startSize),this._startSize.width=n.editingController.width,this._startSize.height=n.editingController.height;const i=this.dataProvider.getCanvasScale();this._startSize.widthOnCanvas=n.editingController.width/i,this._startSize.heightOnCanvas=n.editingController.height/i;for(const l of n.editingController.nodes)this._nodeStartSizeMap.set(l,{x:l.x,y:l.y,width:l.el_W,height:l.el_H});this._onResizing&&this.$dom.removeEventListener("mousemove",this._onResizing),this._onResizeEnd&&this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._resizeDraggingEvent=null,this._resizeDraggingStoped=!1,this._onResizing=this.onResizing.bind(this),this._onResizeEnd=this.onResizeEnd.bind(this),this.$dom.addEventListener("mousemove",this._onResizing),this.$dom.addEventListener("mouseup",this._onResizeEnd);const a=this.onResizingRequest.bind(this),r=()=>{a(),this._resizeDraggingTimer=requestAnimationFrame(r)};this._resizeDraggingTimer=requestAnimationFrame(r),this.emitEvent(A.onResizeStart,n.editingController.nodes,t)}onResizing(e){this._resizeDraggingEvent=e}onResizingRequest(){if(!this._resizeDraggingEvent||this._resizeDraggingStoped)return;const e=this.getViewXyByEvent(this._resizeDraggingEvent);this.canvasAutoMoving(e);const t=this.getViewXyByCanvasXy(this._startEventCanvasXy),n=this.getViewXyByCanvasXy(this._startSizeCanvasXy),i=e.x-t.x,a=e.y-t.y,r=this.getOptions();let l=r.editingController.width,c=r.editingController.height,d=r.editingController.x,h=r.editingController.y;const f=this.dataProvider.getCanvasScale();this._resizeType==="tl"?(d=t.x+i,h=t.y+a,l=this._startSize.widthOnCanvas*f-i,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="tr"?(h=t.y+a,d=n.x,l=this._startSize.widthOnCanvas*f+i,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="bl"?(d=t.x+i,h=n.y,l=this._startSize.widthOnCanvas*f-i,c=this._startSize.heightOnCanvas*f+a):this._resizeType==="br"?(d=n.x,h=n.y,l=this._startSize.widthOnCanvas*f+i,c=this._startSize.heightOnCanvas*f+a):this._resizeType==="t"?(h=t.y+a,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="r"?(d=n.x,l=this._startSize.widthOnCanvas*f+i):this._resizeType==="b"?(c=this._startSize.heightOnCanvas*f+a,h=n.y):this._resizeType==="l"&&(d=t.x+i,l=this._startSize.widthOnCanvas*f-i),l<this.resizeMinLimit.width&&(l=this.resizeMinLimit.width),c<this.resizeMinLimit.width&&(c=this.resizeMinLimit.height),this.dataProvider.updateOptions({editingController:{...r.editingController,x:d,y:h,width:l,height:c}}),this._applyResizeScale(this._resizeDraggingEvent),this._updateEditingControllerView(),this._dataUpdated()}_applyResizeScale(e){const t=this.getOptions(),n=this.dataProvider.getCanvasScale(),i=t.editingController.width/n/this._startSize.widthOnCanvas,a=t.editingController.height/n/this._startSize.heightOnCanvas,r=this._startSizeCanvasXy,l=this.getCanvasXyByViewXy({x:t.editingController.x,y:t.editingController.y});let c=!0,d=!0;this._resizeType==="t"||this._resizeType==="b"?c=!1:(this._resizeType==="r"||this._resizeType==="l")&&(d=!1);for(const h of t.editingController.nodes){const f=this._nodeStartSizeMap.get(h),p=f.width*i,u=f.height*a,g=l.x+i*(f.x-r.x),m=l.y+a*(f.y-r.y),y=p,v=u;this.emitEvent(A.beforeNodeResize,h,g,m,y,v)===!1||(c&&this.dataProvider.updateNode(h.id,{x:g,width:y,el_W:y}),d&&this.dataProvider.updateNode(h.id,{y:m,height:v,el_H:v}))}}onResizeEnd(e){cancelAnimationFrame(this._resizeDraggingTimer),this._resizeDraggingStoped=!0;const t=this.getViewXyByEvent(e),n=t.x-this._startPoint.x,i=t.y-this._startPoint.y;this._applyResizeScale(e),this.$dom.removeEventListener("mousemove",this._onResizing),this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._onResizing=null,this._onResizeEnd=null,L("onResizeEnd:",this.getOptions().editingController.nodes,n,i),this.emitEvent(A.onResizeEnd,this.getOptions().editingController.nodes,n,i,e)}draggingSelectedNodes(e,t,n,i,a){const r=this.updateReferenceLineView(e,t,n,i,a);if(r){const{showV:c,fixedX:d,showH:h,fixedY:f}=r;c&&(i+=d-t,t=d),h&&(a+=f-n,n=f)}const l=this.getOptions();if(!l.editingController.nodes.includes(e))this.dataProvider.updateNode(e.id,{x:t,y:n}),this._updateEditingLineView();else{for(const c of l.editingController.nodes){const d=this._nodeXYMappingBeforeDrag[c.id];d&&this.dataProvider.updateNode(c.id,{x:d.x+i,y:d.y+a})}this._updateEditingControllerView()}}_updateEditingConnectControllerView(){const e=this.getOptions();if(!e.nodeConnectController.show)return;const t=e.nodeConnectController.node,n=t.x,i=t.y,a=t.x+t.el_W,r=t.y+t.el_H,l=0,c=this.dataProvider.getCanvasScale(),d=n,h=i,f=a-n,p=r-i,u=this.getViewXyByCanvasXy({x:d,y:h});this.dataProvider.updateOptions({nodeConnectController:{...e.nodeConnectController,x:u.x-l*c,y:u.y-l*c,width:f*c+l*2*c,height:p*c+l*2*c}})}setEditingLine(e){this.dataProvider.setEditingLine(e),this._updateEditingLineView(),this._dataUpdated()}updateReferenceLineView(e,t,n,i,a){const r=this.getOptions();if(!r.showReferenceLine)return;if(!r.editingReferenceLine.show){const M=Math.abs(i),C=Math.abs(a);M+C>2&&this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,show:!0}})}if(!r.editingReferenceLine.show)return;const l=t,c=e.el_W,d=e.el_H,h=t+c/2,f=t+c,p=n,u=n+d/2,g=n+d,m=this.getViewXyByCanvasXy({x:h,y:u});let y=!1,v=!1,w=0,N=0;const O=this.getNodes().filter(M=>this._nodeXYMappingBeforeDrag[M.id]?!1:Math.abs(M.x-h)<600&&Math.abs(M.y-u)<600);O.sort((M,C)=>{const D=ge(h,u,M.x+M.el_W/2,M.y+M.el_H/2),X=ge(h,u,C.x+C.el_W/2,C.y+C.el_H/2);return D<X?-1:1});let{v_x:b,v_y:T,v_height:P,h_x:S,h_y:k,h_width:R}=r.editingReferenceLine;for(const M of O){const C=M.x,D=M.el_W,X=M.el_H,G=M.x+D/2,B=M.x+D,E=M.y,F=M.y+X/2,$=M.y+X,te=Math.abs(l-C),Q=Math.abs(h-G),oe=Math.abs(f-B),ie=Math.abs(p-E),ne=Math.abs(u-F),ae=Math.abs(g-$),K=5;if(Q<800&&ne<800){if(!v&&Q<K){const Y=this.getViewXyByCanvasXy({x:G,y:F});b=Y.x,T=m.y>Y.y?Y.y:m.y,P=Math.round(Math.abs(m.y-Y.y)),v=!0,w=G-c/2}if(!v&&te<K){const Y=this.getViewXyByCanvasXy({x:C,y:F});b=Y.x,T=m.y>Y.y?Y.y:m.y,P=Math.round(Math.abs(m.y-Y.y)),v=!0,w=C}if(!v&&oe<K){const Y=this.getViewXyByCanvasXy({x:B,y:F});b=Y.x,T=m.y>Y.y?Y.y:m.y,P=Math.round(Math.abs(m.y-Y.y)),v=!0,w=B-c}if(!y&&ne<K){const Y=this.getViewXyByCanvasXy({x:G,y:F});k=Y.y,S=m.x>Y.x?Y.x:m.x,R=Math.round(Math.abs(m.x-Y.x)),y=!0,N=F-d/2}if(!y&&ie<K){const Y=this.getViewXyByCanvasXy({x:G,y:E});k=Y.y,S=m.x>Y.x?Y.x:m.x,R=Math.round(Math.abs(m.x-Y.x)),y=!0,N=E}if(!y&&ae<K){const Y=this.getViewXyByCanvasXy({x:G,y:$});k=Y.y,S=m.x>Y.x?Y.x:m.x,R=Math.abs(m.x-Y.x),y=!0,N=$-d}if(y&&v)break}}if(this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,v_x:b,v_y:T,v_height:P,h_x:S,h_y:k,h_width:R,directionH:y,directionV:v}}),r.referenceLineAdsorption)return{showV:v,fixedX:w,showH:y,fixedY:N}}hideEditingLineView(){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}})}updateEditingLineView(){this._updateEditingLineView(),this._dataUpdated()}_updateEditingLineView(){this.updateElementLines();const e=this.getOptions();if(!e.editingLineController.show)return;const t=e.editingLineController.line,n=this.getLinkByLine(t);if(!t||t.to==="newRelationTemplate-to"){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}let i,a,r;const l=this.createLineDrawInfo(n,t);if(!l){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}if(t.lineShape===H.StandardOrthogonal){let{textPosition:N,pathData:O,points:b,startDirection:T,endDirection:P}=l;r=N,i=b[0],a=b[b.length-1];const S=[];for(let k=0;k<b.length-1;k++){const R=b[k],M=b[k+1],C={pIndex:k,optionName:"cp-"+k,x:0,y:0,direction:"v",startDirection:T,endDirection:P};R.x!==M.x&&(C.direction="h");const D=this.getViewXyByCanvasXy({x:(R.x+M.x)/2,y:(R.y+M.y)/2});C.x=D.x,C.y=D.y,S.push(C)}if(S.length!==1){if(S.length!==2)if(S.length===3){const k=b[0],R=b[1],M=b[3];if(S[1].direction==="v"){const C=k.x,D=R.x,X=M.x;if(Math.max(C,D,X)!==D&&Math.min(C,D,X)!==D)S[1].optionName="cx";else{const B=Math.abs(D-C),E=Math.abs(D-X);B>=E?S[1].optionName="td":B<E&&(S[1].optionName="fd")}}else{const C=k.y,D=R.y,X=M.y;if(Math.max(C,D,X)!==D&&Math.min(C,D,X)!==D)S[1].optionName="cy";else{const B=Math.abs(D-C),E=Math.abs(D-X);B>=E?S[1].optionName="td":B<E&&(S[1].optionName="fd")}}}else S.length===4?(S[1].optionName="fd",S[2].optionName="td"):S.length===5&&(S[1].optionName="fd",S[2].direction==="v"?S[2].optionName="cx":S[2].optionName="cy",S[3].optionName="td")}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:S,line49Points:b}})}else if(t.lineShape===H.HardOrthogonal){let{textPosition:N,pathData:O,points:b,startDirection:T,endDirection:P}=l;r=N;const S=[];b=t.ctrlPointsFor49,i=b[0],a=b[b.length-1];const k=b;for(let R=0;R<k.length-1;R++){const M=k[R],C=k[R+1],D={pIndex:R,optionName:"cp-"+R,x:0,y:0,direction:"v",startDirection:T,endDirection:P};M.x!==C.x?(D.direction="h",Math.abs(M.x-C.x)<15&&(D.hide=!0)):Math.abs(M.y-C.y)<15&&(D.hide=!0);const X=this.getViewXyByCanvasXy({x:(M.x+C.x)/2,y:(M.y+C.y)/2});D.x=X.x,D.y=X.y,S.push(D)}for(let R=0;R<S.length;R++){const M=S[R-1],C=S[R],D=S[R+1];R===0&&C.direction===D.direction&&(C.hide=!0),R===S.length-1&&C.direction===M.direction&&(C.hide=!0)}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:S,line49Points:k}})}else if(t.lineShape!==1){r=l.textPosition;const N=Ze(l.pathData);let O,b;t.isReverse?(i=N.endPoint,a=N.startPoint,O=this.getViewXyByCanvasXy(N.ctrl1),b=this.getViewXyByCanvasXy(N.ctrl2)):(i=N.startPoint,a=N.endPoint,O=this.getViewXyByCanvasXy(N.ctrl1),b=this.getViewXyByCanvasXy(N.ctrl2)),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,ctrlPoint1:O,ctrlPoint2:b}})}else{r=l.textPosition;const N=l.pathData,O=Ze(N);i=O.startPoint,a=O.endPoint}const c=this.getViewXyByCanvasXy(t.isReverse?a:i),d=this.getViewXyByCanvasXy(t.isReverse?i:a);this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,startPoint:c,endPoint:d}});const h=this.getViewXyByCanvasXy(r),f=this.$canvasDom.querySelector(`g[data-id='${t.id}']`);let p=0,u=0,g=t.textOffsetX||0,m=t.textOffsetY||0;const y=this.dataProvider.getCanvasScale();let v=20,w=20;if(f){const N=f.querySelector("text.rg-line-text");if(N){g=Math.floor(parseFloat(N.getAttribute("x")||"0")),m=Math.floor(parseFloat(N.getAttribute("y")||"0"));const O=N.clientWidth,b=N.clientHeight;v=O,w=b}}v+=40,w+=10,v>120&&(v=120),w>20&&(w=20),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,text:{...this.getOptions().editingLineController.text,width:v,height:w,x:h.x+p+g*y,y:h.y+u+m*y}}})}startMoveLineVertex(e,t,n){t.stopPropagation();const i=this.getOptions().editingLineController.line,a=this.getLinkByLine(i);let r,l;if(a)r=a.fromNode,l=a.toNode;else{const{from:h,to:f}=this.generateFakeLineConfig(i);r=h,l=f}let c=r;this.dataProvider.setEditingLine(null),a?this.removeLine(i):this.removeFakeLine(i),console.log("DragLine start:",e,i.isReverse);let d=!1;i.lineShape===H.HardOrthogonal&&(i.lineShape=H.StandardOrthogonal),e==="start"?(i.fromJunctionPointOffsetX=0,i.fromJunctionPointOffsetY=0,c=l,d=!0):(i.toJunctionPointOffsetX=0,i.toJunctionPointOffsetY=0),this.startCreatingLinePlot(t,{template:i,fromNode:c,isReverse:d,onCreateLine:n})}startCreateLineFromNode(e,t,n,i){n.stopPropagation();const a=JSON.parse(JSON.stringify(t));if(this._startCreateLineFromNodeTime=Date.now(),!a.from){if(!e){const l=this.getOptions().editingController.nodes;l.length===1&&(e=l[0])}e&&(a.from=e.id,a.fromType=e.targetType)}if(!a.from)throw console.error("Error:lineTemplate:",a),Error("Error:startCreateLineByTemplate: lineTemplate must has [fromType, from]");const r=this.getFakeLineTarget(a.fromType,a.from,a);if(!r)throw console.error("Error:fakeTarget[fromType, from]:",a.fromType,a.from,a),Error(`Error:startCreateLineByTemplate: error from fakeTarget[fromType, from]:${a.fromType}, ${a.from}`);a.lineShape||(a.lineShape=6),this.startCreatingLinePlot(n,{template:a,fromNode:r,isReverse:!1,onCreateLine:i})}onLineVertexBeDropped(e,t,n={x:0,y:0},i){t.stopPropagation();const a=this.getOptions();if(!a.creatingLinePlot||Date.now()-this._startCreateLineFromNodeTime<500)return;console.log("Connect end:isReverse:",a.newLineTemplate.isReverse);const r=a.nodeConnectController.node;let{toJunctionPoint:l,toJunctionPointOffsetX:c,toJunctionPointOffsetY:d,fromJunctionPoint:h,fromJunctionPointOffsetX:f,fromJunctionPointOffsetY:p}=a.newLineTemplate;if(!a.newLinkTemplate.fromNode)a.newLineTemplate.isReverse?(l=e,c=n.x,d=n.y):(h=e,f=n.x,p=n.y),this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:h,fromJunctionPointOffsetX:f,fromJunctionPointOffsetY:p,toJunctionPoint:l,toJunctionPointOffsetX:c,toJunctionPointOffsetY:d},newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:r}});else{a.newLineTemplate.isReverse?(h=e,f=n.x,p=n.y):(l=e,c=n.x,d=n.y);const u=this.getOptions().newLinkTemplate.fromNode;this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:h,fromJunctionPointOffsetX:f,fromJunctionPointOffsetY:p,toJunctionPoint:l,toJunctionPointOffsetX:c,toJunctionPointOffsetY:d},newLinkTemplate:{...this.getOptions().newLinkTemplate,toNodeObject:r}});const g=r;try{const m={newLineTemplate:this.getOptions().newLineTemplate,fromNode:u,toNode:g};this.emitEvent(A.onLineVertexDropped,m),i&&i(m.fromNode,m.toNode,m.newLineTemplate),this.onReadyToCreateLine(this.getOptions().newLinkTemplate.fromNode,this.getOptions().nodeConnectController.node)!==!0&&this.stopCreatingLinePlot()}catch(m){this.stopCreatingLinePlot(),console.warn("[Custom Reject onCreateLine By Throw Error:",m)}}}startMoveLineText(e,t){if(we(e))return;const n=this.getViewXyByEvent(e),a=this.getOptions().editingLineController.line;console.log("startMoveLineText:",a.id);const r=a.textOffsetX||0,l=a.textOffsetY||0;let c=!1;const d=f=>{const p=this.dataProvider.getCanvasScale(),u=this.getViewXyByEvent(f),g=u.x-n.x,m=u.y-n.y;(g>0||m>0)&&(c=!0),a.textOffsetX=Math.round(r+g/p),a.textOffsetY=Math.round(l+m/p),this._updateEditingLineView(),this._dataUpdated()},h=f=>{this.$dom.removeEventListener("mousemove",d),this.$dom.removeEventListener("mouseup",h),c&&t&&t(),this._dataUpdated()};this.$dom.addEventListener("mousemove",d),this.$dom.addEventListener("mouseup",h)}startMoveLine6CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const r=this.getOptions().editingLineController.line;let l=r.ctrlPoints||[];l.length===0&&(l.push({x:0,y:0}),l.push({x:0,y:0})),this.dataProvider.updateLine(r.id,{ctrlPoints:l}),console.log("startMoveLine6CtrlPoint:line:",r),l=r.ctrlPoints,r.isReverse&&(e=l.length-1-e);const c=this.dataProvider.getCanvasScale(),d=l[e],{x:h,y:f}=d,p=()=>{n(r),this._dataUpdated()};Z.startDrag(t,{x:0,y:0},p,(u,g)=>{d.x=h+u/c,d.y=f+g/c,this.dataProvider.updateLine(r.id,{ctrlPoints:l}),this._updateEditingLineView(),this._dataUpdated()})}startMoveLine44CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const a=this.getOptions().editingLineController,r=a.line;console.log("startMoveLine44CtrlPoint:",r==null?void 0:r.lineShape,e.optionName);let l=r.ctrlOptionsFor44;l||(l={cx:0,cy:0,fd:0,td:0},this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l}),l=r.ctrlOptionsFor44);const c=l[e.optionName],d={indexOffset:0};let h=r.ctrlPointsFor49?JSON.parse(JSON.stringify(r.ctrlPointsFor49)):null;const f=(u,g)=>{console.log("lineSplitCtrlMoving:",r==null?void 0:r.lineShape,e.optionName);const m=this.dataProvider.getCanvasScale();if(r.lineShape===H.StandardOrthogonal){if(e.optionName==="cx"){const v=c+u/m*1;l.cx=v,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="cy"){const v=c+g/m*1;l.cy=v,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="fd"){const y=Me[e.startDirection],v=e.direction==="v"?u*y.x:g*y.y;l.fd=c+v/m,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="td"){const y=Me[e.endDirection],v=e.direction==="v"?u*y.x:g*y.y;l.td=c+v/m,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.direction==="v"&&Math.abs(u)>5||e.direction==="h"&&Math.abs(g)>5){const y=a.line49Points;h=JSON.parse(JSON.stringify(y)),console.log(":startCtrlPointsFor49:::",h),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:h}),this.dataProvider.updateLine(r.id,{lineShape:H.HardOrthogonal})}}else if(r.lineShape===H.HardOrthogonal){const{newPoints:y,pointsChanged:v}=Cn(r.ctrlPointsFor49,h,e.pIndex+d.indexOffset,e,d,u/m,g/m);v&&(h=JSON.parse(JSON.stringify(y))),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:y})}},p=()=>{if(r.lineShape===H.HardOrthogonal){const u=ke(r.ctrlPointsFor49);this.dataProvider.updateLine(r.id,{ctrlPointsFor49:u})}this._updateEditingLineView(),n&&n(r),this._dataUpdated()};Z.startDrag(t,{x:0,y:0},p,(u,g)=>{f(u,g),this._updateEditingLineView(),this._dataUpdated()})}onLineVertexBeDroppedOnConnectController(e,t,n,i){if(L("onLineVertexBeDroppedOnConnectController",e,t,n),t.stopPropagation(),!n){this.onLineVertexBeDropped(e,t,void 0,i);return}const a=Ce(t),r=n.getBoundingClientRect(),l={x:r.left,y:r.top+r.height/2},c={x:r.left+r.width/2,y:r.top},d={x:r.left+r.width,y:r.top+r.height/2},h={x:r.left+r.width/2,y:r.top+r.height};let f=de.left;const p={x:0,y:0};if(e)f=e,f===de.top||f===de.bottom?p.x=a.clientX-h.x:f===de.right?p.y=a.clientY-d.y:p.y=a.clientY-l.y;else{const g=ge(a.clientX,a.clientY,l.x,l.y),m=ge(a.clientX,a.clientY,c.x,c.y),y=ge(a.clientX,a.clientY,d.x,d.y),v=ge(a.clientX,a.clientY,h.x,h.y),w=Math.min(g,m,y,v);w===g?(f=de.left,p.x=a.clientX-l.x,p.y=a.clientY-l.y):w===m?(f=de.top,p.x=a.clientX-c.x,p.y=a.clientY-c.y):w===y?(f=de.right,p.x=a.clientX-d.x,p.y=a.clientY-d.y):w===v&&(f=de.bottom,p.x=a.clientX-h.x,p.y=a.clientY-h.y)}const u=this.dataProvider.getCanvasScale();p.x=p.x/u,p.y=p.y/u,L("onMouseUpWithOffset:",e,p),this.onLineVertexBeDropped(f,t,p,i)}}class ii extends ni{constructor(){super();_(this,"$miniViewCanvas");_(this,"$mvCanvasCtx");_(this,"_canvasDomScale",1);_(this,"miniViewBox",{visibleAreaStart:{x:0,y:0},visibleAreaEnd:{x:0,y:0},canvas_start_x:0,canvas_start_y:0,canvas_end_x:0,canvas_end_y:0,canvas_width:0,canvas_height:0,miniview_width:0,miniview_height:0});_(this,"visibleArea",{x:0,y:0});_(this,"_canvasItemMiniSizeLimit",1)}setMiniViewCanvas(e){this.$miniViewCanvas=e,this.$mvCanvasCtx=this.$miniViewCanvas.getContext("2d")}updateMiniView(){!this.getOptions().showMiniView||(this.updateMiniViewVisibleArea(),this._updateMiniView())}_updateMiniView(){try{const e=Date.now();this.mvDosomethingBeforeDraw(),this.mvDrawAllNodes()}catch(e){console.error(e)}}mvDosomethingBeforeDraw(){let e=9999999,t=9999999,n=-9999999,i=-9999999,a=0;for(const v of this.getNodes())if(v.rgCalcedVisibility&&v.opacity!==0){v.x<e&&(e=v.x),v.y<t&&(t=v.y);const w=v.x+v.el_W,N=v.y+v.el_H;w>n&&(n=w),N>i&&(i=N),a++}const r=1,l=50,c=50;a===0?(this.miniViewBox.canvas_start_x=-100-l,this.miniViewBox.canvas_start_y=-100-c,this.miniViewBox.canvas_end_x=100+l,this.miniViewBox.canvas_end_y=100+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y):(this.miniViewBox.canvas_start_x=e-l,this.miniViewBox.canvas_start_y=t-c,this.miniViewBox.canvas_end_x=n+l,this.miniViewBox.canvas_end_y=i+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y);const d=this.$miniViewCanvas.parentElement.getBoundingClientRect(),h=d.width,f=d.height;let p=0,u=0,g=1;h/this.miniViewBox.canvas_width<f/this.miniViewBox.canvas_height?(g=h/this.miniViewBox.canvas_width*r,p=h,u=h/this.miniViewBox.canvas_width*this.miniViewBox.canvas_height):(g=f/this.miniViewBox.canvas_height*r,p=f/this.miniViewBox.canvas_height*this.miniViewBox.canvas_width,u=f),this.miniViewBox.miniview_width=h,this.miniViewBox.miniview_height=f,this.$miniViewCanvas.width=h,this.$miniViewCanvas.height=f,this.$mvCanvasCtx.canvas.width=h*window.devicePixelRatio,this.$mvCanvasCtx.canvas.height=f*window.devicePixelRatio,this.$mvCanvasCtx.canvas.style.width=`${h}px`,this.$mvCanvasCtx.canvas.style.height=`${f}px`;const m=(f-u)/2,y=(h-p)/2;this.miniViewBox.canvas_start_x-=y/g,this.miniViewBox.canvas_start_y-=m/g,this.$mvCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$mvCanvasCtx.scale(g,g),this._canvasDomScale=g,this.$mvCanvasCtx.clearRect(0,0,this.$mvCanvasCtx.canvas.width,this.$mvCanvasCtx.canvas.height)}updateMiniViewVisibleArea(){const e=this.getCanvasXyByViewXy({x:0,y:0}),t=this.getOptions().viewSize,n=this.getCanvasXyByViewXy({x:t.width,y:t.height}),i=this._canvasDomScale,a=n.x-e.x,r=n.y-e.y;this.miniViewBox.visibleAreaStart=e,this.miniViewBox.visibleAreaEnd=n;const l=i*a,c=i*r,d=e.x-this.miniViewBox.canvas_start_x,h=e.y-this.miniViewBox.canvas_start_y,f=i*d,p=i*h;let u=!1;(f+l<0||p+c<0||p>this.miniViewBox.miniview_height||f>this.miniViewBox.miniview_width)&&(u=!0),this.dataProvider.updateOptions({miniViewVisibleHandle:{...this.getOptions().miniViewVisibleHandle,emptyContent:u,width:l,height:c,x:f,y:p}})}mvDrawAllNodes(){const e=this._canvasDomScale,t=this.getOptions().defaultNodeShape;for(const n of this.getNodes())if(n.rgCalcedVisibility&&n.opacity!==0){let i=n.el_W,a=n.el_H;e*i<this._canvasItemMiniSizeLimit&&(i=this._canvasItemMiniSizeLimit/this._canvasDomScale),e*a<this._canvasItemMiniSizeLimit&&(a=this._canvasItemMiniSizeLimit/this._canvasDomScale);const r=_e(n.nodeShape,t);this.mvDrawNode(n,r,i,a)}}mvDrawNode(e,t,n,i){t===Ne.circle?this.mvDrawNode4Circle(e,n,i):this.mvDrawNode4Rect(e,n,i)}mvDrawNode4Rect(e,t,n){const i=this.$mvCanvasCtx,a=e.x-this.miniViewBox.canvas_start_x,r=e.y-this.miniViewBox.canvas_start_y;i.beginPath(),i.globalAlpha=e.opacity||1,i.rect(a,r,t,n),i.fillStyle=this.getNodeColor(e),i.fill(),i.strokeStyle="#666666",i.lineWidth=2,i.stroke(),i.globalAlpha=1}mvDrawNode4Circle(e,t,n){const i=this.$mvCanvasCtx,a=e.x+t/2-this.miniViewBox.canvas_start_x,r=e.y+n/2-this.miniViewBox.canvas_start_y;i.beginPath(),i.globalAlpha=e.opacity||1,i.ellipse(a,r,t/2,n/2,0,0,2*Math.PI),i.fillStyle=this.getNodeColor(e),i.fill(),i.strokeStyle="#666666",i.lineWidth=2,i.stroke(),i.globalAlpha=1}mvDrawAllLines(){for(const e of this.getLinks())e.fromNode.rgCalcedVisibility&&e.toNode.rgCalcedVisibility&&this.mvDrawLine(e,e.line)}mvDrawLine(e,t){const n=this.$mvCanvasCtx,i=this.createLineDrawInfo(e,t);n.beginPath(),n.globalAlpha=t.opacity||1,this.mvDrawSvgPathOnCanvas(n,i.pathData);const a=this.getOptions();n.strokeStyle=t.color||a.defaultLineColor||"#888888",n.lineWidth=t.lineWidth||a.defaultLineWidth||1,n.stroke(),n.globalAlpha=1}mvDrawSvgPathOnCanvas(e,t){const n=t.match(/[a-zA-Z][^a-zA-Z]*/g);let i=0,a=0,r=0,l=0,c=0,d=0,h=0,f=0,p=!1;n.forEach(u=>{const g=u.trim().split(/[ ,]+/),m=g[0].toUpperCase(),y=g[0]===g[0].toLowerCase();switch(m){case"M":i=j(r,g[1],y)-this.miniViewBox.canvas_start_x,a=j(l,g[2],y)-this.miniViewBox.canvas_start_y,r=i,l=a,p&&(e.closePath(),p=!1),e.moveTo(i,a);break;case"L":i=j(r,g[1],y)-this.miniViewBox.canvas_start_x,a=j(l,g[2],y)-this.miniViewBox.canvas_start_y,e.lineTo(i,a);break;case"C":c=j(r,g[1],y),d=j(l,g[2],y),h=j(r,g[3],y),f=j(l,g[4],y),i=j(r,g[5],y),a=j(l,g[6],y),r=i,l=a,e.bezierCurveTo(c,d,h,f,i,a);break;case"Q":c=j(r,g[1],y),d=j(l,g[2],y),i=j(r,g[3],y),a=j(l,g[4],y),r=i,l=a;break;case"V":a=j(l,g[1],y),l=a,e.lineTo(i,a);break;case"H":i=j(r,g[1],y),r=i,e.lineTo(i,a);break;case"Z":e.closePath(),p=!1;break;default:L(`Unsupported command: ${m}`)}})}onVisibleViewHandleDragStart(e){e.preventDefault(),e.stopPropagation(),console.log("onVisibleViewHandleDragStart:");const t=this.getOptions(),n=t.canvasOffset.x,i=t.canvasOffset.y,a=this.miniViewBox.canvas_width,r=this.miniViewBox.canvas_height,l=()=>{const u=f/this.miniViewBox.miniview_width,g=p/this.miniViewBox.miniview_height,m=this.dataProvider.getCanvasScale(),y=a*u*m,v=r*g*m;console.log("setCanvasOffset:buff:",f,p),this.dataProvider.setCanvasOffset(n-y,i-v),this._updateEditingControllerView(),this.updateMiniViewVisibleArea(),this.updateShouldRenderGraphData(),this.dataProvider.dataUpdated()};let c;const d=(u,g,m)=>{c&&clearInterval(c),this.onCanvasDragEnd(m)};let h=!1,f=0,p=0;Z.startDrag(e,{x:0,y:0},d,(u,g)=>{f=u,p=g,console.log("onVisibleViewHandleDragStart:move:",u,g),!h&&Math.abs(u)+Math.abs(g)>3&&(console.log("onVisibleViewHandleDragStart:start"),h=!0,c=setInterval(()=>{l()},50))})}resetByVisiableView(e){!this.getOptions().miniViewVisibleHandle.emptyContent||(this.setZoom(100),this._moveToCenter(),this.zoomToFit())}}class oi extends ii{constructor(){super();_(this,"$watermarkDom",null);_(this,"$watermarkPosition","br");_(this,"$backgroundDom",null);_(this,"_originBackgroundColor","")}setWatermarkDom(e,t=!0,n=!1,i="br"){t&&(this.$watermarkDom=e),this.$watermarkPosition=i}setBackgroundDom(e,t=!0,n=!0){e===null?(this._originBackgroundColor=this.options.backgroundColor,this.dataProvider.updateOptions({backgroundColor:"transparent"}),t?this.$backgroundDom=e:this.$backgroundDom=null):(this.dataProvider.updateOptions({backgroundColor:this._originBackgroundColor}),this.$backgroundDom=null)}async prepareForImageGeneration(){return this.$canvasDom}async restoreAfterImageGeneration(){}}class si extends oi{constructor(){super();_(this,"resizeObserver");_(this,"resizeListenerMap",new WeakMap);_(this,"domToNodeIdMap",new WeakMap);_(this,"mutationObserver4Nodes");_(this,"mutationObserver4CanvasSlotBehind");_(this,"mutationObserver4CanvasSlotAbove");_(this,"_updateCanvasConnectTargetsTask");_(this,"onKeyDownHanlder");_(this,"onKeyUpHanlder")}setDom(e){L("relation-graph mounted on:",this.instanceId,e),this.$dom=e}setCanvasDom(e){L("relation-graph canvas dom mounted!"),this.$canvasDom=e,this.reinitMutationObservers(),this.getLineTextContainer({isFakeLine:!0}),this.getLineTextContainer({isFakeLine:!1})}getResizeObserver(){return this.resizeObserver||(this.resizeObserver=new ResizeObserver((e,t)=>{for(const n of e){const i=this.resizeListenerMap.get(n.target);i?n.borderBoxSize?i(n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):i(n.target.clientWidth,n.target.clientHeight):n.borderBoxSize?this._onNodeDomResize(n.target,n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):this._onNodeDomResize(n.target,n.target.clientWidth,n.target.clientHeight)}})),this.resizeObserver}initDom(){this.addResizeListener(this.$dom,(e,t)=>{L("resizeListener:this.$dom"),this.resetViewSize(),this.updateEasyView(),this._rgAsConnectArea&&this.updateCanvasConnectTargetsPosition("View Resize"),this._updateEditingLineView(),this._updateEditingControllerView(),this._dataUpdated(),setTimeout(()=>{L("resizeListener:updateShouldRenderGraphData"),this.emitEvent(A.onViewResize,{width:e,height:t}),this._dataUpdated()},500)}),this._rgAsConnectArea||(this.removeKeyboardListener(),this.addKeyboardListener())}updateCanvasConnectTargetsPosition(e="api"){this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-above"))}reinitMutationObservers(){this.destroyMutationObserver();const e=this.$canvasDom.querySelector(".rg-nodes-container-wrapper");if(e)this.mutationObserver4Nodes=new MutationObserver(i=>{if(this.dataProvider.getConnectTargets().length>0)for(const a of i){const r=this.getNodeElByChildrenTarget(a.target),l=this.domToNodeIdMap.get(r);l&&this.updateConnectTargetsOnNode("Mutation",l,r)}}),this.mutationObserver4Nodes.observe(e,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-nodes-container-wrapper");const t=this.$canvasDom.parentElement.querySelector(".rg-canvas-slot-behind");if(t)this.mutationObserver4CanvasSlotBehind=new MutationObserver(i=>{console.warn("MutationObserver:updateConnectTargetsOnCanvas:mutations:",i),this.updateConnectTargetsOnCanvas("CanvasBehind-Mutation",t)}),this.mutationObserver4CanvasSlotBehind.observe(t,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-canvas-slot-behind");const n=this.$canvasDom.parentElement.querySelector(".rg-canvas-slot-above");n&&(this.mutationObserver4CanvasSlotAbove=new MutationObserver(i=>{this.updateConnectTargetsOnCanvas("CanvasAbove-Mutation",n)}),this.mutationObserver4CanvasSlotAbove.observe(n,{childList:!0,subtree:!0,characterData:!0}))}destroyMutationObserver(){this.mutationObserver4Nodes&&(this.mutationObserver4Nodes.disconnect(),this.mutationObserver4Nodes=void 0),this.mutationObserver4CanvasSlotBehind&&(this.mutationObserver4CanvasSlotBehind.disconnect(),this.mutationObserver4CanvasSlotBehind=void 0),this.mutationObserver4CanvasSlotAbove&&(this.mutationObserver4CanvasSlotAbove.disconnect(),this.mutationObserver4CanvasSlotAbove=void 0)}addKeyboardListener(){this.onKeyDownHanlder=e=>{we(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!1&&this.setCanvasMoveMode(!0)),this.emitEvent(A.onKeyboardDown,e))},this.onKeyUpHanlder=e=>{we(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!0&&this.setCanvasMoveMode(!1)),this.emitEvent(A.onKeyboardUp,e))},this.$dom.addEventListener("keydown",this.onKeyDownHanlder),this.$dom.addEventListener("keyup",this.onKeyUpHanlder)}removeKeyboardListener(){this.onKeyDownHanlder&&this.$dom.removeEventListener("keydown",this.onKeyDownHanlder),this.onKeyUpHanlder&&this.$dom.removeEventListener("keyup",this.onKeyUpHanlder)}addResizeListener(e,t){this.resizeListenerMap.set(e,t),this.getResizeObserver().observe(e)}_onNodeDomResize(e,t,n){if(t===0||n===0)return;const i=this.domToNodeIdMap.get(e);this._onNodeResize(e,i,t,n)}_onNodeResize(e,t,n,i){n===0||i===0||(this.updateConnectTargetsOnNode("Node-Created",t,e),this.updateNodeOffsetSize(t,n,i))}addNodeResizeListener(e,t){this.domToNodeIdMap.set(e,t.id),this._onNodeResize(e,t.id,e.offsetWidth,e.offsetHeight),this.getResizeObserver().observe(e)}removeNodeResizeListener(e){this.domToNodeIdMap.delete(e),e?this.getResizeObserver().unobserve(e):L("removeNodeResizeListener: dom is null or undefined!")}removeResizeListener(e){this.resizeListenerMap.delete(e),this.resizeObserver&&this.resizeObserver.unobserve(e)}destroyResizeObserver(){this.resizeObserver&&this.resizeObserver.disconnect()}getCanvasSlotRectItems(){const e=this.$dom.querySelectorAll(".rg-map > .rg-map-canvas > .rg-canvas-slot"),t=[];for(const n of e)for(const i of n.children){const a=i,r={x:a.offsetLeft||0,y:a.offsetTop||0,nodeShape:1,el_W:a.scrollWidth,el_H:a.scrollHeight};t.push(r)}return t}}class ai extends si{constructor(){super()}dataUpdated(){this._requestDataUpdate()}setOptions(o){L("setOptions:",o),this._updateOptions(o),this._dataUpdated()}updateOptions(o){L("updateOptions:",o),this._updateOptions(o),this._dataUpdated()}moveToCenter(o){this._moveToCenter(o),this._dataUpdated()}transToLinker(o=!0){this._rgAsConnectArea=o,this.resetViewSize(),this.updateCanvasConnectTargetsPosition("Linker"),this.removeKeyboardListener(),this._rgAsConnectArea||this.addKeyboardListener(),this._dataUpdated()}setRootNodeId(o){L("setRootNodeId:",o),this.dataProvider.setRootNodeId(o)}getRootNode(){return this.dataProvider.getRootNode()}getCheckedNode(){return this.getNodeById(this.getOptions().checkedNodeId)}getCheckedLine(){if(!this.getLineById(this.getOptions().checkedLineId))return this.getFakeLineById(this.getOptions().checkedLineId)}getSelectedNodes(){return this.getNodes().filter(o=>o.selected)}getEditingNodes(){return[...this.getOptions().editingController.nodes]}async setJsonData(o){this._setJsonData(o),await this.doLayout(o.rootId)}async appendJsonData(o,e=!0){L("appendData:",o),this.loadGraphJsonData(o),e&&await this.doLayout()}async applyInitialData(o){L("applyInitialData:",o),await this.setJsonData(o),this.moveToCenter(),this.zoomToFit()}getGraphJsonData(){var t;const o=[],e=[];return this.getNodes().forEach(n=>{const i=Se(n);i&&o.push(i)}),this.getLines().forEach(n=>{const i=Re(n);i&&e.push(i)}),{rootId:((t=this.dataProvider.getRootNode())==null?void 0:t.id)||"",nodes:o,lines:e}}transRGNodeToJsonObject(o){return Se(o)}transRGLinkToJsonObject(o){return Fe(o)}transRGLineToJsonObject(o){return Re(o)}getGraphJsonOptions(){const o={},e=["layouter","layoutor","autoLayouting","canvasNVInfo","canvasOffset","canvasZoom","fullscreen","instanceId","layoutClassName","layoutDirection","layoutLabel","layoutName","resetViewSize","viewELSize","viewNVInfo","viewSize","canvasSize","newLinkTemplate","newLineTemplate","newNodeTemplate"],t=this.getOptions();return Object.keys(t).forEach(n=>{e.includes(n)||(o[n]=t[n])}),o}clearGraph(){this._clearGraph(),this._dataUpdated()}printOptions(){const o=this.getGraphJsonOptions();console.log("options:",o),console.log("options-json-string:"),console.log(JSON.stringify(o))}printData(){const o=this.getGraphJsonData();console.log("data:",o),console.log("data-json-string:"),console.log(JSON.stringify(o))}printGraphJsonData(){this.printOptions(),this.printData()}}class Pt extends ai{constructor(){super();_(this,"viewComponentUnmounted",!1)}setListeners(e){this.listeners=e}ready(){this.initDom(),this.resetViewSize(!0),this.addFullscreenListener(),this.emitEvent(A.onReady,this),this.viewComponentUnmounted=!1}beforeUnmount(){this.viewComponentUnmounted=!0,this.removeFullscreenListener(),this.removeKeyboardListener(),this.destroyMutationObserver(),this.destroyResizeObserver()}}const ri=ye.Provider,li=ot.Provider,di=Ee.Provider,ci=re.Provider;function Rt(s,o=!1){const e=s?Reflect.construct(s,[]):new Pt;return e._rgAsConnectArea=o,console.log("[RGProvider]Creating new graphInstance",e.instanceId,o),e}function $e(s,o=!1){const e=I.useContext(ye);return e||(console.log("[RGProvider]No parent RGProvider found, creating new graphInstance"),Rt(s,o))}const St=({graphInstance:s,children:o})=>{const[e,t]=I.useState(0),{data:n,dataStores:i}=hi(),a=I.useRef(0),r=I.useCallback(l=>{a.current++,t(a.current)},[]);return a.current===0&&s.setReactiveData4React(i,r),x.jsx(ri,{value:s,children:x.jsx(li,{value:r,children:x.jsx(di,{value:e,children:x.jsx(ci,{value:n,children:o})})})})},Ue=({graphInstance:s,children:o})=>I.useContext(ye)?x.jsx(x.Fragment,{children:o}):x.jsx(St,{graphInstance:s,children:o}),hi=()=>{const[s,o]=I.useState(Oe({})),[e,t]=I.useState([]),[n,i]=I.useState([]),[a,r]=I.useState([]);return{data:{options:s,shouldRenderNodes:e,shouldRenderLines:n,shouldRenderFakeLines:a},dataStores:{store4Options:{set:u=>{o({...u})}},store4ShouldRenderNodes:{set:u=>{t(u)}},store4ShouldRenderLines:{set:u=>{i(u)}},store4ShouldRenderFakeLines:{set:u=>{r(u)}}}}},xe=s=>s,ui=`graphRef.value.getInstance() will be deprecated
|
|
42
|
+
`}},ee=({iconName:s,className:o})=>{const e=rn[s];return x.jsx("svg",{className:`rg-icon ${o||""}`,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",dangerouslySetInnerHTML:{__html:e.data}})},ht=({node:s,expandOrCollapseNode:o,expandHolderPosition:e})=>{const t=s.expanded===!1?"rg-node-expand-button c-expanded":"rg-node-expand-button c-collapsed";return x.jsx("div",{className:`rg-node-expand-holder c-expand-positon-${e}`,children:x.jsx("div",{className:t,onClickCapture:o,onTouchEnd:o,children:s.expanded===!1?x.jsx(ee,{iconName:"icon-fangda"}):x.jsx(ee,{iconName:"icon-suoxiao"})})})},ut=({nodeProps:s,nodeSlot:o,nodeExpandButtonSlot:e,defaultExpandHolderPosition:t,dragging:n,checked:i})=>{const a=W(),r=I.useRef();I.useEffect(()=>(a.addNodeResizeListener(r.current,s),()=>{r.current&&a.removeNodeResizeListener(r.current)}),[]);const l=async v=>{a.expandOrCollapseNode(s,v.nativeEvent)},c=v=>{v.type==="mousedown"&&v.button!==0||(v.stopPropagation(),a.onNodeDragStart(s,v.nativeEvent))},d=s.width?s.width+"px":void 0,h=s.height?s.height+"px":void 0,f=s.borderWidth===void 0?void 0:s.borderWidth+"px",p=s.borderColor,u=s.opacity,g=s.rgCalcedVisibility,y=s.expandHolderPosition||t||"hide",m=s.expandHolderPosition&&s.expandHolderPosition!=="hide"||t!=="hide"&&s.rgChildrenSize>0;return x.jsxs("div",{ref:r,style:{display:g?void 0:"none","--rg-node-z-index":s.zIndex?s.zIndex:void 0,pointerEvents:u===0?"none":void 0,transform:`translate(${s.x}px, ${s.y}px)`,"--rg-node-color":s.color,"--rg-node-font-color":s.fontColor,"--rg-node-font-size":s.fontSize?s.fontSize+"px":void 0,"--rg-node-border-width":f,"--rg-node-border-radius":s.borderRadius&&s.borderRadius+"px","--rg-node-border-color":p,"--rg-node-width":d,"--rg-node-height":h,"--rg-node-opacity":s.opacity===void 0?void 0:s.opacity},className:["rg-node-peel",s.selected&&"rg-node-selected",n&&"rg-node-dragging",i&&"rg-node-checked",`rg-node-shape-${s.nodeShape===void 0?1:s.nodeShape}`,`rg-node-type-${s.type}`,s.className,(s.disablePointEvent||s.opacity===0)&&"rg-node-disable-events"].filter(Boolean).join(" "),"data-id":s.id,children:[m&&(e?e({node:s,expandOrCollapseNode:l,expandHolderPosition:y}):x.jsx(ht,{node:s,expandOrCollapseNode:l,expandHolderPosition:y})),x.jsx("div",{className:"rg-node",onMouseDown:v=>{c(v)},onTouchStart:v=>{c(v)},children:o?o({node:s,defaultExpandHolderPosition:t,checked:i,dragging:n}):x.jsx("div",{className:"rg-node-text",children:x.jsx("span",{children:s.text})})})]})},ft=({nodeSlot:s,nodeExpandButtonSlot:o,defaultExpandHolderPosition:e,draggingNodeId:t,checkedNodeId:n,allNodeConfigList:i})=>x.jsx("div",{className:"rg-nodes-container",children:i.map(a=>x.jsx(ut,{nodeProps:a,nodeSlot:s,nodeExpandButtonSlot:o,defaultExpandHolderPosition:e,dragging:a.id===t,checked:a.id===n},a.id))});pe.default.memo(ft,(s,o)=>s.allNodeConfigList!==o.allNodeConfigList||s.draggingNodeId!==o.draggingNodeId||s.checkedNodeId!==o.checkedNodeId||s.nodeSlot!==o.nodeSlot||s.nodeExpandButtonSlot!==o.nodeExpandButtonSlot?!1:s.defaultExpandHolderPosition===o.defaultExpandHolderPosition);const ln=({showEasyView:s,lineSlot:o,defaultLineTextOnPath:e,checkedLineId:t,graphInstanceId:n})=>{const i=W(),{shouldRenderFakeLines:a}=J(),r=s?[]:i.getShouldRenderFakeLines(a);return x.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[x.jsx("div",{className:"rg-linetext-container"}),x.jsxs("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx(st,{forElementLines:!0}),!s&&r.map(l=>l.hidden!==!0&&x.jsx(dt,{line:l,lineSlot:o,defaultLineTextOnPath:e,checked:l.id===t,graphInstanceId:n},l.id))]})]})},dn=({lineSlot:s,defaultLineTextOnPath:o,graphInstanceId:e})=>{const t=W(),{options:n}=J(),i=t.generateCreatingLineConfig(n);return x.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[x.jsx("div",{className:"rg-linetext-container"}),x.jsx("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:s?s({lineConfig:i}):x.jsx(lt,{lineConfig:i,defaultLineTextOnPath:o,graphInstanceId:e})})]})},cn=({nodeSlot:s,lineSlot:o,nodeExpandButtonSlot:e,showEasyView:t,creatingLine:n,defaultExpandHolderPosition:i,draggingNodeId:a,checkedNodeId:r,checkedLineId:l,graphInstanceId:c,defaultLineTextOnPath:d})=>{const h=W(),{shouldRenderNodes:f,shouldRenderLines:p}=J(),u=I.useMemo(()=>t?[]:h.getShouldRenderNodes(f),[h,f,t]),g=I.useMemo(()=>t?[]:h.getShouldRenderLines(p),[h,p,t]);return x.jsxs("div",{className:"rg-single-graph",children:[x.jsx(ct,{graphInstanceId:c,showEasyView:t,defaultLineTextOnPath:d,checkedLineId:l,lineSlot:o,allLineConfigList:g}),x.jsx("div",{className:"rg-nodes-container-wrapper",children:!t&&x.jsx(ft,{defaultExpandHolderPosition:i,draggingNodeId:a,checkedNodeId:r,nodeSlot:s,nodeExpandButtonSlot:e,allNodeConfigList:u})}),x.jsx(ln,{graphInstanceId:c,showEasyView:t,defaultLineTextOnPath:d,checkedLineId:l,lineSlot:o}),n&&x.jsx(dn,{defaultLineTextOnPath:d,checkedLineId:l,lineSlot:o})]})},hn=s=>{const o=W(),{options:e}=J(),t=I.useRef();return I.useEffect(()=>(w("[RGEasyView mounted]"),o.setEasyViewCanvas(t.current),()=>{w("[RGEasyView UnMounted]")}),[]),x.jsx("div",{className:`rg-easy-view ${e.showEasyView?"rg-easy-view-active":""}`,children:x.jsx("canvas",{ref:t})})},un=s=>{const o=W(),{options:e}=J();se();const t=I.useRef(),n=I.useRef(),i=I.useMemo(()=>e.canvasSize,[e.canvasSize]),a=I.useMemo(()=>e.canvasOffset,[e.canvasOffset]),r=I.useMemo(()=>e.canvasZoom/100,[e.canvasZoom]),l={width:`${i.width}px`,height:`${i.height}px`,backgroundColor:"transparent",transform:`translate(${a.x}px, ${a.y}px) scale(${r},${r})`};I.useEffect(()=>(w("[RGCanvas mounted]"),o.setCanvasDom(t.current),()=>{w("[RGCanvas UnMounted]")}),[]);const c=h=>{h.type==="mousedown"&&h.button!==0||o.onCanvasDragStart(h.nativeEvent)},d=h=>{h.preventDefault(),o.onContextmenu(h.nativeEvent)};return x.jsxs("div",{ref:n,className:["rg-map",e.canvasOpacity===1?"rg-map-ready":""].join(" "),onContextMenu:h=>{d(h)},onMouseDown:h=>{c(h)},onTouchStart:h=>{c(h)},children:[x.jsx("div",{className:"rg-map-background",children:s.backgroundSlot}),x.jsx(hn,{}),x.jsx("div",{style:l,className:"rg-map-canvas rg-canvas-behind",children:x.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-behind",children:s.canvasPlugSlot&&(typeof s.canvasPlugSlot=="function"?x.jsx(s.canvasPlugSlot,{}):s.canvasPlugSlot)})}),x.jsx("div",{ref:t,style:l,className:"rg-map-canvas",children:x.jsx(cn,{nodeSlot:s.nodeSlot,lineSlot:s.lineSlot,nodeExpandButtonSlot:s.nodeExpandButtonSlot,showEasyView:e.showEasyView,creatingLine:e.creatingLinePlot&&e.newLinkTemplate.fromNode,defaultExpandHolderPosition:e.defaultExpandHolderPosition,draggingNodeId:e.draggingNodeId,checkedNodeId:e.checkedNodeId,defaultLineTextOnPath:e.defaultLineTextOnPath,checkedLineId:e.checkedLineId,graphInstanceId:e.instanceId})}),x.jsx("div",{style:l,className:"rg-map-canvas rg-canvas-above",children:x.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-above",children:s.canvasPlugAboveSlot})})]})},fn=()=>{const s=W(),o=(s==null?void 0:s.options.canvasMoveMode)||!1,e=t=>{s&&s.startMoveCanvas(t.nativeEvent,!0)};return x.jsx("div",{className:`rg-move-operator ${o?"rg-move-operator-active":""}`,children:x.jsx("div",{className:"rg-move-touchpad",onMouseDown:e,onTouchStart:e})})},gn=()=>{const s=W(),{options:o}=J(),e=t=>{s.clearLoading()};return x.jsx(x.Fragment,{children:o&&x.jsx("div",{className:`rg-graph-loading ${o.graphLoading?"":"rg-graph-loading-hide"}`,onClick:t=>{e()},children:x.jsxs("div",{className:"rg-graph-loading-message",children:[x.jsx(ee,{iconName:"icon-lianjiezhong",className:"rg-graph-loading-icon"}),o.graphLoadingText||"Loading..."]})})})},pn=({nodeSlot:s})=>{W();const{options:o}=J();return o&&x.jsxs("div",{className:"rg-operate",children:[x.jsxs("div",{className:"rg-creating-container",children:[o.creatingNodePlot&&o.showTemplateNode&&x.jsx(ut,{nodeProps:o.newNodeTemplate,nodeSlot:s}),o.creatingSelection&&x.jsx("div",{className:"rg-selection",style:{transform:`translate(${o.selectionView.x}px, ${o.selectionView.y}px)`,width:o.selectionView.width+"px",height:o.selectionView.height+"px"}})]}),x.jsx(fn,{}),x.jsx(gn,{})]})},gt=({direction:s="",positionH:o="",positionV:e="",children:t})=>{const n=W();se();const{options:i}=J(),a=()=>{n==null||n.toggleAutoLayout()},r=async()=>{n&&(n.enableCanvasAnimation(),n.setZoom(100),n.moveToCenter(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300))},l=async d=>{await(n==null?void 0:n.zoom(d))},c=async()=>{await(n==null?void 0:n.fullscreen())};return I.useEffect(()=>{},[]),x.jsxs("div",{className:`rg-toolbar rg-xs-toolbar rg-toolbar-h-${o||i.toolBarPositionH||"left"} rg-toolbar-v-${e||i.toolBarPositionV||"bottom"} rg-toolbar-${s||i.toolBarDirection||"h"}`,children:[x.jsx("div",{title:"Full Screen",className:"rg-mb-button",style:{marginTop:0},onClick:c,children:x.jsx(ee,{iconName:"icon-quanping"})}),x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>l(20),children:x.jsx(ee,{iconName:"icon-fangda"})}),x.jsx("div",{className:"rg-current-zoom",onClick:r,children:`${Math.round(i.canvasZoom)}%`}),x.jsx("div",{className:"rg-mb-button",style:{marginTop:0},onClick:()=>l(-20),children:x.jsx(ee,{iconName:"icon-suoxiao"})})]}),i.layout.supportAutoLayout&&x.jsx("div",{title:i.layout.autoLayouting?"Stop Force Layout":"Start Force Layout",className:`rg-mb-button ${i.layout.autoLayouting?"rg-mb-button-on":""}`,onClick:a,children:i.layout.autoLayouting?x.jsx(ee,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):x.jsx(ee,{iconName:"icon-zidong"})}),t]})},pt=({children:s})=>x.jsx(x.Fragment,{}),He=({children:s})=>x.jsx(x.Fragment,{}),yt=({children:s})=>x.jsx(x.Fragment,{}),mt=({children:s})=>x.jsx(x.Fragment,{}),vt=({children:s,forDisplay:o,forImage:e})=>{const t=W(),n=I.useRef(null);return I.useEffect(()=>(t.setBackgroundDom(n.current,o,e),()=>{t.setBackgroundDom(null,o,e)}),[]),x.jsx("div",{className:"rg-background",ref:n,children:s})},xt=s=>{const o=W();se();const e=I.useRef(),[t,n]=I.useState(!1);I.useEffect(()=>{w("<RelationGraph> Dom Mounted!"),o.setDom(e.current),n(!0);const C=N=>{o.onMouseWheel(N)};return e.current.addEventListener("wheel",C,{passive:!1}),()=>{var N;w("<RelationGraph> Dom UnMounted!"),(N=e.current)==null||N.removeEventListener("wheel",C),o.beforeUnmount()}},[]);const{options:i}=J();let a,r;const l=[],c=[],d=[],h=[],f=pe.default.Children.toArray(s.children).filter(C=>{if(C&&pe.default.isValidElement(C))if(C.type===Dt){const N=C.props.children;if(typeof N=="function")a=N;else throw new Error("RGSlotOnNode children must be a function, e.g. <RGSlotOnNode>{ (node: RGNode) => <div>{node.text}</div> }</RGSlotOnNode>")}else if(C.type===pt){const N=C.props.children;if(typeof N=="function")r=N;else throw new Error("RGSlotOnLine children must be a function, e.g. <RGSlotOnLine>{ (lineConfig: RGGenerateLineConfig) => <RGLineContent lineConfig={lineConfig} /> }</RGSlotOnLine>")}else{if(C.type===He)return l.push(C.props.children),!1;if(C.type===yt)return c.push(C.props.children),!1;if(C.type===mt)return d.push(C.props.children),!1;if(C.type===vt)return h.push(C.props.children),!1}return!0}),p=l,u=d,g=c.concat(...f);if(a&&s.nodeSlot)throw new Error("You can only provide nodeSlot or RGSlotOnNode, but not both.");if(r&&s.lineSlot)throw new Error("You can only provide lineSlot or RGSlotOnLine, but not both.");const y=a||s.nodeSlot,m=r||s.lineSlot,v=s.nodeExpandButtonSlot;return x.jsx("div",{ref:e,id:`relation-graph-ins-${i==null?void 0:i.instanceId}`,className:["relation-graph",(i==null?void 0:i.creatingLinePlot)&&"rg-creating-line",(i==null?void 0:i.dragEventAction)==="move"?"rg-move-mode":"",i!=null&&i.enableNodeXYAnimation?"rg-enable-node-xy-animation":"",(i==null?void 0:i.enableCanvasTransformAnimation)&&"rg-enable-canvas-animation"].filter(Boolean).join(" "),tabIndex:1,style:{width:"100%",height:i!=null&&i.viewHeight?i==null?void 0:i.viewHeight:"100%",opacity:t?1:0,"--rg-checked-item-bg-color":i==null?void 0:i.checkedItemBackgroundColor,"--rg-background-color":i==null?void 0:i.backgroundColor,"--rg-node-color":i==null?void 0:i.defaultNodeColor,"--rg-node-border-color":i==null?void 0:i.defaultNodeBorderColor,"--rg-node-border-width":(i==null?void 0:i.defaultNodeBorderWidth)+"px","--rg-node-border-radius":(i==null?void 0:i.defaultNodeBorderRadius)+"px","--rg-line-color":i==null?void 0:i.defaultLineColor,"--rg-line-width":(i==null?void 0:i.defaultLineWidth)+"px"},children:i&&x.jsxs(x.Fragment,{children:[i.showToolBar&&x.jsx(gt,{}),x.jsx(un,{nodeSlot:y,lineSlot:m,canvasPlugSlot:g,canvasPlugAboveSlot:u,nodeExpandButtonSlot:v,backgroundSlot:h}),x.jsx(pn,{nodeSlot:y}),x.jsx("div",{className:"rg-graph-plugs",children:x.jsx("div",{className:"rg-view-slot",children:p})})]})})},Ct=s=>{const o=W();return I.useEffect(()=>{tt("React"),o.setOptions(s.options);const e=Ge(s);w("[RelationGraph]mounted:listeners:",e),o.setListeners(e),o.ready(),o.dataUpdated(),s.initialData&&(w("[RelationGraph] apply data"),o.applyInitialData(s.initialData))},[]),x.jsx(xt,{...s})};class yn{constructor(o){_(this,"$evCanvasCtx");_(this,"viewScale",1);_(this,"offset",{x:0,y:0});const e=o.getContext("2d");if(!e)throw new Error("\u65E0\u6CD5\u83B7\u53D6 Canvas 2D \u4E0A\u4E0B\u6587");this.$evCanvasCtx=e}setSize(o,e){const t=this.$evCanvasCtx.canvas;t.width=o*window.devicePixelRatio,t.height=e*window.devicePixelRatio,t.style.width=`${o}px`,t.style.height=`${e}px`,this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.applyCurrentViewTransform()}setScale(o){this.viewScale=o,this.applyCurrentViewTransform()}applyCurrentViewTransform(){this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$evCanvasCtx.scale(this.viewScale,this.viewScale)}setViewOffset(o,e){this.offset.x=o/this.viewScale,this.offset.y=e/this.viewScale}beforeDraw(){}evDrawNode4Rect(o,e,t,n,i,a,r=5,l){const c=this.$evCanvasCtx,d=this.offset.x+o,h=this.offset.y+e;let f=Math.max(0,r);t<2*f&&(f=t/2),n<2*f&&(f=n/2),c.beginPath(),c.globalAlpha=a,f===0?c.rect(d,h,t,n):(c.moveTo(d+f,h),c.arcTo(d+t,h,d+t,h+f,f),c.arcTo(d+t,h+n,d+t-f,h+n,f),c.arcTo(d,h+n,d,h+n-f,f),c.arcTo(d,h,d+f,h,f),c.closePath()),c.fillStyle=i,c.fill(),c.globalAlpha=1,c.strokeStyle=l,c.lineWidth=1,c.stroke()}evDrawNode4Circle(o,e,t,n,i,a,r){const l=this.$evCanvasCtx,c=this.offset.x+o+t/2,d=this.offset.y+e+n/2;l.beginPath(),l.globalAlpha=a,l.ellipse(c,d,t/2,n/2,0,0,2*Math.PI),l.fillStyle=i,l.fill(),l.strokeStyle=r,l.lineWidth=1,l.stroke(),l.globalAlpha=1}evDrawLine(o,e,t,n){const i=this.$evCanvasCtx;i.beginPath(),i.globalAlpha=n,this.evDrawSvgPathOnCanvas(i,o),i.strokeStyle=t,i.lineWidth=e*this.viewScale<.5?.5:e,i.stroke(),i.globalAlpha=1}getPointValue(o,e,t){return t?o+parseFloat(e):parseFloat(e)}evDrawSvgPathOnCanvas(o,e){const t=e.match(/[a-zA-Z][^a-zA-Z]*/g);if(!t)return;let n=0,i=0,a=0,r=0,l=0,c=0,d=0,h=0,f="";o.beginPath(),t.forEach(p=>{const u=p.trim(),g=u.charAt(0),m=u.substring(1).trim().split(/[ ,]+/).filter(L=>L!=="").map(parseFloat);let v=0,C=0,N=0,O=0,b=0,T=0,R=0,P=0,k=0,S=0,M=0;switch(g){case"M":n=m[0],i=m[1],a=n,r=i,o.moveTo(n+this.offset.x,i+this.offset.y);for(let L=2;L<m.length;L+=2)n=m[L],i=m[L+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"L":for(let L=0;L<m.length;L+=2)n=m[L],i=m[L+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"l":for(let L=0;L<m.length;L+=2)n+=m[L],i+=m[L+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"H":for(let L=0;L<m.length;L++)n=m[L],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"h":for(let L=0;L<m.length;L++)n+=m[L],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"V":for(let L=0;L<m.length;L++)i=m[L],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"v":for(let L=0;L<m.length;L++)i+=m[L],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"C":for(let L=0;L<m.length;L+=6)N=m[L],O=m[L+1],b=m[L+2],T=m[L+3],v=m[L+4],C=m[L+5],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,C+this.offset.y),n=v,i=C,l=b,c=T;break;case"c":for(let L=0;L<m.length;L+=6)N=n+m[L],O=i+m[L+1],b=n+m[L+2],T=i+m[L+3],v=n+m[L+4],C=i+m[L+5],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,C+this.offset.y),l=b,c=T,n=v,i=C;break;case"S":for(let L=0;L<m.length;L+=4)f.match(/[CS]/i)?(N=2*n-l,O=2*i-c):(N=n,O=i),b=m[L],T=m[L+1],v=m[L+2],C=m[L+3],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,C+this.offset.y),n=v,i=C,l=b,c=T;break;case"s":for(let L=0;L<m.length;L+=4)f.match(/[CS]/i)?(N=2*n-l,O=2*i-c):(N=n,O=i),b=n+m[L],T=i+m[L+1],v=n+m[L+2],C=i+m[L+3],o.bezierCurveTo(N+this.offset.x,O+this.offset.y,b+this.offset.x,T+this.offset.y,v+this.offset.x,C+this.offset.y),l=b,c=T,n=v,i=C;break;case"Q":for(let L=0;L<m.length;L+=4)N=m[L],O=m[L+1],v=m[L+2],C=m[L+3],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,C+this.offset.y),n=v,i=C,d=N,h=O;break;case"q":for(let L=0;L<m.length;L+=4)N=n+m[L],O=i+m[L+1],v=n+m[L+2],C=i+m[L+3],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,C+this.offset.y),d=N,h=O,n=v,i=C;break;case"T":for(let L=0;L<m.length;L+=2)f.match(/[QT]/i)?(N=2*n-d,O=2*i-h):(N=n,O=i),v=m[L],C=m[L+1],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,C+this.offset.y),n=v,i=C,d=N,h=O;break;case"t":for(let L=0;L<m.length;L+=2)f.match(/[QT]/i)?(N=2*n-d,O=2*i-h):(N=n,O=i),v=n+m[L],C=i+m[L+1],o.quadraticCurveTo(N+this.offset.x,O+this.offset.y,v+this.offset.x,C+this.offset.y),d=N,h=O,n=v,i=C;break;case"A":for(let L=0;L<m.length;L+=7)R=m[L],P=m[L+1],k=m[L+2],S=m[L+3],M=m[L+4],v=m[L+5],C=m[L+6],this.drawArc(o,n,i,R,P,k,S,M,v,C),n=v,i=C;break;case"a":for(let L=0;L<m.length;L+=7)R=m[L],P=m[L+1],k=m[L+2],S=m[L+3],M=m[L+4],v=n+m[L+5],C=i+m[L+6],this.drawArc(o,n,i,R,P,k,S,M,v,C),n=v,i=C;break;case"Z":case"z":o.closePath(),n=a,i=r;break;default:console.warn(`\u672A\u652F\u6301\u7684SVG\u547D\u4EE4\u5B57\u7B26: ${g}`)}g.match(/[CSQT]/i)?f=g:f=""})}drawArc(o,e,t,n,i,a,r,l,c,d){if(n=Math.abs(n),i=Math.abs(i),n===0||i===0){o.lineTo(c+this.offset.x,d+this.offset.y);return}const h=a%360*Math.PI/180,f=Math.sin(h),p=Math.cos(h),u=p*(e-c)/2+f*(t-d)/2,g=-f*(e-c)/2+p*(t-d)/2,y=u*u/(n*n)+g*g/(i*i);y>1&&(n*=Math.sqrt(y),i*=Math.sqrt(y));let m=(r===l?-1:1)*Math.sqrt(Math.max(0,(n*n*i*i-n*n*g*g-i*i*u*u)/(n*n*g*g+i*i*u*u)));isNaN(m)&&(m=0);const v=m*n*g/i,C=m*-i*u/n,N=p*v-f*C+(e+c)/2,O=f*v+p*C+(t+d)/2,b=(u-v)/n,T=(g-C)/i,R=(-u-v)/n,P=(-g-C)/i;let k=Math.atan2(T,b),S=Math.atan2(T*R-b*P,b*R+T*P);l===0&&S>0?S-=2*Math.PI:l===1&&S<0&&(S+=2*Math.PI);const M=k+S;o.ellipse?o.ellipse(N+this.offset.x,O+this.offset.y,n,i,h,k,M,l===0):(console.warn("ctx.ellipse is not supported. Arc will be drawn as a line."),o.lineTo(c+this.offset.x,d+this.offset.y))}}let me={x:0,y:0};const ve={x:0,y:0},le={x:0,y:0};let De,Ae;const Ve=s=>{const o={clientX:0,clientY:0};if(ce(s)){const e=s.touches||s.targetTouches;if(!e)throw new Error("error targetTouches");o.clientX=e[0].clientX,o.clientY=e[0].clientY}else o.clientX=s.clientX,o.clientY=s.clientY;return o},Z={startDrag(s,o,e,t){t?De=(n,i,a)=>{const r=n-le.x,l=i-le.y;t(r,l,ve,le,a)}:De=(n,i)=>{me.x=ve.x+(n-le.x),me.y=ve.y+(i-le.y)},Ae=e,me=o,ve.x=me.x,ve.y=me.y;try{const n=Ve(s);le.x=n.clientX,le.y=n.clientY,ce(s)?(document.body.addEventListener("touchmove",Z.onNodeMove),document.body.addEventListener("touchend",Z.onNodeDragend),document.body.addEventListener("mousemove",Z.onNodeMove),document.body.addEventListener("mouseup",Z.onNodeDragend),s.preventDefault()):(document.body.addEventListener("mousemove",Z.onNodeMove),document.body.addEventListener("mouseup",Z.onNodeDragend))}catch(n){console.error(n.message)}},onNodeMove(s){const o=Ve(s);De(o.clientX,o.clientY,s)},onNodeDragend(s){if(ce(s)?(document.body.removeEventListener("touchmove",Z.onNodeMove),document.body.removeEventListener("touchend",Z.onNodeDragend),document.body.removeEventListener("mousemove",Z.onNodeMove),document.body.removeEventListener("mouseup",Z.onNodeDragend)):(document.body.removeEventListener("mousemove",Z.onNodeMove),document.body.removeEventListener("mouseup",Z.onNodeDragend)),Ae){const o=Ve(s),e=o.clientX,t=o.clientY,n=e-le.x,i=t-le.y;Ae(n,i,s)}}};function mn(s,o,e,t,n,i,a,r,l){const c=n-s,d=i-o,h=Math.sqrt(c*c+d*d);if(h===0)return{x:s,y:o};const f=l*d/h,p=-(l*c)/h,u=s+f,g=o+p,y=s-e/2,m=s+e/2,v=o-t/2,C=o+t/2;let N=[];if(c!==0){let T=(y-u)/c,R=g+T*d;R>=v&&R<=C&&N.push({x:y,y:R});let P=(m-u)/c,k=g+P*d;k>=v&&k<=C&&N.push({x:m,y:k})}if(d!==0){let T=(v-g)/d,R=u+T*c;R>=y&&R<=m&&N.push({x:R,y:v});let P=(C-g)/d,k=u+P*c;k>=y&&k<=m&&N.push({x:k,y:C})}if(N.length===0&&c===0&&d===0)return{x:u,y:g};let O=null,b=1/0;return N.forEach(T=>{const R=Math.sqrt((T.x-n)**2+(T.y-i)**2);R<b&&(b=R,O=T)}),O}const q={getRectPoint(s,o,e,t,n,i,a,r,l=!1,c=1,d=0,h=14,f=!1){const p=s+n/2,u=o+i/2,g=e+a/2,y=t+r/2;if(c>1){const P=Math.min(h,n,i),k=-P/2,S=P/(c-1),M=l&&f||!l&&!f?k*-1-d*S:k+d*S,L=mn(p,u,n,i,g,y,a,r,M);if(L)return L}const m=p<g?1:-1,v=u<y?1:-1;if(y===u)return{x:p+m*n/2,y:u};const C=Math.abs((g-p)/(y-u)),N=n/i;let O=0,b=0;C<N?(O=m*i/2*C,b=v*i/2):(O=m*n/2,b=v*n/2/C);const T=p+O,R=u+b;return{x:T,y:R}},getRectPointBasic(s,o,e,t,n,i,a,r){const l=s+n/2,c=o+i/2,d=e+a/2,h=t+r/2;let f=h===c?0:(d-l)/(h-c);f===0&&h===c&&d===l?f=1:f===0&&(f=(d-l)/(h-c+(h>c?-1:1)*1e-4));const p=n/i;let u=0,g=0,y="1";return Math.abs(f)<p?(y="2",c<=h?(g=i/2,u=g*f):(g=-i/2,u=g*f)):(y="3",l<=d?(u=n/2,g=f===0&&d===l?0:u/f):(u=-n/2,g=f===0&&d===l?0:u/f)),{x:l+u,y:c+g,_case:y}},getRectJoinPoint(s){const{from_x:o,from_y:e,to_x:t,to_y:n,f_W:i,f_H:a,t_W:r,t_H:l}=s,c=o+i/2,d=e+a/2,h=t+r/2,f=n+l/2,p=h-c,u=f-d,g=p/(i/2),y=u/(a/2);return Math.abs(g)>Math.abs(y)?g>0?{x:o+i,y:d}:{x:o,y:d}:y>0?{x:c,y:e+a}:{x:c,y:e}},getRectHJoinPoint(s){const{from_x:o,from_y:e,to_x:t,f_W:n,f_H:i,t_W:a}=s,r=i/2;return o+n<t?{x:o+n,y:e+r}:{x:o,y:e+r}},getRectLeftJoinPoint(s){const{from_x:o,from_y:e,f_H:t}=s;return{x:o,y:e+t/2}},getRectRightJoinPoint(s){const{from_x:o,from_y:e,f_W:t,f_H:n}=s;return{x:o+t,y:e+n/2}},getRectTopJoinPoint(s){const{from_x:o,from_y:e,f_W:t}=s;return{x:o+t/2,y:e}},getRectBottomJoinPoint(s){const{from_x:o,from_y:e,f_W:t,f_H:n}=s;return{x:o+t/2,y:e+n}},getRectHorizontalLineJoinPoint(s){return this.getRectVJoinPoint(s)},getRectVerticalLineLineJoinPoint(s){return this.getRectHJoinPoint(s)},getRectVJoinPoint(s){const{from_x:o,from_y:e,to_y:t,f_W:n,f_H:i,t_H:a}=s,r=n/2;return e+i<t?{y:e+i,x:o+r}:{y:e,x:o+r}},getBorderPoint(s,o,e,t,n,i,a,r,l){return l===0?this.getCirclePoint(s,o,e,t,n,i,a,r):this.getRectPoint(s,o,e,t,n,i,a,r)},getBorderPoint4MultiLine(s){const{from_x:o,from_y:e,to_x:t,to_y:n,f_W:i,f_H:a,t_W:r,t_H:l,nodeShape:c,isReverse:d=!1,isEndPoint:h,totalLinesBetweenNodes:f=1,currentLineIndex:p=0,lineDistance:u=50}=s;return c===0?this.getCirclePoint4MultiLine(o,e,t,n,i,a,r,l,d,f,p,u,h):this.getRectPoint(o,e,t,n,i,a,r,l,d,f,p,u,h)},getCirclePoint(s,o,e,t,n,i,a,r){const l=e+a/2,c=t+r/2,d=s+n/2,h=o+i/2,f=l-d;if(f===0)return{x:d,y:h-i/2*(c<h?1:-1)};const u=(c-h)/f,g=Math.sqrt(1/(1/(n/2)**2+u**2/(i/2)**2))*(l<d?1:-1),y=u*g;return{x:d-g,y:h-y}},getCirclePoint4MultiLine(s,o,e,t,n,i,a,r,l,c,d,h,f){let p=e+a/2;const u=t+r/2;let g=s+n/2;const y=o+i/2;let m=p-g;m>-1&&m<1&&(p=p-.5,g=g+.5,m=-1);let C=0;if(c>1){const M=Math.min(h,n,i),L=-M/2,D=M/(c-1);C=l&&f||!l&&!f?L*-1-d*D:L+d*D}const N=u-y,O=Math.sqrt(m**2+N**2)*C/m,b=N/m,T=n/2,R=i/2,P=g<p?-1:1,k=(-1*T**2*b*O+T*R*Math.sqrt(Math.abs(R**2+b**2*T**2-O**2))/P)/(R**2+T**2*b**2),S=b*k+O;return{x:g-k,y:y-S}},getCirclePointBasic(s,o,e,t,n,i,a,r,l){const c=s+n/2,d=o+i/2,h=e+a/2,f=t+r/2,p=h-c,u=f-d,g=Math.sqrt(p*p+u*u),y=g-l,m=y*p/g*-1,v=y*u/g*-1;return{x:h+m,y:f+v}},getCirclePointPlus(s,o,e,t,n,i,a,r){const l=s+n/2,c=o+i/2,d=e+a/2,h=t+r/2,f=d-l,p=h-c,u=Math.sqrt(f*f+p*p),g=(u-n/2)*f/u*-1,y=(u-i/2)*p/u*-1;return{x:d+g,y:h+y}},getOvalPoint(s,o,e,t,n,i=180){const a=t*(360/n),r=(180-i+a)*Math.PI/180;return{x:s+e*Math.sin(r),y:o+e*Math.cos(r)*-1}},getRotatedPoint(s,o,e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=(s-e)*a-(o-t)*r+e,c=(s-e)*r+(o-t)*a+t;return{x:l,y:c}},getFlippedX(s,o){return o-(s-o)},getFlippedY(s,o){return o-(s-o)},getAngleType(s,o){if(s>=0&&o>=0)return 1;if(s<0&&o>=0)return 2;if(s<0&&o<0)return 3;if(s>=0&&o<0)return 4},getTextAngle(s,o,e,t){let n=Math.atan2(t-o,e-s)*180/Math.PI;return n<0&&(n+=360),n>90&&n<=270&&(n+=180),n>=360&&(n-=360),Math.round(n)}},ge=(s,o,e,t)=>{const n=s-e,i=o-t;return Math.sqrt(n**2+i**2)};function Ue(s,o,e,t,n=0,i=0){let a=1,r=n,l=i,c=0;for(let d of e){const h=d.width,f=d.height;f>c&&(c=f),t(d,r,l),r+=h+o,a>s?(l+=c+o,a=1,r=0,c=0):a++}}class vn{constructor(o){_(this,"graphInstance");_(this,"initialized",!1);_(this,"isFolderLayout",!1);this.graphInstance=o}analyzeNetwork(o,e,t=!1,n=!1){this.initialized||(this.initialized=!0),o.forEach(u=>{u.lot||(u.lot={}),u.lot.eached=!1,u.lot.index_of_level=0,u.lot.index_of_p_childs=0,u.lot.index_of_parent=0,u.lot.strength=0,u.lot.strengthWithChilds_from=0,u.lot.strengthWithChilds=0,u.lot.childrenSizeVisible=0,u.lot.childrenSize=0,u.lot.childs=[],u.lot.subling=void 0,u.lot.parent=void 0}),e.lot.parent=void 0;const i=this.markNodeParent(e);w("groupNodes:marked-tree-node:",i.networkNodes.length);const a=[],r={direct:1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},l={direct:-1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},c=[e];this.expandLevelNodesWithDirection(a,c,0,t,n,r,l),this.calcStrengthWithChildsValue(a),this.calcStrengthFromValue(e,1),t&&this.calcStrengthFromValue(e,-1);const d=a.filter(u=>u.lot.level===1),h=d.length===0?1:d.map(u=>u.lot.strengthWithChilds).reduce((u,g)=>u+g,0);r.max_strength=h;const f=a.filter(u=>u.lot.level>=0);w("groupNodes:tree-nodes:",f.length,r);const p={tree:{networkNodes:f,analyticResult:r},reverseTree:{networkNodes:[],analyticResult:l}};if(t){const u=a.filter(m=>m.lot.level===-1),g=u.length===0?1:u.map(m=>m.lot.strengthWithChilds).reduce((m,v)=>m+v,0);l.max_strength=g;const y=a.filter(m=>m.lot.level<=0);w("groupNodes:reverse-tree-nodes:",y.length,l),p.reverseTree.networkNodes=y}for(const u of o)this.graphInstance.updateNode(u,{rgChildrenSize:u.lot.childrenSize});return p}markNodeParent(o){let e=[];return this._markNodeParent(e,[o],0),{networkNodes:e}}_markNodeParent(o,e,t){t===0&&e.forEach(i=>{i.lot.parent=void 0});const n=[];for(const i of e){o.includes(i)||o.push(i);for(const a of this.graphInstance.getNodeRelatedNodes(i))o.includes(a)||(o.push(a),a.lot.parent=i,n.push(a))}n.length>0&&this._markNodeParent(o,n,t+1)}expandLevelNodesWithDirection(o,e,t,n,i,a,r){const l=n&&t<0?r:a;w(`bothWay:${n}(deep:${i}) level ${t} size: ${e.length}`,l.direct),e.length>l.max_length&&(l.max_length=e.length),t>l.max_deep&&(l.max_deep=t),t<l.min_deep&&(l.min_deep=t),l.levels.has(t)||l.levels.set(t,{level:t,all_size:e.length,all_strength:0});const c=l.levels.get(t);e.forEach(u=>{u.lot.eached=!0,u.lot.subling=c,u.lot.level=t,o.push(u)});const d=[],h=[];let f=1,p=0;e.forEach(u=>{let g=[],y=[];n?i||t===0?(g=this.graphInstance.getNodeIncomingNodes(u),y=this.graphInstance.getNodeOutgoingNodes(u)):(t<0&&(f=-1),y=this.graphInstance.getNodeRelatedNodes(u)):y=this.graphInstance.getNodeRelatedNodes(u),this._appendNodeChildrenToNextLevelNodes(u,y,h,c,n,1),this._appendNodeChildrenToNextLevelNodes(u,g,d,c,n,-1),u.lot.index_of_level=p,p++}),c.all_strength>l.max_strength&&(l.max_strength=c.all_strength),h.length>0&&this.expandLevelNodesWithDirection(o,h,t+f,n,i,a,r),d.length>0&&this.expandLevelNodesWithDirection(o,d,t-1,n,i,a,r)}_appendNodeChildrenToNextLevelNodes(o,e,t,n,i,a){let r=0,l=0,c=0;if(e.forEach(d=>{d.lot||(d.lot={eached:!1,childs:[]}),d.lot.eached||(l++,d.lot.parent=o,B.isVisibleNode(d)&&(d.lot.eached=!0,d.lot.index_of_parent=c++,t.push(d),r++),o.lot.childs.push(d))}),a===1){const d=r>0?r:1;o.lot.strength=d,n.all_strength+=d,o.lot.strength_of_level=n.all_strength,o.lot.childrenSizeVisible=r,o.lot.childrenSize=l}}calcStrengthWithChildsValue(o){this.isFolderLayout?o.forEach(e=>{e.lot.strengthWithChilds=1,this.conductStrengthToParents(e)}):(o.forEach(e=>{e.lot.childrenSizeVisible>0&&(e.lot.strengthWithChilds=0)}),o.forEach(e=>{e.lot.childrenSizeVisible===0&&(e.lot.strengthWithChilds=1,this.conductStrengthToParents(e))}))}calcStrengthFromValue(o,e=1){this._calcStrengthFromValue([o],0,e===-1?-1:1)}_calcStrengthFromValue(o,e,t=1){const n=[];let i=0;o.forEach(a=>{if(a.lot.level===0||t===(a.lot.level<0?-1:1)){a.lot.childs.forEach(l=>{n.push(l)}),a.lot.parent&&i<a.lot.parent.lot.strengthWithChilds_from&&(i=a.lot.parent.lot.strengthWithChilds_from);const r=this.isFolderLayout?1:0;a.lot.strengthWithChilds_from=i+r,i+=a.lot.strengthWithChilds}}),n.length>0&&this._calcStrengthFromValue(n,e+(t<0?-1:1),t)}conductStrengthToParents(o){if(o.lot.parent){const e=Math.abs(o.lot.level)-1===Math.abs(o.lot.parent.lot.level);(this.isFolderLayout||e)&&(o.lot.parent.lot.strengthWithChilds+=1,this.conductStrengthToParents(o.lot.parent))}}}class fe{constructor(o,e,t){_(this,"graphOptions");_(this,"layoutOptions");_(this,"graphInstance");_(this,"networkAnalyzer");_(this,"allNodes",[]);_(this,"isMainLayouer",!0);_(this,"requireLinks",!1);_(this,"allLinks",[]);_(this,"rootNode");this.layoutOptions=o,this.graphOptions=e,this.graphInstance=t,this.networkAnalyzer=new vn(t)}setLinks(o){w("setLinks:",o.length),this.allLinks=o}generateCalcNodes(o){const e=[],t=new Map;for(const n of o){const i={rgNode:n,x:n.x,y:n.y,width:n.width||n.el_W||50,height:n.height||n.el_H||50};e.push(i),t.set(n.id,i)}return{calcNodes:e,calcNodeMap:t}}generateLevels(o){const e=[],t=new Map;for(const n of o){if(!n.lot||typeof n.lot.level!="number")continue;const i=n.lot.level;e.includes(i)||(e.push(i),t.set(i,[])),t.get(i).push(n)}return e.sort((n,i)=>n-i),{levels:e,levelNodesMap:t}}adjustNodePositions(o,e,t){if(!o||o.length===0)return[];for(let n=1;n<o.length;n++){const i=o[n],a=o[n-1];switch(e){case"right":i.x<a.x+a.width+t&&(i.x=a.x+a.width+t);break;case"left":i.x+i.width>a.x-t&&(i.x=a.x-i.width-t);break;case"bottom":i.y<a.y+a.height+t&&(i.y=a.y+a.height+t);break;case"top":i.y+i.height>a.y-t&&(i.y=a.y-i.height-t);break}}return o}getReverseAlignItems(o){return xn[o]}updateNodePosition(o,e,t){this.graphInstance.updateNode(typeof o=="string"?o:o.id,{x:e,y:t})}layoutEnd(){this.graphInstance&&(this.graphInstance.dataProvider.updateShouldRenderGraphData(),this.graphInstance._dataUpdated())}}const xn={start:"end",end:"start",center:"center"};class Re extends fe{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");_(this,"fastStart",!1);_(this,"skipInitLayout",!1);_(this,"maxLayoutTimes",300);_(this,"byNode",!0);_(this,"byLine",!0);_(this,"lockX",!1);_(this,"lockY",!1);_(this,"force_node_repulsion",1);_(this,"force_line_elastic",1);_(this,"disableLiveChanges",!1);_(this,"force_x_coefficient",1);_(this,"force_y_coefficient",1);_(this,"instanceId","");_(this,"calcNodes",[]);_(this,"_graphEventHandler");_(this,"layoutTimes",0);_(this,"prev10",[]);_(this,"visibleNodes",[]);_(this,"_onFinishCallback");_(this,"_onTickCallback");_(this,"calcNodeMap",new WeakMap);_(this,"forCalcNodes",[]);_(this,"recentGraphVelocity",[]);_(this,"graphVelocityBalancedValue",.1);_(this,"prevLogTime",0);_(this,"animationFrameTimer",0);_(this,"prevNodeLevel1Index",0);_(this,"prevNodeLevel2Index",0);_(this,"stoped",!1);_(this,"maxTractionLength",400);_(this,"zeroForceLength",40);_(this,"maxRepulsionDistance",600);_(this,"nodeCollisionRadius",40);_(this,"maxMoveSpeed",100);_(this,"n2nMaxForce",50);this.layoutOptions=e,this.updateOptions(e),this.requireLinks=!0,this.instanceId=n?n.generateNewUUID(5):"error-id"}updateOptions(e){e.fastStart!==void 0&&(this.fastStart=e.fastStart),e.maxLayoutTimes!==void 0&&(this.maxLayoutTimes=e.maxLayoutTimes),e.byNode!==void 0&&(this.byNode=e.byNode),e.byLine!==void 0&&(this.byLine=e.byLine),e.force_node_repulsion!==void 0&&(this.force_node_repulsion=e.force_node_repulsion),e.force_line_elastic!==void 0&&(this.force_line_elastic=e.force_line_elastic),e.force_x_coefficient!==void 0&&(this.force_x_coefficient=e.force_x_coefficient),e.force_y_coefficient!==void 0&&(this.force_y_coefficient=e.force_y_coefficient),e.disableLiveChanges!==void 0&&(this.disableLiveChanges=e.disableLiveChanges),e.skipInitLayout!==void 0&&(this.skipInitLayout=e.skipInitLayout),e.maxTractionLength!==void 0&&(this.maxTractionLength=e.maxTractionLength),e.zeroForceLength!==void 0&&(this.zeroForceLength=e.zeroForceLength),e.maxRepulsionDistance!==void 0&&(this.maxRepulsionDistance=e.maxRepulsionDistance),e.nodeCollisionRadius!==void 0&&(this.nodeCollisionRadius=e.nodeCollisionRadius)}placeNodes(e,t){if(w("RGForceLayout["+this.instanceId+"].placeNodes"),this.calcNodes=e,this.allNodes.length===0&&(this.allNodes=e),this.rootNode=t,this.fastStart)w("RGForceLayout["+this.instanceId+"] fastStart"),this.calcNodes.forEach(n=>{if(n.fixed===!0)return;let i=n.x,a=n.y,r=!1;(Number.isNaN(i)||i===void 0)&&(i=Math.floor(Math.random()*200)-100,r=!0),(Number.isNaN(a)||a===void 0)&&(a=Math.floor(Math.random()*200)-100,r=!0),i===0&&a===0&&(i=Math.floor(Math.random()*200)-100,a=Math.floor(Math.random()*200)-100,r=!0),r&&this.updateNodePosition(n,i,a)});else if(!this.skipInitLayout){if(w("!!!initNodesPosition....."),t){w("layout by root:",t),(Number.isNaN(t.x)||t.x===void 0)&&this.updateNodePosition(t,0,0);const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,t),{networkNodes:i,analyticResult:a}=n;t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const r=B.getNodeLotXY({alignItemsX:"center",alignItemsY:"center"},t);t.lot.x=r.x,t.lot.y=r.y,this.placeRelativePosition(t,i,a,1,[]),w("!!!initNodesPosition fixedRootNode:2:",t.x,t.y),i.forEach(l=>{if(l.fixed===!0||!l.rgCalcedVisibility||l===t)return;const c=l.lot.x-B.getNodeWidth(l)/2,d=l.lot.y-B.getNodeHeight(l)/2;this.updateNodePosition(l,c,d)})}}this.allNodes.forEach(n=>{let i=n.x,a=n.y,r=!1;(Number.isNaN(i)||i===void 0)&&(i=0,r=!0),(Number.isNaN(a)||a===void 0)&&(a=0,r=!0),r&&this.updateNodePosition(n,i,a)}),w("["+this.instanceId+"]Start Auto Layout....."),this.start()}getLevelR(e,t){if(e.length===0)return;let n=0;for(let i=0;i<t;i++)n+=e[i]||e[e.length-1];return n}placeRelativePosition(e,t,n,i,a){w("analyticResult:",this.layoutOptions,n,i,a);const r={x:e.lot.x,y:e.lot.y},l=t.filter(c=>c.lot.level===1);this.placeNodesInFanRegion(l,0,360,r,1,n.max_strength,a,1,i,0)}calculateMinimumRadius(e,t=0){if(e.length===0||e.length===1)return 0;const n=e.map(d=>{const h=d.width||d.el_W,f=d.height||d.el_H;return Math.sqrt(h*h+f*f)/2+t/2}),i=[];for(let d=0;d<n.length;d++){const h=(d+1)%n.length;i.push(n[d]+n[h])}let a=Math.max(...i)/2,r=i.reduce((d,h)=>d+h,0);const l=100;let c=r;for(let d=0;d<l;d++){const h=(a+r)/2;let f=0;for(const p of i){const u=p/(2*h);if(u>1){f=10;break}f+=2*Math.asin(u)}f>2*Math.PI?a=h:(r=h,c=h)}return c}placeNodesInFanRegion(e,t,n,i,a,r,l,c,d,h){var y,m;let f=t;const p=n-t,u=200;let g=this.getLevelR(l,a)||h+u*d;a===1&&d===1&&(!this.layoutOptions.levelGaps||this.layoutOptions.levelGaps.length===0)&&(g=this.calculateMinimumRadius(e,10),g=Math.min(Math.max(g,200),500));for(const v of e){const C=((y=v.lot)==null?void 0:y.strengthWithChilds)/r,N=i.x+g,O=i.y,b=C*p,T=f+b/2,R=q.getRotatedPoint(N,O,i.x,i.y,T);v.lot.x=R.x,v.lot.y=R.y,v.lot.childs&&v.lot.childs.length>0&&this.placeNodesInFanRegion(v.lot.childs,f,f+b,i,a+1,(m=v.lot)==null?void 0:m.strengthWithChilds,l,c+1,d,g),f+=b}}graphEventHandle(e,...t){if(e===A.onNodeDragStart){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!0)}else if(e===A.onNodeDragging){const n=t[0],i=t[1],a=t[2],r=this.calcNodeMap.get(n);console.log("[force]onNodeDragging:",n.id,r),r&&(r.x=i,r.y=a)}else if(e===A.onNodeDragEnd){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!1)}}connectToGraphInstance(){this._graphEventHandler=this.graphEventHandle.bind(this),this.graphInstance&&this.graphInstance.addEventHandler(this._graphEventHandler)}disConnectToGraphInstance(){this.graphInstance&&this.graphInstance.removeEventHandler(this._graphEventHandler)}updateVisibleNodes(e){this.visibleNodes=[],e&&(this.allNodes=e),this.allNodes.forEach(t=>{t.lot||(w("node miss lot:",t.text),t.lot={x:t.x,y:t.y,childs:[]}),this.visibleNodes.push(t)}),this.resetCalcNodes(),w("visibleNodes:",this.visibleNodes.length)}viewUpdate(){this._onTickCallback&&this._onTickCallback(),this.graphInstance&&this.graphInstance.forceLayoutTickCallback()}autoLayout(e=!1){if(this.updateVisibleNodes(),this.isMainLayouer){const t=this.graphInstance.dataProvider.getOptions();this.graphInstance.dataProvider.updateOptions({layout:{...t.layout,autoLayouting:!0}})}this.doForceLayout(0)}onFinish(e){this._onFinishCallback=e}onTick(e){this._onTickCallback=e}applyFBuffToNodes(){for(const e of this.forCalcNodes)this.applyToNodePosition(e)}applyPositionToNodes(){this.visibleNodes.forEach(e=>{if(e.fixed)return;const t=this.calcNodeMap.get(e);t&&(e.x=t.x,e.y=t.y)}),this.viewUpdate()}layoutFinished(){if(cancelAnimationFrame(this.animationFrameTimer),this.isMainLayouer){const e=this.graphInstance.dataProvider.getOptions();this.graphInstance.dataProvider.updateOptions({layout:{...e.layout,autoLayouting:!1}})}console.warn("Force Layout["+this.instanceId+"] finished on:",this.layoutTimes,"of",this.maxLayoutTimes),w("Force Layout["+this.instanceId+"] finished"),this.applyFBuffToNodes(),this.applyPositionToNodes(),this.disConnectToGraphInstance();try{this._onFinishCallback&&this._onFinishCallback()}catch(e){console.error(e)}}resetCalcNodes(){this.forCalcNodes=[],this.calcNodeMap=new WeakMap,this.visibleNodes.forEach(e=>{const t={rgNode:e,Fx:0,Fy:0,x:e.x,y:e.y,dragging:!1,force_weight:e.force_weight||1,forceCenterOffset_X:(e.width||e.el_W||60)/2,forceCenterOffset_Y:(e.height||e.el_H||60)/2,fixed:e.fixed||!1};this.forCalcNodes.push(t),this.calcNodeMap.set(e,t)}),this.allLinks=this.graphInstance.getLinksBetweenNodes(this.visibleNodes)}start(){this.stoped&&this.layoutTimes===0||(this.stoped=!1,this.layoutTimes=0,this.updateVisibleNodes(),this.connectToGraphInstance(),this.autoLayout(!0))}doForceLayout(e){if(this.graphInstance.viewComponentUnmounted){w("["+this.instanceId+"]stop layout:viewComponentUnmounted"),this.layoutFinished();return}let t="0";e>0?(this.prev10.length>=10&&(this.prev10.splice(0,1),t=(1e3/((this.prev10[this.prev10.length-1]-this.prev10[0])/10)).toFixed(1)),this.prev10.push(e)):this.visibleNodes.length===0&&this.updateVisibleNodes(),this.layoutTimes++,this.calcNodesPosition(),this.applyFBuffToNodes(),this.disableLiveChanges||this.layoutTimes%2===0&&this.applyPositionToNodes(),this.layoutTimes<=this.maxLayoutTimes?(Date.now()-this.prevLogTime>3e3&&(w("Force Layout["+this.instanceId+"] Is Working...layoutTimes:",this.layoutTimes,"of",this.maxLayoutTimes,t,"Hz",this.visibleNodes.length),this.prevLogTime=Date.now()),this.animationFrameTimer=requestAnimationFrame(this.doForceLayout.bind(this))):this.layoutFinished()}syncNodePosition(e,t,n){const i=this.allNodes.find(r=>r.id===e),a=this.calcNodeMap.get(i);a&&(a.x=t,a.y=n)}calcNodesPosition(){if(this.byNode)for(let e=this.prevNodeLevel1Index;e<this.forCalcNodes.length;e++){const t=this.forCalcNodes[e];if(!t.dragging&&!t.fixed){for(let n=this.prevNodeLevel2Index;n<this.forCalcNodes.length;n++)if(e!==n){const i=this.forCalcNodes[n];if(i.dragging)continue;this.addGravityByNode(t,i)}}}if(this.byLine){if(this.allLinks&&this.allLinks.length>0){for(const e of this.allLinks)if(!e.line.forDisplayOnly){let t=e.line.force_elastic===void 0?1:e.line.force_elastic;if(this.visibleNodes.includes(e.fromNode)&&this.visibleNodes.includes(e.toNode)){const n=this.calcNodeMap.get(e.fromNode),i=this.calcNodeMap.get(e.toNode);this.addElasticByLine(n,i,t)}}}else for(const e of this.visibleNodes)if(e.lot&&e.lot.parent){const t=this.calcNodeMap.get(e.lot.parent),n=this.calcNodeMap.get(e);this.addElasticByLine(t,n,1)}}return!0}stop(){if(this.stoped=!0,this.layoutTimes===0)return;const e=this.graphInstance.dataProvider.getOptions();cancelAnimationFrame(this.animationFrameTimer),w("[RGForceLayout]["+this.instanceId+"]stop:",e.layout.autoLayouting,this.layoutTimes),this.layoutTimes=Number.MAX_VALUE,this.layoutFinished()}addElasticByLine(e,t,n=1){const i=e.x,a=e.y,r=t.x,l=t.y;let c=Math.sqrt((a-l)**2+(i-r)**2);if(c<this.zeroForceLength)return;c>this.maxTractionLength&&(c=this.maxTractionLength);const d=(c-this.zeroForceLength)*.02*this.force_line_elastic*n,h=d,f=d,p=(i-r)/c,u=(a-l)/c;this.addFtoNode(e,p*h*-1,u*h*-1),this.addFtoNode(t,p*f,u*f)}addGravityByNode(e,t,n=1){const i=e.x,a=e.y,r=t.x,l=t.y;if(n===1&&(Math.abs(i-r)>this.maxRepulsionDistance||Math.abs(a-l)>this.maxRepulsionDistance))return;const c=Math.sqrt((a-l)**2+(i-r)**2);if(n===1&&c>this.maxRepulsionDistance)return;let d=(this.maxRepulsionDistance-c)*.02*this.force_node_repulsion*n;c<this.nodeCollisionRadius&&(d=d*2);const h=(i-r)/c,f=(a-l)/c;this.addFtoNode(e,h*d,f*d)}addFtoNode(e,t,n){if(e.fixed||e.dragging||Number.isNaN(t)||Number.isNaN(n))return;t>this.n2nMaxForce&&(t=this.n2nMaxForce),n>this.n2nMaxForce&&(n=this.n2nMaxForce),t<-this.n2nMaxForce&&(t=-this.n2nMaxForce),n<-this.n2nMaxForce&&(n=-this.n2nMaxForce);const i=e.force_weight||1;this.lockX||(e.Fx+=t*(1/i)),this.lockY||(e.Fy+=n*(1/i))}applyToNodePosition(e){if(e.fixed)return 0;if(e.dragging){const i=e.rgNode;return this.updateNodePosition(i,e.x,e.y),0}if(this.calcNodes!==this.allNodes&&!this.calcNodes.includes(e.rgNode))return 0;let t=e.Fx,n=e.Fy;if(t>this.maxMoveSpeed&&(t=this.maxMoveSpeed),n>this.maxMoveSpeed&&(n=this.maxMoveSpeed),t<-this.maxMoveSpeed&&(t=-this.maxMoveSpeed),n<-this.maxMoveSpeed&&(n=-this.maxMoveSpeed),e.x=e.x+t*this.force_x_coefficient,e.y=e.y+n*this.force_y_coefficient,!this.disableLiveChanges){const i=e.rgNode;this.updateNodePosition(i,e.x,e.y)}e.Fx=0,e.Fy=0}}class Lt extends fe{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,w("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="start"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const a=this.layoutOptions.layoutExpansionDirection,r=a==="start"||a==="left"||a==="top"?"start":a==="end"||a==="right"||a==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps or treeNodeGapH,treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes,this.layoutOptions.rotate||(this.layoutOptions.rotate=0)}placeNodes(e,t){if(console.log("tree:placeNodes:rootNode",t.id,t),w("RGTreeLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}w("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};this.rootNode=t,this.allNodes=e,t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=B.getNodeLotXY(n,t);t.lot.x=a.x,t.lot.y=a.y;const r=e;if(w("groupNodes:2:",r.length,r.map(d=>d.text).join(",")),this.layoutOptions.simpleTree===!0){const{tree:d}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!1);this.placeNodesPosition(this.rootNode,d.networkNodes,d.analyticResult)}else{const{tree:d,reverseTree:h}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!0);this.placeNodesPosition(this.rootNode,d.networkNodes,d.analyticResult),this.placeNodesPosition(this.rootNode,h.networkNodes,h.analyticResult)}const l=this.layoutOptions.rotate||0;console.log("rotate:",l);const c={x:t.x,y:t.y};this.allNodes.forEach(d=>{if(d.fixed!==!0&&!!B.isVisibleNode(d)&&(Number.isNaN(d.lot.x)&&(w("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(w("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==t)){if(l){const u=q.getRotatedPoint(d.lot.x,d.lot.y,c.x,c.y,l);d.lot.x=u.x,d.lot.y=u.y}const h=d.lot.level<0?i:n,f=B.getNodeXByLotX(h,d),p=B.getNodeYByLotY(h,d);this.updateNodePosition(d,f,p)}}),w("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t,n){this.placeRelativePosition(e,t,n)}placeRelativePosition(e,t,n){const i=this.layoutOptions.layoutExpansionDirection,{levels:a,levelNodesMap:r}=this.generateLevels(t),l=n.max_strength;if(this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"){const c=this.layoutOptions.treeNodeGapH||20,d=this.layoutOptions.treeNodeGapV||20,h=new Map;for(const y of a){const m=r.get(y);h.set(y,Math.max(...m.map(v=>v.el_H)))}let f=0,p=0;for(const y of t){const m=y.el_W;f+=m,p++}const g=f/p+c;t.forEach(y=>{y.fixed!==!0&&y!==e&&(this.layoutOptions.from==="bottom"?y.lot.y=e.lot.y-this.getLevelDistance(y.lot.level,h,d+10):y.lot.y=e.lot.y+this.getLevelDistance(y.lot.level,h,d+10))}),t.forEach(y=>{y.fixed!==!0&&y.lot.level!==0&&(i==="start"?y.lot.x=e.lot.x-g*y.lot.strengthWithChilds_from:i==="end"?y.lot.x=e.lot.x+g*y.lot.strengthWithChilds_from:y.lot.x=e.lot.x+g*(l/-2+y.lot.strengthWithChilds_from+y.lot.strengthWithChilds/2))}),this.applyNodesGap(t,"v"),this.gatherNodes(t,"v",g)}else{const c=this.layoutOptions.treeNodeGapH||20,d=this.layoutOptions.treeNodeGapV||20;console.log("levelNodesMap:",r);const h=new Map;for(const y of a){const m=r.get(y);h.set(y,Math.max(...m.map(v=>v.el_W||v.width||50)))}let f=0,p=0;for(const y of t){const m=y.el_H;f+=m,p++}if(p===0)return;const g=f/p+d;t.forEach(y=>{y.fixed!==!0&&y!==e&&(this.layoutOptions.from==="right"?y.lot.x=e.lot.x-this.getLevelDistance(y.lot.level,h,c+50):y.lot.x=e.lot.x+this.getLevelDistance(y.lot.level,h,c+50))}),t.forEach(y=>{y.fixed!==!0&&y.lot.level!==0&&(i==="start"?y.lot.y=e.lot.y-g*y.lot.strengthWithChilds_from:i==="end"?y.lot.y=e.lot.y+g*y.lot.strengthWithChilds_from:y.lot.y=e.lot.y+g*(l/-2+y.lot.strengthWithChilds_from+y.lot.strengthWithChilds/2))}),console.log("levelMaxWidthMap:",e.id,h),this.applyNodesGap(t,"h"),this.gatherNodes(t,"h",g)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return i}else{let i=0;for(let a=0;a>e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return-i}}getLevelGap(e,t,n,i){let a=t+(i===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(a=r)}return a}applyNodesGap(e,t){if(this.layoutOptions.ignoreNodeSize)return;const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},a=this.layoutOptions.layoutExpansionDirection,{levels:r,levelNodesMap:l}=this.generateLevels(e),c=new Map;for(const f of r){const p=l.get(f);c.set(f,Math.max(...p.map(u=>u.el_W)))}const{calcNodes:d,calcNodeMap:h}=this.generateCalcNodes(e);d.forEach(f=>{const p=f.rgNode.lot.level<0?i:n;f.x=B.getNodeXByLotX(p,f.rgNode),f.y=B.getNodeYByLotY(p,f.rgNode),f.width=f.rgNode.el_W,f.height=f.rgNode.el_H,f.buffY=0});for(const f of r){const p=l.get(f)||[];if(t==="h")if(a==="end"){p.sort((g,y)=>g.lot.y-y.lot.y);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"bottom",this.layoutOptions.treeNodeGapV);for(const g of u){const y=g.rgNode.lot.level<0?i:n;g.rgNode.lot.y=B.getNodeLotXY(y,g).y}}else{p.sort((g,y)=>y.lot.y-g.lot.y);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"top",this.layoutOptions.treeNodeGapV);for(const g of u){const y=g.rgNode.lot.level<0?i:n;g.rgNode.lot.y=B.getNodeLotXY(y,g).y}}else if(a==="end"){p.sort((g,y)=>g.lot.x-y.lot.x);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"right",this.layoutOptions.treeNodeGapH);for(const g of u){const y=g.rgNode.lot.level<0?i:n,m=B.getNodeLotXY(y,g);g.rgNode.lot.x=m.x}}else{p.sort((g,y)=>y.lot.x-g.lot.x);const u=p.map(g=>h.get(g.id));this.adjustNodePositions(u,"left",this.layoutOptions.treeNodeGapH);for(const g of u){const y=g.rgNode.lot.level<0?i:n;g.rgNode.lot.x=B.getNodeLotXY(y,g).x}}console.log("levelNodes:",f,p)}if(t==="h"){const f=new Map,p=new Map;for(const C of r){const O=l.get(C).map(b=>h.get(b.id));f.set(C,Math.max(...O.map(b=>b.width))),p.set(C,Math.min(...O.map(b=>b.x)))}const u=this.layoutOptions.treeNodeGapH;let g=r.filter(C=>C>0).sort((C,N)=>C-N),y=r.filter(C=>C<0).sort((C,N)=>N-C),m=1;this.layoutOptions.from==="right"&&([y,g]=[g,y],m=-1);let v=0;for(const C of g){const N=C-m,O=p.get(N),b=f.get(N),T=p.get(C)+v;f.get(C);const R=O+b+u;if(R>T){const P=R-T;console.log("[xxxxx]move",N,C,R,T,P),v=P;const k=l.get(C);for(const S of k)S.lot.x+=v;p.set(C,T+P)}else p.set(C,T)}v=0;for(const C of y){const N=C+m,O=p.get(N);f.get(N);const b=p.get(C)+v,T=f.get(C),R=O-u;if(b+T>R){const P=R-(b+T);v=P;const k=l.get(C);for(const S of k)S.lot.x+=v;p.set(C,b+P)}else p.set(C,b)}}else{const f=new Map,p=new Map;for(const C of r){const O=l.get(C).map(b=>h.get(b.id));f.set(C,Math.max(...O.map(b=>b.height))),p.set(C,Math.min(...O.map(b=>b.y)))}const u=this.layoutOptions.treeNodeGapV;let g=r.filter(C=>C>0).sort((C,N)=>C-N),y=r.filter(C=>C<0).sort((C,N)=>N-C),m=1;this.layoutOptions.from==="bottom"&&([y,g]=[g,y],m=-1);let v=0;for(const C of g){const N=C-m,O=p.get(N),b=f.get(N),T=p.get(C)+v;f.get(C);const R=O+b+u;if(R>T){const P=R-T;console.log("[xxxxx]move",N,C,R,T,P),v=P;const k=l.get(C);for(const S of k)S.lot.y+=v;p.set(C,T+P)}else p.set(C,T)}v=0;for(const C of y){const N=C+m,O=p.get(N);f.get(N);const b=p.get(C)+v,T=f.get(C),R=O-u;if(b+T>R){const P=R-(b+T);v=P;const k=l.get(C);for(const S of k)S.lot.y+=v;p.set(C,b+P)}else p.set(C,b)}}}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const{calcNodes:i,calcNodeMap:a}=this.generateCalcNodes(e);i.forEach(l=>{l.movedNodeSizeBefore=1,l.movedNodeSizeAfter=1});const{levelNodesMap:r}=this.generateLevels(e);e.forEach(l=>{if(l.fixed!==!0&&l.lot.level!==0){const c=r.get(l.lot.level)||[];if(l.lot.strengthWithChilds===1&&l.lot.childrenSizeVisible<=1){const d=this.getBloomingNearByParent(l,l.lot.parent,c,t);if(d){const h=a.get(l.id);t==="h"?l.lot.y-d.lot.y>0?(l.lot.y=d.lot.y+n*h.movedNodeSizeAfter,h.movedNodeSizeAfter++):(l.lot.y=d.lot.y-n*h.movedNodeSizeBefore,h.movedNodeSizeBefore++):l.lot.x-d.lot.x>0?(l.lot.x=d.lot.x+n*h.movedNodeSizeAfter,h.movedNodeSizeAfter++):(l.lot.x=d.lot.x-n*h.movedNodeSizeBefore,h.movedNodeSizeBefore++)}}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const l of n)if(l.lot.childrenSizeVisible>1&&l.lot.parent===t){const c=i==="h"?l.lot.y-t.lot.y:l.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=l)}if(r&&r!==e)return r}}class wt extends Re{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");this.layoutOptions=e,this.layoutOptions.distanceCoefficient||(this.layoutOptions.distanceCoefficient=1),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps option in layoutOptions")}placeNodes(e,t){if(w("RGCenterLayout:placeNodes"),!t){w("root is null:",t);return}w("layout by root:",t),this.allNodes=e,this.calcNodes=e,this.rootNode=t;const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode),{networkNodes:i,analyticResult:a}=n;if(this.layoutOptions.genLotInfoOnly){w("only gen lot info, return");return}t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const r={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},l=B.getNodeLotXY(r,t);t.lot.x=l.x,t.lot.y=l.y;const c=this.layoutOptions.rotate||0;w("root position:",t.lot.x,t.lot.y);const d=this.layoutOptions.distanceCoefficient||1,h=this.getLevelDistanceArr();this.placeRelativePosition(this.rootNode,i,a,d,h);const f={x:t.x,y:t.y};i.forEach(p=>{if(p.fixed!==!0&&!!p.rgCalcedVisibility&&p!==t){if(c){const m=q.getRotatedPoint(p.lot.x,p.lot.y,f.x,f.y,c);p.lot.x=m.x,p.lot.y=m.y}const u=r,g=B.getNodeXByLotX(u,p),y=B.getNodeYByLotY(u,p);this.updateNodePosition(p,g,y)}}),this.layoutEnd()}getLevelDistanceArr(){let e=[];if(this.layoutOptions.levelGaps){if(Array.isArray(this.layoutOptions.levelGaps))e=this.layoutOptions.levelGaps;else return console.error("Error levelDistance, levelDistance must is Array"),new Array(10).fill(200);if(e.length>0&&e.length<10)for(let t=e.length;t<10;t++)e.push(e[e.length-1])}return e}}class _t extends Re{constructor(o,e,t){super(o,e,t)}placeNodes(o,e){if(e)w("layout by root:",e);else{w("root is null:",e);return}this.allNodes=o,this.rootNode=e,e.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(e,0,0);const t={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},n=this.layoutOptions.rotate||0,i=B.getNodeLotXY(t,e);e.lot.x=i.x,e.lot.y=i.y;const a=this.allNodes.filter(c=>c.rgCalcedVisibility),r=a.length;let l=r*90/Math.PI/2;l<200&&(l=200),l>800&&(l=800),a.forEach((c,d)=>{const h=q.getOvalPoint(i.x,i.y,l,d,r);c.lot.x=h.x,c.lot.y=h.y,console.log("xxxxxxxxxxxxxx:",c.id,c.lot.x,c.lot.y)}),a.forEach(c=>{if(c.fixed===!0||!c.rgCalcedVisibility)return;if(n){const p=q.getRotatedPoint(c.lot.x,c.lot.y,e.lot.x,e.lot.y,n);c.lot.x=p.x,c.lot.y=p.y}const d=t,h=B.getNodeXByLotX(d,c),f=B.getNodeYByLotY(d,c);this.updateNodePosition(c,h,f)}),this.layoutEnd()}}class Nt extends fe{constructor(e,t,n){super(e,t,n);_(this,"graphOptions");_(this,"layoutOptions");_(this,"allNodes",[]);this.layoutOptions=e,this.graphOptions=t}placeNodes(e,t){if(t)w("layout by root:",t);else{w("root is null:",t);return}w("allNodes:",e.length),this.networkAnalyzer.analyzeNetwork(e,t,!1,!1),w("[Fixed layout canvasOffset]",this.graphOptions.viewSize,this.graphOptions.canvasSize),this.layoutEnd()}}class Cn extends fe{constructor(e,t,n){super(e,t,n);_(this,"graphInstance");_(this,"layoutOptions");_(this,"levelGaps",[]);this.layoutOptions=e,w("new RGSmartTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps&&(Array.isArray(this.layoutOptions.levelGaps)?this.levelGaps=this.layoutOptions.levelGaps:console.error("Error levelDistance, levelDistance must is Array"));const i=this.layoutOptions.from;i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=30),this.layoutOptions.treeNodeGapV<30&&(this.layoutOptions.treeNodeGapV=30)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=30),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.treeNodeGapH<30&&(this.layoutOptions.treeNodeGapH=30)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX,this.layoutOptions.alignItemsY),this.requireLinks=!0,this.graphInstance=n}placeNodes(e,t){if(w("RGSmartTreeLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,w("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},{tree:a,reverseTree:r}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode,!0,!0);t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const l=B.getNodeLotXY(n,t);t.lot.x=l.x,t.lot.y=l.y,this.placeRelativePosition(t,[...a.networkNodes].concat(r.networkNodes),Math.max(a.analyticResult.max_strength,r.analyticResult.max_strength)),w("allNodes:",e.length);const c={left:0,top:90,right:180,bottom:270}[this.layoutOptions.from],d={x:t.x,y:t.y};this.allNodes.forEach(p=>{if(p.fixed===!0||!p.rgCalcedVisibility)return;if(Number.isNaN(p.lot.x)&&(w("bad lot x:",p.text,p.lot.x),p.lot.x=0),Number.isNaN(p.lot.y)&&(w("bad lot y:",p.text,p.lot.y),p.lot.y=0),c){const m=q.getRotatedPoint(p.lot.x,p.lot.y,d.x,d.y,c);p.lot.x=m.x,p.lot.y=m.y}const u=p.lot.level<0?i:n,g=B.getNodeXByLotX(u,p),y=B.getNodeYByLotY(u,p);this.updateNodePosition(p,g,y)}),w("create rootNode coordinates:1",t.x,t.y);const h=new Re({layoutName:"force",maxLayoutTimes:30,force_node_repulsion:.1,force_line_elastic:1,fixedRootNode:!0,disableLiveChanges:!0},this.graphOptions,this.graphInstance);h.isMainLayouer=!1,h.requireLinks=!0,this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?h.lockY=!0:h.lockX=!0;const f=t.fixed;t.fixed=!0,h.skipInitLayout=!0,h.resetCalcNodes(),setTimeout(()=>{t.fixed=f},800),h.onFinish(()=>{t.fixed=f,this.graphInstance&&(this.graphInstance.enableNodeXYAnimation(),this.graphInstance._dataUpdated()),this.applyNodesGap(this.allNodes),this.graphInstance&&(this.graphInstance._dataUpdated(),setTimeout(()=>{this.graphInstance.disableNodeXYAnimation(),this.graphInstance._dataUpdated()},300))}),h.placeNodes(this.allNodes,t),this.layoutEnd()}placeRelativePosition(e,t,n){const i=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h";let a=this.layoutOptions.treeNodeGapH||300,r=this.layoutOptions.treeNodeGapV||10;i==="v"&&([a,r]=[r,a]);const{levels:l,levelNodesMap:c}=this.generateLevels(t),d=new Map;for(const g of l){const y=c.get(g);d.set(g,Math.max(...y.map(m=>m.el_W)))}let h=0,f=0;for(const g of t){const y=g.el_H;h+=y,f++}if(f===0)return;const u=h/f+r;t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.x=e.lot.x+this.getLevelDistance(g.lot.level,d,a))}),t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.level===0?g.lot.y=e.lot.y+u*g.lot.index_of_level:g.lot.y=e.lot.y+u*(n/-2+g.lot.strengthWithChilds_from+g.lot.strengthWithChilds/2))})}applyNodesGap(e){const t=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h",{levels:n,levelNodesMap:i}=this.generateLevels(e),a=new Map;for(const c of n){const d=i.get(c);a.set(c,Math.max(...d.map(h=>h.el_W)))}const{calcNodes:r,calcNodeMap:l}=this.generateCalcNodes(e);r.forEach(c=>{c.x=c.rgNode.x,c.y=c.rgNode.y,c.width=c.rgNode.el_W,c.height=c.rgNode.el_H,c.buffY=0});for(const c of n){const d=i.get(c)||[];if(t==="h"){const h=d.map(u=>l.get(u.id)),f=h.filter(u=>u.y<this.rootNode.y).sort((u,g)=>g.y-u.y),p=h.filter(u=>u.y>=this.rootNode.y).sort((u,g)=>u.y-g.y);this.adjustNodePositions(f,"top",5),this.adjustNodePositions(p,"bottom",5);for(const u of h)u.rgNode.y=u.y}else{const h=d.map(u=>l.get(u.id)),f=h.filter(u=>u.x<this.rootNode.x).sort((u,g)=>g.x-u.x),p=h.filter(u=>u.x>=this.rootNode.x).sort((u,g)=>u.x-g.x);this.adjustNodePositions(f,"left",5),this.adjustNodePositions(p,"right",5);for(const u of h)u.rgNode.x=u.x}console.log("levelNodes:",c,d)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=1;a<=e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r)}return i}else{let i=0;for(let a=-1;a>=e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r)}return-i}}getLevelGap(e,t,n){var a;let i=t+(e===-1?n/2:0);if(((a=this.layoutOptions.levelGaps)==null?void 0:a.length)>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(i=r)}return i}}class bt extends fe{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,w("new RGFolderLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.bottomJunctionPointOffsetX===void 0&&(this.layoutOptions.bottomJunctionPointOffsetX=-50);const i=this.layoutOptions.from;i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps, treeNodeGapH, treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes}placeNodes(e,t){if(w("RGFolderLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,console.log("fixedRootNode:",this.layoutOptions.fixedRootNode);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=B.getNodeLotXY(n,t);t.lot.x=a.x,t.lot.y=a.y,w("allNodes:",e.length),this.networkAnalyzer.isFolderLayout=!0;const{tree:r}=this.networkAnalyzer.analyzeNetwork(e,t,!1,!1);this.placeRelativePosition(t,r.networkNodes,r.analyticResult),w("networkNodes:",r.networkNodes.length),this.allNodes.forEach(l=>{if(l.fixed!==!0&&(Number.isNaN(l.lot.x)&&(w("bad lot x:",l.text,l.lot.x),l.lot.x=0),Number.isNaN(l.lot.y)&&(w("bad lot y:",l.text,l.lot.y),l.lot.y=0),l!==t)){const c=l.lot.level<0?i:n,d=B.getNodeXByLotX(c,l),h=B.getNodeYByLotY(c,l);this.updateNodePosition(l,d,h)}}),w("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeRelativePosition(e,t,n){const i=this.layoutOptions.treeNodeGapH||20,a=this.layoutOptions.treeNodeGapV||20,r=new Map;let l=0,c=0;for(const f of t){const p=f.lot.level,u=f.el_W,g=f.el_H;l+=g,c++;const y=r.get(p);y===void 0?r.set(p,u):u>y&&r.set(p,y)}if(c===0)return;console.log("levelMaxWidthMap:",r);const h=l/c+a;t.forEach(f=>{f.fixed!==!0&&f!==e&&(this.layoutOptions.from==="right"?f.lot.x=e.lot.x-this.getLevelDistance(f.lot.level,r,i+50):f.lot.x=e.lot.x+this.getLevelDistance(f.lot.level,r,i+50))}),t.forEach(f=>{f.fixed!==!0&&f!==e&&f.lot.level!==0&&(f.lot.y=e.lot.y+h*f.lot.strengthWithChilds_from)}),this.gatherNodes(t,"h",h)}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const i={};e.forEach(a=>{if(a.lot.level!==0)return;const r=a.lot.level+"";i[r]||(i[r]=[]),i[r].push(a),a.lot.movedNodeSizeBefore=1,a.lot.movedNodeSizeAfter=1}),e.forEach(a=>{if(a.fixed!==!0&&a.lot.level!==0){const r=a.lot.level+"",l=i[r];if(a.lot.strengthWithChilds===1&&a.lot.childrenSizeVisible<=1){const c=this.getBloomingNearByParent(a,a.lot.parent,l,t);c&&(t==="h"?a.lot.y-c.lot.y>0?(a.lot.y=c.lot.y+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(a.lot.y=c.lot.y-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++):a.lot.x-c.lot.x>0?(a.lot.x=c.lot.x+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(a.lot.x=c.lot.x-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++))}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const l of n)if(l.lot.childrenSizeVisible>1&&l.lot.parent===t){const c=i==="h"?l.lot.y-t.lot.y:l.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=l)}if(r&&r!==e)return r}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++)i+=t.get(a)+this.getLevelGap(a,n);return i}else{let i=e<-1?0:-t.get(e)/2;for(let a=e;a<0;a++)i+=t.get(a)+this.getLevelGap(a,n)+50;return-i}}getLevelGap(e,t){var i;let n=t;if(((i=this.layoutOptions.levelGaps)==null?void 0:i.length)>0){const a=this.layoutOptions.levelGaps[Math.abs(e)];a&&(n=a)}return n}}const he=s=>!s||s.length===0?"":s.map(o=>{switch(o.type){case"M":return`${o.type} ${o.x} ${o.y}`;case"l":return`${o.type} ${o.dx} ${o.dy}`;case"L":return`${o.type} ${o.x} ${o.y}`;case"h":return`${o.type} ${o.dx}`;case"v":return`${o.type} ${o.dy}`;case"c":return`${o.type} ${o.dx1} ${o.dy1} ${o.dx2} ${o.dy2} ${o.dx} ${o.dy}`;case"s":return`${o.type} ${o.dx2} ${o.dy2} ${o.dx} ${o.dy}`;case"q":return`${o.type} ${o.dx1} ${o.dy1} ${o.dx} ${o.dy}`;case"Q":return`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`;case"t":return`${o.type} ${o.dx} ${o.dy}`;case"a":return`${o.type} ${o.rx} ${o.ry} ${o.xAxisRotation} ${o.largeArcFlag} ${o.sweepFlag} ${o.dx} ${o.dy}`;case"Z":return o.type;default:return console.warn("\u672A\u77E5\u7684\u8DEF\u5F84\u547D\u4EE4\u7C7B\u578B:",o),""}}).join(" ").trim(),qe=s=>{const o=s.match(/[a-zA-Z][^a-zA-Z]*/g);let e=0,t=0,n=0,i=0,a=0,r=0,l=0,c=0;const d={x:0,y:0},h={x:0,y:0},f=[];for(const p of o){const u=p.trim().split(/[ ,]+/),g=u[0].toUpperCase(),y=u[0]===u[0].toLowerCase();switch(g){case"M":e=j(n,u[1],y),t=j(i,u[2],y),n=e,i=t;break;case"L":e=j(n,u[1],y),t=j(i,u[2],y),f.push({x:e,y:t});break;case"C":a=j(n,u[1],y),r=j(i,u[2],y),l=j(n,u[3],y),c=j(i,u[4],y),e=j(n,u[5],y),t=j(i,u[6],y),n=e,i=t;break;case"Q":a=j(n,u[1],y),r=j(i,u[2],y),e=j(n,u[3],y),t=j(i,u[4],y),n=e,i=t;break;case"V":t=j(i,u[1],y),i=t;break;case"H":e=j(n,u[1],y),n=e;break;case"Z":break;default:console.log(`Unsupported command: ${g}`)}p===o[0]&&(d.x=e,d.y=t),p===o[o.length-1]&&(h.x=e,h.y=t)}return{startPoint:d,ctrl1:{x:a,y:r},ctrl2:{x:l,y:c},endPoint:h,lines:f}},j=(s,o,e)=>e?s+parseFloat(o):parseFloat(o),Ln=(s,o,e,t,n,i,a)=>{const r=JSON.parse(JSON.stringify(s));let l=!1;if(e<0||e>=s.length-1)return{newPoints:r,pointsChanged:l};r[e-1];const c=r[e],d=r[e+1];o[e-1];const h=o[e];o[e+1];let f=i,p=a;if(t.direction==="v"){const u=o[e-2],g=o[e+2],y=h.x+f;let m=3e3;if(u){const v=Math.abs(u.x-y);v<10&&v<m&&(m=v,f=u.x-h.x)}if(g){const v=Math.abs(g.x-y);v<10&&v<m&&(m=v,f=g.x-h.x)}}else{const u=o[e-2],g=o[e+2],y=h.y+p;let m=3e3;if(u){const v=Math.abs(u.y-y);v<10&&v<m&&(m=v,p=u.y-h.y)}if(g){const v=Math.abs(g.y-y);v<10&&v<m&&(m=v,p=g.y-h.y)}}if(t.direction==="v")if(e===0){const u=c.y<d.y?1:-1,g={x:c.x,y:c.y},y={x:c.x,y:c.y+20*u};c.x=y.x+f,c.y=y.y,r.splice(e,0,g,y),n.indexOffset+=2,l=!0}else if(e===s.length-2){const u=c.y<d.y?1:-1,g={x:h.x+f,y:d.y-20*u},y={x:d.x,y:d.y-20*u};r.splice(e+1,0,g,y),l=!0}else c.x=h.x+f,d.x=h.x+f;else if(e===0){const u=c.x<d.x?1:-1,g={x:c.x,y:c.y},y={x:c.x+20*u,y:c.y};c.x=y.x,c.y=h.y+p,r.splice(e,0,g,y),n.indexOffset+=2,l=!0}else if(e===s.length-2){const u=c.x<d.x?1:-1,g={x:d.x-20*u,y:h.y+p},y={x:d.x-20*u,y:d.y};r.splice(e+1,0,g,y),l=!0}else c.y=h.y+p,d.y=h.y+p;return{newPoints:r,pointsChanged:l}},wn=(s,o={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:i}=s;o.rotate=q.getTextAngle(e,t,n,i),o.x=e+(n-e)/2,o.y=t+(i-t)/2,Number.isNaN(o.rotate)&&(o.rotate=0);const a=n-e,r=i-t,l=[{type:"M",x:e,y:t},{type:"l",dx:a,dy:r}],c=he(l);return{pathCommands:l,pathData:c,textPosition:o,points:[]}},_n=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fx:n,fy:i,fcx:a,fcy:r,f_W:l,f_H:c,tx:d,ty:h,tcx:f,tcy:p,t_W:u,t_H:g}=s,y=d-n,m=h-i,v=n-a,C=i-r,N=d-f,O=h-p,b=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0;let T=Math.min(b,Math.abs(y))*(n<d?1:-1),R=Math.min(b,Math.abs(m))*(i<h?1:-1);const P=t.fromJunctionPoint||e.defaultJunctionPoint||U.border,k=t.toJunctionPoint||e.defaultJunctionPoint||U.border,S=t.lineDirection||(P===U.tb||P===U.top||P===U.bottom?"v":"h")||(Math.abs(v)>=l/2?"h":"v"),M=t.lineDirection||(k===U.tb||k===U.top||k===U.bottom?"v":"h")||(Math.abs(N)>=u/2?"h":"v"),L=[];let D=0,X=0;if(S==="v"){const z=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(h-i)/2),15),E=C>0?z:-z;if(t.placeText==="start"?(D=n,X=i+(C>0?20:-5)):t.placeText==="center"||t.placeText==="middle"?(D=n+(d-n)/2,X=i+E):(D=d,X=h-(C>0?20:-5)),L.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"v",dy:Math.round(E-R)},{type:"c",dx1:0,dy1:Math.round(R),dx2:Math.round(T),dy2:Math.round(R),dx:Math.round(T),dy:Math.round(R)}),M==="v")L.push({type:"h",dx:Math.round(d-n-T*2)},{type:"c",dx1:Math.round(T),dy1:0,dx2:Math.round(T),dy2:Math.round(R),dx:Math.round(T),dy:Math.round(R)},{type:"v",dy:Math.round(h-i-E-R)});else{const F=Math.min(30,Math.abs(d-n)/2),$=N>0?-F:F;L.push({type:"h",dx:Math.round(d-n+$-T)},{type:"c",dx1:Math.round(T),dy1:0,dx2:Math.round(T),dy2:Math.round(R),dx:Math.round(T),dy:Math.round(R)},{type:"v",dy:Math.round(h-i-E-R)},{type:"h",dx:Math.round($-T)})}}else{const z=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(d-n)/2),15),E=v>0?z:-z;if(t.placeText==="start"?(D=n+(v>0?10:-50),X=i):t.placeText==="center"||t.placeText==="middle"?(D=n+E,X=i+(h-i)/2):(D=d-(v>0?10:-50),X=h),T=Math.min(b,Math.abs(y))*(n>a?1:-1),R=Math.min(b,Math.abs(m))*(i<h?1:-1),L.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"h",dx:Math.round(E-T)},{type:"c",dx1:Math.round(T),dy1:0,dx2:Math.round(T),dy2:Math.round(R),dx:Math.round(T),dy:Math.round(R)}),M==="v"){T=Math.min(b,Math.abs(y))*(h<p?1:-1),R=Math.min(b,Math.abs(m))*(h<p?1:-1);const F=Math.min(30,Math.abs(h-i)/2),$=O>0?-F:F;L.push({type:"v",dy:Math.round(h-i+$-R)},{type:"h",dx:Math.round(d-n-E-T)},{type:"c",dx1:0,dy1:Math.round(R),dx2:Math.round(T),dy2:Math.round(R),dx:Math.round(T),dy:Math.round(R)},{type:"v",dy:Math.round($-R)})}else T=Math.min(b,Math.abs(y))*(n+E<d?1:-1),R=Math.min(b,Math.abs(m))*(h>i?1:-1),L.push({type:"v",dy:Math.round(h-i-R*2)},{type:"c",dx1:0,dy1:Math.round(R),dx2:Math.round(T),dy2:Math.round(R),dx:Math.round(T),dy:Math.round(R)},{type:"h",dx:Math.round(d-n-E-T)})}o.x=D,o.y=X;const G=he(L);return{pathCommands:L,pathData:G,textPosition:o,points:[]}},Me={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},Nn=({source:s,sourcePosition:o="bottom",target:e})=>o==="left"||o==="right"?s.x<e.x?{x:1,y:0}:{x:-1,y:0}:s.y<e.y?{x:0,y:1}:{x:0,y:-1},Je=(s,o)=>Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));function Be({source:s,sourcePosition:o="bottom",target:e,targetPosition:t="top",center:n,sourceOffset:i,targetOffset:a}){const r=Me[o],l=Me[t],c={x:s.x+r.x*i,y:s.y+r.y*i},d={x:e.x+l.x*a,y:e.y+l.y*a},h=Nn({source:c,sourcePosition:o,target:d}),f=h.x!==0?"x":"y",p=h[f];let u=[],g,y;const m={x:0,y:0},v={x:0,y:0};let C=0;if(r[f]*l[f]===-1){g=n.x,y=n.y;const O=[{x:g,y:c.y},{x:g,y:d.y}],b=[{x:c.x,y},{x:d.x,y}];r[f]===p?(C=1.1,u=f==="x"?O:b):(C=1.2,u=f==="x"?b:O)}else{const O=[{x:c.x,y:d.y}],b=[{x:d.x,y:c.y}];if(f==="x"?u=r.x===p?b:O:u=r.y===p?O:b,o===t){C=2.1;const S=Math.abs(s[f]-e[f]),M=r[f]===p?i:a;if(S<=M){const L=Math.min(M-1,M-S);r[f]===p?m[f]=(c[f]>s[f]?-1:1)*L:v[f]=(d[f]>e[f]?-1:1)*L}}if(o!==t){C=2.2;const S=f==="x"?"y":"x",M=r[f]===l[S],L=c[S]>d[S],D=c[S]<d[S];(r[f]===1&&(!M&&L||M&&D)||r[f]!==1&&(!M&&D||M&&L))&&(u=f==="x"?O:b)}const T={x:c.x+m.x,y:c.y+m.y},R={x:d.x+v.x,y:d.y+v.y},P=Math.max(Math.abs(T.x-u[0].x),Math.abs(R.x-u[0].x)),k=Math.max(Math.abs(T.y-u[0].y),Math.abs(R.y-u[0].y));P>=k?(g=(T.x+R.x)/2,y=u[0].y):(g=u[0].x,y=(T.y+R.y)/2)}return[[s,{x:c.x+m.x,y:c.y+m.y},...u,{x:d.x+v.x,y:d.y+v.y},e],g,y,0,0,C]}const ke=s=>{const o=[];for(let e=0;e<s.length;e++){const t=s[e];if(t.x=Math.round(t.x),t.y=Math.round(t.y),e===0||e===s.length-1)o.push(t);else{const n=o[o.length-1];t.x===n.x&&t.y===n.y||o.push(t)}}for(let e=2;e<o.length;e++){const t=o[e-2],n=o[e-1],i=o[e],a=t.x===n.x?"v":"h",r=n.x===i.x?"v":"h";a===r&&(n.merged=!0)}return o.filter(e=>e.merged!==!0)};function bn(s,o,e,t){const n=Math.min(Je(s,o)/2,Je(o,e)/2,t),{x:i,y:a}=o;if(s.x===i&&i===e.x||s.y===a&&a===e.y)return[{type:"L",x:i,y:a}];if(s.y===a){const c=s.x<e.x?-1:1,d=s.y<e.y?1:-1;return[{type:"L",x:i+n*c,y:a},{type:"Q",x1:i,y1:a,x:i,y:a+n*d}]}const r=s.x<e.x?1:-1,l=s.y<e.y?-1:1;return[{type:"L",x:i,y:a+n*l},{type:"Q",x1:i,y1:a,x:i+n*r,y:a}]}const Ot=(s,o)=>{const e=[];return s.forEach((t,n)=>{if(n===0)e.push({type:"M",x:Math.round(t.x),y:Math.round(t.y)});else if(n===s.length-1){const i=s[n-1];let a=i.x===t.x?0:i.x<t.x?-1:1,r=i.y===t.y?0:i.y<t.y?-1:1;s.length===2&&(a=0,r=0),e.push({type:"l",dx:Math.round(t.x-i.x+o*a),dy:Math.round(t.y-i.y+o*r)})}else{const i=bn(s[n-1],t,s[n+1],o);e.push(...i)}}),e};var de=(s=>(s.border="border",s.ltrb="ltrb",s.tb="tb",s.lr="lr",s.left="left",s.right="right",s.top="top",s.bottom="bottom",s))(de||{});const Ie=(s,o,e,t,n,i,a,r)=>s==="left"?"left":s==="right"?"right":s==="top"?"top":s==="bottom"?"bottom":s==="horizontalLine"?t?i>r?"bottom":"top":i<r?"bottom":"top":s==="verticalLine"?t?n>a?"right":"left":n<a?"right":"left":o===1?"right":o===-1?"left":e===1?"bottom":e===-1?"top":"left",Ze=s=>s==="left"?"right":s==="right"?"left":s==="top"?"bottom":s==="bottom"?"top":"left",Tt=s=>{if(s.length<2)throw new Error("At least two points are required to form a polyline.");let o=0;const e=[];for(let i=1;i<s.length;i++){const a=s[i].x-s[i-1].x,r=s[i].y-s[i-1].y,l=Math.sqrt(a*a+r*r);e.push(l),o+=l}const t=o/2;let n=0;for(let i=0;i<e.length;i++)if(n+=e[i],n>=t){const a=s[i],r=s[i+1],l=e[i],d=(t-(n-l))/l,h=a.x+(r.x-a.x)*d,f=a.y+(r.y-a.y)*d;return{x:h,y:f}}return{x:0,y:0}},On=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:l,fy:c,fcx:d,fcy:h,f_W:f,f_H:p,tx:u,ty:g,tcx:y,tcy:m,t_W:v,t_H:C}=s,N=l-d,O=c-h;let b=N>1?1:N<-1?-1:0,T=O>1?1:O<-1?-1:0;Math.abs(b)===1&&Math.abs(T)===1&&(Math.abs(N)>Math.abs(O)?T=0:b=0),b===0&&T===0&&(b=1);const R=u-y,P=g-m;let k=R>1?1:R<-1?-1:0,S=P>1?1:P<-1?-1:0;Math.abs(k)===1&&Math.abs(S)===1&&(Math.abs(R)>Math.abs(P)?S=0:k=0),k===0&&S===0&&(b=-1);const M=Ie(n,b,T,!1,l,c,u,g),L=Ie(i,k,S,!0,l,c,u,g),D=M,X=L,G=l+(u-l)/2,z=c+(g-c)/2;let E={x:0,y:0},F=20,$=20;t.ctrlOptionsFor44&&(E={x:t.ctrlOptionsFor44.cx,y:t.ctrlOptionsFor44.cy},F+=t.ctrlOptionsFor44.fd,$+=t.ctrlOptionsFor44.td);const te=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,[Q]=Be({source:{x:l,y:c},sourcePosition:D,target:{x:u,y:g},targetPosition:X,center:{x:G+E.x,y:z+E.y},sourceOffset:F,targetOffset:$}),oe=ke(Q),ie=Ot(oe,te),ne=he(ie),ae=Tt(Q);if(o.x=ae.x,o.y=ae.y,a==="v"){const K=O>1?1:O<-1?-1:0,Y=P>1?1:P<-1?-1:0;t.placeText==="start"?(o.x=l,o.y=c+K*10):t.placeText==="end"&&(o.x=u,o.y=g+Y*10)}else{const K=N>1?1:N<-1?-1:0,Y=R>1?1:R<-1?-1:0;t.placeText==="start"?(o.x=l+K*10,o.y=c):t.placeText==="end"&&(o.x=u+Y*10,o.y=g)}return{pathCommands:ie,pathData:ne,textPosition:o,points:oe,startDirection:D,endDirection:X}},Tn=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:l,fy:c,fcx:d,fcy:h,f_W:f,f_H:p,tx:u,ty:g,tcx:y,tcy:m,t_W:v,t_H:C}=s,N=l-d,O=c-h;let b=N>3?1:N<-3?-1:0,T=O>3?1:O<-3?-1:0;Math.abs(b)===1&&Math.abs(T)===1&&(Math.abs(N)>Math.abs(O)?T=0:b=0),b===0&&T===0&&(b=1);const R=u-y,P=g-m;let k=R>3?1:R<-3?-1:0,S=P>3?1:P<-3?-1:0;Math.abs(k)===1&&Math.abs(S)===1&&(Math.abs(R)>Math.abs(P)?S=0:k=0),k===0&&S===0&&(b=-1);let M=Ie(n,b,T,!1,l,c,u,g),L=Ie(i,k,S,!0,l,c,u,g);const D=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,X=t.ctrlPointsFor49;let G={x:Math.round(l),y:Math.round(c)},z={x:Math.round(u),y:Math.round(g)},E={x:Math.round(X[0].x),y:Math.round(X[0].y)},F={x:Math.round(X[X.length-1].x),y:Math.round(X[X.length-1].y)},$=[...X];if(t.isReverse&&([M,L]=[L,M]),Math.abs(G.x-E.x)>3||Math.abs(G.y-E.y)>3){const ne=G.x+(E.x-G.x)/2,ae=G.y+(E.y-G.y)/2,K=Ze(M),[Y]=Be({source:G,sourcePosition:M,target:E,targetPosition:K,center:{x:ne,y:ae},sourceOffset:20,targetOffset:5});$=ke([...Y,...$])}if(Math.abs(z.x-F.x)>3||Math.abs(z.y-F.y)>3){const ne=F.x+(z.x-F.x)/2,ae=F.y+(z.y-F.y)/2,K=Ze(L),[Y]=Be({source:F,sourcePosition:K,target:z,targetPosition:L,center:{x:ne,y:ae},sourceOffset:5,targetOffset:20});$=ke([...$,...Y])}const te=$,Q=Ot(te,D),oe=he(Q),ie=Tt(X);return o.x=ie.x,o.y=ie.y,{pathCommands:[],pathData:oe,textPosition:o,points:te,startDirection:M,endDirection:L}},Rn=(s,o={x:0,y:0,rotate:0})=>{const{line:e,lineShape:t,fx:n,fy:i,fcx:a,fcy:r,tx:l,ty:c,tcx:d,tcy:h}=s,f=l-n,p=c-i;let u=n-a,g=i-r,y=l-d,m=c-h,{fromJunctionPoint:v,toJunctionPoint:C}=e;e.isReverse&&([v,C]=[C,v]),(v===U.left||v===U.right)&&(g=0),(v===U.top||v===U.bottom)&&(u=0),(C===U.left||C===U.right)&&(m=0),(C===U.top||C===U.bottom)&&(y=0);const N=Math.min(200,Math.max(100,Math.abs(f/2))),O=Math.min(200,Math.max(100,Math.abs(p/2))),b=u/(Math.abs(u)+Math.abs(g))*N,T=g/(Math.abs(u)+Math.abs(g))*O;let R={x:b,y:T};const P=y/(Math.abs(y)+Math.abs(m))*N+f,k=m/(Math.abs(y)+Math.abs(m))*O+p;let S={x:P,y:k};e.ctrlPoints&&e.ctrlPoints.length>0&&(e.isReverse?(R.x+=e.ctrlPoints[1].x,R.y+=e.ctrlPoints[1].y,S.x+=e.ctrlPoints[0].x,S.y+=e.ctrlPoints[0].y):(R.x+=e.ctrlPoints[0].x,R.y+=e.ctrlPoints[0].y,S.x+=e.ctrlPoints[1].x,S.y+=e.ctrlPoints[1].y));const M={x:n+R.x,y:i+R.y},L={x:n+S.x,y:i+S.y},D={x:n+f,y:i+p},X=[{type:"M",x:n,y:i},{type:"c",dx1:R.x,dy1:R.y,dx2:S.x,dy2:S.y,dx:f,dy:p}];t===8&&X.push({type:"Z"});const G=Rt({x:n,y:i},M,L,D,t<6?.8:.5);o.x=G.x,o.y=G.y;const z=he(X);return{pathCommands:X,pathData:z,textPosition:o,points:[]}},Rt=(s,o,e,t,n=.5)=>{const i={x:(1-n)*s.x+n*o.x,y:(1-n)*s.y+n*o.y},a={x:(1-n)*o.x+n*e.x,y:(1-n)*o.y+n*e.y},r={x:(1-n)*e.x+n*t.x,y:(1-n)*e.y+n*t.y},l={x:(1-n)*i.x+n*a.x,y:(1-n)*i.y+n*a.y},c={x:(1-n)*a.x+n*r.x,y:(1-n)*a.y+n*r.y};return{x:(1-n)*l.x+n*c.x,y:(1-n)*l.y+n*c.y}},Sn=(s,o={x:0,y:0,rotate:0})=>{const{line:e,totalLinesBetweenNodes:t,currentLineIndex:n,lineDirection:i,lineShape:a,fx:r,fy:l,fcx:c,fcy:d,f_W:h,f_H:f,tx:p,ty:u,tcx:g,tcy:y,t_W:m,t_H:v}=s,C=p-r,N=u-l,O=p>r?1:-1,b=u>l?1:-1,T=i==="v"?b:O,R=r-c,P=l-d,k=p-g,S=u-y,M=1/(t+1)*(n+1);let L={x:0,y:0},D={x:0,y:0};if(a===H.Curve2)L=i==="v"?{x:0,y:T*30}:{x:T*30,y:0},D=i==="v"?{x:C*M,y:T*-10}:{x:T*-10,y:N*M};else if(a===H.Curve3)L=i==="v"?{x:0,y:N*M}:{x:T*30,y:0},D=i==="v"?{x:0,y:0}:{x:T*-10,y:N*M};else if(a===H.Curve5)L={x:0,y:0},D=i==="v"?{x:0,y:N*M}:{x:C*M,y:0};else if(a===H.Curve7||a===H.Curve8){const oe=R/(Math.abs(R)+Math.abs(P))*30,ie=P/(Math.abs(R)+Math.abs(P))*30;L={x:oe,y:ie};const ne=k/(Math.abs(k)+Math.abs(S))*30+C,ae=S/(Math.abs(k)+Math.abs(S))*30+N;D={x:ne,y:ae}}const X={x:r+L.x,y:l+L.y},G={x:r+D.x,y:l+D.y},z={x:r+C,y:l+N},E=[{type:"M",x:r,y:l},{type:"c",dx1:L.x,dy1:L.y,dx2:D.x,dy2:D.y,dx:C,dy:N}];a===8&&E.push({type:"Z"});const F=Rt({x:r,y:l},X,G,z,a<6?.8:.5);o.x=F.x,o.y=F.y;const $=he(E);return{pathCommands:E,pathData:$,textPosition:o,points:[]}};class Pn{constructor(){_(this,"graphData",{rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]});_(this,"options",{});_(this,"runtimeDATA4NodeMap",new Map);_(this,"runtimeDATA4Links",[]);_(this,"runtimeDATA4LinkMap",new Map);_(this,"runtimeDATA4ConnectTargets",[]);_(this,"runtimeDATA4ElLineTargets",[]);_(this,"runtimeDATA4ShouldRenderItems",{nodes:[],lines:[],fakeLines:[]})}}class Mn extends Pn{constructor(){super()}getOptions(){return this.options}getNodeById(o){return this.runtimeDATA4NodeMap.get(o)}getLineById(o){var e;return(e=this.runtimeDATA4LinkMap.get(o))==null?void 0:e.line}getLinkByLineId(o){return this.runtimeDATA4LinkMap.get(o)}getFakeLineById(o){return this.graphData.fakeLines.find(e=>e.id===o)}getNodes(){return this.graphData.nodes}getLinks(){return this.runtimeDATA4Links}getFakeLines(){return this.graphData.fakeLines}getLines(){return this.runtimeDATA4Links.map(o=>o.line)}getRootNode(){return this.graphData.rootNode}getShouldRenderNodes(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.nodes:this.graphData.nodes}getShouldRenderLines(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.lines:this.graphData.normalLines}getShouldRenderFakeLines(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.fakeLines:this.graphData.fakeLines}isPerformanceMode(){return this.options.performanceMode}getCanvasScale(){return this.options.canvasZoom/100}getConnectTargets(){return this.runtimeDATA4ConnectTargets}getConnectTargetById(o){if(!o)throw new Error("[getConnectTargetById]targetId is empty");for(let e=0;e<this.runtimeDATA4ConnectTargets.length;e++){const t=this.runtimeDATA4ConnectTargets[e];if(t.targetId===o)return t}}getElLineTargets(){return this.runtimeDATA4ElLineTargets}getElLineTargetById(o){return this.runtimeDATA4ElLineTargets.find(e=>e.id===o)}calcShouldRenderNodes(){const o=[];return this.graphData.nodes.forEach(e=>{e.rgShouldRender!==!1&&e.rgCalcedVisibility!==!1&&o.push(e)}),o}calcShouldRenderLines(){const o=[];return this.runtimeDATA4Links.forEach(e=>{e.rgShouldRender!==!1&&e.line.hidden!==!0&&e.rgCalcedVisibility!==!1&&o.push(e.line)}),o}calcShouldRenderFakeLines(){return this.graphData.fakeLines}findNodeByXy(o){const e=this.graphData.nodes;for(let t=e.length-1;t>=0;t--){const n=e[t],i=n.x,a=n.y,r=n.el_W||n.width||50,l=n.el_H||n.height||50;if(o.x>i&&o.x<i+r&&o.y>a&&o.y<a+l)return n}return null}}class kn{constructor(){_(this,"map");this.map=new Map}_key(o,e){return o<=e?`${o}${e}`:`${e}${o}`}addEdge(o,e){const t=this._key(o,e),n=this.map.get(t)||0;return this.map.set(t,n+1),n}getCount(o,e){const t=this._key(o,e);return this.map.get(t)||0}clear(){this.map.clear()}}class Se extends Mn{constructor(){super();_(this,"commits");_(this,"updateViewHook",e=>{});this.options=Te({}),this.commits=this.resetCommints()}clearReactiveData(){this.graphData.nodes=[],this.graphData.normalLines=[],this.graphData.fakeLines=[],this.runtimeDATA4Links.splice(0,this.runtimeDATA4Links.length),this.runtimeDATA4ElLineTargets.splice(0,this.runtimeDATA4ElLineTargets.length),this.runtimeDATA4NodeMap.clear(),this.runtimeDATA4LinkMap.clear(),this.graphData.rootNode=void 0,this.updateShouldRenderGraphData(),this.commits.optionsChanged=!0,this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0,this.commits.fakeLinesListChanged=!0}resetCommints(){return{optionsChanged:!1,changedNodes:[],nodesListChanged:!1,changedLines:[],linesListChanged:!1,changedFakeLines:[],fakeLinesListChanged:!1,changedConnectTargets:[],connectTargetsListChanged:!1}}commitLine(e){this.commits.linesListChanged=!0}commitNode(e){this.commits.changedNodes.includes(e)||this.commits.changedNodes.push(e),this.commits.linesListChanged=!0,this.commits.fakeLinesListChanged=!0}commitFakeLine(e){this.commits.fakeLinesListChanged=!0}commitConnectTarget(e){this.commits.changedConnectTargets.includes(e)||this.commits.changedConnectTargets.push(e),this.commits.fakeLinesListChanged=!0}dataUpdated(){const e=this.commits;this.commits=this.resetCommints(),this.updateViewHook(e)}updateOptions(e){var t;if(e.layout&&console.log("RGDataProvider:updateOptions:layout:",(t=e.layout)==null?void 0:t.layoutName,e.layout),Object.assign(this.options,e),this.isPerformanceMode()&&!this.options.showEasyView){const n=Object.keys(e);console.log("changedKeys:",n.join(",")),n.includes("canvasZoom")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0),n.includes("viewSize")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0),n.includes("canvasOffset")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0)}this.commits.optionsChanged=!0}clearChecked(){this.updateOptions({checkedNodeId:"",checkedLineId:""})}setCanvasOffset(e,t){this.updateOptions({canvasOffset:{x:e,y:t}}),this.commits.optionsChanged=!0}setCanvasZoom(e){this.updateOptions({canvasZoom:e})}setEditingLine(e){if(e){const t=this.getLineById(e.id)||this.getFakeLineById(e.id);t&&this.updateOptions({editingLineController:{...this.options.editingLineController,line:t,show:!0},checkedLineId:e.id})}else this.updateOptions({editingLineController:{...this.options.editingLineController,line:null,show:!1},checkedLineId:""})}setEditingNodes(e){for(const n of e)if(!n||!this.getNodeById(n.id)){console.error("setEditingNodes Error: node not found:",n);return}this.getNodes().filter(n=>n.selected).forEach(n=>this.updateNode(n.id,{selected:!1})),this.updateOptions({editingController:{...this.options.editingController,nodes:e,show:e.length>0}}),e.length>1&&this.options.editingController.nodes.forEach(n=>this.updateNode(n.id,{selected:!0}))}setCanvasCenter(e,t){const n=this.options.viewSize.width/2,i=this.options.viewSize.height/2,a=this.options.canvasZoom/100;this.setCanvasOffset(n-e*a,i-t*a)}removeNodeById(e){this.beforeNodeBeRemove(e),w("Removed Node line/connect-arget\uFF1A",e);let t=0;for(let n=0;n<this.graphData.nodes.length;n++)e.includes(this.graphData.nodes[n].id)&&(this.graphData.nodes.splice(n,1),n--,t++);for(const n of e)this.runtimeDATA4NodeMap.delete(n);w("Removed node\uFF1A",e,t),this.commits.nodesListChanged=!0}removeLineByIds(e){w("_removeLineByIds:",e.length,e),this.removeFakeLineByIds(e);let t=0;for(let n=0;n<this.graphData.normalLines.length;n++){const i=this.graphData.normalLines[n];e.includes(i.id)&&(this.graphData.normalLines.splice(n,1),n--,t++)}w("_removeLineByIds:",t),this.removeLinkByLineIds(e),this.updateLinks(),this.commits.linesListChanged=!0}removeFakeLineByIds(e){w("_removeFakeLineByIds:",e.length,e);let t=0;for(let n=0;n<this.graphData.fakeLines.length;n++){const i=this.graphData.fakeLines[n];e.includes(i.id)&&(this.graphData.fakeLines.splice(n,1),n--,t++)}this.commits.fakeLinesListChanged=!0,w("_removeFakeLineByIds:",t)}removeLinkByLineIds(e){w("_removeLinkByLineIds:",e.length,e);let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const i=this.runtimeDATA4Links[n];e.includes(i.lineId)&&(this.runtimeDATA4Links.splice(n,1),this.runtimeDATA4LinkMap.delete(i.lineId),n--,t++)}this.commits.fakeLinesListChanged=!0,w("_removeLinkByLineIds:",t)}removeConnectTarget(e){const t=this.runtimeDATA4ConnectTargets.findIndex(n=>n.targetId===e);if(t!==-1){const n=this.runtimeDATA4ConnectTargets[t];(n.targetType===V.NodePoint||n.targetType===V.CanvasPoint)&&this.runtimeDATA4ConnectTargets.splice(t,1)}this.commits.connectTargetsListChanged=!0}updateLinks(e=[]){const t=new kn;for(const n of this.runtimeDATA4Links){const{from:i,to:a}=n.line,r=t.addEdge(i,a);r!==n.currentLineIndex&&(n.currentLineIndex=r,this.commitLine(n.lineId))}for(const n of this.runtimeDATA4Links){const{from:i,to:a}=n.line,r=t.getCount(i,a);r!==n.totalLinesBetweenNodes&&(n.totalLinesBetweenNodes=r,this.commitLine(n.lineId))}t.clear()}beforeNodeBeRemove(e){let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const i=this.runtimeDATA4Links[n];(e.includes(i.fromNode.id)||e.includes(i.toNode.id))&&(this.removeLinkByLineIds([i.lineId]),n--,t++)}w("Removed Node link\uFF1A",e,t);for(let n=0;n<this.graphData.fakeLines.length;n++){const i=this.graphData.fakeLines[n];let a=!1;if(i.fromType===V.Node&&e.includes(i.from))a=!0;else if(i.fromType===V.CanvasPoint||i.fromType===V.NodePoint){const r=this.getConnectTargetById(i.from);r&&r.nodeId&&e.includes(r.nodeId)&&(a=!0)}else if(i.toType===V.CanvasPoint||i.toType===V.NodePoint){const r=this.getConnectTargetById(i.to);r&&r.nodeId&&e.includes(r.nodeId)&&(a=!0)}a&&(this.graphData.fakeLines.splice(n,1),n--,this.commits.fakeLinesListChanged=!0)}for(let n=0;n<this.runtimeDATA4ConnectTargets.length;n++){const i=this.runtimeDATA4ConnectTargets[n];i.nodeId&&e.includes(i.nodeId)&&(this.runtimeDATA4ConnectTargets.splice(n,1),this.commitConnectTarget(i.targetId),n--)}}addFakeLines(e){for(const t of e)if(t.id||console.warn("[relation-graph]Must have id for fake line:",t),this.graphData.fakeLines.some(n=>n.id===t.id))console.log("[relation-graph]Ignore duplicate fake line id:",t.id);else{t.isFakeLine=!0;const n=ue(t,this.options);n.id||(n.id=ze(6)),this.graphData.fakeLines.push(n)}this.commits.fakeLinesListChanged=!0}clearFakeLines(){this.graphData.fakeLines.splice(0,this.graphData.fakeLines.length),this.commits.fakeLinesListChanged=!0}addNodes(e){for(const t of e)this.runtimeDATA4NodeMap.set(t.id,t);this.graphData.nodes.push(...e.map(t=>this.runtimeDATA4NodeMap.get(t.id))),this.commits.nodesListChanged=!0}addLines(e){this.graphData.normalLines.push(...e);const t=[];for(const n of e){const i=this.getNodeById(n.from),a=this.getNodeById(n.to),r={lineId:n.id,line:n,fromNode:i,toNode:a,currentLineIndex:0,totalLinesBetweenNodes:1,rgShouldRender:!0,rgCalcedVisibility:!0};this.runtimeDATA4LinkMap.set(r.lineId,r),t.push(r)}this.runtimeDATA4Links.push(...t.map(n=>this.runtimeDATA4LinkMap.get(n.lineId))),this.updateLinks(),this.commits.linesListChanged=!0}updateNode(e,t){const n=this.getNodeById(e);if(!n){console.error("Cannot find node to update:",e,t);return}const i=t.hidden!==void 0&&n.hidden!==t.hidden;if(Object.assign(n,t,{id:e}),i){const a=B.getDescendantNodes(n);this.updateNodesVisibleProperty([n].concat(a))}this.commitNode(e)}updateNodeData(e,t){const n=this.getNodeById(e);if(!n){console.error("Cannot find node to update:",e);return}this.updateNode(e,{data:Object.assign(n.data||{},t)})}updateLine(e,t){const n=this.getLineById(e);if(!n){this.updateFakeLine(e,t);return}Object.assign(n,t,{id:e}),this.commitLine(e)}updateLineData(e,t){const n=this.getLineById(e);if(!n){console.error("Cannot find line to update:",e);return}this.updateLine(e,{data:Object.assign(n.data||{},t)})}updateFakeLine(e,t){const n=this.getFakeLineById(e);if(!n){console.error("Cannot find fakeLine to update:",e,t);return}Object.assign(n,t,{id:e}),this.commitFakeLine(e)}updateConnectTarget(e,t){const n=this.getConnectTargetById(e);!n||(Object.assign(n,t,{targetId:e}),this.commitConnectTarget(e))}updateElLineTarget(e,t){const n=this.getElLineTargetById(e);!n||Object.assign(n,t,{id:e})}updateNodesVisibleProperty(e){let t=!1;e||(e=this.getNodes(),t=!0);for(const n of e){const i=B.isVisibleNode(n);n.rgCalcedVisibility!==i&&(n.rgCalcedVisibility=i,this.commitNode(n.id))}for(const n of this.runtimeDATA4Links)if(t||e.includes(n.fromNode)||e.includes(n.toNode)){const a=this.calcLinkVisibility(n);n.rgCalcedVisibility=a,this.commitLine(n.lineId)}}calcLinkVisibility(e){return e.fromNode.rgCalcedVisibility&&e.toNode.rgCalcedVisibility}updateShouldRenderGraphData(){const e=this.options,t=e.canvasZoom/100,n={x:-e.canvasOffset.x/t,y:-e.canvasOffset.y/t},i={x:n.x+e.viewSize.width/t,y:n.y+e.viewSize.height/t},a=e.snapshotting;for(const r of this.getNodes()){let l=!0;a||r.alwaysRender?l=!0:((r.x>i.x||r.y>i.y)&&(l=!1),(r.x+r.el_W<n.x||r.y+r.el_H<n.y)&&(l=!1)),r.rgShouldRender=l}for(const r of this.runtimeDATA4Links){if(a){r.rgShouldRender=!0;continue}r.rgShouldRender=r.fromNode.rgShouldRender||r.toNode.rgShouldRender}this.options.showEasyView?(this.runtimeDATA4ShouldRenderItems.nodes=[],this.runtimeDATA4ShouldRenderItems.lines=[],this.runtimeDATA4ShouldRenderItems.fakeLines=[]):(this.runtimeDATA4ShouldRenderItems.nodes=this.calcShouldRenderNodes(),this.runtimeDATA4ShouldRenderItems.lines=this.calcShouldRenderLines(),this.runtimeDATA4ShouldRenderItems.fakeLines=this.calcShouldRenderFakeLines())}addConnectTarget(e){return this.runtimeDATA4ConnectTargets.push(e),this.commits.connectTargetsListChanged=!0,this.commits.fakeLinesListChanged=!0,this.getConnectTargetById(e.targetId)}addElLineTarget(e){this.runtimeDATA4ElLineTargets.push(e),this.commits.fakeLinesListChanged=!0}setRootNodeId(e){if(this.graphData.rootNode=this.graphData.nodes.find(t=>t.id===e),!this.graphData.rootNode)throw new Error("The root node [rootId] is not set! Or cannot get the root node:"+e+", If you don't have any nodes to display, you can simply set an invisible node: {id:'root', opacity:0}")}}class In{constructor(){_(this,"listeners");_(this,"useReactiveDataToAutoUpdateView",!1);_(this,"instanceId");_(this,"dataProvider");_(this,"options");_(this,"_dataUpdatedRequested",!1);_(this,"eventHandlers",[]);_(this,"_emitHook");this.dataProvider=new Se,this.options=this.dataProvider.getOptions(),this.listeners={},this.instanceId="RG-"+this.generateNewUUID(5)}generateNewUUID(o=5){return ze(o)}enableDebugLog(o){this.dataProvider.updateOptions({debug:o}),window&&(window.relationGraphDebug=o)}_dataUpdated(){this._requestDataUpdate()}_requestDataUpdate(){!window||!window.requestAnimationFrame||this._dataUpdatedRequested||(this._dataUpdatedRequested=!0,requestAnimationFrame(this._doSomethingAfterDataUpdated.bind(this)))}_doSomethingAfterDataUpdated(){try{!this.useReactiveDataToAutoUpdateView||this.dataProvider.isPerformanceMode()?(this._previousUpdateTime=Date.now(),this.updateShouldRenderGraphData(),this.updateEasyView(),this.dataProvider&&this.dataProvider.dataUpdated()):this.updateMiniView()}catch(o){console.error("[relation-graph]Error:",o)}finally{this._dataUpdatedRequested=!1}}addEventHandler(o){this.eventHandlers.includes(o)||this.eventHandlers.push(o)}removeEventHandler(o){const e=this.eventHandlers.indexOf(o);e!==-1&&this.eventHandlers.splice(e,1)}setEventEmitHook(o){this._emitHook=o,console.warn("[setEventEmitHook]",this._emitHook)}emitEvent(o,...e){let{result:t,handled:n}=this.defaultEventHandler(o,...e);for(const i of this.eventHandlers){const a=i(o,...e);a!==void 0&&(t=a,n=!0)}if(n||this._emitHook&&this._emitHook(o,...e,i=>{i!==void 0&&(t=i)}),t!==void 0)return w("[custom event hook]Event:",o," => returnValue:",t),t}defaultEventHandler(o,...e){let t,n=!1;if(o===A.onReady)this.listeners.onReady&&(n=!0,this.listeners.onReady(this));else if(o===A.onNodeDragStart)this.listeners.onNodeDragStart&&(n=!0,this.listeners.onNodeDragStart(e[0],e[1]));else if(o===A.onNodeDragging){if(this.listeners.onNodeDragging){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3],c=e[4],d=e[5];t=this.listeners.onNodeDragging(i,a,r,l,c,d)}}else if(o===A.onCanvasDragging){if(this.listeners.onCanvasDragging){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3];t=this.listeners.onCanvasDragging(i,a,r,l)}}else if(o===A.onNodeDragEnd){const i=e[0],a=e[1],r=e[2],l=e[3];this.listeners.onNodeDragEnd&&(n=!0,this.listeners.onNodeDragEnd(i,a,r,l))}else if(o===A.onZoomEnd)this.listeners.onZoomEnd&&(n=!0,this.listeners.onZoomEnd());else if(o===A.onNodeClick){if(this.listeners.onNodeClick){n=!0;const i=e[0],a=e[1];this.listeners.onNodeClick(i,a)}}else if(o===A.onLineClick){if(this.listeners.onLineClick){n=!0;const i=e[0],a=e[1],r=e[2];this.listeners.onLineClick(i,a,r)}}else if(o===A.onNodeExpand){if(this.listeners.onNodeExpand){n=!0;const i=e[0],a=e[1];this.listeners.onNodeExpand(i,a)}}else if(o===A.onNodeCollapse){if(this.listeners.onNodeCollapse){n=!0;const i=e[0],a=e[1];this.listeners.onNodeCollapse(i,a)}}else if(o===A.onCanvasDragEnd){if(this.listeners.onCanvasDragEnd){n=!0;const i=e[0];this.listeners.onCanvasDragEnd(i)}}else if(o===A.onCanvasClick){if(this.listeners.onCanvasClick){n=!0;const i=e[0];this.listeners.onCanvasClick(i)}}else if(o===A.onCanvasSelectionEnd){if(this.listeners.onCanvasSelectionEnd){n=!0;const i=e[0],a=e[1];this.listeners.onCanvasSelectionEnd(i,a)}}else if(o===A.onContextmenu){if(this.listeners.onContextmenu){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3],c=e[4];this.listeners.onContextmenu(i,a,r,l,c)}}else if(o===A.onFullscreen){if(this.listeners.onFullscreen){n=!0;const i=e[0],a=e[1];t=this.listeners.onFullscreen(i,a)}}else if(o===A.beforeAddNodes){if(this.listeners.beforeAddNodes){n=!0;const i=e[0];t=this.listeners.beforeAddNodes(i)}}else if(o===A.beforeAddLines){if(this.listeners.beforeAddLines){n=!0;const i=e[0];t=this.listeners.beforeAddLines(i)}}else if(o===A.onKeyboardDown){if(this.listeners.onKeyboardDown){n=!0;const i=e[0];t=this.listeners.onKeyboardDown(i)}}else if(o===A.onKeyboardUp){if(this.listeners.onKeyboardUp){n=!0;const i=e[0];t=this.listeners.onKeyboardUp(i)}}else if(o===A.onLineBeCreated){if(this.listeners.onLineBeCreated){n=!0;const i=e[0];t=this.listeners.onLineBeCreated(i)}}else if(o===A.onCanvasDragStart){if(this.listeners.onCanvasDragStart){n=!0;const i=e[0],a=e[1],r=e[2];t=this.listeners.onCanvasDragStart(i,a,r)}}else if(o===A.onResizeEnd){if(this.listeners.onResizeEnd){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3];t=this.listeners.onResizeEnd(i,a,r,l)}}else if(o===A.onResizeStart){if(this.listeners.onResizeStart){n=!0;const i=e[0],a=e[1];t=this.listeners.onResizeStart(i,a)}}else if(o===A.beforeNodeResize){if(this.listeners.beforeNodeResize){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3],c=e[4];t=this.listeners.beforeNodeResize(i,a,r,l,c)}}else if(o===A.onViewResize&&this.listeners.onViewResize){n=!0;const i=e[0];t=this.listeners.onViewResize(i)}return{result:t,handled:n}}setEventListener(o){Object.assign(this.listeners,o)}}class En extends In{constructor(){super(...arguments);_(this,"$dom");_(this,"$canvasDom");_(this,"_rgAsConnectArea",!1);_(this,"$lineTextContainer4NormalLine");_(this,"$lineTextContainer4FakeLine");_(this,"viewBoundingClientRect",null)}getLineTextContainer(e){if(!(!e||!this.$canvasDom))return e.isFakeLine?(this.$lineTextContainer4NormalLine||(this.$lineTextContainer4NormalLine=this.$canvasDom.querySelector(".rg-lines-container-el-lines .rg-linetext-container"),this.dataStores.textContainer4NormalRef&&(this.dataStores.textContainer4NormalRef.value=this.$lineTextContainer4NormalLine)),this.$lineTextContainer4NormalLine):(this.$lineTextContainer4FakeLine||(this.$lineTextContainer4FakeLine=this.$canvasDom.querySelector(".rg-lines-container-normal-lines .rg-linetext-container"),this.dataStores.textContainer4FakeLineRef&&(this.dataStores.textContainer4FakeLineRef.value=this.$lineTextContainer4FakeLine)),this.$lineTextContainer4FakeLine)}getViewBoundingClientRect(){var t;if(!this.$dom)return this.viewBoundingClientRect||console.error("[getViewBoundingClientRect] RelationGraph DOM is not set yet!"),this.viewBoundingClientRect;const e=(t=this.$dom)==null?void 0:t.getBoundingClientRect();return this.viewBoundingClientRect=e,e}getBoundingClientRect(){return console.warn("Please use getViewBoundingClientRect instead of getBoundingClientRect, this method is compatible with older api versions."),this.getViewBoundingClientRect()}_getEventPoint(e){return this.getViewXyByEvent(e)}getViewXyByEvent(e){const t={x:e.clientX,y:e.clientY};if(ce(e)){const n=e.touches||e.targetTouches;if(!n)throw new Error("error targetTouches");t.x=n[0].clientX,t.x=n[0].clientY}return this.getViewXyByClientXy(t)}getViewXyByClientXy(e){const t=this.getViewBoundingClientRect();return{x:e.x-t.x,y:e.y-t.y}}getCanvasXyByClientXy(e){const t=this.getViewBoundingClientRect(),n={x:e.x-t.left,y:e.y-t.top};return this.getCanvasXyByViewXy(n)}getCanvasXyByViewXy(e){if(this._rgAsConnectArea)return e;const t=this.dataProvider.getOptions(),n=t.canvasZoom/100,i={x:e.x-t.canvasOffset.x,y:e.y-t.canvasOffset.y};return{x:i.x/n,y:i.y/n}}getViewXyByCanvasXy(e){const t=this.dataProvider.getOptions(),n=t.canvasZoom/100;return{x:e.x*n+t.canvasOffset.x,y:e.y*n+t.canvasOffset.y}}getCanvasCoordinateByClientCoordinate(e){return console.warn("Please use getCanvasXyByClientXy instead of getCanvasCoordinateByClientCoordinate, this method is compatible with older api versions."),this.getCanvasXyByClientXy(e)}isNode(e){const t=we(e,"rg-node-peel","rg-map");if(!!t)return this.dataProvider.getNodeById(t.dataset.id)}isLine(e){const t=we(e,"rg-line-peel","relation-graph");if(!!t)return this.dataProvider.getLineById(t.dataset.id)}isLink(e){throw new Error("Please use isLine")}}class Dn extends Se{constructor(e,t,n,i){super();_(this,"dataStores");this.dataStores=e;const a=Object.assign({},this.options,n);this.options=n,Object.assign(this.options,a),this.graphData=t,this.runtimeDATA4Links=i.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=i.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=i.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=i.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=i.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=i.runtimeDATA4ElLineTargets,this.updateViewHook=r=>{if(console.log("###########updateViewHook"),r.optionsChanged&&(this.dataStores.store4Options.set(this.getOptions()),console.log("[updateViewHook]optionsChanged")),r.nodesListChanged&&(this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),console.log("[updateViewHook]nodesListChanged")),r.linesListChanged){const l=this.getShouldRenderLines();this.dataStores.store4ShouldRenderLines.set(l),console.log("[updateViewHook]linesListChanged")}if(r.fakeLinesListChanged){const l=this.getShouldRenderFakeLines();this.dataStores.store4ShouldRenderFakeLines.set(l),console.log("[updateViewHook]fakeLinesListChanged")}}}}class An extends Se{constructor(o,e,t){super(),this.graphData=o,this.runtimeDATA4Links=t.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=t.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=t.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=t.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=t.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=t.runtimeDATA4ElLineTargets;const n=Object.assign({},this.options,e);this.options=e,Object.assign(this.options,n)}}class Vn extends Se{constructor(e,t){super();_(this,"dataStores");this.dataStores=e,this.updateViewHook=n=>{n.optionsChanged&&this.dataStores.store4Options.set(this.getOptions()),(n.nodesListChanged||n.changedNodes.length>0)&&(this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),console.log("[updateViewHook]nodesListChanged")),(n.linesListChanged||n.changedLines.length>0)&&(this.dataStores.store4ShouldRenderLines.set(this.getShouldRenderLines()),console.log("[updateViewHook]linesListChanged")),(n.fakeLinesListChanged||n.changedFakeLines.length>0)&&this.dataStores.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()])}}}class Xn extends Se{constructor(o,e){super(),e(),this.updateViewHook=t=>{if(t.optionsChanged&&o.store4Options.set(this.getOptions()),t.linesListChanged||t.changedLines.length>0||t.nodesListChanged||t.changedNodes.length>0){const n=this.getShouldRenderNodes();o.store4ShouldRenderNodes.set([...n])}if(t.linesListChanged||t.changedLines.length>0){const n=this.getShouldRenderLines();o.store4ShouldRenderLines.set(n)}t.fakeLinesListChanged?o.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()]):t.changedFakeLines.length>0&&o.store4ShouldRenderFakeLines.set(this.getShouldRenderFakeLines())}}}class Bn extends En{constructor(){super();_(this,"_initRawPropertyFn",(e,t,n)=>{});_(this,"dataStores")}setReactiveData4Vue2(e,t,n,i){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new An(e,t,n),this._initRawPropertyFn=i,this.options=this.dataProvider.options,this.dataStores={shouldRenderNodesStore:n.runtimeDATA4ShouldRenderItems.nodes,shouldRenderLinesStore:n.runtimeDATA4ShouldRenderItems.lines,shouldRenderFakeLinesStore:n.runtimeDATA4ShouldRenderItems.fakeLines}}setReactiveData4Vue3(e,t,n,i,a){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new Dn(e,t,n,i),this._initRawPropertyFn=a,this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines,optionsRef:e.optionsRef,shouldRenderNodesRef:e.shouldRenderNodesRef,shouldRenderLinesRef:e.shouldRenderLinesRef,shouldRenderFakeLinesRef:e.shouldRenderFakeLinesRef,textContainer4NormalRef:e.textContainer4NormalRef,textContainer4FakeLineRef:e.textContainer4FakeLineRef},console.error("[RelationGraphWith2Data] setReactiveData4Vue3:",this.options)}setReactiveData4React(e,t){this.dataProvider=new Xn(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines}}setReactiveData4Svelte(e,t){this.dataProvider=new Vn(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines},console.log("[RelationGraphWith2Data] setReactiveData4Svelte:",this.options)}generateNewNodeId(e=5){const t=ze(e);return this.dataProvider.getNodeById(t)?this.generateNewNodeId(e+1):t}}class zn extends Bn{constructor(){super()}getOptions(){return this.dataProvider.getOptions()}getNodeById(o){return this.dataProvider.getNodeById(o)}getLineById(o){return this.dataProvider.getLineById(o)}getLinkByLineId(o){return this.dataProvider.getLinkByLineId(o)}getLinkByLine(o){return this.getLinkByLineId(o.id)}getLines(){return this.dataProvider.getLines()}getElementLineById(o){return this.getFakeLineById(o)}getElementLines(){return this.getFakeLines()}getFakeLines(){return this.dataProvider.getFakeLines()}getFakeLineById(o){return this.dataProvider.getFakeLineById(o)}getNodes(){return this.dataProvider.getNodes()}getLinks(){return this.dataProvider.getLinks()}_getAllLinks(){const o=this.getLinks();return this._getFakeLineLinks().concat(o)}getNodeByTargetId(o){const e=this.dataProvider.getConnectTargetById(o);if(e&&e.nodeId)return this.getNodeById(e.nodeId)}_getFakeLineLinks(){const o=[];for(const e of this.getFakeLines())if(!e.forDisplayOnly&&(e.fromType===V.Node||e.fromType===V.NodePoint||e.fromType===V.CanvasPoint)&&(e.toType===V.Node||e.toType===V.NodePoint||e.toType===V.CanvasPoint)){let t=null,n=null;e.fromType===V.Node?t=this.getNodeById(e.from):(e.fromType===V.NodePoint||e.fromType===V.CanvasPoint)&&(t=this.getNodeByTargetId(e.from)),e.toType===V.Node?n=this.getNodeById(e.to):(e.toType===V.NodePoint||e.toType===V.CanvasPoint)&&(n=this.getNodeByTargetId(e.to)),t&&n&&o.push({lineId:e.id,line:e,fromNode:t,toNode:n,totalLinesBetweenNodes:1,currentLineIndex:0,rgShouldRender:!0,rgCalcedVisibility:!0})}return o}getConnectTargets(){return this.dataProvider.getConnectTargets()}getConnectTargetById(o){return this.dataProvider.getConnectTargetById(o)}}class Gn extends zn{constructor(){super()}getRelatedLinesByNode(o){const e=[];for(const t of this._getAllLinks())(o===t.fromNode||o===t.toNode)&&e.push(t.line);return e}getLinksBetweenNodes(o){const e=[],t=this._getAllLinks();for(const n of t)o.includes(n.fromNode)&&o.includes(n.toNode)&&e.push(n);return e}getLinesBetweenNodes(o){return this.getLinksBetweenNodes(o).map(e=>e.line)}getNodeRelatedNodes(o,e={incoming:!0,outgoing:!0}){const t=[];for(const n of this.getLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:i,toNode:a}=n;e.outgoing&&i===o&&(t.includes(a)||t.push(a)),e.incoming&&a===o&&(t.includes(i)||t.push(i))}for(const n of this._getFakeLineLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:i,toNode:a}=n;e.outgoing&&i===o&&(t.includes(a)||t.push(a)),e.incoming&&a===o&&(t.includes(i)||t.push(i))}return t}getNodeIncomingNodes(o){return this.getNodeRelatedNodes(o,{incoming:!0,outgoing:!1})}getNodeOutgoingNodes(o){return this.getNodeRelatedNodes(o,{incoming:!1,outgoing:!0})}findGroupNodes(o,e=[]){return this._getNetworkNodesByNode(o,e)}getGroupNodesByNode(o,e=[]){return this._getNetworkNodesByNode(o,e)}getNetworkNodesByNode(o){return this._getNetworkNodesByNode(o)}_getNetworkNodesByNode(o,e=[]){if(!o)throw new Error("Call graphInstance.getNetworkNodesByNode:error: node is undefined");e.includes(o)||e.push(o);for(const t of this.getNodeRelatedNodes(o))e.includes(t)||this._getNetworkNodesByNode(t,e);return e}getStuffSize(o){return console.warn("Please use getNodesRectBox instead of getStuffSize, this method is compatible with older api versions."),this.getNodesRectBox(o)}getNodesViewInfo(o){return console.warn("Please use getNodesRectBox instead of getNodesViewInfo, this method is compatible with older api versions."),this.getNodesRectBox(o)}getNodesRectBox(o){const t=(o||this.getNodes()).filter(d=>d.rgCalcedVisibility!==!1);if(t.length===0)return{width:10,height:10,minX:0,minY:0,maxX:0,maxY:0};let n=9999999,i=9999999,a=-9999999,r=-9999999;t.forEach(d=>{d.x<n&&(n=d.x),d.x+(d.width||d.el_W)>a&&(a=d.x+(d.width||d.el_W)),d.y<i&&(i=d.y);const f=d.y+(d.height||d.el_H);f>r&&(r=f)});const l=a-n,c=r-i;return{width:l<0?0:l,height:c<0?0:c,minX:n===9999999?0:n,minY:i===9999999?0:i,maxX:a===-9999999?0:a,maxY:r===-9999999?0:r}}getNodesCenter(o){const e=this.getNodesRectBox(o);w("getNodesCenter:",e);const t=e.minX+(e.maxX-e.minX)/2,n=e.minY+(e.maxY-e.minY)/2;return{x:t,y:n}}getDescendantNodes(o){return B.getDescendantNodes(o)}getNodesInSelectionView(o){const e=this.getCanvasXyByViewXy({x:o.x,y:o.y}),t=this.getCanvasXyByViewXy({x:o.x+o.width,y:o.y+o.height}),n=[];return this.getNodes().forEach(i=>{const a=i.x+i.el_W/2,r=i.y+i.el_H/2;a>e.x&&r>e.y&&a<t.x&&r<t.y&&n.push(i)}),n}getShouldRenderNodes(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderNodes()}getShouldRenderLines(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderLines()}getShouldRenderFakeLines(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderFakeLines()}}class Fn extends Gn{constructor(){super();_(this,"_elLineUpdateTimer");_(this,"_canvasCurrentInfo",{x:0,y:0,scale:1});_(this,"_nodeResizeEffectTimer");_(this,"prevAddNodeTimestamp",0);_(this,"_nodesElSizeMap",new Map)}removeLine(e){this.removeLines([e])}removeLines(e){this.removeLineByIds(e.map(t=>t.id))}removeLineById(e){this.removeLineByIds([e])}removeLineByIds(e){this.dataProvider.removeLineByIds(e),this._dataUpdated()}removeFakeLine(e){this.removeFakeLineById(e.id)}removeFakeLineById(e){w("removeLineById:",e),this.dataProvider.removeFakeLineByIds([e]),this._dataUpdated()}removeLink(e){w("removeLink:",e),this.removeLinkByLineId(e.lineId)}removeLinkByLineId(e){this.dataProvider.removeLineByIds([e]),this._dataUpdated()}removeNodeById(e){this.dataProvider.removeNodeById([e]),this._dataUpdated()}removeNodesByIds(e){e.forEach(t=>this.dataProvider.removeNodeById(e)),this._dataUpdated()}removeNodes(e){this.dataProvider.removeNodeById(e.map(t=>t.id)),this._dataUpdated()}removeNode(e){this.dataProvider.removeNodeById([e.id]),this._dataUpdated()}removeELementLineById(e){w("removeELementLineById:",e),this.removeFakeLineById(e)}addNode(e){if(w("addNode:",e),e&&Array.isArray(e)){console.error("addNode: node is array:",e);return}this._addNodes([e]),this._dataUpdated()}addNodes(e){if(w("addNodes:",e),e&&!Array.isArray(e)){console.error("addNodes: nodes is not array:",e);return}this._addNodes(e),this._dataUpdated()}addLine(e){if(w("addLine:",e),e&&Array.isArray(e)){console.error("addLine: line is array:",e);return}this.addLines([e])}addLines(e){if(w("addLines:",e),e&&!Array.isArray(e)){console.error("addLines: lines is not array:",e);return}if(e.length===0)return;const t=e.filter(i=>!i.isFakeLine);this._addLines(t);const n=e.filter(i=>i.isFakeLine);this.addFakeLines(n),this._dataUpdated()}_addFakeLines(e){this.dataProvider.addFakeLines(e)}addFakeLines(e){w("addFakeLines:",e),this._addFakeLines(e),this._dataUpdated()}updateElementLines(){this.dataProvider.getElLineTargets().length!==0&&(w("updateElementLines:runtimeDATA4ElLineTargets:",this.dataProvider.getElLineTargets().length),this._elLineUpdateTimer&&clearTimeout(this._elLineUpdateTimer),this._elLineUpdateTimer=setTimeout(()=>{this._updateElementLines(),this._dataUpdated()},100))}_updateElementLines(){this._updateCanvasBoxInfo();for(const e of this.dataProvider.getElLineTargets())this.updateElementTarget(e)}_updateCanvasBoxInfo(){const e=this.$canvasDom.getBoundingClientRect();this._canvasCurrentInfo.x=e.x,this._canvasCurrentInfo.y=e.y,this._canvasCurrentInfo.scale=this.dataProvider.getOptions().canvasZoom/100}updateElementTarget(e){const t=this._getElementTargetPosition(document.getElementById(e.id),e);t?this.dataProvider.updateElLineTarget(e.id,{hidden:!1,...t}):this.dataProvider.updateElLineTarget(e.id,{hidden:!0})}_getElementTargetPosition(e){if(!e)return null;const t=e.getBoundingClientRect(),n=(t.x-this._canvasCurrentInfo.x)/this._canvasCurrentInfo.scale,i=(t.y-this._canvasCurrentInfo.y)/this._canvasCurrentInfo.scale,a=t.width/this._canvasCurrentInfo.scale,r=t.height/this._canvasCurrentInfo.scale;return{x:n,y:i,el_W:a,el_H:r}}addElementLines(e){w("addElementLines:",e),e.forEach(t=>{t.fromType=V.HTMLElementId,t.toType=V.HTMLElementId,t.isFakeLine=!0,t.id||(t.id=this.generateNewUUID(6)),t.forDisplayOnly=!0}),this.addFakeLines(e),console.log("addElementLines:",e.length,e),this.updateElementLines()}updateNodeOffsetSize(e,t,n){const i=this.getNodeById(e);if(!i)return;const a=i.el_W,r=i.el_H;(a!==t||r!==n)&&(this.dataProvider.updateNode(e,{el_W:t,el_H:n}),this._nodeResizeEffectTimer&&clearTimeout(this._nodeResizeEffectTimer),this._nodeResizeEffectTimer=setTimeout(()=>{this._dataUpdated()},100))}clearFakeLines(){this.dataProvider.clearFakeLines(),this._dataUpdated()}clearElementLines(){const e=[];for(const t of this.getFakeLines())(t.fromType===V.HTMLElementId||t.toType===V.HTMLElementId)&&e.push(t.id);this.dataProvider.removeFakeLineByIds(e),this._dataUpdated()}_addNodes(e){this.emitEvent(A.beforeAddNodes,e);const t={};this.getNodes().forEach(a=>{t[a.id]=a});const n=[],i=this.getOptions();e.forEach(a=>{let r=t[a.id];if(!r){let{text:l,id:c}=a;!l&&a.label&&(l=a.label,console.warn('Use "label" as "text":',a.label)),l===void 0&&c&&(l=c,console.warn('Use "id" as "text":',c)),r=Oe(Object.assign({},a,{text:l}),i,this._nodesElSizeMap),this._initRawPropertyFn&&this._initRawPropertyFn(r,"lot",r.lot),r&&(t[r.id]=r,n.push(r))}}),this.dataProvider.addNodes(n),n.length>0&&(this.prevAddNodeTimestamp=Date.now())}_addLines(e){this.emitEvent(A.beforeAddLines,e);const t=[];e.forEach(n=>{let{from:i,to:a,text:r}=n;if(!i)if(n.source)i=n.source,console.warn('Use "source" as "from":',n.source);else{console.error('JsonLine Must have field:"from"',n);return}if(!a)if(n.target)a=n.target,console.warn('Use "target" as "to":',n.target);else{console.error('JsonLine Must have field:"to"',n);return}if(r||n.label&&(r=n.label,console.warn('Use "label" as "text":',n.label)),!this.getNodeById(i)){console.error("Can not found from node:",n);return}if(!this.getNodeById(a)){console.error("Can not found to node:",n);return}if(n.id){if(this.getLineById(n.id)){console.warn("_addLines:skip duplicate line id:",n.id);return}else if(t.some(f=>f.id===n.id)){console.warn("Duplicate line id in new lines:",n.id);return}}else n.id="L-"+this.generateNewUUID(6);const d=ue(Object.assign({},n,{from:i,to:a,text:r}),this.getOptions());t.push(d)}),this.dataProvider.addLines(t)}updateNode(e,t){this.dataProvider.updateNode(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateNodePosition(e,t,n){var a;const i=typeof e=="string"?e:e.id;this.dataProvider.updateNode(i,{x:t,y:n}),this.getOptions().layout.autoLayouting&&((a=this.layoutor)==null||a.syncNodePosition(i,t,n)),this._dataUpdated()}updateNodeData(e,t){this.dataProvider.updateNodeData(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateLine(e,t){this.dataProvider.updateLine(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateLineData(e,t){this.dataProvider.updateLineData(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateFakeLine(e,t){this.dataProvider.updateFakeLine(typeof e=="string"?e:e.id,t),this._dataUpdated()}flatNodeData(e,t,n,i){B.flatNodeData(e,t,n,i)}backupNodesElSize(){for(const e of this.getNodes())this._nodesElSizeMap.set(e.id,[e.el_W,e.el_H])}loadGraphJsonData(e){e.lines||(e.lines=e.relations,e.lines&&console.warn("[relation-graph] For compatibility with older version, Use jsonData.relations as jsonData.lines, It is recommended that you define your data using")),e.lines||(e.lines=e.links||e.edges,e.lines&&console.warn("[relation-graph] For compatibility with older version, Use jsonData.links/jsonData.edges as jsonData.lines, It is recommended that you define your data using"));const t=e.nodes||[],n=e.lines||[],i=[],a=[];this.flatNodeData(t,null,i,a),n.forEach(r=>{a.push(r)}),this._addNodes(i),w("Nodes is initialized"),this._addLines(a),this._dataUpdated(),e.fakeLines&&this.addFakeLines(e.fakeLines),setTimeout(()=>{e.elementLines&&(console.warn("elementLines is deprecated, please use fakeLines with isFakeLine and fromType/toType = RGInnerConnectTargetType.HTMLElementId instead:",e.elementLines),this.addElementLines(e.elementLines)),this._dataUpdated()},500)}updateShouldRenderGraphData(e=!1){!e&&!this.dataProvider.isPerformanceMode()||this.dataProvider.updateShouldRenderGraphData()}updateNodesVisibleProperty(e){this.dataProvider.updateNodesVisibleProperty(e)}updateVisibleNodesSize(){for(const e of this.getShouldRenderNodes()){const t=this.getNodeElByNodeId(e.id);t&&this._onNodeDomResize(t,t.clientWidth,t.clientHeight)}}_clearGraph(){this.backupNodesElSize(),this.dataProvider.clearReactiveData(),this.dataProvider.clearChecked(),this.dataProvider.setEditingLine(null),this.dataProvider.setEditingNodes([])}_setJsonData(e,t=!1){this._clearGraph(),this.loadGraphJsonData(e)}}class Yn extends Fn{constructor(){super();_(this,"canvasConnectTargetsMap",new Map);_(this,"nodeConnectTargetsMap",new Map);_(this,"connectTargetElementMap",new Map);_(this,"_connectTargetUpdateRequestedSet",new Map);_(this,"_updateTimer");_(this,"_removedConnectTargetMap",new Map)}updateConnectTargetsOnCanvas(e,t){if(!t)return;console.warn(`updateConnectTargetsOnCanvas:[${e}]:`);const n=t.classList.contains("rg-canvas-slot-above")?"above":"behind",i=this.canvasConnectTargetsMap.get(n);i&&i.length>0&&this.updateConnectTargetList(e,t,i)}updateConnectTargetsByNodeId(e){const t=this.getNodeElByNodeId(e);this.updateConnectTargetsOnNode("API",e,t)}getNodeElByNodeId(e){return this.$dom.querySelector(`[data-id="${e}"]`)}updateConnectTargetsOnNode(e,t,n){const i=this.nodeConnectTargetsMap.get(t)||[];i.length!==0&&this.updateConnectTargetList(e,n,i)}updateConnectTargetList(e,t,n){const i=this.dataProvider.getCanvasScale();for(const a of n){const r=this.connectTargetElementMap.get(a.targetId);if(!r){console.error("Can not find el for connectTarget:",a.targetId,a);continue}this._requestUpdateConnectTargetOffset(e,a,r,t,i)}}_requestUpdateConnectTargetOffset(e,t,n,i,a){this._connectTargetUpdateRequestedSet.set(t.targetId,{stableTimes:0,connectTarget:t,by:e,connectTargetEl:n,relativeEl:i}),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(this._connectTargetUpdateRequestedSet.size+10,50))}_updateAllRequestedConnectTargetOffsets(){let e=0,t=0;for(const n of this._connectTargetUpdateRequestedSet.values()){const{by:i,connectTargetEl:a,relativeEl:r,connectTarget:l}=n;if(this.dataProvider.isPerformanceMode()&&l.nodeId){const f=this.getNodeById(l.nodeId);if(!f||!f.rgShouldRender||!f.rgCalcedVisibility){t++;continue}}if(!this.dataProvider.getConnectTargetById(l.targetId))continue;const d=this.dataProvider.getCanvasScale();this._updateConnectTargetOffset(i,l,a,r,d)?e++:n.stableTimes++,n.stableTimes>2&&this._connectTargetUpdateRequestedSet.delete(l.targetId)}e>0?(console.warn(`_updateAllRequestedConnectTargetOffsets: ${e} of ${this._connectTargetUpdateRequestedSet.size} changed, ${t} Skipped!`),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(e/2+10,100)),this._dataUpdated()):(console.warn("_updateAllRequestedConnectTargetOffsets:::::::OK",this._connectTargetUpdateRequestedSet.size),this._connectTargetUpdateRequestedSet.clear(),this._dataUpdated())}_updateConnectTargetOffset(e,t,n,i,a){const r=i.getBoundingClientRect(),l=n.getBoundingClientRect(),c=Math.round(l.x-r.x),d=Math.round(l.y-r.y),h=this.dataProvider.getCanvasScale(),f=Math.round(c/h),p=Math.round(d/h),u=Math.round(l.width/h),g=Math.round(l.height/h),y=t.offsetX!==f,m=t.offsetY!==p,v=u!==0&&t.width!==u,C=g!==0&&t.height!==g;return y||m||v||C?(this.dataProvider.updateConnectTarget(t.targetId,{offsetX:f,offsetY:p,width:u,height:g}),!0):!1}_onConnectTargetMounted(e,t,n,i){const a=this.dataProvider.getCanvasScale();this._requestUpdateConnectTargetOffset(e,t,n,i,a)}getNodeElByChildrenTarget(e){return we(e,"rg-node-peel","rg-map")}registerConnectTarget(e,t,n,i,a={}){if(n!==V.NodePoint&&n!==V.CanvasPoint)return;if(!e){console.error(`[registerConnectTarget]Can not find CanvasPoint target DOM: ${t}`);return}const r=this.getNodeElByChildrenTarget(e),l=r==null?void 0:r.dataset.id;if(l==="rg-newNodeTemplate")return;let c=this.dataProvider.getConnectTargetById(t);if(!c){const h={targetId:t,targetType:n,junctionPoint:i,nodeId:"",width:20,height:20,offsetX:0,offsetY:0,offsetPercentX:0,offsetPercentY:0,targetData:a||{}};this.reuseConnectTarget(h),c=this.dataProvider.addConnectTarget(h)}return this.connectTargetElementMap.set(c.targetId,e),(l?this.getNodeById(l):null)?this._addConnectTargetToNodeMap(l,c,e,r):this._addConnectTargetToCanvasMap(c,e),c}_addConnectTargetToNodeMap(e,t,n,i){this.dataProvider.updateConnectTarget(t.targetId,{junctionPoint:t.junctionPoint,targetType:V.NodePoint,nodeId:e,targetData:Object.assign({},t.targetData||{},{nodeId:e})});let a=this.nodeConnectTargetsMap.get(e);a?a.some(r=>r.targetId===t.targetId)||a.push(t):this.nodeConnectTargetsMap.set(e,[t]),this._onConnectTargetMounted("NT-Mounted",t,n,i)}_addConnectTargetToCanvasMap(e,t){let n=we(t,"rg-canvas-slot","rg-map");if(!!n&&n){const i=n.classList.contains("rg-canvas-slot-above")?"above":"behind";this.dataProvider.updateConnectTarget(e.targetId,{junctionPoint:e.junctionPoint,targetType:V.CanvasPoint,targetData:Object.assign({},e.targetData||{})});const a=this.canvasConnectTargetsMap.get(i);a?a.some(r=>r.targetId===e.targetId)||a.push(e):this.canvasConnectTargetsMap.set(i,[e]),this._onConnectTargetMounted("CT-Mounted",e,t,n)}}unregisterConnectTarget(e){const t=this.dataProvider.getConnectTargetById(e);if(!t)return;let n;if(t.nodeId&&this.nodeConnectTargetsMap.has(t.nodeId))n=this.nodeConnectTargetsMap.get(t.nodeId);else{const i=this.canvasConnectTargetsMap.get("behind");if(i){let a=i.findIndex(r=>r.targetId===e);a!==-1?n=this.canvasConnectTargetsMap.get("behind"):(a=this.canvasConnectTargetsMap.get("above").findIndex(r=>r.targetId===e),a!==-1&&(n=this.canvasConnectTargetsMap.get("above")))}}if(n){const i=n.findIndex(a=>a.targetId===e);i!==-1&&n.splice(i,1)}this.dataProvider.removeConnectTarget(e),this.connectTargetElementMap.delete(e),this._removedConnectTargetMap.set(t.targetId,t)}reuseConnectTarget(e){if(this._removedConnectTargetMap.has(e.targetId)){const t=this._removedConnectTargetMap.get(e.targetId);e.offsetX=t.offsetX,e.offsetY=t.offsetY,e.width=t.width,e.height=t.height,e.offsetPercentX=t.offsetPercentX,e.offsetPercentY=t.offsetPercentY,this._removedConnectTargetMap.delete(e.targetId)}}}class Hn extends Yn{constructor(){super();_(this,"fakeLineTargetRender")}generateCreatingLineConfig(e){e||(e=this.dataProvider.getOptions());const{newLinkTemplate:t,newLineTemplate:n}=e,i=t.fromNode;if(!i)return{line:n,from:null,to:null,totalLinesBetweenNodes:1,currentLineIndex:0};const a=t.toNode,r=a.targetType===V.Node?t.toNode:this.getFakeLineTarget(a.targetType,a.id,n);return{line:Object.assign({},n,{isFakeLine:!1}),from:this.getFakeLineTarget(i.targetType,i.id,n),to:r,totalLinesBetweenNodes:1,currentLineIndex:0}}generateLineConfig(e){const t=this.getLinkByLine(e);return!t||!t.rgCalcedVisibility?!1:{line:t.line,from:t.fromNode,to:t.toNode,totalLinesBetweenNodes:t.totalLinesBetweenNodes,currentLineIndex:t.currentLineIndex}}generateFakeLineConfig(e){let t=1,n=0;if(e.fromType===V.HTMLElementId&&e.toType===V.HTMLElementId){const r=this.dataProvider.getFakeLines().filter(l=>l.from===e.from&&l.to===e.to);r.length>1&&(console.warn("sameTargetLines element-line:",e),t=r.length,n=r.indexOf(e))}let i=this.getFakeLineTarget(e.fromType,e.from,e),a=this.getFakeLineTarget(e.toType,e.to,e);return!i&&e.fromType===V.Node?(console.error("[generateFakeLineConfig]error fakeLine from:",e.fromType,e.from,e),!1):!a&&e.fromType===V.Node?(console.error("[generateFakeLineConfig]error fakeLine to:",e.toType,e.to,e),!1):{line:e,from:i,to:a,totalLinesBetweenNodes:t,currentLineIndex:n}}setFakeLineTargetRender(e){this.fakeLineTargetRender=e}getFakeLineTarget(e,t,n){if(e===V.HTMLElementId){let i=this.dataProvider.getElLineTargets().find(a=>a.id===t);return i||(i={x:300,y:300,targetType:V.HTMLElementId,nodeShape:1,id:t,el_W:40,el_H:40,hidden:!0},this.dataProvider.addElLineTarget(i),this.updateElementLines()),i.hidden?null:i}else{if(e===V.Node)return this.getNodeById(t);if(e===V.NodePoint||e===V.CanvasPoint){const i=this.dataProvider.getConnectTargetById(t);if(!i)return;if(i.nodeId){const a=this.getNodeById(i.nodeId);if(!a){console.error("[getFakeLineTarget]Can not find NodePoint-s Node:",`${i.targetId}@${i.nodeId}`);return}return{x:a.x+i.offsetPercentX*a.el_W+i.offsetX,y:a.y+i.offsetPercentY*a.el_H+i.offsetY,targetType:V.NodePoint,targetData:i.targetData,nodeShape:0,id:t,el_W:i.width,el_H:i.height,hidden:!1}}else return{x:i.offsetX,y:i.offsetY,targetType:V.CanvasPoint,targetData:i.targetData,nodeShape:0,id:t,el_W:i.width,el_H:i.height,hidden:!1}}}if(this.fakeLineTargetRender)return this.fakeLineTargetRender(e,t,n)}}class jn extends Hn{constructor(){super()}_updateOptions(o){!o.instanceId&&this.getOptions().instanceId!==o.instanceId&&(o.instanceId=this.instanceId);const e=Object.assign({},o);if(e.layouts)throw new Error('Graph options do not support setting layouts properties, Please use "layout"!');if(e.lineUseTextPath)throw new Error('Graph options do not support setting layouts properties, Please use "defaultLineTextOnPath"!');if(e.debug!==void 0){const t=e.debug===!0;t&&w("RGOptions:user instance options:",e),window&&(window.relationGraphDebug=t)}e.layout?(this.dataProvider.updateOptions({...e,layout:{...this.getOptions().layout,...e.layout}}),this.layoutor&&this.layoutor.updateOptions&&this.layoutor.updateOptions(e.layout)):this.dataProvider.updateOptions(e)}resetViewSize(o=!1){const e=this.getViewBoundingClientRect(),t={};t.viewSize={width:e.width,height:e.height},this._rgAsConnectArea?(t.canvasZoom=100,t.canvasOffset={x:0,y:0}):o&&(t.canvasZoom=100,t.canvasOffset={x:t.viewSize.width/2,y:t.viewSize.height/2}),this.dataProvider.updateOptions(t),w("resetViewSize:1:",t),this._dataUpdated()}loading(o=""){this.dataProvider.updateOptions({graphLoading:!0,graphLoadingText:o}),this._dataUpdated()}clearLoading(){this.dataProvider.updateOptions({graphLoading:!1,graphLoadingText:""}),this._dataUpdated()}setCheckedNode(o){this.dataProvider.updateOptions({checkedNodeId:o?typeof o=="string"?o:o.id:""}),this._dataUpdated()}setCheckedLine(o){this.dataProvider.updateOptions({checkedLineId:o?typeof o=="string"?o:o.id:""})}clearChecked(){this.dataProvider.clearChecked(),this._dataUpdated()}clearSelected(){const o=this.getNodes().filter(n=>n.selected),e=this.getLines().filter(n=>n.selected),t=this.getFakeLines().filter(n=>n.selected);o.forEach(n=>this.dataProvider.updateNode(n.id,{selected:!1})),e.forEach(n=>this.dataProvider.updateLine(n.id,{selected:!1})),t.forEach(n=>this.dataProvider.updateFakeLine(n.id,{selected:!1})),this._dataUpdated()}setCanvasOffset(o,e){this.dataProvider.setCanvasOffset(o,e),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}setCanvasMoveMode(o){this.dataProvider.updateOptions({canvasMoveMode:o}),this._dataUpdated()}onMiniViewMounted(){this.dataProvider.updateOptions({showMiniView:!0}),this._dataUpdated()}onMiniViewUnMounted(){this.dataProvider.updateOptions({showMiniView:!1})}onReferenceLineMounted(o){this.dataProvider.updateOptions({referenceLineAdsorption:o||!1,showReferenceLine:!0})}onReferenceLineUnMounted(){this.dataProvider.updateOptions({referenceLineAdsorption:!1,showReferenceLine:!1})}}class Wn extends jn{constructor(){super()}getCreatingLine(o){if(o||(o=this.getOptions()),!o.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=this.generateCreatingLineConfig();return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}}getCreatingNode(o){return o||(o=this.getOptions()),o.creatingNodePlot?{creating:o.creatingNodePlot,nodeJson:o.newNodeTemplate}:{creating:!1}}}const $n=s=>{const o=Math.sin(s)*1e4;return o-Math.floor(o)},Qe=(s,o,e,t,n,i)=>{const r=e-s,l=t-o,c=Math.sqrt(r*r+l*l),d=Math.max(2,Math.floor(c/12)),h=-l/c,f=r/c,p=[{type:"M",x:s,y:o}];let u=s,g=o;for(let y=1;y<=d;y++){let m=s+r*y/d,v=o+l*y/d;if(y<d){const C=$n(n+y)-.5;m+=h*C*i,v+=f*C*i}p.push({type:"l",dx:m-u,dy:v-g}),u=m,g=v}return p},Un=(s,o={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:i}=s;o.rotate=q.getTextAngle(e,t,n,i),o.x=e+(n-e)/2,o.y=t+(i-t)/2,Number.isNaN(o.rotate)&&(o.rotate=0);const a=e+t+n+i,r=Qe(e,t,n,i,a,2.5),l=Qe(e,t,n,i,a+99,1.5),c=`${he(r)} ${he(l)}`;return{pathCommands:[...r,...l],pathData:c,textPosition:o,points:[]}};class qn extends Wn{constructor(){super()}_getJunctionPoint(o,e){return o===U.border?q.getBorderPoint4MultiLine(e):o===U.ltrb?q.getRectJoinPoint(e):o===U.tb?q.getRectVJoinPoint(e):o===U.lr?q.getRectHJoinPoint(e):o===U.left?q.getRectLeftJoinPoint(e):o===U.right?q.getRectRightJoinPoint(e):o===U.top?q.getRectTopJoinPoint(e):o===U.bottom?q.getRectBottomJoinPoint(e):o==="horizontalLine"?q.getRectHorizontalLineJoinPoint(e):o==="verticalLine"?q.getRectVerticalLineLineJoinPoint(e):q.getBorderPoint4MultiLine(e)}createLinePath(o,e,t){throw new Error("createLinePath() is deprecated, please use createLineDrawInfo() instead.")}createLineDrawInfo(o,e){let t,n,i=1,a=0;if(o&&(a=o.currentLineIndex,i=o.totalLinesBetweenNodes),o)t=o.fromNode,n=o.toNode;else{const r=e;if(t=this.getFakeLineTarget(r.fromType,r.from,r),n=this.getFakeLineTarget(r.toType,r.to,r),!t){console.error("Invalid line configuration:error from:",e);return}if(!n){console.error("Invalid line configuration:error to:",e);return}}return this.generateLinePath({line:e,from:t,to:n,totalLinesBetweenNodes:i,currentLineIndex:a})}_getLineDefaultOptions(){const o=this.getOptions();return{layoutDirection:o.layout.layoutDirection,multiLineDistance:o.multiLineDistance,defaultJunctionPoint:o.defaultJunctionPoint,lineRadius:o.defaultPolyLineRadius,defaultLineJunctionOffset:o.defaultLineJunctionOffset,defaultNodeShape:o.defaultNodeShape}}generateLinePath(o){o.totalLinesBetweenNodes===void 0&&(o.totalLinesBetweenNodes=1),o.currentLineIndex===void 0&&(o.currentLineIndex=0),o.defaultOptions===void 0&&(o.defaultOptions=this._getLineDefaultOptions());try{const e=this.withLineJunctionPoints(o);return this.createLinePathData(e)}catch(e){if(e.rgError)return this.createErrorLineValue(e.errorCode,e.x,e.y);throw e}}throwLineError(o,e,t){return{rgError:!0,errorCode:o,x:e,y:t}}createErrorLineValue(o,e,t){const n={x:0,y:0,rotate:0},i=[{type:"M",x:0,y:0},{type:"l",dx:e,dy:t}];return{pathCommands:i,pathData:he(i),textPosition:n,points:[]}}withLineJunctionPoints({line:o,from:e,to:t,totalLinesBetweenNodes:n,currentLineIndex:i,defaultOptions:a}){if(!e||!t)throw w("error from-to:",e,t),this.throwLineError("F",-10,0);let r=o.lineShape||1;const l=o.lineDirection||a.layoutDirection||"h";let c=e.x||0,d=e.y||0,h=t.x||0,f=t.y||0;if(Number.isNaN(c)||Number.isNaN(d))throw w("error start node:",e.text,e.x,e.y),this.throwLineError("A",-10,-10);if(Number.isNaN(h)||Number.isNaN(f))throw w("error end point:",t.text,t.x,t.y),this.throwLineError("B",10,-10);let p=e.el_W||60,u=e.el_H||60;if(Number.isNaN(p)||Number.isNaN(u))throw this.throwLineError("C",-10,10);let g=t.el_W||60,y=t.el_H||60;if(Number.isNaN(g)||Number.isNaN(y))throw this.throwLineError("D",10,10);if(c===0&&h===0&&d===0&&f===0)throw this.throwLineError("D",10,10);const m=h-c+(f-d)>0,v=o.isReverse?t:e,C=o.isReverse?e:t,N=Ne(v.nodeShape,a.defaultNodeShape),O=o.junctionOffset||a.defaultLineJunctionOffset||0;c-=O,d-=O,h-=O,f-=O,p+=O*2,u+=O*2,g+=O*2,y+=O*2;const b={from_x:c,from_y:d,to_x:h,to_y:f,f_W:p,f_H:u,t_W:g,t_H:y,nodeShape:N,isReverse:m,isEndPoint:!1,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||30},T=Ne(C.nodeShape,a.defaultNodeShape),R={from_x:h,from_y:f,to_x:c,to_y:d,f_W:g,f_H:y,t_W:p,t_H:u,nodeShape:T,isReverse:m,isEndPoint:!0,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||50},P=a.defaultJunctionPoint||U.border;let k=o.fromJunctionPoint||P,S=o.toJunctionPoint||P,M=o.fromJunctionPointOffsetX||0,L=o.fromJunctionPointOffsetY||0,D=o.toJunctionPointOffsetX||0,X=o.toJunctionPointOffsetY||0;o.isReverse&&([k,S]=[S,k],[M,L,D,X]=[D,X,M,L]),(e===t||c===0&&h===0&&d===0&&f===0)&&M===0&&L===0&&D===0&&X===0&&((r===H.StandardStraight||r===H.Curve2||r===H.Curve3||r===H.SimpleOrthogonal||r===H.Curve5)&&(r=H.StandardCurve),X=20);const G=this._getJunctionPoint(k,b);G.x+=M,G.y+=L;const z=this._getJunctionPoint(S,R);if(z.x+=D,z.y+=X,!G||!z)throw this.throwLineError("E",-20,-20);const E=c+p/2,F=d+u/2,$=h+g/2,te=f+y/2;k==="horizontalLine"?(G.x=z.x,(r===44||r===49)&&(G.x+=(z.x>$?1:-1)*30)):k==="verticalLine"&&(G.y=z.y,(r===44||r===49)&&(G.y+=(z.y>te?1:-1)*30)),S==="horizontalLine"?(z.x=G.x,(r===44||r===49)&&(z.x+=(G.x>E?1:-1)*30)):S==="verticalLine"&&(z.y=G.y,(r===44||r===49)&&(z.y+=(G.y>F?1:-1)*30));const Q=G.x,oe=G.y,ie=z.x,ne=z.y;if(Number.isNaN(Q)||Number.isNaN(oe))throw w("error start point:",e.text),this.throwLineError("F",-10,0);if(Number.isNaN(ie)||Number.isNaN(ne))throw w("error end point:",t.text),this.throwLineError("G",10,0);return{line:o,totalLinesBetweenNodes:n,currentLineIndex:i,lineDirection:l==="v"?"v":"h",lineShape:r,lineRadius:a.lineRadius||0,fromJunctionPoint:k,toJunctionPoint:S,fx:Q,fy:oe,fcx:E,fcy:F,f_W:p,f_H:u,tx:ie,ty:ne,tcx:$,tcy:te,t_W:g,t_H:y}}createLinePathData(o){const{lineShape:e}=o;let t;return e===H.SimpleOrthogonal?t=_n(o,void 0,this._getLineDefaultOptions()):e===H.StandardOrthogonal?t=On(o,void 0,this._getLineDefaultOptions()):e===H.HardOrthogonal?t=Tn(o,void 0,this._getLineDefaultOptions()):e===H.StandardCurve?t=Rn(o):e===H.Curve2||e===H.Curve3||e===H.Curve5||e===H.Curve7?t=Sn(o):e===H.Curve8?t=Un(o):t=wn(o),t}getArrowMarkerId(o,e=!1){let t=o.showStartArrow===!0,n=o.showEndArrow!==!1;if(o.isReverse&&([t,n]=[n,t]),e){if(!t)return;if(o.startMarkerId)return`url('#${o.startMarkerId}')`}else{if(!n)return;if(o.endMarkerId)return`url('#${o.endMarkerId}')`}return`url('#${this.getLineArrow(o.color,e,!1)}')`}getLineArrow(o,e=!1,t=!1){const n=e?"start-":"";return`${this.getOptions().instanceId}-${n}arrow-default`}getTextTransform(o,e){if(!o||!e)return"translate(0,0)";const{x:t,y:n,rotate:i}=e;if(Number.isNaN(t)||Number.isNaN(n))return"translate(0,0)";const a=this.getOptions(),r=o.textOffsetX||a.defaultLineTextOffsetX||0,l=o.textOffsetY||a.defaultLineTextOffsetY||0,c=o.lineShape||1;return c===H.StandardStraight||c===H.SimpleOrthogonal?`translate(-50%, -50%) translate(${t+r}px,${n+l}px) rotate(${i||0}deg)`:`translate(-50%, -50%) translate(${t+r}px,${n+l}px)`}generateLineTextStyle(o,e){const t=this.getOptions(),n={transform:"",transformOrigin:""};if(!o||!e)return{cssStyles:n};const{line:i}=o,{textPosition:a}=e;if(!i||!a)return{cssStyles:n};let r=i.text||"";r.length>t.lineTextMaxLength&&(r=r.substring(0,t.lineTextMaxLength||15)+"...");const{x:l,y:c,rotate:d}=a;if(Number.isNaN(l)||Number.isNaN(c))return{text:r,cssStyles:n};const h=[],f=i.textAnchor||"center";f==="start"?h.push("translate(0%, -50%)"):f==="end"?h.push("translate(-100%, -50%)"):h.push("translate(-50%, -50%)"),h.push(`translate(${l}px,${c}px)`);const p=i.textOffsetX||t.defaultLineTextOffsetX||0,u=i.textOffsetY||t.defaultLineTextOffsetY||0,g=i.lineShape||1;return(i.useTextOnPath||t.defaultLineTextOnPath)&&g===1&&d&&h.push(`rotate(${d||0}deg)`),g===H.StandardStraight?(n.transformOrigin="50% 50%",h.push(`translate(${p}px,${u}px)`)):h.push(`translate(${p}px,${u}px)`),n.transform=h.join(" "),{text:r,cssStyles:n}}generateLineTextStyle4TextOnPath(o){const{line:e,from:t,to:n}=o;let i=e.text;if(!i||!n||!t)return null;let a=0;const r=this.getOptions();i.length>r.lineTextMaxLength&&(i=i.substring(0,r.lineTextMaxLength||15)+"...");const l=e.textOffsetX||r.defaultLineTextOffsetX||0,c=e.textOffsetY||r.defaultLineTextOffsetY||0,d={x:l,y:c-6};let h="50%";e.placeText==="start"?(h="0%",d.x+=20):e.placeText==="end"?(h="100%",d.x-=20):e.placeText==="center"?h="50%":e.placeText&&(h=e.placeText);let f="middle";return e.textAnchor&&(f=e.textAnchor),{text:i,textOffset:d,textAnchor:f,onPathStartOffset:h,textRotate:a}}}class Jn extends qn{constructor(){super()}zoom(o,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions();try{const i=this.emitEvent(A.beforeZoomStart,n.canvasZoom,o,t);if(w("[zoom]","abortZoom:",i),i===!0)return;if(n.canvasZoom+o<n.minCanvasZoom){if(w("zoom:minCanvasZoom"),o=n.minCanvasZoom-n.canvasZoom,o===0)return}else if(n.canvasZoom+o>n.maxCanvasZoom&&(w("zoom:maxCanvasZoom"),o=n.maxCanvasZoom-n.canvasZoom,o===0))return;const a=o/100,r=this.getViewBoundingClientRect(),l=n.canvasZoom/100,c=Math.max(.01,Math.min(10,l+a));e||(e={x:r.x+r.width/2,y:r.y+r.height/2});const d=e.x-r.left,h=e.y-r.top,f=d-(d-n.canvasOffset.x)*(c/l),p=h-(h-n.canvasOffset.y)*(c/l),u=n.canvasZoom,g=c*100;this._performanceModeLogicHook(u,g),this.dataProvider.updateOptions({canvasOffset:{x:f,y:p},canvasZoom:g}),this.emitEvent(A.onZoomEnd,g,u)}finally{this._updateEditingControllerView(),this._dataUpdated()}}_performanceModeLogicHook(o,e){const t=this.getOptions();o<=40?e>40&&(t.performanceMode&&this.updateShouldRenderGraphData(!0),this.dataProvider.updateOptions({showEasyView:!1}),w("zoom:hide:showEasyView",o,e),this.updateElementLines()):o>40&&e<=40&&(w("zoom:show:showEasyView",o,e),t.performanceMode&&this.dataProvider.updateOptions({showEasyView:!0}))}setZoom(o,e){const t=this.getOptions(),n=Math.round(o-t.canvasZoom);this.zoom(n,e)}}class Zn extends Jn{constructor(){super()}fitContentHeight(o=20){this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated();const e=this.getOptions(),t=this.getNodesRectBox(),n=t.height,i=t.width,a=e.viewSize.width-o*2,r=t.minX+t.width/2,l=t.minY+t.height/2;console.warn("[fitContentHeight]nodesCenter:",r,l),this.dataProvider.setCanvasCenter(r,l);const c=Math.min(1,a/i),d=n*c+o*2;this.dataProvider.updateOptions({viewSize:{...e.viewSize,height:d},viewHeight:d+"px"}),setTimeout(()=>{this.setZoom(c*100),this._moveToCenter(),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()},200)}_moveToCenter(o){const e=this.getNodesCenter(o);this.dataProvider.setCanvasCenter(e.x,e.y),this._dataUpdated()}setCanvasCenter(o,e){this.dataProvider.setCanvasCenter(o,e),this._dataUpdated()}zoomToFit(o){const e=this.getOptions(),t=this.getCanvasSlotRectItems(),n=t.length>0?[...t,...o||this.getNodes()]:o,i=this.getNodesRectBox(n),a=50,r=e.viewSize.width/(i.width+a*2),l=e.viewSize.height/(i.height+a*2),c=Math.min(r,l,1);w("zoomToFit:",{stuffSize:i,zoomPercent:c,zoomPercentX:r,zoomPercentY:l,viewSize:e.viewSize}),this._moveToCenter(n),this.setZoom(c*100),this._dataUpdated()}async zoomToFitWithAnimation(o){this.enableCanvasAnimation(),this.zoomToFit(o),await this.sleep(330),this.disableCanvasAnimation()}async moveToCenterWithAnimation(o){this.enableCanvasAnimation(),this.moveToCenter(o),await this.sleep(330),this.disableCanvasAnimation()}enableNodeXYAnimation(){this.dataProvider.updateOptions({enableNodeXYAnimation:!0}),this._dataUpdated()}disableNodeXYAnimation(){this.dataProvider.updateOptions({enableNodeXYAnimation:!1}),this._dataUpdated()}enableCanvasAnimation(){this.dataProvider.updateOptions({enableCanvasTransformAnimation:!0}),this._dataUpdated()}disableCanvasAnimation(){this.dataProvider.updateOptions({enableCanvasTransformAnimation:!1}),this._dataUpdated()}focusNodeById(o){const e=this.getNodeById(o);e&&this.focusNode(e)}focusRootNode(){throw new Error("focusRootNode is deprecated, please use focusNodeById instead.")}focusNode(o){w("checked:",o);const e=this.getOptions();this.setZoom(100);const t=o.width||50,n=o.height||50,i=o.x*-1+e.viewSize.width/2-t/2,a=o.y*-1+e.viewSize.height/2-n/2;this.dataProvider.setCanvasOffset(i,a),this.dataProvider.updateOptions({checkedNodeId:o.id})}}class Qn extends fe{constructor(e,t,n){super(e,t,n);_(this,"rotate",0);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,w("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;console.log("this.layoutOptions.alignItemsX:1:",this.layoutOptions.alignItemsX),i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="start"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const a=this.layoutOptions.layoutExpansionDirection,r=a==="start"||a==="left"||a==="top"?"start":a==="end"||a==="right"||a==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.treeNodeGapH<100&&(this.layoutOptions.treeNodeGapH=100),this.layoutOptions.treeNodeGapV<10&&(this.layoutOptions.treeNodeGapV=10),(this.layoutOptions.from==="bottom"||this.layoutOptions.from==="right")&&(this.rotate=180),this.layoutOptions.changeNodeSizeDuringLayout===void 0&&(this.layoutOptions.changeNodeSizeDuringLayout=!1)}placeNodes(e,t){if(console.log("tree:placeNodes:rootNode",t.id,t),w("RGTreeLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}w("allNodes:",e.length),this.layoutOptions.alignItemsX,this.layoutOptions.alignItemsY,this.layoutOptions.alignParentItemsX,this.layoutOptions.alignParentItemsY,this.rootNode=t,this.allNodes=e,t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0),t.lot.x=t.x,t.lot.y=t.y;const n=e;w("groupNodes:2:",n.length,n.map(r=>r.text).join(","));const i=this.rotate;console.log("rotate:",i),this.networkAnalyzer.analyzeNetwork(n,this.rootNode,!1),this.placeNodesPosition(t,n);const a={x:t.x,y:t.y};this.allNodes.forEach(r=>{if(r.fixed!==!0&&!!B.isVisibleNode(r)&&(Number.isNaN(r.lot.x)&&(w("bad lot x:",r.text,r.lot.x),r.lot.x=0),Number.isNaN(r.lot.y)&&(w("bad lot y:",r.text,r.lot.y),r.lot.y=0),r!==t)){this.layoutOptions.from==="right"&&(r.lot.x=q.getFlippedX(r.lot.x,a.x)),this.layoutOptions.from==="bottom"&&(r.lot.y=q.getFlippedY(r.lot.y,a.y));const l=this.layoutOptions.from==="right"?B.getNodeXByLotX({alignItemsX:"end"},r):r.lot.x,c=this.layoutOptions.from==="bottom"?B.getNodeYByLotY({alignItemsY:"end"},r):r.lot.y;this.updateNodePosition(r,l,c)}});for(const r of this.allNodes)this.graphInstance.updateNode(r,{rgChildrenSize:r.lot.childs.length});w("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t){this.placeRelativePosition(e,t)}placeRelativePosition(e,t){e.lot.parent=void 0,e.lot.level=0;const n=[];this.buildNetwork([e],n,0);const i=Math.max(...n.map(c=>c.lot.level)),a=this.layoutOptions.from==="left"||this.layoutOptions.from==="right";this.reduceNodeRect(n,i,a),a?this.placeNodeChildrenH(n,0):this.placeNodeChildrenV(n,0);let r=e.lot.x-e.x,l=e.lot.y-e.y;this.layoutOptions.from==="right"&&(r+=e.lot.width),this.layoutOptions.from==="bottom"&&(l+=e.lot.height),n.forEach(c=>{c.fixed!==!0&&(c.lot.x-=r,c.lot.y-=l)}),console.log("levelMaxWidthMap:",e.id)}buildNetwork(e,t,n){n===0&&t.push(...e);const i=[];e.forEach(a=>{if(!B.isVisibleNode(a))return;const r=this.graphInstance.getNodeIncomingNodes(a).filter(B.isVisibleNode),c=this.graphInstance.getNodeOutgoingNodes(a).filter(B.isVisibleNode).filter(h=>!t.includes(h));t.push(...c);const d=r.filter(h=>!t.includes(h));t.push(...d),a.lot.level=n,a.lot.toNodes=c,a.lot.fromNodes=d;for(const h of d.concat(c))h.lot.parent=a,i.includes(h)||i.push(h)}),i.length>0&&this.buildNetwork(i,t,n+1)}reduceNodeRect(e,t,n=!1){let i=this.layoutOptions.treeNodeGapH,a=this.layoutOptions.treeNodeGapV;const r=i,l=a,c=e.filter(d=>d.lot.level===t);console.log("reduceNodeRect:level:",t,c.length);for(const d of c){if(!B.isVisibleNode(d))continue;let h=d.width||d.el_W||50,f=d.height||d.el_H||50;if(d.lot.width=h,d.lot.height=f,d.lot.toNodes.length===0&&d.lot.fromNodes.length===0)d.lot.width_with_childs=h,d.lot.height_with_childs=f;else if(n){let p=0,u=0;for(const m of d.lot.fromNodes)m.lot.height_with_childs>u&&(u=m.lot.height_with_childs),p+=m.lot.width_with_childs+l;let g=0,y=0;for(const m of d.lot.toNodes)m.lot.height_with_childs>y&&(y=m.lot.height_with_childs),g+=m.lot.width_with_childs+l;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),f=Math.max(u+r/2,f/2)+Math.max(y+r/2,f/2),d.lot.width_with_childs=h+Math.max(p,g)+l,d.lot.height_with_childs=f}else{let p=0,u=0;for(const m of d.lot.fromNodes)m.lot.width_with_childs>p&&(p=m.lot.width_with_childs),u+=m.lot.height_with_childs+l;let g=0,y=0;for(const m of d.lot.toNodes)m.lot.width_with_childs>g&&(g=m.lot.width_with_childs),y+=m.lot.height_with_childs+l;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),h=Math.max(p+r/2,h/2)+Math.max(g+r/2,h/2),d.lot.width_with_childs=h,d.lot.height_with_childs=f+Math.max(u,y)+l}}t>=0&&this.reduceNodeRect(e,t-1,n)}placeNodeChildrenV(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let l=0;const c=e.filter(d=>d.lot.level===t);console.log("placeNodeChildren:level:",t,c.length);for(const d of c){l++;let h=d.lot.width;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),t===0&&(d.lot.groupStartX=d.lot.x+h/2-d.lot.width_with_childs/2);const f=d.lot.groupStartX,p=d.lot.y;let u=0,g=0;for(const m of d.lot.fromNodes)m.lot.width_with_childs>u&&(u=m.lot.width_with_childs);for(const m of d.lot.toNodes)m.lot.width_with_childs>g&&(g=m.lot.width_with_childs);const y=f+Math.max(u+a/2,h/2);if(d.lot.fromNodes.length>0){let m=d.lot.height+r;for(const v of d.lot.fromNodes)v.lot.groupStartX=y-v.lot.width_with_childs-a/2,v.lot.y=p+m+r,m+=v.lot.height_with_childs+r}if(d.lot.toNodes.length>0){let m=d.lot.height+r;for(const v of d.lot.toNodes)v.lot.groupStartX=y+a/2,v.lot.y=p+m+r,m+=v.lot.height_with_childs+r}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(d.lot.x=f,d.width=d.lot.width_with_childs):d.lot.x=y-d.lot.width/2:d.lot.x=f}l>0&&this.placeNodeChildrenV(e,t+1)}placeNodeChildrenH(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let l=0;const c=e.filter(d=>d.lot.level===t);console.log("placeNodeChildren:level:",t,c.length);for(const d of c){l++;let h=d.lot.height;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),t===0&&(d.lot.groupStartY=d.lot.y+h/2-d.lot.height_with_childs/2);const f=d.lot.groupStartY,p=d.lot.x;let u=0,g=0;for(const m of d.lot.fromNodes)m.lot.height_with_childs>u&&(u=m.lot.height_with_childs);for(const m of d.lot.toNodes)m.lot.height_with_childs>g&&(g=m.lot.height_with_childs);const y=f+Math.max(u+a/2,h/2);if(d.lot.fromNodes.length>0){let m=d.lot.width+r;for(const v of d.lot.fromNodes)v.lot.groupStartY=y-v.lot.height_with_childs-a/2,v.lot.x=p+m+r,m+=v.lot.width_with_childs+r}if(d.lot.toNodes.length>0){let m=d.lot.width+r;for(const v of d.lot.toNodes)v.lot.groupStartY=y+a/2,v.lot.x=p+m+r,m+=v.lot.width_with_childs+r}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(d.lot.y=f,d.height=d.lot.height_with_childs):d.lot.y=y-d.lot.height/2:d.lot.y=f}l>0&&this.placeNodeChildrenH(e,t+1)}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return i}else{let i=0;for(let a=0;a>e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return-i}}getLevelGap(e,t,n,i){let a=t+(i===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(a=r)}return a}}class Kn extends Zn{constructor(){super();_(this,"_layoutTimer",null);_(this,"_layoutPromise",null);_(this,"_layoutResolve",null);_(this,"layoutor")}async doLayout(e){const t=Date.now()-this.prevAddNodeTimestamp;return t<300&&(this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated(),await Xe(300-t)),this._layoutPromise||(this._layoutPromise=new Promise(n=>{this._layoutResolve=n})),clearTimeout(this._layoutTimer),this._layoutTimer=setTimeout(async()=>{var n;try{await this._doLayout(e),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()}finally{(n=this._layoutResolve)==null||n.call(this),this._layoutResolve=null,this._layoutPromise=null}},50),this._layoutPromise}async _doLayout(e){this.updateNodesVisibleProperty();const t=this.getNodes();w("node size\uFF1A",t.length);let n=this.dataProvider.getRootNode();if(e&&(n=typeof e=="string"?this.getNodeById(e):e),n||(n=t[0],this._rgAsConnectArea||(w("[relation-graph]No root node, use first node as root:",n),w("[relation-graph]You can set rootNode call doLayout(rootNode | nodeId) with a node id"))),!n)throw new Error("custom rootNode not found, id:"+e);const i=this.getOptions();this.dataProvider.setRootNodeId(n?n.id:""),this.stopAutoLayout();const a=this.createLayout(i.layout,!0);if(a.layoutOptions.layoutName==="force")a.isMainLayouer=!0,a.onFinish(()=>{this.emitEvent(A.onForceLayoutFinish)}),await Xe(100),w("doLayout:start force:",t.length),a.placeNodes(t,n);else{this.enableNodeXYAnimation();let r=[];n&&(r=this.getNetworkNodesByNode(n),a.placeNodes(r,n)),w("doLayout:placeOtherNodes:all:",t.length,"mainGroupNodes:",r.length),this.placeOtherNodes(r),setTimeout(()=>{this.disableNodeXYAnimation()},300),w("doLayout:placeOtherNodes ok!")}t.forEach(r=>this.dataProvider.updateNode(r.id,{x:r.x||0,y:r.y||0,rgChildrenSize:r.rgChildrenSize||0})),this.updateElementLines()}async refresh(e=!0){this.resetViewSize(!0),this._dataUpdated(),e&&await this.doLayout(),this.updateElementLines(),this._dataUpdated()}placeOtherNodes(e=[]){const t=this.getOptions();if(t.layout.layoutName==="fixed"||!t.placeOtherGroup)return;const i=[],a=[],r=this.getNodes();r.forEach(c=>{if(c.fixed===!0||e.includes(c))return;this.getNodeRelatedNodes(c).length===0?a.push(c):i.push(c)}),w("doLayout:allNodes:",r.length),w("doLayout:mainGroupNodes:",e.length),w("doLayout:notInMainGroupNodes:",i.length),w("doLayout:singleNodes:",a.length);const l=[{nodes:e}];this.placeNextNetwork(i,[...e],l),this.placeSingleNodes(a),l.push({nodes:a}),this.sortGroups(l),this._dataUpdated()}placeSingleNodes(e){if(e.length>0){const t=Math.ceil(Math.sqrt(e.length));Ue(t,30,e.map(i=>({width:i.el_W,height:i.el_H,node:i})),(i,a,r)=>{const l=i.node;l.x=a,l.y=r,l.lot||(l.lot={childs:[]})}),w("[placeSingleNodes]Single nodes:",e.length)}}sortGroups(e){w("[placeSingleNodes]sortGroups groupList:",e.length,e.map(a=>a.nodes.length));const t=e.map(a=>{const r=this.getNodesRectBox(a.nodes);return{width:r.width,height:r.height,nodes:a.nodes,orignX:r.minX,orignY:r.minY}});if(t.length===0)return;const n=Math.floor(Math.sqrt(t.length))||1;Ue(n,100,t,(a,r,l)=>{const c=r-a.orignX,d=l-a.orignY;w(`[placeNextNetwork]Move ${a.nodes.length} Nodes :`,c,d,a," > ");for(const h of a.nodes)this.updateNodePosition(h,h.x+c,h.y+d)},t[0].orignX,t[0].orignY)}placeNextNetwork(e,t,n){if(e.length>0){const i=this.getOptions();w("[placeNextNetwork]notPlacedNodes nodes:",e.length);const a=JSON.parse(JSON.stringify(i.layout)),r=e[0],l=this.createLayout(a);if(l.isMainLayouer=!1,w("[placeNextNetwork]layoutName:",l.layoutOptions.layoutName,"root:",r.text),l.layoutOptions.layoutName==="force"){const h=l;h.maxLayoutTimes=0}r.fixed?w("[placeNextNetwork]fixed root x,y:",r.x,r.y,r.text):(this.updateNodePosition(r,0,0),w("[placeNextNetwork]set root x,y:",r.x,r.y,r.text)),l.layoutOptions.fixedRootNode=!0;const c=this.getNetworkNodesByNode(r);w("[placeNextNetwork]thisNetworkNodes:",e.length),l.placeNodes(c,r),t.push(...c),n.push({nodes:c});const d=[];e.forEach(h=>{t.includes(h)||d.push(h)}),i.placeOtherGroup&&this.placeNextNetwork(d,t,n),this._dataUpdated()}else w("[placeOtherGroup]thisGroupNodes:all is OK!")}toggleAutoLayout(){const e=this.getOptions();w("toggleAutoLayout:to:",e.layout.autoLayouting),e.layout.autoLayouting?this.stopAutoLayout():this.startAutoLayout()}startAutoLayout(){var e;(e=this.layoutor)!=null&&e.start&&(w("Start force layout:"+this.layoutor.instanceId),this.layoutor.start())}stopAutoLayout(){var e;(e=this.layoutor)!=null&&e.stop&&(w("Stop force layout:"+this.layoutor.instanceId),this.layoutor.stop())}createLayout(e,t=!1){w("########createLayout:",e);const n=this.getOptions();it(e);let i=null;if(e.layoutName==="tree"?i=new Lt(e,n,this):e.layoutName==="center"?i=new wt(e,n,this):e.layoutName==="circle"?i=new _t(e,n,this):e.layoutName==="force"?i=new Re(e,n,this):e.layoutName==="fixed"?i=new Nt(e,n,this):e.layoutName==="smart-tree"?i=new Cn(e,n,this):e.layoutName==="io-tree"?i=new Qn(e,n,this):e.layoutName==="folder"&&(i=new bt(e,n,this)),!i)throw new Error("unknown layout: "+e.layoutName);return w("########supportAutoLayout:",i.autoLayout!==void 0,e.disableAsForceLayout),this.setLayoutor(i,t,i.autoLayout!==void 0&&e.disableAsForceLayout!==!0),i}setLayoutor(e,t,n=!1){e.isMainLayouer=t,e.layoutOptions.fixedRootNode=!0,t&&(this.layoutor=e,this._updateOptions({layout:{supportAutoLayout:n}}))}}const ei=async(s,o)=>{const e=s||document.documentElement;o?await ti(e):await ni()},ti=async s=>{s.requestFullscreen?await s.requestFullscreen():s.mozRequestFullScreen?await s.mozRequestFullScreen():s.webkitRequestFullscreen?await s.webkitRequestFullscreen():s.msRequestFullscreen&&await s.msRequestFullscreen()},ni=async()=>{document.exitFullscreen?await document.exitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()};class ii extends Kn{constructor(){super();_(this,"_prevClickNodeTime",0);_(this,"_nodeXYMappingBeforeDrag",{});_(this,"canvasAutoMoving",e=>{const t=this.getOptions(),n=t.viewSize,i=40;let a=0,r=0;e.x<i?a=i-e.x:n.width-i<e.x&&(a=n.width-i-e.x),e.y<i?r=i-e.y:n.height-i<e.y&&(r=n.height-i-e.y);const l=a!==0||r!==0;l&&(a=Math.max(Math.min(a/5,30),-30),r=Math.max(Math.min(r/5,30),-30));const c=t.canvasOffset.x+a,d=t.canvasOffset.y+r;return this.onCanvasDragging(c,d,a,r),l});_(this,"_canvasMovingTimer");_(this,"_relayoutTaskTimer");_(this,"_onMovingWhenCreatingLine");_(this,"_step1EventTime",0);_(this,"_onCreateLineCallback");_(this,"_mouseWheelTimer");_(this,"_mouseWheelEventPrevApplyTime",0);_(this,"_mouseWheelForce",{x:0,y:0});_(this,"_fullscreenchangeHandler")}onNodeClick(e,t){if(Date.now()-this._prevClickNodeTime<200){w("[node]click abort : time < 200");return}this._prevClickNodeTime=Date.now();const n=this.getOptions();if(n.creatingLinePlot){this.onNodeClickWhenCreatingLinePlot(e);return}const i=e.disablePointEvent===void 0?n.disableNodePointEvent:e.disablePointEvent;w("[node]node click",e.text,n.creatingLinePlot,i),!t.shiftKey&&!i&&(n.checkedLineId="",this.dataProvider.updateOptions({checkedLineId:"",checkedNodeId:e.id})),this.emitEvent(A.onNodeClick,e,t),this._prevClickNodeTime=Date.now()}onNodeDragStart(e,t){if(!e||_e(t))return;const n=this.getOptions();if((e.disableDrag||n.disableDragNode)&&!(t.target&&t.target.closest(".rg-node-drag-handler"))){const g=y=>{this.onNodeClick(e,y),document.body.removeEventListener("mouseup",g)};document.body.addEventListener("mouseup",g);return}isNaN(e.x)&&(e.x=0),isNaN(e.y)&&(e.y=0),this.dataProvider.setEditingLine(null),this.dataProvider.updateOptions({checkedLineId:""});let a=!1;const r=(u,g,y)=>{y.stopPropagation(),a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.dataProvider.updateOptions({draggingNodeId:"",editingReferenceLine:{...n.editingReferenceLine,show:!1}}),this._onNodeDragEnd(e,u,g,y),d?this.emitEvent(A.onNodeDragEnd,e,y,u,g):this.onNodeClick(e,t),this._dataUpdated()};this._nodeXYMappingBeforeDrag={},this._nodeXYMappingBeforeDrag[e.id]={x:e.x,y:e.y};for(const u of n.editingController.nodes)this._nodeXYMappingBeforeDrag[u.id]={x:u.x,y:u.y};const l=this.getCanvasXyByViewXy(this.getViewXyByEvent(t)),c={x:e.x,y:e.y};let d=!1;this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer);let h;const f=()=>{if(!h||a)return;const u=this.getViewXyByEvent(h),g=this.getCanvasXyByViewXy(u),y=g.x-l.x,m=g.y-l.y;let v=y+c.x,C=m+c.y,N=v-c.x,O=C-c.y;const b=this.emitEvent(A.onNodeDragging,e,v,C,N,O,h);b&&(typeof b.x=="number"&&(v=b.x,N=v-c.x),typeof b.y=="number"&&(C=b.y,O=C-c.y)),this.canvasAutoMoving(u),this.draggingSelectedNodes(e,v,C,N,O),this._dataUpdated()},p=()=>{f(),this._canvasMovingTimer=requestAnimationFrame(p)};Z.startDrag(t,c,r,(u,g,y,m,v)=>{d?h=v:Math.abs(u)+Math.abs(g)>4&&(w("[node]onNodeDragStart...",ce(h),h),this.emitEvent(A.onNodeDragStart,e,h),d=!0,this.dataProvider.updateOptions({draggingNodeId:e.id}),this._canvasMovingTimer=requestAnimationFrame(p)),this.updateElementLines(),this._dataUpdated()})}_onNodeDragEnd(e,t,n,i){this.updateElementLines()}onLineClick(e,t){const n=this.getLinkByLineId(e.id);w("onLineClick:","line:",e,"link:",n);const i=this.getOptions();(e.disablePointEvent===void 0?i.disableLinePointEvent:e.disablePointEvent)||(this.setCheckedNode(""),this.setCheckedLine(e)),this.emitEvent(A.onLineClick,e,n,t),this._dataUpdated()}expandOrCollapseNode(e,t){t.stopPropagation(),e.expanded===!1?this.expandNode(e,t):this.collapseNode(e,t)}expandNode(e,t){w("onNodeExpand:",e),this.dataProvider.updateNode(e.id,{expanded:!0}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(A.onNodeExpand,e,t)}collapseNode(e,t){w("onNodeCollapse:",e),this.dataProvider.updateNode(e.id,{expanded:!1}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(A.onNodeCollapse,e,t)}_effectWhenExpandedOrCollapsed(e){const t=this.getDescendantNodes(e);this.updateNodesVisibleProperty([e].concat(t)),this._relayoutTaskTimer&&clearTimeout(this._relayoutTaskTimer),this._relayoutTaskTimer=setTimeout(()=>{this.updateElementLines(),this._dataUpdated();const n=this.getOptions();n.reLayoutWhenExpandedOrCollapsed&&(n.layout.layoutName==="force"?this.startAutoLayout():this.doLayout())},100)}onCanvasDragEnd(e){this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated(),this.emitEvent(A.onCanvasDragEnd,e)}onCanvasClick(e){if(this.getOptions().creatingLinePlot)this.onCanvasClickWhenCreatingLinePlot(e);else{if(this.dataProvider.isPerformanceMode()){const n=this.getNodeAtEvent(e);if(n){this.emitEvent(A.onNodeClick,n,e);return}}this.emitEvent(A.onCanvasClick,e)}}getNodeAtEvent(e){const t=this.getCanvasXyByClientXy(e);return this.dataProvider.findNodeByXy(t)}onCanvasSelectionEnd(e,t){this.emitEvent(A.onCanvasSelectionEnd,e,t),w("[canvas]onCanvasSelectionEnd:",e),this._dataUpdated()}startCreatingNodePlot(e,t){if(!t)throw new Error("startCreatingNodePlot need setting param");if(!t.onCreateNode)throw new Error("startCreatingNodePlot need setting.onCreateNode param as callback");const n=Oe(JSON.parse(JSON.stringify(Ye)),this.getOptions()),i=ce(e);this.dataProvider.updateOptions({newNodeTemplate:Object.assign({},n,t.templateNode),creatingNodePlot:!0,showTemplateNode:!i});let a=(u,g)=>{const y=this.getOptions().newNodeTemplate,m={width:y.width||50,height:y.height||50};this.dataProvider.updateOptions({newNodeTemplate:{...y,x:u-m.width/2,y:g-m.height/2}}),this._dataUpdated()};const r=this.getViewBoundingClientRect();w("[CreatingNodePlot]startCreatingNodePlot:");const l=Ce(e),c=l.clientX-r.x+10,d=l.clientY-r.y+10;i||a(c,d);const h=u=>{w("[CreatingNodePlot]objectTemplateMove");const g=this.getViewXyByEvent(u);t.templateMove&&t.templateMove(g.x,g.y),a(g.x,g.y)},f=u=>{w("[CreatingNodePlot]user abort!"),this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("click",p),this.$dom.removeEventListener("contextmenu",f),this.dataProvider.updateOptions({creatingNodePlot:!1})},p=u=>{let g=!1;if(this.getOptions().creatingNodePlot||(g=!0),this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("click",p),this.$dom.removeEventListener("contextmenu",f),this.dataProvider.updateOptions({creatingNodePlot:!1}),g){w("[CreatingNodePlot]action be abort!");return}const y=Ce(u),m=y.clientX-r.x+10,v=y.clientY-r.y+10;if(Math.abs(c-m)<30&&Math.abs(d-v)<30){w("[CreatingNodePlot]create node be abort!");return}const C=this.getCanvasXyByClientXy({x:y.clientX,y:y.clientY});w("[CreatingNodePlot]objectBePlaced:",C),t.onCreateNode(C.x,C.y,this.getOptions().newNodeTemplate),this._dataUpdated()};setTimeout(()=>{this.$dom.addEventListener("click",p),this.$dom.addEventListener("contextmenu",f)},300),i||this.$dom.addEventListener("mousemove",h)}startCreatingLinePlot(e,t){const n=ce(e);t&&t.onCreateLine&&(this._onCreateLineCallback=t.onCreateLine);const i=ue({from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:""},this.getOptions());t&&t.template&&Object.assign(i,t.template),this.dataProvider.updateOptions({newLineTemplate:Object.assign(i,{isReverse:t.isReverse||!1})}),this.dataProvider.updateOptions({newLineTemplate:Object.assign(i,{isReverse:t.isReverse||!1,disablePointEvent:!0}),creatingLinePlot:!0});const a=Object.assign({},this.getOptions().newLinkTemplate,{fromNode:null,toNode:{id:"",targetType:V.Node,x:0,y:0,el_W:2,el_H:2},toNodeObject:null});t&&t.fromNode&&(a.toNode.x=t.fromNode.x+50,a.toNode.y=t.fromNode.y+50,a.fromNode=t.fromNode,this._step1EventTime=Date.now()),this.dataProvider.updateOptions({newLinkTemplate:a}),w("[CreatingLinePlot]startCreatingLinePlot:isTouchEvent:",n),n||(w("[CreatingLinePlot]Listener move"),this._onMovingWhenCreatingLine&&this.$dom.removeEventListener("mousemove",this._onMovingWhenCreatingLine),this._onMovingWhenCreatingLine=this.onMovingWhenCreatingLinePlot.bind(this),this.$dom.addEventListener("mousemove",this._onMovingWhenCreatingLine)),this._dataUpdated()}stopCreatingLinePlot(){w("[CreatingLinePlot]stop CreatingLinePlot!"),this.dataProvider.updateOptions({creatingLinePlot:!1,newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:null,toNodeObject:null},nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}),this._onCreateLineCallback=void 0,this.$dom.removeEventListener("mousemove",this._onMovingWhenCreatingLine),this._onMovingWhenCreatingLine=void 0,this._dataUpdated()}onMovingWhenCreatingLinePlot(e){w("[CreatingLinePlot]mousemove");const t=this.getCanvasXyByClientXy({x:e.clientX,y:e.clientY}),n=this.getOptions(),i=e.target;let a="",r=V.Node;const l=this.isNode(i);let c=!1,d={x:0,y:0,el_W:5,el_H:5,nodeShape:0};l&&(a=l.id,l===this.getOptions().newLinkTemplate.fromNode?this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}):(this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:l,show:!0}}),this._updateEditingConnectControllerView()));const h=i.closest(".rg-connect-ctl-handler");if(h){let f=this.getOptions().nodeConnectController.node;w("[CreatingLinePlot]content point:",h.dataset.point);let p=h.dataset.point||"border";if(h.classList.contains("rg-connect-target")){const{width:u,height:g,x:y,y:m}=h.getBoundingClientRect(),v=this.getCanvasXyByClientXy({x:y,y:m}),C=this.dataProvider.getCanvasScale(),N={x:v.x,y:v.y,el_W:u/C,el_H:g/C,nodeShape:1,id:h.dataset.targetId,targetData:JSON.parse(h.dataset.targetData||"{}"),targetType:h.dataset.targetType};c=!0,d.x=N.x,d.y=N.y,d.el_W=N.el_W,d.el_H=N.el_H,d.nodeShape=N.nodeShape,console.log("[CreatingLinePlot]fakeNode:",JSON.stringify(N)),this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:N,show:!1}}),p=h.dataset.point,n.newLinkTemplate.toNode&&(a=N.id,r=N.targetType,this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,nodeShape:N.nodeShape}}})),this._updateEditingConnectControllerView()}else f&&(r=V.Node,c=!0,d.x=f.x,d.y=f.y,d.el_W=f.el_W,d.el_H=f.el_H,d.nodeShape=f.nodeShape,i.dataset.innode==="true"&&(d.x=t.x,d.y=t.y,d.el_W=2,d.el_H=2,d.nodeShape=1));n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:p}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:p}})}else w("[CreatingLinePlot]point:",i.dataset.point),n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:U.border}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:U.border}}),n.newLinkTemplate.toNode&&(r=V.Node);n.newLinkTemplate.toNode&&(a&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,id:a}}}),this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,targetType:r}}})),n.newLinkTemplate.fromNode&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,x:c?d.x:t.x,y:c?d.y:t.y,el_W:d.el_W,el_H:d.el_H,nodeShape:d.nodeShape}}}),this._dataUpdated()}onCanvasClickWhenCreatingLinePlot(e){if(Date.now()-this._step1EventTime<500){w("[CreatingLinePlot]step1EventTime:",this._step1EventTime);return}const t=this.getOptions();if(!t.newLinkTemplate.fromNode){w("[CreatingLinePlot]CreatingLinePlot:fromNode not set!");return}let n=!1;if(!t.newLinkTemplate.toNodeObject){w("[CreatingLinePlot]CreatingLinePlot:toNodeObject not set!");const i=Ce(e),a=this.getCanvasXyByClientXy({x:i.clientX,y:i.clientY});n=this.onReadyToCreateLine(t.newLinkTemplate.fromNode,a)}n!==!0&&this.stopCreatingLinePlot()}onNodeClickWhenCreatingLinePlot(e){const t=this.getOptions();t.newLinkTemplate.fromNode?(w("[CreatingLinePlot]step 2: set toNodeObjecct:",t.newLinkTemplate.fromNode,e),this.dataProvider.updateOptions({newLinkTemplate:{...t.newLinkTemplate,toNodeObject:e}}),this.onReadyToCreateLine(t.newLinkTemplate.fromNode,e)!==!0&&this.stopCreatingLinePlot()):(w("[CreatingLinePlot]step 1: set fromNode:",e),this.dataProvider.updateOptions({newLinkTemplate:{...t.newLinkTemplate,fromNode:e,toNode:{...t.newLinkTemplate.toNode,x:e.x+50,y:e.y+50}}}),this._step1EventTime=Date.now())}onReadyToCreateLine(e,t){w("[CreatingLinePlot][fire-event]onCreateLine:",e,t);const n=this.getOptions(),i=ue(n.newLineTemplate,this.getOptions());n.newLineTemplate.isReverse?(i.from=t?t.id:"",i.to=e?e.id:"",i.isReverse=void 0,[e,t]=[t,e]):(i.from=e?e.id:"",i.to=t?t.id:""),i.disablePointEvent=!1;const a=this.emitEvent(A.beforeCreateLine,{lineJson:i,fromNode:e,toNode:t});if(w("[CreatingLinePlot]onCreateLine:abort-flag:",a),a===!0){w("[CreatingLinePlot]onCreateLine:abort!");return}if(this._onCreateLineCallback){w("[CreatingLinePlot]onCreateLine:callback");try{this._onCreateLineCallback(e,t,i)}catch(l){return console.warn("[Custom Reject Connect By Throw Error:",l),!1}}return w("[CreatingLinePlot]onCreateLine:emitEvent"),this.emitEvent(A.onLineBeCreated,{lineJson:i,fromNode:e,toNode:t})}onContextmenu(e){e.stopPropagation(),e.preventDefault(),this.stopCreatingLinePlot();let t="canvas",n=this.isNode(e.target);n?t="node":(n=this.isLine(e.target),n&&(t="line")),w("contextmenu:objectType",t,n);const i=Ce(e),a=this.getCanvasXyByClientXy({x:i.clientX,y:i.clientY}),r=this.getViewXyByCanvasXy(a);this.emitEvent(A.onContextmenu,e,t,n,a,r)}async fullscreen(e){const t=this.getOptions();if(e!==void 0&&e===t.fullscreen)return;w("fullscreen:newValue:",e),console.log("fullscreen:newValue:",e),e===void 0&&(e=!t.fullscreen);let n=this.$dom;t.fullscreenElementXPath&&(n=document.querySelector(t.fullscreenElementXPath)||this.$dom),await ei(n,e),this.dataProvider.updateOptions({fullscreen:e}),this.emitEvent(A.onFullscreen,e),this._dataUpdated()}onMouseWheel(e){const t=this.getOptions();if(!e.ctrlKey&&!e.metaKey&&(t.disableWheelEvent||t.wheelEventAction==="none"))return!0;try{e.preventDefault(),e.stopPropagation()}catch{}let{deltaX:n,deltaY:i,deltaMode:a}=e;a===1?(n*=40,i*=40):a===2&&(n*=800,i*=800),this._mouseWheelForce.x+=n,this._mouseWheelForce.y+=i,this._applyWheelEvent(e)}_applyWheelEvent(e){clearTimeout(this._mouseWheelTimer),this._mouseWheelTimer=setTimeout(()=>{const t=this._mouseWheelForce.x,n=this._mouseWheelForce.y;this._onMouseWheel(e,t,n),this._mouseWheelForce.x-=t,this._mouseWheelForce.y-=n,this._mouseWheelEventPrevApplyTime=Date.now(),(Math.abs(this._mouseWheelForce.x)>1||Math.abs(this._mouseWheelForce.y)>1)&&this._applyWheelEvent(e)},Date.now()-this._mouseWheelEventPrevApplyTime>50?0:50)}_onMouseWheel(e,t,n){const i=e.ctrlKey||e.metaKey,a=this.getOptions();if(!i&&a.wheelEventAction==="scroll"){let r=Math.max(Math.abs(t),Math.abs(n));const l=t/r,c=n/r;r>200&&(r=200);const d=a.mouseWheelSpeed/10*-l*r,h=a.mouseWheelSpeed/10*-c*r,f=this.emitEvent(A.beforeScrollStart,d,h,e);if(w("[scroll]","abortScroll:",f),f===!0)return;this.scrollView(d,h)}else if(!(!i&&a.wheelEventAction==="none")){const r={x:e.clientX,y:e.clientY};let l=a.mouseWheelSpeed/20*-n;l=Math.max(Math.min(l,20),-20),this.zoom(l,r,e)}}scrollView(e,t){const n=this.getOptions();this.dataProvider.setCanvasOffset(n.canvasOffset.x+e,n.canvasOffset.y+t),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}onLineDragStart(e,t){w("onLineDragStart...");const n=this.getLinkByLine(e),i={x:n.fromNode.x,y:n.fromNode.y},a={x:n.toNode.x,y:n.toNode.y},r=(l,c,d,h,f)=>{const p=this.dataProvider.getCanvasScale();n.fromNode.x=i.x+l/p,n.fromNode.y=i.y+c/p,n.toNode.x=a.x+l/p,n.toNode.y=a.y+c/p,this._updateEditingControllerView(),this._dataUpdated()};Z.startDrag(t,{x:0,y:0},(...l)=>{this.onLineDragEnd(...l)},r)}onLineDragEnd(e,t,n){w("onLineDragEnd"),this.updateElementLines()}onCanvasDragStart(e){if(_e(e)||e.target&&e.target.closest(".rg-line-peel"))return;const t=this.getOptions();if(this.dataProvider.isPerformanceMode()&&t.editingController.nodes.length>0){const n=this.getNodeAtEvent(e);if(n){this.onNodeDragStart(n,e);return}}if(t.dragEventAction==="none"){this.onCanvasClick(e);return}if(t.dragEventAction==="selection"||e.shiftKey){this.startCreateSelection(e);return}if(!t.disableDragLine){const n=this.isLine(e.target);if(n){this.onLineDragStart(n,e);return}}this.startMoveCanvas(e)}startMoveCanvas(e,t=!1){let n;if(ce(e)){let l,c=1;n=(d,h,f,p,u)=>{const g=u.touches||u.targetTouches,y=g[0];if(g&&g.length>1){u.preventDefault();const m=g[1],v=this.getOptions();l||(l={x:m.clientX,y:m.clientY},c=v.canvasZoom);const C={x:y.clientX,y:y.clientY},N={x:m.clientX,y:m.clientY},O=Math.hypot(l.x-p.x,l.y-p.y),T=Math.hypot(N.x-C.x,N.y-C.y)/O,R=v.mouseWheelSpeed*T,P=c*R;this.setZoom(P,p),this._dataUpdated()}else{const m=y.clientX,v=y.clientY,C=m-p.x,N=v-p.y,O=f.x+C,b=f.y+N;this.onCanvasDragging(O,b,N,C),this._updateEditingControllerView(),this._dataUpdated()}}}else n=(l,c,d,h,f)=>{const p=d.x+l,u=d.y+c;this.onCanvasDragging(p,u,l,c),this._updateEditingControllerView(),this._dataUpdated()};const i=this.getOptions(),a={x:i.canvasOffset.x,y:i.canvasOffset.y};let r=t;Z.startDrag(e,a,(l,c,d)=>{this.onCanvasDragStop(l,c,d)},(l,c,d,h,f)=>{r?n(l,c,d,h,f):Math.abs(l)+Math.abs(c)>4&&(this.emitEvent(A.onCanvasDragStart,d,h,f),r=!0)})}onCanvasDragging(e,t,n,i){const a=this.emitEvent(A.onCanvasDragging,e,t,n,i);a!==!1&&(a&&(typeof a.x=="number"&&(e=a.x),typeof a.y=="number"&&(t=a.y)),this.dataProvider.setCanvasOffset(e,t))}onCanvasDragStop(e,t,n){const i=this.getOptions();if(i.creatingSelection){this.dataProvider.updateOptions({creatingSelection:!1}),this.onCanvasSelectionEnd(i.selectionView,n);return}if(Math.abs(e)+Math.abs(t)<4){w("[canvas]onDragEnd as click2"),this._dataUpdated(),this.onCanvasClick(n);return}else w("[canvas]onDragEnd"),this.onCanvasDragEnd(n)}startCreateSelection(e){const t=()=>{if(!n||a)return;const d=this.getViewXyByEvent(n);this.canvasAutoMoving(d)&&this._updateEditingControllerView();const f=this.getViewXyByCanvasXy(r),p=d.x-f.x,u=d.y-f.y;p<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:f.x+p,width:Math.abs(p)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:f.x,width:Math.abs(p)}}),u<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:f.y+u,height:Math.abs(u)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:f.y,height:u}}),this._dataUpdated()};let n,i=!1,a=!0;const r=this.getCanvasXyByViewXy(this.getViewXyByEvent(e)),l=()=>{t(),this._canvasMovingTimer=requestAnimationFrame(l)},c=(d,h,f,p,u)=>{if(n=u,i)n=u;else if(Math.abs(d)+Math.abs(h)>6){i=!0,a=!1;const g=this.getOptions();g.selectionView.width=5,g.selectionView.height=5,this.dataProvider.updateOptions({creatingSelection:!0}),this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this._canvasMovingTimer=requestAnimationFrame(l)}this._dataUpdated()};Z.startDrag(e,{x:0,y:0},(...d)=>{a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.onCanvasDragStop(...d)},c)}addFullscreenListener(){this._fullscreenchangeHandler=()=>{let e=!1;document.fullscreenElement?(w("div entered fullscreen mode",document.fullscreenElement),this.$dom===document.fullscreenElement&&(w("relation-graph is fullscreen!"),e=!0)):w("div exited fullscreen mode"),e!==this.getOptions().fullscreen&&(this.dataProvider.updateOptions({fullscreen:e}),this._dataUpdated(),setTimeout(async()=>{this.resetViewSize(),this._moveToCenter(),this.zoomToFit(),w("relation-graph reset complete!")},500))},document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}removeFullscreenListener(){document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}defaultLineConnectEndHandler(e,t,n){w("defaultLineConnectEndHandler:",e,t,n)}defaultLineVertexBeChangedHandler(e,t,n){w("defaultLineVertexBeChangedHandler:",n&&n.isReverse)}async sleep(e){await Xe(e)}forceLayoutTickCallback(){this._updateEditingControllerView(),this.dataProvider.updateShouldRenderGraphData(),this._dataUpdated()}}class oi extends ii{constructor(){super();_(this,"$easyViewCanvas");_(this,"$rgWebglPainter");_(this,"_updateEasyViewRequested",!1);_(this,"_easyViewOffset",{x:0,y:0})}setEasyViewCanvas(e){this.$easyViewCanvas=e,this.$rgWebglPainter=new yn(e)}updateEasyView(){this.updateMiniView(),this.dataProvider.isPerformanceMode()&&(!this.getOptions().showEasyView||this._updateEasyViewRequested||(this._updateEasyViewRequested=!0,requestAnimationFrame(this._updateEasyView.bind(this))))}_updateEasyView(e){try{const t=Date.now();if(!this.$easyViewCanvas)return;this.updateShouldRenderGraphData(),this.evDosomethingBeforeDraw(),this.evDrawAllLines(),this.evDrawAllNodes()}catch(t){console.error(t)}finally{this._updateEasyViewRequested=!1}}evDosomethingBeforeDraw(){const e=this.getOptions(),t=e.viewSize.width,n=e.viewSize.height;this.$easyViewCanvas.width=t,this.$easyViewCanvas.height=n,this.$rgWebglPainter.setSize(t,n);const i=this.dataProvider.getCanvasScale();this.$rgWebglPainter.setScale(i),this._easyViewOffset.x=e.canvasOffset.x,this._easyViewOffset.y=e.canvasOffset.y,this.$rgWebglPainter.setViewOffset(this._easyViewOffset.x,this._easyViewOffset.y),this.$rgWebglPainter.beforeDraw()}evDrawAllNodes(){const e=this.getOptions().defaultNodeShape;for(const t of this.getNodes()){if(!(t.rgShouldRender!==!1&&t.rgCalcedVisibility&&t.opacity!==0))continue;const i=Ne(t.nodeShape,e);this.evDrawNode(t,i)}}evDrawNode(e,t){t===be.circle?this.evDrawNode4Circle(e):this.evDrawNode4Rect(e)}getNodeColor(e){const t=e.color||this.getOptions().defaultNodeColor||"#dddddd";return t==="transparent"?"rgba(204,204,204,0.2)":t}evDrawNode4Rect(e){const t=e.el_W,n=e.el_H,i=e.opacity||.8,a=this.getNodeColor(e),r=e.borderRadius===void 0?3:e.borderRadius,l=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Rect(e.x,e.y,t,n,a,i,r,l)}evDrawNode4Circle(e){const t=e.el_W,n=e.el_H,i=e.opacity||.8,a=this.getNodeColor(e),r=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Circle(e.x,e.y,t,n,a,i,r)}evDrawAllLines(){for(const e of this.getLinks()){const t=e.fromNode.rgShouldRender!==!1&&e.fromNode.opacity!==0&&e.fromNode.rgCalcedVisibility,n=e.toNode.rgShouldRender!==!1&&e.toNode.opacity!==0&&e.toNode.rgCalcedVisibility;!t&&!n||this.evDrawLine(e,e.line)}}evDrawLine(e,t){const n=this.createLineDrawInfo(e,t),i=t.opacity||1,a=this.getOptions(),r=t.color||a.defaultLineColor||"#888888",l=t.lineWidth||a.defaultLineWidth||1;this.$rgWebglPainter.evDrawLine(n.pathData,l,r,i)}}class si extends oi{constructor(){super();_(this,"_onResizing");_(this,"_onResizeEnd");_(this,"_startPoint",{x:0,y:0});_(this,"_startEventCanvasXy",{x:0,y:0});_(this,"_startSizeCanvasXy",{x:0,y:0});_(this,"_startSize",{x:0,y:0,width:0,height:0,widthOnCanvas:0,heightOnCanvas:0});_(this,"_resizeType","l");_(this,"_nodeStartSizeMap",new WeakMap);_(this,"resizeMinLimit",{width:10,height:10});_(this,"_resizeDraggingTimer");_(this,"_resizeDraggingEvent");_(this,"_resizeDraggingStoped",!0);_(this,"_startCreateLineFromNodeTime",0)}setEditingNodes(e){if(e===null||e.length===0)this.dataProvider.setEditingNodes([]);else{const t=e.map(i=>i.id),n=this.getNodes().filter(i=>t.includes(i.id));this.dataProvider.setEditingNodes(n)}this._updateEditingControllerView(),this._dataUpdated()}addEditingNode(e){if(!this.getNodeById(e.id))throw new Error("Node not found: "+e.id);this.dataProvider.setEditingNodes(this.getOptions().editingController.nodes.concat(e)),this._updateEditingControllerView(),this._dataUpdated()}removeEditingNode(e){this.dataProvider.setEditingNodes(this.getOptions().editingController.nodes.filter(t=>t.id!==e.id)),this._updateEditingControllerView(),this._dataUpdated()}toggleEditingNode(e){this.getOptions().editingController.nodes.findIndex(n=>n.id===e.id)===-1?this.addEditingNode(e):this.removeEditingNode(e)}updateEditingControllerView(){this._updateEditingControllerView(),this._dataUpdated()}_updateEditingControllerView(){this._updateEditingLineView(),this._updateEditingConnectControllerView();const e=this.getOptions();if(!e.editingController.show)return;const{minX:t,minY:n,maxX:i,maxY:a}=this.getNodesRectBox(e.editingController.nodes),r=e.editingController.nodes.length>1?5:0,l=this.dataProvider.getCanvasScale();let c=i-t,d=a-n;if(c<0&&(c=0),d<0&&(d=0),c>0&&d>0){const h=this.getViewXyByCanvasXy({x:t,y:n}),f=h.x-r*l,p=h.y-r*l,u=c*l+r*2*l,g=d*l+r*2*l;this.dataProvider.updateOptions({editingController:{...e.editingController,x:f,y:p,width:u,height:g}})}else this.dataProvider.updateOptions({editingController:{...e.editingController,show:!1}})}onResizeStart(e,t){this._resizeType=e,this._startPoint=this.getViewXyByEvent(t),this._startEventCanvasXy=this.getCanvasXyByViewXy(this._startPoint);const n=this.getOptions();this._startSize.x=n.editingController.x,this._startSize.y=n.editingController.y,this._startSizeCanvasXy=this.getCanvasXyByViewXy(this._startSize),this._startSize.width=n.editingController.width,this._startSize.height=n.editingController.height;const i=this.dataProvider.getCanvasScale();this._startSize.widthOnCanvas=n.editingController.width/i,this._startSize.heightOnCanvas=n.editingController.height/i;for(const l of n.editingController.nodes)this._nodeStartSizeMap.set(l,{x:l.x,y:l.y,width:l.el_W,height:l.el_H});this._onResizing&&this.$dom.removeEventListener("mousemove",this._onResizing),this._onResizeEnd&&this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._resizeDraggingEvent=null,this._resizeDraggingStoped=!1,this._onResizing=this.onResizing.bind(this),this._onResizeEnd=this.onResizeEnd.bind(this),this.$dom.addEventListener("mousemove",this._onResizing),this.$dom.addEventListener("mouseup",this._onResizeEnd);const a=this.onResizingRequest.bind(this),r=()=>{a(),this._resizeDraggingTimer=requestAnimationFrame(r)};this._resizeDraggingTimer=requestAnimationFrame(r),this.emitEvent(A.onResizeStart,n.editingController.nodes,t)}onResizing(e){this._resizeDraggingEvent=e}onResizingRequest(){if(!this._resizeDraggingEvent||this._resizeDraggingStoped)return;const e=this.getViewXyByEvent(this._resizeDraggingEvent);this.canvasAutoMoving(e);const t=this.getViewXyByCanvasXy(this._startEventCanvasXy),n=this.getViewXyByCanvasXy(this._startSizeCanvasXy),i=e.x-t.x,a=e.y-t.y,r=this.getOptions();let l=r.editingController.width,c=r.editingController.height,d=r.editingController.x,h=r.editingController.y;const f=this.dataProvider.getCanvasScale();this._resizeType==="tl"?(d=t.x+i,h=t.y+a,l=this._startSize.widthOnCanvas*f-i,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="tr"?(h=t.y+a,d=n.x,l=this._startSize.widthOnCanvas*f+i,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="bl"?(d=t.x+i,h=n.y,l=this._startSize.widthOnCanvas*f-i,c=this._startSize.heightOnCanvas*f+a):this._resizeType==="br"?(d=n.x,h=n.y,l=this._startSize.widthOnCanvas*f+i,c=this._startSize.heightOnCanvas*f+a):this._resizeType==="t"?(h=t.y+a,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="r"?(d=n.x,l=this._startSize.widthOnCanvas*f+i):this._resizeType==="b"?(c=this._startSize.heightOnCanvas*f+a,h=n.y):this._resizeType==="l"&&(d=t.x+i,l=this._startSize.widthOnCanvas*f-i),l<this.resizeMinLimit.width&&(l=this.resizeMinLimit.width),c<this.resizeMinLimit.width&&(c=this.resizeMinLimit.height),this.dataProvider.updateOptions({editingController:{...r.editingController,x:d,y:h,width:l,height:c}}),this._applyResizeScale(this._resizeDraggingEvent),this._updateEditingControllerView(),this._dataUpdated()}_applyResizeScale(e){const t=this.getOptions(),n=this.dataProvider.getCanvasScale(),i=t.editingController.width/n/this._startSize.widthOnCanvas,a=t.editingController.height/n/this._startSize.heightOnCanvas,r=this._startSizeCanvasXy,l=this.getCanvasXyByViewXy({x:t.editingController.x,y:t.editingController.y});let c=!0,d=!0;this._resizeType==="t"||this._resizeType==="b"?c=!1:(this._resizeType==="r"||this._resizeType==="l")&&(d=!1);for(const h of t.editingController.nodes){const f=this._nodeStartSizeMap.get(h),p=f.width*i,u=f.height*a,g=l.x+i*(f.x-r.x),y=l.y+a*(f.y-r.y),m=p,v=u;this.emitEvent(A.beforeNodeResize,h,g,y,m,v)===!1||(c&&this.dataProvider.updateNode(h.id,{x:g,width:m,el_W:m}),d&&this.dataProvider.updateNode(h.id,{y,height:v,el_H:v}))}}onResizeEnd(e){cancelAnimationFrame(this._resizeDraggingTimer),this._resizeDraggingStoped=!0;const t=this.getViewXyByEvent(e),n=t.x-this._startPoint.x,i=t.y-this._startPoint.y;this._applyResizeScale(e),this.$dom.removeEventListener("mousemove",this._onResizing),this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._onResizing=null,this._onResizeEnd=null,w("onResizeEnd:",this.getOptions().editingController.nodes,n,i),this.emitEvent(A.onResizeEnd,this.getOptions().editingController.nodes,n,i,e)}draggingSelectedNodes(e,t,n,i,a){const r=this.updateReferenceLineView(e,t,n,i,a);if(r){const{showV:c,fixedX:d,showH:h,fixedY:f}=r;c&&(i+=d-t,t=d),h&&(a+=f-n,n=f)}const l=this.getOptions();if(!l.editingController.nodes.includes(e))this.dataProvider.updateNode(e.id,{x:t,y:n}),this._updateEditingLineView();else{for(const c of l.editingController.nodes){const d=this._nodeXYMappingBeforeDrag[c.id];d&&this.dataProvider.updateNode(c.id,{x:d.x+i,y:d.y+a})}this._updateEditingControllerView()}}_updateEditingConnectControllerView(){const e=this.getOptions();if(!e.nodeConnectController.show)return;const t=e.nodeConnectController.node,n=t.x,i=t.y,a=t.x+t.el_W,r=t.y+t.el_H,l=0,c=this.dataProvider.getCanvasScale(),d=n,h=i,f=a-n,p=r-i,u=this.getViewXyByCanvasXy({x:d,y:h});this.dataProvider.updateOptions({nodeConnectController:{...e.nodeConnectController,x:u.x-l*c,y:u.y-l*c,width:f*c+l*2*c,height:p*c+l*2*c}})}setEditingLine(e){this.dataProvider.setEditingLine(e),this._updateEditingLineView(),this._dataUpdated()}updateReferenceLineView(e,t,n,i,a){const r=this.getOptions();if(!r.showReferenceLine)return;if(!r.editingReferenceLine.show){const M=Math.abs(i),L=Math.abs(a);M+L>2&&this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,show:!0}})}if(!r.editingReferenceLine.show)return;const l=t,c=e.el_W,d=e.el_H,h=t+c/2,f=t+c,p=n,u=n+d/2,g=n+d,y=this.getViewXyByCanvasXy({x:h,y:u});let m=!1,v=!1,C=0,N=0;const O=this.getNodes().filter(M=>this._nodeXYMappingBeforeDrag[M.id]?!1:Math.abs(M.x-h)<600&&Math.abs(M.y-u)<600);O.sort((M,L)=>{const D=ge(h,u,M.x+M.el_W/2,M.y+M.el_H/2),X=ge(h,u,L.x+L.el_W/2,L.y+L.el_H/2);return D<X?-1:1});let{v_x:b,v_y:T,v_height:R,h_x:P,h_y:k,h_width:S}=r.editingReferenceLine;for(const M of O){const L=M.x,D=M.el_W,X=M.el_H,G=M.x+D/2,z=M.x+D,E=M.y,F=M.y+X/2,$=M.y+X,te=Math.abs(l-L),Q=Math.abs(h-G),oe=Math.abs(f-z),ie=Math.abs(p-E),ne=Math.abs(u-F),ae=Math.abs(g-$),K=5;if(Q<800&&ne<800){if(!v&&Q<K){const Y=this.getViewXyByCanvasXy({x:G,y:F});b=Y.x,T=y.y>Y.y?Y.y:y.y,R=Math.round(Math.abs(y.y-Y.y)),v=!0,C=G-c/2}if(!v&&te<K){const Y=this.getViewXyByCanvasXy({x:L,y:F});b=Y.x,T=y.y>Y.y?Y.y:y.y,R=Math.round(Math.abs(y.y-Y.y)),v=!0,C=L}if(!v&&oe<K){const Y=this.getViewXyByCanvasXy({x:z,y:F});b=Y.x,T=y.y>Y.y?Y.y:y.y,R=Math.round(Math.abs(y.y-Y.y)),v=!0,C=z-c}if(!m&&ne<K){const Y=this.getViewXyByCanvasXy({x:G,y:F});k=Y.y,P=y.x>Y.x?Y.x:y.x,S=Math.round(Math.abs(y.x-Y.x)),m=!0,N=F-d/2}if(!m&&ie<K){const Y=this.getViewXyByCanvasXy({x:G,y:E});k=Y.y,P=y.x>Y.x?Y.x:y.x,S=Math.round(Math.abs(y.x-Y.x)),m=!0,N=E}if(!m&&ae<K){const Y=this.getViewXyByCanvasXy({x:G,y:$});k=Y.y,P=y.x>Y.x?Y.x:y.x,S=Math.abs(y.x-Y.x),m=!0,N=$-d}if(m&&v)break}}if(this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,v_x:b,v_y:T,v_height:R,h_x:P,h_y:k,h_width:S,directionH:m,directionV:v}}),r.referenceLineAdsorption)return{showV:v,fixedX:C,showH:m,fixedY:N}}hideEditingLineView(){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}})}updateEditingLineView(){this._updateEditingLineView(),this._dataUpdated()}_updateEditingLineView(){this.updateElementLines();const e=this.getOptions();if(!e.editingLineController.show)return;const t=e.editingLineController.line,n=this.getLinkByLine(t);if(!t||t.to==="newRelationTemplate-to"){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}let i,a,r;const l=this.createLineDrawInfo(n,t);if(!l){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}if(t.lineShape===H.StandardOrthogonal){let{textPosition:N,pathData:O,points:b,startDirection:T,endDirection:R}=l;r=N,i=b[0],a=b[b.length-1];const P=[];for(let k=0;k<b.length-1;k++){const S=b[k],M=b[k+1],L={pIndex:k,optionName:"cp-"+k,x:0,y:0,direction:"v",startDirection:T,endDirection:R};S.x!==M.x&&(L.direction="h");const D=this.getViewXyByCanvasXy({x:(S.x+M.x)/2,y:(S.y+M.y)/2});L.x=D.x,L.y=D.y,P.push(L)}if(P.length!==1){if(P.length!==2)if(P.length===3){const k=b[0],S=b[1],M=b[3];if(P[1].direction==="v"){const L=k.x,D=S.x,X=M.x;if(Math.max(L,D,X)!==D&&Math.min(L,D,X)!==D)P[1].optionName="cx";else{const z=Math.abs(D-L),E=Math.abs(D-X);z>=E?P[1].optionName="td":z<E&&(P[1].optionName="fd")}}else{const L=k.y,D=S.y,X=M.y;if(Math.max(L,D,X)!==D&&Math.min(L,D,X)!==D)P[1].optionName="cy";else{const z=Math.abs(D-L),E=Math.abs(D-X);z>=E?P[1].optionName="td":z<E&&(P[1].optionName="fd")}}}else P.length===4?(P[1].optionName="fd",P[2].optionName="td"):P.length===5&&(P[1].optionName="fd",P[2].direction==="v"?P[2].optionName="cx":P[2].optionName="cy",P[3].optionName="td")}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:P,line49Points:b}})}else if(t.lineShape===H.HardOrthogonal){let{textPosition:N,pathData:O,points:b,startDirection:T,endDirection:R}=l;r=N;const P=[];b=t.ctrlPointsFor49,i=b[0],a=b[b.length-1];const k=b;for(let S=0;S<k.length-1;S++){const M=k[S],L=k[S+1],D={pIndex:S,optionName:"cp-"+S,x:0,y:0,direction:"v",startDirection:T,endDirection:R};M.x!==L.x?(D.direction="h",Math.abs(M.x-L.x)<15&&(D.hide=!0)):Math.abs(M.y-L.y)<15&&(D.hide=!0);const X=this.getViewXyByCanvasXy({x:(M.x+L.x)/2,y:(M.y+L.y)/2});D.x=X.x,D.y=X.y,P.push(D)}for(let S=0;S<P.length;S++){const M=P[S-1],L=P[S],D=P[S+1];S===0&&L.direction===D.direction&&(L.hide=!0),S===P.length-1&&L.direction===M.direction&&(L.hide=!0)}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:P,line49Points:k}})}else if(t.lineShape!==1){r=l.textPosition;const N=qe(l.pathData);let O,b;t.isReverse?(i=N.endPoint,a=N.startPoint,O=this.getViewXyByCanvasXy(N.ctrl1),b=this.getViewXyByCanvasXy(N.ctrl2)):(i=N.startPoint,a=N.endPoint,O=this.getViewXyByCanvasXy(N.ctrl1),b=this.getViewXyByCanvasXy(N.ctrl2)),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,ctrlPoint1:O,ctrlPoint2:b}})}else{r=l.textPosition;const N=l.pathData,O=qe(N);i=O.startPoint,a=O.endPoint}const c=this.getViewXyByCanvasXy(t.isReverse?a:i),d=this.getViewXyByCanvasXy(t.isReverse?i:a);this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,startPoint:c,endPoint:d}});const h=this.getViewXyByCanvasXy(r),f=this.$canvasDom.querySelector(`g[data-id='${t.id}']`);let p=0,u=0,g=t.textOffsetX||0,y=t.textOffsetY||0;const m=this.dataProvider.getCanvasScale();let v=20,C=20;if(f){const N=f.querySelector("text.rg-line-text");if(N){g=Math.floor(parseFloat(N.getAttribute("x")||"0")),y=Math.floor(parseFloat(N.getAttribute("y")||"0"));const O=N.clientWidth,b=N.clientHeight;v=O,C=b}}v+=40,C+=10,v>120&&(v=120),C>20&&(C=20),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,text:{...this.getOptions().editingLineController.text,width:v,height:C,x:h.x+p+g*m,y:h.y+u+y*m}}})}startMoveLineVertex(e,t,n){t.stopPropagation();const i=this.getOptions().editingLineController.line,a=this.getLinkByLine(i);let r,l;if(a)r=a.fromNode,l=a.toNode;else{const{from:h,to:f}=this.generateFakeLineConfig(i);r=h,l=f}let c=r;this.dataProvider.setEditingLine(null),a?this.removeLine(i):this.removeFakeLine(i),console.log("DragLine start:",e,i.isReverse);let d=!1;i.lineShape===H.HardOrthogonal&&(i.lineShape=H.StandardOrthogonal),e==="start"?(i.fromJunctionPointOffsetX=0,i.fromJunctionPointOffsetY=0,c=l,d=!0):(i.toJunctionPointOffsetX=0,i.toJunctionPointOffsetY=0),this.startCreatingLinePlot(t,{template:i,fromNode:c,isReverse:d,onCreateLine:n})}startCreateLineFromNode(e,t,n,i){n.stopPropagation();const a=JSON.parse(JSON.stringify(t));if(this._startCreateLineFromNodeTime=Date.now(),!a.from){if(!e){const l=this.getOptions().editingController.nodes;l.length===1&&(e=l[0])}e&&(a.from=e.id,a.fromType=e.targetType)}if(!a.from)throw console.error("Error:lineTemplate:",a),Error("Error:startCreateLineByTemplate: lineTemplate must has [fromType, from]");const r=this.getFakeLineTarget(a.fromType,a.from,a);if(!r)throw console.error("Error:fakeTarget[fromType, from]:",a.fromType,a.from,a),Error(`Error:startCreateLineByTemplate: error from fakeTarget[fromType, from]:${a.fromType}, ${a.from}`);a.lineShape||(a.lineShape=6),this.startCreatingLinePlot(n,{template:a,fromNode:r,isReverse:!1,onCreateLine:i})}onLineVertexBeDropped(e,t,n={x:0,y:0},i){t.stopPropagation();const a=this.getOptions();if(!a.creatingLinePlot||Date.now()-this._startCreateLineFromNodeTime<500)return;console.log("Connect end:isReverse:",a.newLineTemplate.isReverse);const r=a.nodeConnectController.node;let{toJunctionPoint:l,toJunctionPointOffsetX:c,toJunctionPointOffsetY:d,fromJunctionPoint:h,fromJunctionPointOffsetX:f,fromJunctionPointOffsetY:p}=a.newLineTemplate;if(!a.newLinkTemplate.fromNode)a.newLineTemplate.isReverse?(l=e,c=n.x,d=n.y):(h=e,f=n.x,p=n.y),this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:h,fromJunctionPointOffsetX:f,fromJunctionPointOffsetY:p,toJunctionPoint:l,toJunctionPointOffsetX:c,toJunctionPointOffsetY:d},newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:r}});else{a.newLineTemplate.isReverse?(h=e,f=n.x,p=n.y):(l=e,c=n.x,d=n.y);const u=this.getOptions().newLinkTemplate.fromNode;this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:h,fromJunctionPointOffsetX:f,fromJunctionPointOffsetY:p,toJunctionPoint:l,toJunctionPointOffsetX:c,toJunctionPointOffsetY:d},newLinkTemplate:{...this.getOptions().newLinkTemplate,toNodeObject:r}});const g=r;try{const y={newLineTemplate:this.getOptions().newLineTemplate,fromNode:u,toNode:g};this.emitEvent(A.onLineVertexDropped,y),i&&i(y.fromNode,y.toNode,y.newLineTemplate),this.onReadyToCreateLine(this.getOptions().newLinkTemplate.fromNode,this.getOptions().nodeConnectController.node)!==!0&&this.stopCreatingLinePlot()}catch(y){this.stopCreatingLinePlot(),console.warn("[Custom Reject onCreateLine By Throw Error:",y)}}}startMoveLineText(e,t){if(_e(e))return;const n=this.getViewXyByEvent(e),a=this.getOptions().editingLineController.line;console.log("startMoveLineText:",a.id);const r=a.textOffsetX||0,l=a.textOffsetY||0;let c=!1;const d=f=>{const p=this.dataProvider.getCanvasScale(),u=this.getViewXyByEvent(f),g=u.x-n.x,y=u.y-n.y;(g>0||y>0)&&(c=!0),a.textOffsetX=Math.round(r+g/p),a.textOffsetY=Math.round(l+y/p),this._updateEditingLineView(),this._dataUpdated()},h=f=>{this.$dom.removeEventListener("mousemove",d),this.$dom.removeEventListener("mouseup",h),c&&t&&t(),this._dataUpdated()};this.$dom.addEventListener("mousemove",d),this.$dom.addEventListener("mouseup",h)}startMoveLine6CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const r=this.getOptions().editingLineController.line;let l=r.ctrlPoints||[];l.length===0&&(l.push({x:0,y:0}),l.push({x:0,y:0})),this.dataProvider.updateLine(r.id,{ctrlPoints:l}),console.log("startMoveLine6CtrlPoint:line:",r),l=r.ctrlPoints,r.isReverse&&(e=l.length-1-e);const c=this.dataProvider.getCanvasScale(),d=l[e],{x:h,y:f}=d,p=()=>{n(r),this._dataUpdated()};Z.startDrag(t,{x:0,y:0},p,(u,g)=>{d.x=h+u/c,d.y=f+g/c,this.dataProvider.updateLine(r.id,{ctrlPoints:l}),this._updateEditingLineView(),this._dataUpdated()})}startMoveLine44CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const a=this.getOptions().editingLineController,r=a.line;console.log("startMoveLine44CtrlPoint:",r==null?void 0:r.lineShape,e.optionName);let l=r.ctrlOptionsFor44;l||(l={cx:0,cy:0,fd:0,td:0},this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l}),l=r.ctrlOptionsFor44);const c=l[e.optionName],d={indexOffset:0};let h=r.ctrlPointsFor49?JSON.parse(JSON.stringify(r.ctrlPointsFor49)):null;const f=(u,g)=>{console.log("lineSplitCtrlMoving:",r==null?void 0:r.lineShape,e.optionName);const y=this.dataProvider.getCanvasScale();if(r.lineShape===H.StandardOrthogonal){if(e.optionName==="cx"){const v=c+u/y*1;l.cx=v,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="cy"){const v=c+g/y*1;l.cy=v,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="fd"){const m=Me[e.startDirection],v=e.direction==="v"?u*m.x:g*m.y;l.fd=c+v/y,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="td"){const m=Me[e.endDirection],v=e.direction==="v"?u*m.x:g*m.y;l.td=c+v/y,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.direction==="v"&&Math.abs(u)>5||e.direction==="h"&&Math.abs(g)>5){const m=a.line49Points;h=JSON.parse(JSON.stringify(m)),console.log(":startCtrlPointsFor49:::",h),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:h}),this.dataProvider.updateLine(r.id,{lineShape:H.HardOrthogonal})}}else if(r.lineShape===H.HardOrthogonal){const{newPoints:m,pointsChanged:v}=Ln(r.ctrlPointsFor49,h,e.pIndex+d.indexOffset,e,d,u/y,g/y);v&&(h=JSON.parse(JSON.stringify(m))),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:m})}},p=()=>{if(r.lineShape===H.HardOrthogonal){const u=ke(r.ctrlPointsFor49);this.dataProvider.updateLine(r.id,{ctrlPointsFor49:u})}this._updateEditingLineView(),n&&n(r),this._dataUpdated()};Z.startDrag(t,{x:0,y:0},p,(u,g)=>{f(u,g),this._updateEditingLineView(),this._dataUpdated()})}onLineVertexBeDroppedOnConnectController(e,t,n,i){if(w("onLineVertexBeDroppedOnConnectController",e,t,n),t.stopPropagation(),!n){this.onLineVertexBeDropped(e,t,void 0,i);return}const a=Ce(t),r=n.getBoundingClientRect(),l={x:r.left,y:r.top+r.height/2},c={x:r.left+r.width/2,y:r.top},d={x:r.left+r.width,y:r.top+r.height/2},h={x:r.left+r.width/2,y:r.top+r.height};let f=de.left;const p={x:0,y:0};if(e)f=e,f===de.top||f===de.bottom?p.x=a.clientX-h.x:f===de.right?p.y=a.clientY-d.y:p.y=a.clientY-l.y;else{const g=ge(a.clientX,a.clientY,l.x,l.y),y=ge(a.clientX,a.clientY,c.x,c.y),m=ge(a.clientX,a.clientY,d.x,d.y),v=ge(a.clientX,a.clientY,h.x,h.y),C=Math.min(g,y,m,v);C===g?(f=de.left,p.x=a.clientX-l.x,p.y=a.clientY-l.y):C===y?(f=de.top,p.x=a.clientX-c.x,p.y=a.clientY-c.y):C===m?(f=de.right,p.x=a.clientX-d.x,p.y=a.clientY-d.y):C===v&&(f=de.bottom,p.x=a.clientX-h.x,p.y=a.clientY-h.y)}const u=this.dataProvider.getCanvasScale();p.x=p.x/u,p.y=p.y/u,w("onMouseUpWithOffset:",e,p),this.onLineVertexBeDropped(f,t,p,i)}}class ai extends si{constructor(){super();_(this,"$miniViewCanvas");_(this,"$mvCanvasCtx");_(this,"_canvasDomScale",1);_(this,"miniViewBox",{visibleAreaStart:{x:0,y:0},visibleAreaEnd:{x:0,y:0},canvas_start_x:0,canvas_start_y:0,canvas_end_x:0,canvas_end_y:0,canvas_width:0,canvas_height:0,miniview_width:0,miniview_height:0});_(this,"visibleArea",{x:0,y:0});_(this,"_canvasItemMiniSizeLimit",1)}setMiniViewCanvas(e){this.$miniViewCanvas=e,this.$mvCanvasCtx=this.$miniViewCanvas.getContext("2d")}updateMiniView(){!this.getOptions().showMiniView||(this.updateMiniViewVisibleArea(),this._updateMiniView())}_updateMiniView(){try{const e=Date.now();this.mvDosomethingBeforeDraw(),this.mvDrawAllNodes()}catch(e){console.error(e)}}mvDosomethingBeforeDraw(){let e=9999999,t=9999999,n=-9999999,i=-9999999,a=0;for(const v of this.getNodes())if(v.rgCalcedVisibility&&v.opacity!==0){v.x<e&&(e=v.x),v.y<t&&(t=v.y);const C=v.x+v.el_W,N=v.y+v.el_H;C>n&&(n=C),N>i&&(i=N),a++}const r=1,l=50,c=50;a===0?(this.miniViewBox.canvas_start_x=-100-l,this.miniViewBox.canvas_start_y=-100-c,this.miniViewBox.canvas_end_x=100+l,this.miniViewBox.canvas_end_y=100+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y):(this.miniViewBox.canvas_start_x=e-l,this.miniViewBox.canvas_start_y=t-c,this.miniViewBox.canvas_end_x=n+l,this.miniViewBox.canvas_end_y=i+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y);const d=this.$miniViewCanvas.parentElement.getBoundingClientRect(),h=d.width,f=d.height;let p=0,u=0,g=1;h/this.miniViewBox.canvas_width<f/this.miniViewBox.canvas_height?(g=h/this.miniViewBox.canvas_width*r,p=h,u=h/this.miniViewBox.canvas_width*this.miniViewBox.canvas_height):(g=f/this.miniViewBox.canvas_height*r,p=f/this.miniViewBox.canvas_height*this.miniViewBox.canvas_width,u=f),this.miniViewBox.miniview_width=h,this.miniViewBox.miniview_height=f,this.$miniViewCanvas.width=h,this.$miniViewCanvas.height=f,this.$mvCanvasCtx.canvas.width=h*window.devicePixelRatio,this.$mvCanvasCtx.canvas.height=f*window.devicePixelRatio,this.$mvCanvasCtx.canvas.style.width=`${h}px`,this.$mvCanvasCtx.canvas.style.height=`${f}px`;const y=(f-u)/2,m=(h-p)/2;this.miniViewBox.canvas_start_x-=m/g,this.miniViewBox.canvas_start_y-=y/g,this.$mvCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$mvCanvasCtx.scale(g,g),this._canvasDomScale=g,this.$mvCanvasCtx.clearRect(0,0,this.$mvCanvasCtx.canvas.width,this.$mvCanvasCtx.canvas.height)}updateMiniViewVisibleArea(){const e=this.getCanvasXyByViewXy({x:0,y:0}),t=this.getOptions().viewSize,n=this.getCanvasXyByViewXy({x:t.width,y:t.height}),i=this._canvasDomScale,a=n.x-e.x,r=n.y-e.y;this.miniViewBox.visibleAreaStart=e,this.miniViewBox.visibleAreaEnd=n;const l=i*a,c=i*r,d=e.x-this.miniViewBox.canvas_start_x,h=e.y-this.miniViewBox.canvas_start_y,f=i*d,p=i*h;let u=!1;(f+l<0||p+c<0||p>this.miniViewBox.miniview_height||f>this.miniViewBox.miniview_width)&&(u=!0),this.dataProvider.updateOptions({miniViewVisibleHandle:{...this.getOptions().miniViewVisibleHandle,emptyContent:u,width:l,height:c,x:f,y:p}})}mvDrawAllNodes(){const e=this._canvasDomScale,t=this.getOptions().defaultNodeShape;for(const n of this.getNodes())if(n.rgCalcedVisibility&&n.opacity!==0){let i=n.el_W,a=n.el_H;e*i<this._canvasItemMiniSizeLimit&&(i=this._canvasItemMiniSizeLimit/this._canvasDomScale),e*a<this._canvasItemMiniSizeLimit&&(a=this._canvasItemMiniSizeLimit/this._canvasDomScale);const r=Ne(n.nodeShape,t);this.mvDrawNode(n,r,i,a)}}mvDrawNode(e,t,n,i){t===be.circle?this.mvDrawNode4Circle(e,n,i):this.mvDrawNode4Rect(e,n,i)}mvDrawNode4Rect(e,t,n){const i=this.$mvCanvasCtx,a=e.x-this.miniViewBox.canvas_start_x,r=e.y-this.miniViewBox.canvas_start_y;i.beginPath(),i.globalAlpha=e.opacity||1,i.rect(a,r,t,n),i.fillStyle=this.getNodeColor(e),i.fill(),i.strokeStyle="#666666",i.lineWidth=2,i.stroke(),i.globalAlpha=1}mvDrawNode4Circle(e,t,n){const i=this.$mvCanvasCtx,a=e.x+t/2-this.miniViewBox.canvas_start_x,r=e.y+n/2-this.miniViewBox.canvas_start_y;i.beginPath(),i.globalAlpha=e.opacity||1,i.ellipse(a,r,t/2,n/2,0,0,2*Math.PI),i.fillStyle=this.getNodeColor(e),i.fill(),i.strokeStyle="#666666",i.lineWidth=2,i.stroke(),i.globalAlpha=1}mvDrawAllLines(){for(const e of this.getLinks())e.fromNode.rgCalcedVisibility&&e.toNode.rgCalcedVisibility&&this.mvDrawLine(e,e.line)}mvDrawLine(e,t){const n=this.$mvCanvasCtx,i=this.createLineDrawInfo(e,t);n.beginPath(),n.globalAlpha=t.opacity||1,this.mvDrawSvgPathOnCanvas(n,i.pathData);const a=this.getOptions();n.strokeStyle=t.color||a.defaultLineColor||"#888888",n.lineWidth=t.lineWidth||a.defaultLineWidth||1,n.stroke(),n.globalAlpha=1}mvDrawSvgPathOnCanvas(e,t){const n=t.match(/[a-zA-Z][^a-zA-Z]*/g);let i=0,a=0,r=0,l=0,c=0,d=0,h=0,f=0,p=!1;n.forEach(u=>{const g=u.trim().split(/[ ,]+/),y=g[0].toUpperCase(),m=g[0]===g[0].toLowerCase();switch(y){case"M":i=j(r,g[1],m)-this.miniViewBox.canvas_start_x,a=j(l,g[2],m)-this.miniViewBox.canvas_start_y,r=i,l=a,p&&(e.closePath(),p=!1),e.moveTo(i,a);break;case"L":i=j(r,g[1],m)-this.miniViewBox.canvas_start_x,a=j(l,g[2],m)-this.miniViewBox.canvas_start_y,e.lineTo(i,a);break;case"C":c=j(r,g[1],m),d=j(l,g[2],m),h=j(r,g[3],m),f=j(l,g[4],m),i=j(r,g[5],m),a=j(l,g[6],m),r=i,l=a,e.bezierCurveTo(c,d,h,f,i,a);break;case"Q":c=j(r,g[1],m),d=j(l,g[2],m),i=j(r,g[3],m),a=j(l,g[4],m),r=i,l=a;break;case"V":a=j(l,g[1],m),l=a,e.lineTo(i,a);break;case"H":i=j(r,g[1],m),r=i,e.lineTo(i,a);break;case"Z":e.closePath(),p=!1;break;default:w(`Unsupported command: ${y}`)}})}onVisibleViewHandleDragStart(e){e.preventDefault(),e.stopPropagation(),console.log("onVisibleViewHandleDragStart:");const t=this.getOptions(),n=t.canvasOffset.x,i=t.canvasOffset.y,a=this.miniViewBox.canvas_width,r=this.miniViewBox.canvas_height,l=()=>{const u=f/this.miniViewBox.miniview_width,g=p/this.miniViewBox.miniview_height,y=this.dataProvider.getCanvasScale(),m=a*u*y,v=r*g*y;console.log("setCanvasOffset:buff:",f,p),this.dataProvider.setCanvasOffset(n-m,i-v),this._updateEditingControllerView(),this.updateMiniViewVisibleArea(),this.updateShouldRenderGraphData(),this.dataProvider.dataUpdated()};let c;const d=(u,g,y)=>{c&&clearInterval(c),this.onCanvasDragEnd(y)};let h=!1,f=0,p=0;Z.startDrag(e,{x:0,y:0},d,(u,g)=>{f=u,p=g,console.log("onVisibleViewHandleDragStart:move:",u,g),!h&&Math.abs(u)+Math.abs(g)>3&&(console.log("onVisibleViewHandleDragStart:start"),h=!0,c=setInterval(()=>{l()},50))})}resetByVisiableView(e){!this.getOptions().miniViewVisibleHandle.emptyContent||(this.setZoom(100),this._moveToCenter(),this.zoomToFit())}}class ri extends ai{constructor(){super();_(this,"$watermarkDom",null);_(this,"$watermarkPosition","br");_(this,"$backgroundDom",null);_(this,"_originBackgroundColor","");_(this,"graphStatusBeforeImageGeneration",{orignCanvasOffsetX:0,orignCanvasOffsetY:0,orignZoom:0,forceLayouting:!1})}setWatermarkDom(e,t=!0,n=!1,i="br"){t&&(this.$watermarkDom=e),this.$watermarkPosition=i}setBackgroundDom(e,t=!0,n=!0){e===null?(this._originBackgroundColor=this.options.backgroundColor,this.dataProvider.updateOptions({backgroundColor:"transparent"}),t?this.$backgroundDom=e:this.$backgroundDom=null):(this.dataProvider.updateOptions({backgroundColor:this._originBackgroundColor}),this.$backgroundDom=null)}async prepareForImageGeneration(){return this.updateShouldRenderGraphData(),this.updateElementLines(),await this.moveItemsAndFitContent(),this._dataUpdated(),this.$canvasDom.parentElement}async restoreAfterImageGeneration(){const{orignCanvasOffsetX:e,orignCanvasOffsetY:t,orignZoom:n,forceLayouting:i}=this.graphStatusBeforeImageGeneration;this.$canvasDom.parentElement.style.width="100%",this.$canvasDom.parentElement.style.height="100%",this.setZoom(n),this.dataProvider.updateOptions({canvasOffset:{x:e,y:t}}),this._dataUpdated(),i&&this.startAutoLayout(),this.clearLoading()}async moveItemsAndFitContent(){const e=this.getOptions(),t=e.canvasZoom,n=e.canvasOffset.x,i=e.canvasOffset.y,a=e.layout.autoLayouting===!0;a&&(this.stopAutoLayout(),await this.sleep(200)),this.loading("Generating..."),this.dataProvider.updateOptions({snapshotting:!0}),this.dataProvider.clearChecked(),this.setZoom(100),this.updateShouldRenderGraphData(!0),this._dataUpdated(),await this.sleep(200);const r=this.getNodesRectBox(),l=this.getCanvasSlotRectItems(),c=this.getNodesRectBox(l),d=100,h=Math.min(r.minX,c.minX)-d,f=Math.min(r.minY,c.minY)-d,p=Math.max(r.maxX,c.maxX)+d,u=Math.max(r.maxY,c.maxY)+d,g=h,y=f,m=p-h,v=u-f;this.graphStatusBeforeImageGeneration={orignCanvasOffsetX:n,orignCanvasOffsetY:i,orignZoom:t,forceLayouting:a},this.dataProvider.updateOptions({canvasOffset:{x:-g,y:-y}}),this._dataUpdated(),this.setZoom(100),this.$canvasDom.parentElement.style.width=m+"px",this.$canvasDom.parentElement.style.height=v+"px",w("export image:",{imageWidth:m,imageHeight:v,minX:h,minY:f,maxX:p,maxY:u,devicePixelRatio:window.devicePixelRatio}),await this.sleep(200)}}class li extends ri{constructor(){super();_(this,"resizeObserver");_(this,"resizeListenerMap",new WeakMap);_(this,"domToNodeIdMap",new WeakMap);_(this,"mutationObserver4Nodes");_(this,"mutationObserver4CanvasSlotBehind");_(this,"mutationObserver4CanvasSlotAbove");_(this,"_updateCanvasConnectTargetsTask");_(this,"onKeyDownHanlder");_(this,"onKeyUpHanlder")}setDom(e){w("relation-graph mounted on:",this.instanceId,e),this.$dom=e}setCanvasDom(e){w("relation-graph canvas dom mounted!"),this.$canvasDom=e,this.$lineTextContainer4NormalLine=null,this.$lineTextContainer4FakeLine=null,this.reinitMutationObservers(),this.getLineTextContainer({isFakeLine:!0}),this.getLineTextContainer({isFakeLine:!1})}getResizeObserver(){return this.resizeObserver||(this.resizeObserver=new ResizeObserver((e,t)=>{for(const n of e){const i=this.resizeListenerMap.get(n.target);i?n.borderBoxSize?i(n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):i(n.target.clientWidth,n.target.clientHeight):n.borderBoxSize?this._onNodeDomResize(n.target,n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):this._onNodeDomResize(n.target,n.target.clientWidth,n.target.clientHeight)}})),this.resizeObserver}initDom(){this.addResizeListener(this.$dom,(e,t)=>{w("resizeListener:this.$dom"),this.resetViewSize(),this.updateEasyView(),this._rgAsConnectArea&&this.updateCanvasConnectTargetsPosition("View Resize"),this._updateEditingLineView(),this._updateEditingControllerView(),this._dataUpdated(),setTimeout(()=>{w("resizeListener:updateShouldRenderGraphData"),this.emitEvent(A.onViewResize,{width:e,height:t}),this._dataUpdated()},500)}),this._rgAsConnectArea||(this.removeKeyboardListener(),this.addKeyboardListener())}updateCanvasConnectTargetsPosition(e="api"){this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-above"))}reinitMutationObservers(){this.destroyMutationObserver();const e=this.$canvasDom.querySelector(".rg-nodes-container-wrapper");if(e)this.mutationObserver4Nodes=new MutationObserver(i=>{if(this.dataProvider.getConnectTargets().length>0)for(const a of i){const r=this.getNodeElByChildrenTarget(a.target),l=this.domToNodeIdMap.get(r);l&&this.updateConnectTargetsOnNode("Mutation",l,r)}}),this.mutationObserver4Nodes.observe(e,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-nodes-container-wrapper");const t=this.$canvasDom.parentElement.querySelector(".rg-canvas-slot-behind");if(t)this.mutationObserver4CanvasSlotBehind=new MutationObserver(i=>{console.warn("MutationObserver:updateConnectTargetsOnCanvas:mutations:",i),this.updateConnectTargetsOnCanvas("CanvasBehind-Mutation",t)}),this.mutationObserver4CanvasSlotBehind.observe(t,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-canvas-slot-behind");const n=this.$canvasDom.parentElement.querySelector(".rg-canvas-slot-above");n&&(this.mutationObserver4CanvasSlotAbove=new MutationObserver(i=>{this.updateConnectTargetsOnCanvas("CanvasAbove-Mutation",n)}),this.mutationObserver4CanvasSlotAbove.observe(n,{childList:!0,subtree:!0,characterData:!0}))}destroyMutationObserver(){this.mutationObserver4Nodes&&(this.mutationObserver4Nodes.disconnect(),this.mutationObserver4Nodes=void 0),this.mutationObserver4CanvasSlotBehind&&(this.mutationObserver4CanvasSlotBehind.disconnect(),this.mutationObserver4CanvasSlotBehind=void 0),this.mutationObserver4CanvasSlotAbove&&(this.mutationObserver4CanvasSlotAbove.disconnect(),this.mutationObserver4CanvasSlotAbove=void 0)}addKeyboardListener(){this.onKeyDownHanlder=e=>{_e(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!1&&this.setCanvasMoveMode(!0)),this.emitEvent(A.onKeyboardDown,e))},this.onKeyUpHanlder=e=>{_e(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!0&&this.setCanvasMoveMode(!1)),this.emitEvent(A.onKeyboardUp,e))},this.$dom.addEventListener("keydown",this.onKeyDownHanlder),this.$dom.addEventListener("keyup",this.onKeyUpHanlder)}removeKeyboardListener(){this.onKeyDownHanlder&&this.$dom.removeEventListener("keydown",this.onKeyDownHanlder),this.onKeyUpHanlder&&this.$dom.removeEventListener("keyup",this.onKeyUpHanlder)}addResizeListener(e,t){this.resizeListenerMap.set(e,t),this.getResizeObserver().observe(e)}_onNodeDomResize(e,t,n){if(t===0||n===0)return;const i=this.domToNodeIdMap.get(e);this._onNodeResize(e,i,t,n)}_onNodeResize(e,t,n,i){n===0||i===0||(this.updateConnectTargetsOnNode("Node-Created",t,e),this.updateNodeOffsetSize(t,n,i))}addNodeResizeListener(e,t){this.domToNodeIdMap.set(e,t.id),this._onNodeResize(e,t.id,e.offsetWidth,e.offsetHeight),this.getResizeObserver().observe(e)}removeNodeResizeListener(e){this.domToNodeIdMap.delete(e),e?this.getResizeObserver().unobserve(e):w("removeNodeResizeListener: dom is null or undefined!")}removeResizeListener(e){this.resizeListenerMap.delete(e),this.resizeObserver&&this.resizeObserver.unobserve(e)}destroyResizeObserver(){this.resizeObserver&&this.resizeObserver.disconnect()}getCanvasSlotList(){return this.$dom.querySelectorAll(".rg-map > .rg-map-canvas > .rg-canvas-slot")}getCanvasSlotRectItems(){if(!this.$dom)return[];const e=this.getCanvasSlotList(),t=[];for(const n of e)for(const i of n.children){const a=i,r={x:a.offsetLeft||0,y:a.offsetTop||0,nodeShape:1,el_W:a.scrollWidth,el_H:a.scrollHeight};t.push(r)}return t}}class di extends li{constructor(){super()}dataUpdated(){this._requestDataUpdate()}setOptions(o){w("setOptions:",o),this._updateOptions(o),this._dataUpdated()}updateOptions(o){w("updateOptions:",o),this._updateOptions(o),this._dataUpdated()}moveToCenter(o){this._moveToCenter(o),this._dataUpdated()}transToLinker(o=!0){this._rgAsConnectArea=o,this.resetViewSize(),this.updateCanvasConnectTargetsPosition("Linker"),this.removeKeyboardListener(),this._rgAsConnectArea||this.addKeyboardListener(),this._dataUpdated()}setRootNodeId(o){w("setRootNodeId:",o),this.dataProvider.setRootNodeId(o)}getRootNode(){return this.dataProvider.getRootNode()}getCheckedNode(){return this.getNodeById(this.getOptions().checkedNodeId)}getCheckedLine(){const o=this.getLineById(this.getOptions().checkedLineId);return o||this.getFakeLineById(this.getOptions().checkedLineId)}getSelectedNodes(){return this.getNodes().filter(o=>o.selected)}getEditingNodes(){return[...this.getOptions().editingController.nodes]}async setJsonData(o){this._setJsonData(o),await this.doLayout(o.rootId)}async appendJsonData(o,e=!0){w("appendData:",o),this.loadGraphJsonData(o),e&&await this.doLayout()}async applyInitialData(o){w("applyInitialData:",o),await this.setJsonData(o),this.moveToCenter(),this.zoomToFit()}getGraphJsonData(){var i;const o=[],e=[],t=[];this.getNodes().forEach(a=>{const r=Pe(a);r&&o.push(r)}),this.getLines().forEach(a=>{const r=Le(a);r&&e.push(r)}),this.getFakeLines().forEach(a=>{const r=Le(a);r&&t.push(r)});const n={rootId:((i=this.dataProvider.getRootNode())==null?void 0:i.id)||"",nodes:o,lines:e};return t.length>0&&(n.fakeLines=t),n}transRGNodeToJsonObject(o){return Pe(o)}transRGLinkToJsonObject(o){return Fe(o)}transRGLineToJsonObject(o){return Le(o)}getGraphJsonOptions(){const o={},e=["layouter","layoutor","autoLayouting","canvasNVInfo","canvasOffset","canvasZoom","fullscreen","instanceId","layoutClassName","layoutDirection","layoutLabel","layoutName","resetViewSize","viewELSize","viewNVInfo","viewSize","canvasSize","newLinkTemplate","newLineTemplate","newNodeTemplate"],t=this.getOptions();return Object.keys(t).forEach(n=>{e.includes(n)||(o[n]=t[n])}),o}clearGraph(){this._clearGraph(),this._dataUpdated()}printOptions(){const o=this.getGraphJsonOptions();console.log("options:",o),console.log("options-json-string:"),console.log(JSON.stringify(o))}printData(){const o=this.getGraphJsonData();console.log("data:",o),console.log("data-json-string:"),console.log(JSON.stringify(o))}printGraphJsonData(){this.printOptions(),this.printData()}}class St extends di{constructor(){super();_(this,"viewComponentUnmounted",!1)}setListeners(e){this.listeners=e}ready(){this.initDom(),this.resetViewSize(),this.addFullscreenListener(),this.emitEvent(A.onReady,this),this.viewComponentUnmounted=!1}beforeUnmount(){this.viewComponentUnmounted=!0,this.removeFullscreenListener(),this.removeKeyboardListener(),this.destroyMutationObserver(),this.destroyResizeObserver()}}const ci=ye.Provider,hi=ot.Provider,ui=Ee.Provider,fi=re.Provider;function Pt(s,o=!1){const e=s?Reflect.construct(s,[]):new St;return e._rgAsConnectArea=o,console.log("[RGProvider]Creating new graphInstance",e.instanceId,o),e}function je(s,o=!1){const e=I.useContext(ye);return e||(console.log("[RGProvider]No parent RGProvider found, creating new graphInstance"),Pt(s,o))}const Mt=({graphInstance:s,children:o})=>{const[e,t]=I.useState(0),{data:n,dataStores:i}=gi(),a=I.useRef(0),r=I.useCallback(l=>{a.current++,t(a.current)},[]);return a.current===0&&s.setReactiveData4React(i,r),x.jsx(ci,{value:s,children:x.jsx(hi,{value:r,children:x.jsx(ui,{value:e,children:x.jsx(fi,{value:n,children:o})})})})},We=({graphInstance:s,children:o})=>I.useContext(ye)?x.jsx(x.Fragment,{children:o}):x.jsx(Mt,{graphInstance:s,children:o}),gi=()=>{const[s,o]=I.useState(Te({})),[e,t]=I.useState([]),[n,i]=I.useState([]),[a,r]=I.useState([]);return{data:{options:s,shouldRenderNodes:e,shouldRenderLines:n,shouldRenderFakeLines:a},dataStores:{store4Options:{set:u=>{o({...u})}},store4ShouldRenderNodes:{set:u=>{t(u)}},store4ShouldRenderLines:{set:u=>{i(u)}},store4ShouldRenderFakeLines:{set:u=>{r(u)}}}}},xe=s=>s,pi=`graphRef.value.getInstance() will be deprecated
|
|
43
43
|
|
|
44
44
|
It is recommended to use the graphInstance:
|
|
45
45
|
###### Method 1: ######
|
|
@@ -79,7 +79,7 @@ And method graphRef.value.getInstance() will be deprecated in future versions.
|
|
|
79
79
|
More details: https://www.relation-graph.com/docs/better-integration#vue3
|
|
80
80
|
|
|
81
81
|
Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
|
|
82
|
-
`,
|
|
82
|
+
`,yi=`graphRef.value.getInstance() will be deprecated
|
|
83
83
|
|
|
84
84
|
It is recommended to use the graphInstance:
|
|
85
85
|
###### Method 1: ######
|
|
@@ -152,7 +152,7 @@ And method graphRef.value.getInstance() will be deprecated in future versions.
|
|
|
152
152
|
More details: https://www.relation-graph.com/docs/better-integration#vue3
|
|
153
153
|
|
|
154
154
|
Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
|
|
155
|
-
`,
|
|
155
|
+
`,mi=`graphRef.current.getInstance() will be deprecated
|
|
156
156
|
|
|
157
157
|
It is recommended to use the graphInstance:
|
|
158
158
|
###### Method 1: ######
|
|
@@ -226,7 +226,7 @@ And method graphRef.value.getInstance() will be deprecated in future versions.
|
|
|
226
226
|
More details: https://www.relation-graph.com/docs/better-integration#vue3
|
|
227
227
|
|
|
228
228
|
Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
|
|
229
|
-
`,
|
|
229
|
+
`,vi=`Please Initialize the graph using the new method:
|
|
230
230
|
|
|
231
231
|
###### Method 1: ######
|
|
232
232
|
// Use graphInstance to set the data.
|
|
@@ -253,7 +253,7 @@ Initialize using the onReady event of the RelationGraph component. then use grap
|
|
|
253
253
|
|
|
254
254
|
###### More Method: ######
|
|
255
255
|
https://www.relation-graph.com/docs.'
|
|
256
|
-
`,
|
|
256
|
+
`,xi=`Please Initialize the graph using the new method:
|
|
257
257
|
|
|
258
258
|
###### Method 1: ######
|
|
259
259
|
// Use graphInstance to set the data.
|
|
@@ -281,4 +281,4 @@ Initialize using the onReady event of the RelationGraph component. then use grap
|
|
|
281
281
|
|
|
282
282
|
###### More Method: ######
|
|
283
283
|
https://www.relation-graph.com/docs.'
|
|
284
|
-
`,et={Vue3GetInstance:xe(fi),ReactGetInstance:xe(gi),Vue2GetInstance:xe(ui),setJsonData:xe(pi),setJsonData4Vue2:xe(yi)},mi=(s,o)=>{const e=$e(s.relationGraphCore);return I.useImperativeHandle(o,()=>({getInstance(){var t;return(t=s.options)!=null&&t.definitelyNoDataProviderNeeded||console.warn("[relation-graph]",et.ReactGetInstance),e},async setJsonData(){throw new Error(et.setJsonData)}}),[]),I.useEffect(()=>{e.updateOptions(s.options)},[s.options]),I.useEffect(()=>{e.setListeners(Ge(s))},[s]),x.jsx(Ue,{graphInstance:e,children:x.jsx(xt,{...s})})},Mt=pe.default.forwardRef(mi);function vi(s={}){const o=$e(s.relationGraphCore);return{RelationGraph:I.useMemo(()=>{console.log("Creating a MemoizedRelationGraph...");const t=n=>x.jsx(Ue,{graphInstance:o,children:x.jsx(xt,{...n,children:n.children})});return t.displayName="RelationGraph",t},[]),graphInstance:o}}const kt={useRelationGraph:vi,useGraphInstance:W,useAutoUpdateView:se,useCreatingLine:Zt,useCreatingNode:Qt,useEditingNodes:Kt,useEditingLine:en,useViewInformation:nn,useSelection:on,useConnectingNode:tn,useCheckedItem:sn,useGraphStore:J},xi=({children:s})=>{const o=W();se();const{options:e}=J(),[t,n]=I.useState(!1),i=()=>{n(!t)},a=()=>{o.printOptions()},r=()=>{o.getGraphJsonData()},l=()=>{o.enableDebugLog(!e.debug),L("debugLog:",e.debug),updateView()};return x.jsxs("div",{children:[x.jsx("div",{className:"rg-setting-panel-button",onClick:()=>{i()},children:"Debug"}),t&&x.jsxs("div",{className:"rg-setting-panel",children:[x.jsx("div",{className:"c-debug-tools-row",children:x.jsx("button",{onClick:()=>{a()},children:"print options in console"})}),x.jsx("div",{className:"c-debug-tools-row",children:x.jsx("button",{onClick:()=>{r()},children:"print json data in console"})}),x.jsxs("div",{className:"c-debug-tools-row",children:["debug log status: ",e.debug?"true":"false",x.jsxs("button",{onClick:()=>{l()},children:[e.debug?"disable":"enable"," debug log"]})]}),s]})]})},Ci=({children:s,direction:o,positionH:e,positionV:t})=>{const n=W(),{options:i}=J(),a=async()=>{await n.refresh(),n.dataUpdated()},r=()=>{n.toggleAutoLayout()},l=async()=>{await n.fullscreen(),n.dataUpdated()},c=async()=>{n.setZoom(100),n.moveToCenter(),n.enableCanvasAnimation(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300)},d=h=>{n.zoom(h),n.dataUpdated()};return x.jsxs("div",{className:["rg-toolbar","rg-toolbar-h-"+(e||i.toolBarPositionH),"rg-toolbar-v-"+(t||i.toolBarPositionV),"rg-toolbar-"+(o||i.toolBarDirection)].join(" "),children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>{l()},children:x.jsx(ee,{iconName:"icon-quanping"})}),x.jsxs(pe.default.Fragment,{children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>{d(20)},children:x.jsx(ee,{iconName:"icon-fangda"})}),x.jsxs("div",{className:"rg-current-zoom",onClick:()=>{c()},children:[Math.round(i.canvasZoom),"%"]}),x.jsx("div",{className:"rg-mb-button",onClick:()=>{d(-20)},children:x.jsx(ee,{iconName:"icon-suoxiao"})})]}),i.layout.supportAutoLayout&&x.jsx("div",{title:i.layout.autoLayouting?"Stop force":"Start force",className:["rg-mb-button",i.layout.autoLayouting&&"rg-mb-button-on"].join(" "),onClick:()=>{r()},children:i.layout.autoLayouting?x.jsx(ee,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):x.jsx(ee,{iconName:"icon-zidong"})}),x.jsx("div",{className:"rg-mb-button",onClick:()=>{a()},children:x.jsx(ee,{iconName:"icon-ico_reset"})}),s,x.jsx("div",{style:{clear:"both"}})]})},Li=({node:s,children:o})=>{const e=I.useRef(null),t=W();se();const{options:n}=J(),i=s.borderWidth===void 0?void 0:`${s.borderWidth}px`,a=s.width?s.width+"px":void 0,r=s.height?s.height+"px":void 0;I.useEffect(()=>(t.addNodeResizeListener(e.current,s),()=>{e.current&&t.removeNodeResizeListener(e.current)}),[]);const l=h=>{"button"in h&&h.button!==0||(h.stopPropagation(),t.onNodeDragStart(s,h.nativeEvent))},c=["rg-node-peel",s.selected&&"rg-node-selected",s.id===n.draggingNodeId&&"rg-node-dragging",s.id===n.checkedNodeId&&"rg-node-checked",`rg-node-shape-${s.nodeShape===void 0?1:s.nodeShape}`,`rg-node-type-${s.type}`,s.className].filter(Boolean).join(" "),d={transform:`translate(${s.x}px, ${s.y}px)`,"--rg-node-z-index":s.zIndex,"--rg-node-opacity":s.opacity,pointerEvents:s.opacity===0?"none":void 0,"--rg-node-color":s.color||n.defaultNodeColor,"--rg-node-font-color":s.fontColor,"--rg-node-font-size":s.fontSize?`${s.fontSize}px`:void 0,"--rg-node-border-width":i,"--rg-node-width":a,"--rg-node-height":r,"--rg-node-border-radius":s.borderRadius?`${s.borderRadius}px`:void 0,"--rg-node-border-color":s.borderColor};return x.jsx("div",{ref:e,style:d,className:c,"data-id":s.id,children:x.jsx("div",{className:"rg-node",onMouseDown:l,onTouchStart:l,children:o||x.jsx("div",{className:"rg-node-text",children:x.jsx("span",{children:s.text})})})})},wi=({children:s})=>x.jsx(x.Fragment,{}),_i=({children:s})=>{const{options:o}=J();if(!o.editingController.show)return null;const e={width:o.editingController.width+"px",height:o.editingController.height+"px",transform:`translate(${o.editingController.x}px, ${o.editingController.y}px)`};return x.jsx("div",{className:"rg-editing-ctrl",style:e,children:s})},Ni=({disableResizeWidth:s,disableResizeHeight:o,beforeResizeStart:e})=>{const t=W(),{options:n}=J(),i=(a,r)=>{r.stopPropagation(),e&&e(),t.onResizeStart(a,r.nativeEvent)};return x.jsxs("div",{className:"rg-resize-ctl",children:[n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tl",onMouseDown:a=>i("tl",a)}),n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tr",onMouseDown:a=>i("tr",a)}),n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-bl",onMouseDown:a=>i("bl",a)}),!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-br",onMouseDown:a=>i("br",a)}),(n.editingController.width>60||s)&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-t",onMouseDown:a=>i("t",a)}),(n.editingController.width>60||s)&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-b",onMouseDown:a=>i("b",a)}),(n.editingController.height>60||o)&&!s&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-l",onMouseDown:a=>i("l",a)}),(n.editingController.height>60||o)&&!s&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-r",onMouseDown:a=>i("r",a)})]})},bi=({className:s,style:o,position:e="br",width:t,height:n})=>{const i=W();se();const{options:a}=J(),r=I.useRef(null),l=I.useRef(null);I.useEffect(()=>(i.onMiniViewMounted(),i.setMiniViewCanvas(l.current),()=>{i.onMiniViewUnMounted()}),[]);const c=h=>{i.onVisibleViewHandleDragStart(h.nativeEvent)},d=async h=>{i.resetByVisiableView(h.nativeEvent)};return x.jsx("div",{className:`rg-miniview rg-miniview-${e} ${s||""}`,ref:r,style:{...o,"--miniview-width":t,"--miniview-height":n},children:x.jsxs("div",{className:"rg-miniview-container",children:[x.jsx("canvas",{ref:l,className:a.miniViewVisibleHandle.emptyContent?"rg-mv-canvas-reset":"",onClick:d}),x.jsx("div",{className:"rg-mv-visible-area",onMouseDown:c,style:{transform:`translate(${a.miniViewVisibleHandle.x}px, ${a.miniViewVisibleHandle.y}px)`,width:a.miniViewVisibleHandle.width+"px",height:a.miniViewVisibleHandle.height+"px"}})]})})},Oi=({children:s,forDisplay:o,forImage:e,position:t,width:n,height:i})=>{const a=W();se();const{options:r}=J(),l=I.useRef(null);I.useEffect(()=>(a.setWatermarkDom(l.current,e,o,t),()=>{a.setWatermarkDom(null,o,e)}),[n,i]);let c=!1;return r.snapshotting?e===!1?c=!1:c=!0:o===!0?c=!0:c=!1,x.jsx("div",{className:`rg-watermark rg-watermark-${t||"br"}`,style:{display:c?"block":"none","--watermark-width":n,"--watermark-height":i},ref:l,children:s})},Ti=({children:s,forDisplay:o,forImage:e})=>{const t=W(),n=I.useRef(null);return I.useEffect(()=>(t.setBackgroundDom(n.current,o,e),()=>{t.setBackgroundDom(null,o,e)}),[]),x.jsx("div",{className:"rg-background",ref:n,children:s})},Pi=({position:s,children:o})=>{const e=s||"top";return x.jsx("div",{className:`rg-editing-bar rg-editing-bar-${e}`,children:o})},Ri=({textEditable:s=!0,pathEditable:o=!0,onMoveLineVertexStart:e,onMoveLineVertexEnd:t,onLineTextDragEnd:n,onLineTextChanged:i,onLinePathChanged:a,children:r})=>{const l=W();se();const{options:c}=J(),d=c.editingLineController,h=d.line,f=d.show,p=h&&h.text,[u,g]=I.useState(!1),[m,y]=I.useState(""),v=I.useRef(0),w=I.useRef(null);I.useEffect(()=>{f||g(!1)},[f]),I.useEffect(()=>{p!==m&&y(p||"")},[p]),I.useEffect(()=>{l.updateEditingLineView()},[m,h==null?void 0:h.lineShape]),I.useEffect(()=>{u&&w.current&&w.current.focus()},[u]);const N=(E,F)=>{!h||(e&&e(E,h),l.startMoveLineVertex(E,F.nativeEvent,($,te,Q)=>{t&&t($,te,Q),l.defaultLineVertexBeChangedHandler($,te,Q)}))},O=(E,F)=>{l.startMoveLine6CtrlPoint(E,F.nativeEvent,$=>{a&&a($,E)})},b=(E,F)=>{l.startMoveLine44CtrlPoint(E,F.nativeEvent,$=>{a&&a($,E)})},T=E=>{l.startMoveLineText(E.nativeEvent,()=>{h&&n&&n(h)})},P=()=>{v.current&&Date.now()-v.current<500&&g(!0),v.current=Date.now()},S=E=>{h&&h.text!==E.target.value&&(l.updateLine(h.id,{text:E.target.value}),y(E.target.value),i&&i(h)),g(!1)};if(!f||!h)return null;const{startPoint:k,endPoint:R,ctrlPoint1:M,ctrlPoint2:C,line44Splits:D}=d,{lineShape:X}=h,G=`M ${k.x} ${k.y} L ${(M==null?void 0:M.x)||0} ${(M==null?void 0:M.y)||0}`,B=`M ${R.x} ${R.y} L ${(C==null?void 0:C.x)||0} ${(C==null?void 0:C.y)||0}`;return x.jsxs("div",{className:"rg-editing-line-ctrl",children:[r,o&&x.jsx("svg",{className:"rg-edt-ctrl-svg",xmlns:"http://www.w3.org/2000/svg",children:x.jsxs("g",{children:[X===6&&M&&x.jsx("path",{d:G}),X===6&&C&&x.jsx("path",{d:B})]})}),x.jsx("div",{className:"rg-line-ctrl-dot start-dot",style:{"--rg-ctl-x":k.x+"px","--rg-ctl-y":k.y+"px"},onMouseDown:E=>N("start",E)}),x.jsx("div",{className:"rg-line-ctrl-dot end-dot",style:{"--rg-ctl-x":R.x+"px","--rg-ctl-y":R.y+"px"},onMouseDown:E=>N("end",E)}),o&&X===6&&M&&x.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":M.x+"px","--rg-ctl-y":M.y+"px"},onMouseDown:E=>O(0,E)}),o&&X===6&&C&&x.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":C.x+"px","--rg-ctl-y":C.y+"px"},onMouseDown:E=>O(1,E)}),o&&(X===44||X===49)&&D.map(E=>!E.hide&&x.jsx("div",{className:`rg-line-ctrl-dot ctrl-split ${E.optionName.startsWith("cp-")?"":"ctrl-split-core"} ${E.direction==="v"?"ctrl-split-v":""} ${E.direction==="h"?"ctrl-split-h":""}`,style:{"--rg-ctl-x":E.x+"px","--rg-ctl-y":E.y+"px"},onMouseDown:F=>b(E,F)},E.optionName)),s&&h&&x.jsx("div",{className:["rg-line-ctrl-text",u&&"rg-line-ctrl-text-editing"].filter(Boolean).join(" "),style:{"--rg-ctl-x":d.text.x+"px","--rg-ctl-y":d.text.y+"px"},onClick:P,onMouseDown:T,children:u?x.jsx("input",{ref:w,className:"rg-line-text-input",value:m,onChange:E=>y(E.target.value),onBlur:S}):m?x.jsx("p",{children:m}):x.jsx("p",{className:"empty-text",children:"Add Text..."})})]})},It=({mouseUpOnJunctionPointWithOffset:s,mouseUpOnJunctionPoint:o})=>x.jsxs("div",{className:"rg-connect-ctl",onMouseUp:e=>o("",e),onTouchEnd:e=>o("",e),children:[x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-t","data-point":"top",onMouseUp:e=>o("top",e),onTouchEnd:e=>o("top",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-b","data-point":"bottom",onMouseUp:e=>o("bottom",e),onTouchEnd:e=>o("bottom",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-center","data-point":"border",onMouseUp:e=>o("border",e),onTouchEnd:e=>o("border",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-l","data-point":"left",onMouseUp:e=>o("left",e),onTouchEnd:e=>o("left",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-r","data-point":"right",onMouseUp:e=>o("right",e),onTouchEnd:e=>o("right",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-lr","data-point":"lr",onMouseUp:e=>o("lr",e),onTouchEnd:e=>o("lr",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-tb","data-point":"tb",onMouseUp:e=>o("tb",e),onTouchEnd:e=>o("tb",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-bottom-bar","data-point":"bottom","data-innode":"true",onMouseUp:e=>s("bottom",e),onTouchEnd:e=>onMouseUpWithOffset("bottom",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-top-bar","data-point":"top","data-innode":"true",onMouseUp:e=>s("top",e),onTouchEnd:e=>onMouseUpWithOffset("top",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-left-bar","data-point":"left","data-innode":"true",onMouseUp:e=>s("left",e),onTouchEnd:e=>onMouseUpWithOffset("left",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-right-bar","data-point":"right","data-innode":"true",onMouseUp:e=>s("right",e),onTouchEnd:e=>onMouseUpWithOffset("right",e)})]}),Si=({children:s})=>{const o=W();se();const e=I.useRef(),{options:t}=J();if(!t.nodeConnectController.show)return x.jsx(x.Fragment,{});const n=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,void 0,(l,c,d)=>{L("onLineVertexBeDropped:callback:",d)})},i=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,e.current,(l,c,d)=>{L("onLineVertexBeDropped:callback:",d)})};return x.jsx("div",{className:"rg-editing-connect-ctrl",ref:e,style:{transform:`translate(${t.nodeConnectController.x}px, ${t.nodeConnectController.y}px)`,width:t.nodeConnectController.width+"px",height:t.nodeConnectController.height+"px"},children:s||x.jsx(It,{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:i})})},Mi=({lineTemplate:s,onConnectStart:o,onConnectEnd:e,children:t,className:n,style:i})=>{const a=W(),r=l=>{o&&o(s,l.nativeEvent),l.stopPropagation(),a.startCreateLineFromNode(null,s,l.nativeEvent,(c,d,h)=>{e&&e(c,d,h),a.defaultLineConnectEndHandler(c,d,h)})};return x.jsx("div",{className:`rg-connect-source-handle ${n||""}`,style:i,onMouseDown:l=>r(l),onClick:l=>{l.stopPropagation()},children:t})},ki=({children:s,className:o,style:e,junctionPoint:t,targetId:n,targetType:i,targetData:a,lineTemplate:r,disableDrop:l,disableDrag:c,onLineVertexBeDropped:d,onDragConnectStart:h,onDragConnectEnd:f})=>{const p=W(),u=I.useRef(null);I.useEffect(()=>(p.registerConnectTarget(u.current,n,i||V.CanvasPoint,t,a),()=>{p.unregisterConnectTarget(n)}),[]);const g=(y,v)=>{v.stopPropagation(),!l&&p.onLineVertexBeDropped(y,v.nativeEvent,void 0,(w,N,O)=>{d&&d(w,N,O)})},m=y=>{if(y.stopPropagation(),c||p.options.creatingLinePlot)return;const v=Object.assign({},r||{});v.from||(v.from=n),v.fromType||(v.fromType=i||V.NodePoint),v.fromJunctionPoint||(v.fromJunctionPoint=t),h&&h(v,y.nativeEvent),p.startCreateLineFromNode(null,v,y.nativeEvent,(w,N,O)=>{f&&f(w,N,O)})};return x.jsx("div",{ref:u,className:`rg-connect-ctl-handler rg-connect-target ${o||""}`,style:e,"data-point":t,"data-target-id":n,"data-target-type":i||V.CanvasPoint,"data-target-data":JSON.stringify(a),onMouseDown:y=>m(y),onMouseUp:y=>g(t,y),onClick:y=>{y.stopPropagation()},children:s})},Ii=({showText:s,adsorption:o})=>{const e=W(),{options:t}=J();return I.useEffect(()=>(e.onReferenceLineMounted(o),()=>{e.onReferenceLineUnMounted()}),[t]),x.jsxs("div",{className:"rg-editing-referline",style:{display:t.editingReferenceLine.show?"block":"none"},children:[t.editingReferenceLine.directionV&&x.jsx("div",{className:"rg-referline rg-referline-v",style:{transform:`translate(var(--rg-refer-offset), 0px) translate(${t.editingReferenceLine.v_x}px, ${t.editingReferenceLine.v_y}px)`,height:t.editingReferenceLine.v_height+"px"},children:x.jsx("div",{className:"referline",children:s!==!1&&x.jsxs("div",{children:[Math.round(t.editingReferenceLine.v_height),"px"]})})}),t.editingReferenceLine.directionH&&x.jsx("div",{className:"rg-referline rg-referline-h",style:{transform:`translate(0px, var(--rg-refer-offset)) translate(${t.editingReferenceLine.h_x}px, ${t.editingReferenceLine.h_y}px)`,width:t.editingReferenceLine.h_width+"px"},children:x.jsx("div",{className:"referline",children:s!==!1&&x.jsxs("div",{children:[Math.round(t.editingReferenceLine.h_width),"px"]})})})]})},Ei=s=>{const o=W();return I.useEffect(()=>{nt("React-Linker"),o.setOptions(s.options);const e=Ge(s);L("[RelationGraph]mounted:listeners:",e),o.setListeners(e),o.ready(),o.dataUpdated()},[]),I.useEffect(()=>{o.setOptions(s.options||{}),o.dataUpdated()},[s.options]),I.useEffect(()=>{s.lines&&(L("[RelationGraph] apply data"),(async()=>(o.clearGraph(),o.addFakeLines(s.lines),o.dataUpdated()))())},[s.lines]),x.jsx(vt,{...s})},Di=s=>{const o=$e(s.relationGraphCore,!0);return x.jsx(Ue,{graphInstance:o,children:x.jsx(Ei,{...s,children:s.children})})},Ai=s=>{const o=Rt(s.relationGraphCore);return x.jsx(St,{graphInstance:o,children:s.children})},Vi=tt,Xi=Pt,zi={BaseLayout:ue,BidirectionalTreeLayout:Ct,CenterLayout:Lt,CircleLayout:wt,FixedLayout:_t,ForceLayout:Te,RGFolderLayout:Nt},Bi={RGOptionsDataUtils:Jt,RGLineDataUtils:jt,RGNodeDataUtils:Ut,RGGraphMath:q,RGNodesAnalyticUtils:z,RGEffectUtils:Z},Gi=Li,Fi=rt,Yi=at,Hi=xi,ji=Ci,Wi=ht,$i=gt,Ui=bi,qi=Ti,Ji=Oi,Zi=_i,Qi=Ni,Ki=Pi,eo=Ri,to=Si,no=Mi,io=ki,oo=It,so=Ii,ao=We,ro=We,lo=mt,co=yt,Et=wi,ho=pt,uo=Di,Dt=kt,fo=Dt.useRelationGraph,go=Ai,po=Mt;exports.RGBackground=qi;exports.RGConnectSource=no;exports.RGConnectTarget=io;exports.RGDebugView=Hi;exports.RGDirection=it;exports.RGEditingConnectController=to;exports.RGEditingConnectPoints=oo;exports.RGEditingLineController=eo;exports.RGEditingNearNodeWidget=Ki;exports.RGEditingNodeController=Zi;exports.RGEditingReferenceLine=so;exports.RGEditingResize=Qi;exports.RGEventNames=A;exports.RGFakeNode=Gi;exports.RGHooks=Dt;exports.RGInnerConnectTargetType=V;exports.RGInstanceContext=ye;exports.RGJunctionPoint=U;exports.RGLayouts=zi;exports.RGLinePath=Fi;exports.RGLineShape=H;exports.RGLineText=Yi;exports.RGMiniToolBar=$i;exports.RGMiniView=Ui;exports.RGNodeExpandHolder=Wi;exports.RGNodeShape=Ne;exports.RGProvider=go;exports.RGSlotOnCanvas=co;exports.RGSlotOnCanvasAbove=lo;exports.RGSlotOnGraph=ao;exports.RGSlotOnLine=ho;exports.RGSlotOnNode=Et;exports.RGSlotOnView=ro;exports.RGToolBar=ji;exports.RGUpdateContext=ot;exports.RGUpdateSignalContext=Ee;exports.RGUpdateSingalContext=Ee;exports.RGUtils=Bi;exports.RGWatermark=Ji;exports.RelationGraph=po;exports.RelationGraphCore=Xi;exports.RelationGraphStoreContext=ye;exports.RelationLinker=uo;exports._RGHooks=kt;exports.default=Mt;exports.useRelationGraph=fo;exports.version=Vi;
|
|
284
|
+
`,Ke={Vue3GetInstance:xe(yi),ReactGetInstance:xe(mi),Vue2GetInstance:xe(pi),setJsonData:xe(vi),setJsonData4Vue2:xe(xi)},Ci=(s,o)=>{const e=je(s.relationGraphCore);return I.useImperativeHandle(o,()=>({getInstance(){var t;return(t=s.options)!=null&&t.definitelyNoDataProviderNeeded||console.warn("[relation-graph]",Ke.ReactGetInstance),e},async setJsonData(){throw new Error(Ke.setJsonData)}}),[]),I.useEffect(()=>{e.updateOptions(s.options)},[s.options]),I.useEffect(()=>{e.setListeners(Ge(s))},[s]),x.jsx(We,{graphInstance:e,children:x.jsx(Ct,{...s})})},kt=pe.default.forwardRef(Ci);function Li(s={}){const o=je(s.relationGraphCore);return{RelationGraph:I.useMemo(()=>{console.log("Creating a MemoizedRelationGraph...");const t=n=>x.jsx(We,{graphInstance:o,children:x.jsx(Ct,{...n,children:n.children})});return t.displayName="RelationGraph",t},[]),graphInstance:o}}const It={useRelationGraph:Li,useGraphInstance:W,useAutoUpdateView:se,useCreatingLine:Qt,useCreatingNode:Kt,useEditingNodes:en,useEditingLine:tn,useViewInformation:on,useSelection:sn,useConnectingNode:nn,useCheckedItem:an,useGraphStore:J},wi=({children:s})=>{const o=W();se();const{options:e}=J(),[t,n]=I.useState(!1),i=()=>{n(!t)},a=()=>{o.printOptions()},r=()=>{o.getGraphJsonData()},l=()=>{o.enableDebugLog(!e.debug),w("debugLog:",e.debug),updateView()};return x.jsxs("div",{children:[x.jsx("div",{className:"rg-setting-panel-button",onClick:()=>{i()},children:"Debug"}),t&&x.jsxs("div",{className:"rg-setting-panel",children:[x.jsx("div",{className:"c-debug-tools-row",children:x.jsx("button",{onClick:()=>{a()},children:"print options in console"})}),x.jsx("div",{className:"c-debug-tools-row",children:x.jsx("button",{onClick:()=>{r()},children:"print json data in console"})}),x.jsxs("div",{className:"c-debug-tools-row",children:["debug log status: ",e.debug?"true":"false",x.jsxs("button",{onClick:()=>{l()},children:[e.debug?"disable":"enable"," debug log"]})]}),s]})]})},_i=({children:s,direction:o,positionH:e,positionV:t})=>{const n=W(),{options:i}=J(),a=async()=>{await n.refresh(),n.dataUpdated()},r=()=>{n.toggleAutoLayout()},l=async()=>{await n.fullscreen(),n.dataUpdated()},c=async()=>{n.setZoom(100),n.moveToCenter(),n.enableCanvasAnimation(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300)},d=h=>{n.zoom(h),n.dataUpdated()};return x.jsxs("div",{className:["rg-toolbar","rg-toolbar-h-"+(e||i.toolBarPositionH),"rg-toolbar-v-"+(t||i.toolBarPositionV),"rg-toolbar-"+(o||i.toolBarDirection)].join(" "),children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>{l()},children:x.jsx(ee,{iconName:"icon-quanping"})}),x.jsxs(pe.default.Fragment,{children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>{d(20)},children:x.jsx(ee,{iconName:"icon-fangda"})}),x.jsxs("div",{className:"rg-current-zoom",onClick:()=>{c()},children:[Math.round(i.canvasZoom),"%"]}),x.jsx("div",{className:"rg-mb-button",onClick:()=>{d(-20)},children:x.jsx(ee,{iconName:"icon-suoxiao"})})]}),i.layout.supportAutoLayout&&x.jsx("div",{title:i.layout.autoLayouting?"Stop force":"Start force",className:["rg-mb-button",i.layout.autoLayouting&&"rg-mb-button-on"].join(" "),onClick:()=>{r()},children:i.layout.autoLayouting?x.jsx(ee,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):x.jsx(ee,{iconName:"icon-zidong"})}),x.jsx("div",{className:"rg-mb-button",onClick:()=>{a()},children:x.jsx(ee,{iconName:"icon-ico_reset"})}),s,x.jsx("div",{style:{clear:"both"}})]})},Ni=({node:s,children:o})=>{const e=I.useRef(null),t=W();se();const{options:n}=J(),i=s.borderWidth===void 0?void 0:`${s.borderWidth}px`,a=s.width?s.width+"px":void 0,r=s.height?s.height+"px":void 0;I.useEffect(()=>(t.addNodeResizeListener(e.current,s),()=>{e.current&&t.removeNodeResizeListener(e.current)}),[]);const l=h=>{"button"in h&&h.button!==0||(h.stopPropagation(),t.onNodeDragStart(s,h.nativeEvent))},c=["rg-node-peel",s.selected&&"rg-node-selected",s.id===n.draggingNodeId&&"rg-node-dragging",s.id===n.checkedNodeId&&"rg-node-checked",`rg-node-shape-${s.nodeShape===void 0?1:s.nodeShape}`,`rg-node-type-${s.type}`,s.className].filter(Boolean).join(" "),d={transform:`translate(${s.x}px, ${s.y}px)`,"--rg-node-z-index":s.zIndex,"--rg-node-opacity":s.opacity,pointerEvents:s.opacity===0?"none":void 0,"--rg-node-color":s.color||n.defaultNodeColor,"--rg-node-font-color":s.fontColor,"--rg-node-font-size":s.fontSize?`${s.fontSize}px`:void 0,"--rg-node-border-width":i,"--rg-node-width":a,"--rg-node-height":r,"--rg-node-border-radius":s.borderRadius?`${s.borderRadius}px`:void 0,"--rg-node-border-color":s.borderColor};return x.jsx("div",{ref:e,style:d,className:c,"data-id":s.id,children:x.jsx("div",{className:"rg-node",onMouseDown:l,onTouchStart:l,children:o||x.jsx("div",{className:"rg-node-text",children:x.jsx("span",{children:s.text})})})})},bi=({children:s})=>x.jsx(x.Fragment,{}),Oi=({children:s})=>{const{options:o}=J();if(!o.editingController.show)return null;const e={width:o.editingController.width+"px",height:o.editingController.height+"px",transform:`translate(${o.editingController.x}px, ${o.editingController.y}px)`};return x.jsx("div",{className:"rg-editing-ctrl",style:e,children:s})},Ti=({disableResizeWidth:s,disableResizeHeight:o,beforeResizeStart:e})=>{const t=W(),{options:n}=J(),i=(a,r)=>{r.stopPropagation(),e&&e(),t.onResizeStart(a,r.nativeEvent)};return x.jsxs("div",{className:"rg-resize-ctl",children:[n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tl",onMouseDown:a=>i("tl",a)}),n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tr",onMouseDown:a=>i("tr",a)}),n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-bl",onMouseDown:a=>i("bl",a)}),!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-br",onMouseDown:a=>i("br",a)}),(n.editingController.width>60||s)&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-t",onMouseDown:a=>i("t",a)}),(n.editingController.width>60||s)&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-b",onMouseDown:a=>i("b",a)}),(n.editingController.height>60||o)&&!s&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-l",onMouseDown:a=>i("l",a)}),(n.editingController.height>60||o)&&!s&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-r",onMouseDown:a=>i("r",a)})]})},Ri=({className:s,style:o,position:e="br",width:t,height:n})=>{const i=W();se();const{options:a}=J(),r=I.useRef(null),l=I.useRef(null);I.useEffect(()=>(i.onMiniViewMounted(),i.setMiniViewCanvas(l.current),()=>{i.onMiniViewUnMounted()}),[]);const c=h=>{i.onVisibleViewHandleDragStart(h.nativeEvent)},d=async h=>{i.resetByVisiableView(h.nativeEvent)};return x.jsx("div",{className:`rg-miniview rg-miniview-${e} ${s||""}`,ref:r,style:{...o,"--miniview-width":t,"--miniview-height":n},children:x.jsxs("div",{className:"rg-miniview-container",children:[x.jsx("canvas",{ref:l,className:a.miniViewVisibleHandle.emptyContent?"rg-mv-canvas-reset":"",onClick:d}),x.jsx("div",{className:"rg-mv-visible-area",onMouseDown:c,style:{transform:`translate(${a.miniViewVisibleHandle.x}px, ${a.miniViewVisibleHandle.y}px)`,width:a.miniViewVisibleHandle.width+"px",height:a.miniViewVisibleHandle.height+"px"}})]})})},Si=({children:s,forDisplay:o,forImage:e,position:t,width:n,height:i})=>{const a=W();se();const{options:r}=J(),l=I.useRef(null);I.useEffect(()=>(a.setWatermarkDom(l.current,e,o,t),()=>{a.setWatermarkDom(null,o,e)}),[n,i]);let c=!1;return r.snapshotting?e===!1?c=!1:c=!0:o===!0?c=!0:c=!1,x.jsx("div",{className:`rg-watermark rg-watermark-${t||"br"}`,style:{display:c?"block":"none","--watermark-width":n,"--watermark-height":i},ref:l,children:s})},Pi=({position:s,children:o})=>{const e=s||"top";return x.jsx("div",{className:`rg-editing-bar rg-editing-bar-${e}`,children:o})},Mi=({textEditable:s=!0,pathEditable:o=!0,onMoveLineVertexStart:e,onMoveLineVertexEnd:t,onLineTextDragEnd:n,onLineTextChanged:i,onLinePathChanged:a,children:r})=>{const l=W();se();const{options:c}=J(),d=c.editingLineController,h=d.line,f=d.show,p=h&&h.text,[u,g]=I.useState(!1),[y,m]=I.useState(""),v=I.useRef(0),C=I.useRef(null);I.useEffect(()=>{f||g(!1)},[f]),I.useEffect(()=>{p!==y&&m(p||"")},[p]),I.useEffect(()=>{l.updateEditingLineView()},[y,h==null?void 0:h.lineShape]),I.useEffect(()=>{u&&C.current&&C.current.focus()},[u]);const N=(E,F)=>{!h||(e&&e(E,h),l.startMoveLineVertex(E,F.nativeEvent,($,te,Q)=>{t&&t($,te,Q),l.defaultLineVertexBeChangedHandler($,te,Q)}))},O=(E,F)=>{l.startMoveLine6CtrlPoint(E,F.nativeEvent,$=>{a&&a($,E)})},b=(E,F)=>{l.startMoveLine44CtrlPoint(E,F.nativeEvent,$=>{a&&a($,E)})},T=E=>{l.startMoveLineText(E.nativeEvent,()=>{h&&n&&n(h)})},R=()=>{v.current&&Date.now()-v.current<500&&g(!0),v.current=Date.now()},P=E=>{h&&h.text!==E.target.value&&(l.updateLine(h.id,{text:E.target.value}),m(E.target.value),i&&i(h)),g(!1)};if(!f||!h)return null;const{startPoint:k,endPoint:S,ctrlPoint1:M,ctrlPoint2:L,line44Splits:D}=d,{lineShape:X}=h,G=`M ${k.x} ${k.y} L ${(M==null?void 0:M.x)||0} ${(M==null?void 0:M.y)||0}`,z=`M ${S.x} ${S.y} L ${(L==null?void 0:L.x)||0} ${(L==null?void 0:L.y)||0}`;return x.jsxs("div",{className:"rg-editing-line-ctrl",children:[r,o&&x.jsx("svg",{className:"rg-edt-ctrl-svg",xmlns:"http://www.w3.org/2000/svg",children:x.jsxs("g",{children:[X===6&&M&&x.jsx("path",{d:G}),X===6&&L&&x.jsx("path",{d:z})]})}),x.jsx("div",{className:"rg-line-ctrl-dot start-dot",style:{"--rg-ctl-x":k.x+"px","--rg-ctl-y":k.y+"px"},onMouseDown:E=>N("start",E)}),x.jsx("div",{className:"rg-line-ctrl-dot end-dot",style:{"--rg-ctl-x":S.x+"px","--rg-ctl-y":S.y+"px"},onMouseDown:E=>N("end",E)}),o&&X===6&&M&&x.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":M.x+"px","--rg-ctl-y":M.y+"px"},onMouseDown:E=>O(0,E)}),o&&X===6&&L&&x.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":L.x+"px","--rg-ctl-y":L.y+"px"},onMouseDown:E=>O(1,E)}),o&&(X===44||X===49)&&D.map(E=>!E.hide&&x.jsx("div",{className:`rg-line-ctrl-dot ctrl-split ${E.optionName.startsWith("cp-")?"":"ctrl-split-core"} ${E.direction==="v"?"ctrl-split-v":""} ${E.direction==="h"?"ctrl-split-h":""}`,style:{"--rg-ctl-x":E.x+"px","--rg-ctl-y":E.y+"px"},onMouseDown:F=>b(E,F)},E.optionName)),s&&h&&x.jsx("div",{className:["rg-line-ctrl-text",u&&"rg-line-ctrl-text-editing"].filter(Boolean).join(" "),style:{"--rg-ctl-x":d.text.x+"px","--rg-ctl-y":d.text.y+"px"},onClick:R,onMouseDown:T,children:u?x.jsx("input",{ref:C,className:"rg-line-text-input",value:y,onChange:E=>m(E.target.value),onBlur:P}):y?x.jsx("p",{children:y}):x.jsx("p",{className:"empty-text",children:"Add Text..."})})]})},Et=({mouseUpOnJunctionPointWithOffset:s,mouseUpOnJunctionPoint:o})=>x.jsxs("div",{className:"rg-connect-ctl",onMouseUp:e=>o("",e),onTouchEnd:e=>o("",e),children:[x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-t","data-point":"top",onMouseUp:e=>o("top",e),onTouchEnd:e=>o("top",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-b","data-point":"bottom",onMouseUp:e=>o("bottom",e),onTouchEnd:e=>o("bottom",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-center","data-point":"border",onMouseUp:e=>o("border",e),onTouchEnd:e=>o("border",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-l","data-point":"left",onMouseUp:e=>o("left",e),onTouchEnd:e=>o("left",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-r","data-point":"right",onMouseUp:e=>o("right",e),onTouchEnd:e=>o("right",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-lr","data-point":"lr",onMouseUp:e=>o("lr",e),onTouchEnd:e=>o("lr",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-tb","data-point":"tb",onMouseUp:e=>o("tb",e),onTouchEnd:e=>o("tb",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-bottom-bar","data-point":"bottom","data-innode":"true",onMouseUp:e=>s("bottom",e),onTouchEnd:e=>onMouseUpWithOffset("bottom",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-top-bar","data-point":"top","data-innode":"true",onMouseUp:e=>s("top",e),onTouchEnd:e=>onMouseUpWithOffset("top",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-left-bar","data-point":"left","data-innode":"true",onMouseUp:e=>s("left",e),onTouchEnd:e=>onMouseUpWithOffset("left",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-right-bar","data-point":"right","data-innode":"true",onMouseUp:e=>s("right",e),onTouchEnd:e=>onMouseUpWithOffset("right",e)})]}),ki=({children:s})=>{const o=W();se();const e=I.useRef(),{options:t}=J();if(!t.nodeConnectController.show)return x.jsx(x.Fragment,{});const n=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,void 0,(l,c,d)=>{w("onLineVertexBeDropped:callback:",d)})},i=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,e.current,(l,c,d)=>{w("onLineVertexBeDropped:callback:",d)})};return x.jsx("div",{className:"rg-editing-connect-ctrl",ref:e,style:{transform:`translate(${t.nodeConnectController.x}px, ${t.nodeConnectController.y}px)`,width:t.nodeConnectController.width+"px",height:t.nodeConnectController.height+"px"},children:s||x.jsx(Et,{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:i})})},Ii=({lineTemplate:s,onConnectStart:o,onConnectEnd:e,children:t,className:n,style:i})=>{const a=W(),r=l=>{o&&o(s,l.nativeEvent),l.stopPropagation(),a.startCreateLineFromNode(null,s,l.nativeEvent,(c,d,h)=>{e&&e(c,d,h),a.defaultLineConnectEndHandler(c,d,h)})};return x.jsx("div",{className:`rg-connect-source-handle ${n||""}`,style:i,onMouseDown:l=>r(l),onClick:l=>{l.stopPropagation()},children:t})},Ei=({children:s,className:o,style:e,forSvg:t,junctionPoint:n,targetId:i,targetType:a,targetData:r,lineTemplate:l,disableDrop:c,disableDrag:d,onLineVertexBeDropped:h,onDragConnectStart:f,onDragConnectEnd:p})=>{const u=W(),g=I.useRef(null);I.useEffect(()=>(u.registerConnectTarget(g.current,i,a||V.CanvasPoint,n,r),()=>{u.unregisterConnectTarget(i)}),[]);const y=(v,C)=>{C.stopPropagation(),!c&&u.onLineVertexBeDropped(v,C.nativeEvent,void 0,(N,O,b)=>{h&&h(N,O,b)})},m=v=>{if(v.stopPropagation(),d||u.options.creatingLinePlot)return;const C=Object.assign({},l||{});C.from||(C.from=i),C.fromType||(C.fromType=a||V.NodePoint),C.fromJunctionPoint||(C.fromJunctionPoint=n),f&&f(C,v.nativeEvent),u.startCreateLineFromNode(null,C,v.nativeEvent,(N,O,b)=>{p&&p(N,O,b)})};return t?x.jsx("g",{ref:g,className:`rg-connect-ctl-handler rg-connect-target ${o||""}`,style:e,"data-point":n,"data-target-id":i,"data-target-type":a||V.CanvasPoint,"data-target-data":JSON.stringify(r),onMouseDown:v=>m(v),onMouseUp:v=>y(n,v),onClick:v=>{v.stopPropagation()},children:s}):x.jsx("div",{ref:g,className:`rg-connect-ctl-handler rg-connect-target ${o||""}`,style:e,"data-point":n,"data-target-id":i,"data-target-type":a||V.CanvasPoint,"data-target-data":JSON.stringify(r),onMouseDown:v=>m(v),onMouseUp:v=>y(n,v),onClick:v=>{v.stopPropagation()},children:s})},Di=({showText:s,adsorption:o})=>{const e=W(),{options:t}=J();return I.useEffect(()=>(e.onReferenceLineMounted(o),()=>{e.onReferenceLineUnMounted()}),[t]),x.jsxs("div",{className:"rg-editing-referline",style:{display:t.editingReferenceLine.show?"block":"none"},children:[t.editingReferenceLine.directionV&&x.jsx("div",{className:"rg-referline rg-referline-v",style:{transform:`translate(var(--rg-refer-offset), 0px) translate(${t.editingReferenceLine.v_x}px, ${t.editingReferenceLine.v_y}px)`,height:t.editingReferenceLine.v_height+"px"},children:x.jsx("div",{className:"referline",children:s!==!1&&x.jsxs("div",{children:[Math.round(t.editingReferenceLine.v_height),"px"]})})}),t.editingReferenceLine.directionH&&x.jsx("div",{className:"rg-referline rg-referline-h",style:{transform:`translate(0px, var(--rg-refer-offset)) translate(${t.editingReferenceLine.h_x}px, ${t.editingReferenceLine.h_y}px)`,width:t.editingReferenceLine.h_width+"px"},children:x.jsx("div",{className:"referline",children:s!==!1&&x.jsxs("div",{children:[Math.round(t.editingReferenceLine.h_width),"px"]})})})]})},Ai=s=>{const o=W();return I.useEffect(()=>{tt("React-Linker"),o.setOptions(s.options);const e=Ge(s);w("[RelationGraph]mounted:listeners:",e),o.setListeners(e),o.ready(),o.dataUpdated()},[]),I.useEffect(()=>{o.setOptions(s.options||{}),o.dataUpdated()},[s.options]),I.useEffect(()=>{s.lines&&(w("[RelationGraph] apply data"),(async()=>(o.clearGraph(),o.addFakeLines(s.lines),o.dataUpdated()))())},[s.lines]),x.jsx(xt,{...s})},Vi=s=>{const o=je(s.relationGraphCore,!0);return x.jsx(We,{graphInstance:o,children:x.jsx(Ai,{...s,children:s.children})})},Xi=s=>{const o=Pt(s.relationGraphCore);return x.jsx(Mt,{graphInstance:o,children:s.children})},Bi=et,zi=St,Gi={BaseLayout:fe,BidirectionalTreeLayout:Lt,CenterLayout:wt,CircleLayout:_t,FixedLayout:Nt,ForceLayout:Re,RGFolderLayout:bt},Fi={RGOptionsDataUtils:Zt,RGLineDataUtils:Wt,RGNodeDataUtils:qt,RGGraphMath:q,RGNodesAnalyticUtils:B,RGEffectUtils:Z},Yi=Ni,Hi=rt,ji=at,Wi=wi,$i=_i,Ui=ht,qi=gt,Ji=Ri,Zi=vt,Qi=Si,Ki=Oi,eo=Ti,to=Pi,no=Mi,io=ki,oo=Ii,so=Ei,ao=Et,ro=Di,lo=He,co=He,ho=mt,uo=yt,Dt=bi,fo=pt,go=Vi,At=It,po=At.useRelationGraph,yo=Xi,mo=kt;exports.RGBackground=Zi;exports.RGConnectSource=oo;exports.RGConnectTarget=so;exports.RGDebugView=Wi;exports.RGDirection=nt;exports.RGEditingConnectController=io;exports.RGEditingConnectPoints=ao;exports.RGEditingLineController=no;exports.RGEditingNearNodeWidget=to;exports.RGEditingNodeController=Ki;exports.RGEditingReferenceLine=ro;exports.RGEditingResize=eo;exports.RGEventNames=A;exports.RGFakeNode=Yi;exports.RGHooks=At;exports.RGInnerConnectTargetType=V;exports.RGInstanceContext=ye;exports.RGJunctionPoint=U;exports.RGLayouts=Gi;exports.RGLinePath=Hi;exports.RGLineShape=H;exports.RGLineText=ji;exports.RGMiniToolBar=qi;exports.RGMiniView=Ji;exports.RGNodeExpandHolder=Ui;exports.RGNodeShape=be;exports.RGProvider=yo;exports.RGSlotOnCanvas=uo;exports.RGSlotOnCanvasAbove=ho;exports.RGSlotOnGraph=lo;exports.RGSlotOnLine=fo;exports.RGSlotOnNode=Dt;exports.RGSlotOnView=co;exports.RGToolBar=$i;exports.RGUpdateContext=ot;exports.RGUpdateSignalContext=Ee;exports.RGUpdateSingalContext=Ee;exports.RGUtils=Fi;exports.RGWatermark=Qi;exports.RelationGraph=mo;exports.RelationGraphCore=zi;exports.RelationGraphStoreContext=ye;exports.RelationLinker=go;exports._RGHooks=It;exports.default=kt;exports.useRelationGraph=po;exports.version=Bi;
|