@html-graph/html-graph 1.0.0 → 1.1.1

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/dist/main.umd.cjs CHANGED
@@ -1 +1 @@
1
- (function(S,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(S=typeof globalThis<"u"?globalThis:S||self,E(S.HtmlGraph={}))})(this,function(S){"use strict";var pt=Object.defineProperty;var Vt=(S,E,f)=>E in S?pt(S,E,{enumerable:!0,configurable:!0,writable:!0,value:f}):S[E]=f;var n=(S,E,f)=>Vt(S,typeof E!="symbol"?E+"":E,f);const E=(e,t)=>({x:e/2,y:t/2}),f=(e,t,o)=>({x:t.x*e.x-t.y*e.y+((1-t.x)*o.x+t.y*o.y),y:t.y*e.x+t.x*e.y+((1-t.x)*o.y-t.y*o.x)}),N=(e,t,o)=>({x:t*Math.cos(e),y:o*Math.sin(e)}),u={x:0,y:0},P=(e,t,o,r)=>{const s=[u,{x:o,y:r},{x:o,y:-r}].map(l=>f(l,e,u)).map(l=>({x:l.x+t.x,y:l.y+t.y})),h=`M ${s[0].x} ${s[0].y}`,c=`L ${s[1].x} ${s[1].y}`,d=`L ${s[2].x} ${s[2].y}`;return`${h} ${c} ${d}`},D=(e,t)=>{const o=[];if(e.length>0&&o.push(`M ${e[0].x} ${e[0].y}`),e.length===2&&o.push(`L ${e[1].x} ${e[1].y}`),e.length>2){const r=e.length-1;let i=0,s=0,h=0;e.forEach((c,d)=>{let l=0,a=0,g=0;const y=d>0,x=d<r,v=y&&x;if(y&&(l=-i,a=-s,g=h),x){const p=e[d+1];i=p.x-c.x,s=p.y-c.y,h=Math.sqrt(i*i+s*s)}const T=h!==0?Math.min((v?t:0)/h,d<r-1?.5:1):0,C=v?{x:c.x+i*T,y:c.y+s*T}:c,$=g!==0?Math.min((v?t:0)/g,d>1?.5:1):0,b=v?{x:c.x+l*$,y:c.y+a*$}:c;d>0&&o.push(`L ${b.x} ${b.y}`),v&&o.push(`C ${c.x} ${c.y} ${c.x} ${c.y} ${C.x} ${C.y}`)})}return o.join(" ")},V=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.style.pointerEvents="none",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.overflow="visible",e},W=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","g");return e.style.transformOrigin="50% 50%",e},F=(e,t)=>{const o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("stroke",e),o.setAttribute("stroke-width",`${t}`),o.setAttribute("fill","none"),o},L=e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill",e),t},R=(e,t)=>{const o={x:e.x+e.width/2,y:e.y+e.height/2},r={x:t.x+t.width/2,y:t.y+t.height/2},i=Math.min(o.x,r.x),s=Math.min(o.y,r.y),h=Math.abs(r.x-o.x),c=Math.abs(r.y-o.y),d=o.x<=r.x?1:-1,l=o.y<=r.y?1:-1;return{x:i,y:s,width:h,height:c,flipX:d,flipY:l}},st=e=>{const t=f({x:e.arrowLength,y:u.y},e.fromVect,u),o=f({x:e.to.x-e.arrowLength,y:e.to.y},e.toVect,e.to),r={x:t.x+e.fromVect.x*e.curvature,y:t.y+e.fromVect.y*e.curvature},i={x:o.x-e.toVect.x*e.curvature,y:o.y-e.toVect.y*e.curvature},s=`M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`,h=e.hasSourceArrow?"":`M ${u.x} ${u.y} L ${t.x} ${t.y} `,c=e.hasTargetArrow?"":` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;return`${h}${s}${c}`},ht=e=>{const t=e.hasSourceArrow?f({x:e.arrowLength,y:u.y},e.fromVect,u):u,o=e.hasTargetArrow?f({x:e.to.x-e.arrowLength,y:e.to.y},e.toVect,e.to):e.to,r=e.arrowLength,i=Math.cos(e.detourDirection)*e.detourDistance,s=Math.sin(e.detourDirection)*e.detourDistance,h=i*e.flipX,c=s*e.flipY,d=f({x:r,y:u.y},e.fromVect,u),l={x:d.x+h,y:d.y+c},a=f({x:e.to.x-r,y:e.to.y},e.toVect,e.to),g={x:a.x+h,y:a.y+c},y={x:(l.x+g.x)/2,y:(l.y+g.y)/2},x={x:d.x+e.curvature*e.fromVect.x,y:d.y+e.curvature*e.fromVect.y},v={x:a.x-e.curvature*e.toVect.x,y:a.y-e.curvature*e.toVect.y},M={x:d.x+h,y:d.y+c},T={x:a.x+h,y:a.y+c};return[`M ${t.x} ${t.y}`,`L ${d.x} ${d.y}`,`C ${x.x} ${x.y} ${M.x} ${M.y} ${y.x} ${y.y}`,`C ${T.x} ${T.y} ${v.x} ${v.y} ${a.x} ${a.y}`,`L ${o.x} ${o.y}`].join(" ")},ct=e=>{const t=e.hasSourceArrow?f({x:e.arrowLength,y:u.y},e.fromVect,u):u,o=e.hasTargetArrow?f({x:e.to.x-e.arrowLength,y:e.to.y},e.toVect,e.to):e.to,r=e.arrowLength+e.arrowOffset,i=r-e.roundness,s=f({x:i,y:u.y},e.fromVect,u),h=f({x:e.to.x-i,y:e.to.y},e.toVect,e.to),c=Math.max((s.x+h.x)/2,r),d=e.to.y/2,l={x:e.flipX>0?c:-r,y:s.y},a={x:l.x,y:d},g={x:e.flipX>0?e.to.x-c:e.to.x+r,y:h.y},y={x:g.x,y:d};return D([t,s,l,a,y,g,h,o],e.roundness)},B=e=>{const t=e.hasSourceArrow?f({x:e.arrowLength,y:u.y},e.fromVect,u):u,o=e.hasTargetArrow?f({x:e.to.x-e.arrowLength,y:e.to.y},e.toVect,e.to):e.to,r=e.arrowLength+e.arrowOffset,i=f({x:r,y:u.y},e.fromVect,u),s=Math.cos(e.detourDirection)*e.detourDistance,h=Math.sin(e.detourDirection)*e.detourDistance,c=s*e.flipX,d=h*e.flipY,l={x:i.x+c,y:i.y+d},a=f({x:e.to.x-r,y:e.to.y},e.toVect,e.to),g={x:a.x+c,y:a.y+d};return D([t,i,l,g,a,o],e.roundness)},dt=e=>{const t=e.hasSourceArrow?f({x:e.arrowLength,y:u.y},e.fromVect,u):u,o=e.hasTargetArrow?f({x:e.to.x-e.arrowLength,y:e.to.y},e.toVect,e.to):e.to,r=e.arrowLength+e.arrowOffset,i=f({x:r,y:u.y},e.fromVect,u),s=f({x:e.to.x-r,y:e.to.y},e.toVect,e.to);return D([t,i,s,o],e.roundness)},lt=e=>{const t=e.hasSourceArrow?f({x:e.arrowLength,y:u.y},e.fromVect,u):u,o=e.hasTargetArrow?f({x:e.to.x-e.arrowLength,y:e.to.y},e.toVect,e.to):e.to,r=e.arrowLength+e.arrowOffset,i=r-e.roundness,s=f({x:i,y:u.y},e.fromVect,u),h=f({x:e.to.x-i,y:e.to.y},e.toVect,e.to),c=Math.max((s.y+h.y)/2,r),d=e.to.x/2,l={x:s.x,y:e.flipY>0?c:-r},a={x:d,y:l.y},g={x:h.x,y:e.flipY>0?e.to.y-c:e.to.y+r},y={x:d,y:g.y};return D([t,s,l,a,y,g,h,o],e.roundness)},z=e=>{const t=e.arrowOffset,o=e.side,r=e.arrowLength+t,i=r+2*o,h=[{x:e.arrowLength,y:u.y},{x:r,y:u.y},{x:r,y:e.side},{x:i,y:e.side},{x:i,y:-e.side},{x:r,y:-e.side},{x:r,y:u.y},{x:e.arrowLength,y:u.y}].map(d=>f(d,e.fromVect,u)),c=`M ${u.x} ${u.y} L ${h[0].x} ${h[0].y} `;return`${e.hasSourceArrow||e.hasTargetArrow?"":c}${D(h,e.roundness)}`},at=e=>{const t=e.smallRadius,o=e.radius,r=Math.sqrt(t*t+o*o),i=t+o,s=e.arrowLength+r*(1-o/i),h=t*o/i,d=[{x:e.arrowLength,y:u.y},{x:s,y:h},{x:s,y:-h}].map(g=>f(g,e.fromVect,u)),l=[`M ${d[0].x} ${d[0].y}`,`A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,`A ${o} ${o} 0 1 0 ${d[2].x} ${d[2].y}`,`A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`].join(" "),a=`M 0 0 L ${d[0].x} ${d[0].y} `;return`${e.hasSourceArrow||e.hasTargetArrow?"":a}${l}`},w=Object.freeze({color:"#777777",width:1,arrowLength:15,arrowWidth:4,arrowOffset:15,hasSourceArrow:!1,hasTargetArrow:!1,cycleRadius:30,cycleSquareSide:30,roundness:10,detourDistance:100,detourDirection:-Math.PI/2,detourDirectionVertical:0,smallCycleRadius:15,curvature:90});class K{constructor(t){n(this,"svg",V());n(this,"group",W());n(this,"line");n(this,"sourceArrow",null);n(this,"targetArrow",null);n(this,"arrowLength");n(this,"arrowWidth");n(this,"curvature");n(this,"portCycleRadius");n(this,"portCycleSmallRadius");n(this,"detourDirection");n(this,"detourDistance");n(this,"hasSourceArrow");n(this,"hasTargetArrow");this.arrowLength=(t==null?void 0:t.arrowLength)??w.arrowLength,this.arrowWidth=(t==null?void 0:t.arrowWidth)??w.arrowWidth,this.curvature=(t==null?void 0:t.curvature)??w.curvature,this.portCycleRadius=(t==null?void 0:t.cycleRadius)??w.cycleRadius,this.portCycleSmallRadius=(t==null?void 0:t.smallCycleRadius)??w.smallCycleRadius,this.detourDirection=(t==null?void 0:t.detourDirection)??w.detourDirection,this.detourDistance=(t==null?void 0:t.detourDistance)??w.detourDistance,this.hasSourceArrow=(t==null?void 0:t.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(t==null?void 0:t.hasTargetArrow)??w.hasTargetArrow;const o=(t==null?void 0:t.color)??w.color,r=(t==null?void 0:t.width)??w.width;this.svg.appendChild(this.group),this.line=F(o,r),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=L(o),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=L(o),this.group.appendChild(this.targetArrow))}render(t){const{x:o,y:r,width:i,height:s,flipX:h,flipY:c}=R(t.from,t.to);this.svg.style.transform=`translate(${o}px, ${r}px)`,this.svg.style.width=`${i}px`,this.svg.style.height=`${s}px`,this.group.style.transform=`scale(${h}, ${c})`;const d=N(t.from.direction,h,c),l=N(t.to.direction,h,c),a={x:i,y:s};let g,y=l,x=-this.arrowLength;if(t.from.portId===t.to.portId?(g=at({fromVect:d,radius:this.portCycleRadius,smallRadius:this.portCycleSmallRadius,arrowLength:this.arrowLength,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),y=d,x=this.arrowLength):t.from.nodeId===t.to.nodeId?g=ht({to:a,fromVect:d,toVect:l,flipX:h,flipY:c,arrowLength:this.arrowLength,detourDirection:this.detourDirection,detourDistance:this.detourDistance,curvature:this.curvature,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):g=st({to:a,fromVect:d,toVect:l,arrowLength:this.arrowLength,curvature:this.curvature,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",g),this.sourceArrow){const v=P(d,u,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=P(y,a,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}class _{constructor(t){n(this,"svg",V());n(this,"group",W());n(this,"line");n(this,"sourceArrow",null);n(this,"targetArrow",null);n(this,"arrowLength");n(this,"arrowWidth");n(this,"arrowOffset");n(this,"roundness");n(this,"cycleSquareSide");n(this,"detourDirection");n(this,"detourDistance");n(this,"hasSourceArrow");n(this,"hasTargetArrow");this.arrowLength=(t==null?void 0:t.arrowLength)??w.arrowLength,this.arrowWidth=(t==null?void 0:t.arrowWidth)??w.arrowWidth,this.arrowOffset=(t==null?void 0:t.arrowOffset)??w.arrowOffset,this.cycleSquareSide=(t==null?void 0:t.cycleSquareSide)??w.cycleSquareSide;const o=(t==null?void 0:t.roundness)??w.roundness;this.roundness=Math.min(o,this.arrowOffset,this.cycleSquareSide/2),this.detourDirection=(t==null?void 0:t.detourDirection)??w.detourDirection,this.detourDistance=(t==null?void 0:t.detourDistance)??w.detourDistance,this.hasSourceArrow=(t==null?void 0:t.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(t==null?void 0:t.hasTargetArrow)??w.hasTargetArrow;const r=(t==null?void 0:t.color)??w.color,i=(t==null?void 0:t.width)??w.width;this.svg.appendChild(this.group),this.line=F(r,i),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=L(r),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=L(r),this.group.appendChild(this.targetArrow))}render(t){const{x:o,y:r,width:i,height:s,flipX:h,flipY:c}=R(t.from,t.to);this.svg.style.transform=`translate(${o}px, ${r}px)`,this.svg.style.width=`${i}px`,this.svg.style.height=`${s}px`,this.group.style.transform=`scale(${h}, ${c})`;const d=N(t.from.direction,h,c),l=N(t.to.direction,h,c),a={x:i,y:s};let g,y=l,x=-this.arrowLength;if(t.from.portId===t.to.portId?(g=z({fromVect:d,arrowLength:this.arrowLength,side:this.cycleSquareSide,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),y=d,x=this.arrowLength):t.from.nodeId===t.to.nodeId?g=B({to:a,fromVect:d,toVect:l,flipX:h,flipY:c,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,detourDirection:this.detourDirection,detourDistance:this.detourDistance,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):g=ct({to:a,fromVect:d,toVect:l,flipX:h,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",g),this.sourceArrow){const v=P(d,u,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=P(y,a,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}class J{constructor(t){n(this,"svg",V());n(this,"group",W());n(this,"line");n(this,"sourceArrow",null);n(this,"targetArrow",null);n(this,"arrowLength");n(this,"arrowWidth");n(this,"arrowOffset");n(this,"roundness");n(this,"cycleSquareSide");n(this,"detourDirection");n(this,"detourDistance");n(this,"hasSourceArrow");n(this,"hasTargetArrow");this.arrowLength=(t==null?void 0:t.arrowLength)??w.arrowLength,this.arrowWidth=(t==null?void 0:t.arrowWidth)??w.arrowWidth,this.arrowOffset=(t==null?void 0:t.arrowOffset)??w.arrowOffset,this.cycleSquareSide=(t==null?void 0:t.cycleSquareSide)??w.cycleSquareSide;const o=(t==null?void 0:t.roundness)??w.roundness;this.roundness=Math.min(o,this.arrowOffset,this.cycleSquareSide/2),this.detourDirection=(t==null?void 0:t.detourDirection)??w.detourDirection,this.detourDistance=(t==null?void 0:t.detourDistance)??w.detourDistance,this.hasSourceArrow=(t==null?void 0:t.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(t==null?void 0:t.hasTargetArrow)??w.hasTargetArrow;const r=(t==null?void 0:t.color)??w.color,i=(t==null?void 0:t.width)??w.width;this.svg.appendChild(this.group),this.line=F(r,i),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=L(r),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=L(r),this.group.appendChild(this.targetArrow))}render(t){const{x:o,y:r,width:i,height:s,flipX:h,flipY:c}=R(t.from,t.to);this.svg.style.transform=`translate(${o}px, ${r}px)`,this.svg.style.width=`${i}px`,this.svg.style.height=`${s}px`,this.group.style.transform=`scale(${h}, ${c})`;const d=N(t.from.direction,h,c),l=N(t.to.direction,h,c),a={x:i,y:s};let g,y=l,x=-this.arrowLength;if(t.from.portId===t.to.portId?(g=z({fromVect:d,arrowLength:this.arrowLength,side:this.cycleSquareSide,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),y=d,x=this.arrowLength):t.from.nodeId===t.to.nodeId?g=B({to:a,fromVect:d,toVect:l,flipX:h,flipY:c,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,detourDirection:this.detourDirection,detourDistance:this.detourDistance,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):g=dt({to:a,fromVect:d,toVect:l,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",g),this.sourceArrow){const v=P(d,u,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=P(y,a,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}class Q{constructor(t){n(this,"svg",V());n(this,"group",W());n(this,"line");n(this,"sourceArrow",null);n(this,"targetArrow",null);n(this,"arrowLength");n(this,"arrowWidth");n(this,"arrowOffset");n(this,"roundness");n(this,"cycleSquareSide");n(this,"detourDirection");n(this,"detourDistance");n(this,"hasSourceArrow");n(this,"hasTargetArrow");this.arrowLength=(t==null?void 0:t.arrowLength)??w.arrowLength,this.arrowWidth=(t==null?void 0:t.arrowWidth)??w.arrowWidth,this.arrowOffset=(t==null?void 0:t.arrowOffset)??w.arrowOffset,this.cycleSquareSide=(t==null?void 0:t.cycleSquareSide)??w.cycleSquareSide;const o=(t==null?void 0:t.roundness)??w.roundness;this.roundness=Math.min(o,this.arrowOffset,this.cycleSquareSide/2),this.detourDirection=(t==null?void 0:t.detourDirection)??w.detourDirectionVertical,this.detourDistance=(t==null?void 0:t.detourDistance)??w.detourDistance,this.hasSourceArrow=(t==null?void 0:t.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(t==null?void 0:t.hasTargetArrow)??w.hasTargetArrow;const r=(t==null?void 0:t.color)??w.color,i=(t==null?void 0:t.width)??w.width;this.svg.appendChild(this.group),this.line=F(r,i),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=L(r),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=L(r),this.group.appendChild(this.targetArrow))}render(t){const{x:o,y:r,width:i,height:s,flipX:h,flipY:c}=R(t.from,t.to);this.svg.style.transform=`translate(${o}px, ${r}px)`,this.svg.style.width=`${i}px`,this.svg.style.height=`${s}px`,this.group.style.transform=`scale(${h}, ${c})`;const d=N(t.from.direction,h,c),l=N(t.to.direction,h,c),a={x:i,y:s};let g,y=l,x=-this.arrowLength;if(t.from.portId===t.to.portId?(g=z({fromVect:d,arrowLength:this.arrowLength,side:this.cycleSquareSide,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),y=d,x=this.arrowLength):t.from.nodeId===t.to.nodeId?g=B({to:a,fromVect:d,toVect:l,flipX:h,flipY:c,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,detourDirection:this.detourDirection,detourDistance:this.detourDistance,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):g=lt({to:a,fromVect:d,toVect:l,flipY:c,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",g),this.sourceArrow){const v=P(d,u,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=P(y,a,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}const gt=e=>{if(typeof e=="function")return e;switch(e==null?void 0:e.type){case"straight":return()=>new J({color:e.color,width:e.width,arrowLength:e.arrowLength,arrowWidth:e.arrowWidth,arrowOffset:e.arrowOffset,hasSourceArrow:e.hasSourceArrow,hasTargetArrow:e.hasTargetArrow,cycleSquareSide:e.cycleSquareSide,roundness:e.roundness,detourDistance:e.detourDistance,detourDirection:e.detourDirection});case"horizontal":return()=>new _({color:e.color,width:e.width,arrowLength:e.arrowLength,arrowWidth:e.arrowWidth,arrowOffset:e.arrowOffset,hasSourceArrow:e.hasSourceArrow,hasTargetArrow:e.hasTargetArrow,cycleSquareSide:e.cycleSquareSide,roundness:e.roundness,detourDistance:e.detourDistance,detourDirection:e.detourDirection});case"vertical":return()=>new Q({color:e.color,width:e.width,arrowLength:e.arrowLength,arrowWidth:e.arrowWidth,arrowOffset:e.arrowOffset,hasSourceArrow:e.hasSourceArrow,hasTargetArrow:e.hasTargetArrow,cycleSquareSide:e.cycleSquareSide,roundness:e.roundness,detourDistance:e.detourDistance,detourDirection:e.detourDirection});default:return()=>new K({color:e.color,width:e.width,arrowLength:e.arrowLength,arrowWidth:e.arrowWidth,hasSourceArrow:e.hasSourceArrow,hasTargetArrow:e.hasTargetArrow,cycleRadius:e.cycleRadius,smallCycleRadius:e.smallCycleRadius,curvature:e.curvature,detourDistance:e.detourDistance,detourDirection:e.detourDirection})}},G=e=>()=>e,Z=G(0),U=()=>{let e=0;return()=>e++},ut=(e,t)=>{let o=Z,r=Z;e==="incremental"&&(o=U()),t==="incremental"&&(r=U());const i=U();return e==="shared-incremental"&&(o=i),t==="shared-incremental"&&(r=i),typeof e=="number"&&(o=G(e)),typeof t=="number"&&(r=G(t)),typeof e=="function"&&(o=e),typeof t=="function"&&(r=t),{nodesPriorityFn:o,edgesPriorityFn:r}},wt=e=>{var o,r,i,s,h;const t=ut((o=e==null?void 0:e.nodes)==null?void 0:o.priority,(r=e==null?void 0:e.edges)==null?void 0:r.priority);return{nodes:{centerFn:((i=e==null?void 0:e.nodes)==null?void 0:i.centerFn)??E,priorityFn:t.nodesPriorityFn},ports:{direction:((s=e==null?void 0:e.ports)==null?void 0:s.direction)??0},edges:{shapeFactory:gt(((h=e==null?void 0:e.edges)==null?void 0:h.shape)??{}),priorityFn:t.edgesPriorityFn}}};class yt{constructor(){n(this,"nodes",new Map);n(this,"ports",new Map);n(this,"nodePorts",new Map);n(this,"portNodeId",new Map);n(this,"edges",new Map);n(this,"incommingEdges",new Map);n(this,"outcommingEdges",new Map);n(this,"cycleEdges",new Map)}addNode(t){this.nodes.set(t.nodeId,{element:t.element,x:t.x,y:t.y,centerFn:t.centerFn,priority:t.priority}),this.nodePorts.set(t.nodeId,new Map)}getAllNodeIds(){return Array.from(this.nodes.keys())}getNode(t){return this.nodes.get(t)}removeNode(t){this.nodes.delete(t),this.nodePorts.delete(t)}addPort(t){this.ports.set(t.portId,{element:t.element,direction:t.direction}),this.cycleEdges.set(t.portId,new Set),this.incommingEdges.set(t.portId,new Set),this.outcommingEdges.set(t.portId,new Set),this.portNodeId.set(t.portId,t.nodeId),this.nodePorts.get(t.nodeId).set(t.portId,t.element)}getPort(t){return this.ports.get(t)}getAllPortIds(){return Array.from(this.ports.keys())}getNodePortIds(t){const o=this.nodePorts.get(t);if(o!==void 0)return Array.from(o.keys())}getPortNodeId(t){return this.portNodeId.get(t)}removePort(t){const o=this.portNodeId.get(t);this.portNodeId.delete(t),this.nodePorts.get(o).delete(t),this.ports.delete(t)}addEdge(t){this.edges.set(t.edgeId,{from:t.from,to:t.to,shape:t.shape,priority:t.priority}),t.from!==t.to?(this.outcommingEdges.get(t.from).add(t.edgeId),this.incommingEdges.get(t.to).add(t.edgeId)):this.cycleEdges.get(t.from).add(t.edgeId)}updateEdgeFrom(t,o){const r=this.edges.get(t);this.removeEdge(t),this.addEdge({edgeId:t,from:o,to:r.to,shape:r.shape,priority:r.priority})}updateEdgeTo(t,o){const r=this.edges.get(t);this.removeEdge(t),this.addEdge({edgeId:t,from:r.from,to:o,shape:r.shape,priority:r.priority})}getAllEdgeIds(){return Array.from(this.edges.keys())}getEdge(t){return this.edges.get(t)}removeEdge(t){const o=this.edges.get(t),r=o.from,i=o.to;this.cycleEdges.get(r).delete(t),this.cycleEdges.get(i).delete(t),this.incommingEdges.get(r).delete(t),this.incommingEdges.get(i).delete(t),this.outcommingEdges.get(r).delete(t),this.outcommingEdges.get(i).delete(t),this.edges.delete(t)}clear(){this.nodes.clear(),this.ports.clear(),this.nodePorts.clear(),this.portNodeId.clear(),this.edges.clear(),this.incommingEdges.clear(),this.outcommingEdges.clear(),this.cycleEdges.clear()}getPortIncomingEdgeIds(t){return Array.from(this.incommingEdges.get(t))}getPortOutcomingEdgeIds(t){return Array.from(this.outcommingEdges.get(t))}getPortCycleEdgeIds(t){return Array.from(this.cycleEdges.get(t))}getPortAdjacentEdgeIds(t){return[...this.getPortIncomingEdgeIds(t),...this.getPortOutcomingEdgeIds(t),...this.getPortCycleEdgeIds(t)]}getNodeIncomingEdgeIds(t){const o=Array.from(this.nodePorts.get(t).keys());let r=[];return o.forEach(i=>{r=[...r,...this.getPortIncomingEdgeIds(i)]}),r}getNodeOutcomingEdgeIds(t){const o=Array.from(this.nodePorts.get(t).keys());let r=[];return o.forEach(i=>{r=[...r,...this.getPortOutcomingEdgeIds(i)]}),r}getNodeCycleEdgeIds(t){const o=Array.from(this.nodePorts.get(t).keys());let r=[];return o.forEach(i=>{r=[...r,...this.getPortCycleEdgeIds(i)]}),r}getNodeAdjacentEdgeIds(t){return[...this.getNodeIncomingEdgeIds(t),...this.getNodeOutcomingEdgeIds(t),...this.getNodeCycleEdgeIds(t)]}}const O=e=>({scale:1/e.scale,x:-e.x/e.scale,y:-e.y/e.scale}),q={scale:1,x:0,y:0};class ft{constructor(){n(this,"viewportMatrix",q);n(this,"contentMatrix",q)}getViewportMatrix(){return this.viewportMatrix}getContentMatrix(){return this.contentMatrix}patchViewportMatrix(t){this.viewportMatrix={scale:t.scale??this.viewportMatrix.scale,x:t.x??this.viewportMatrix.x,y:t.y??this.viewportMatrix.y},this.contentMatrix=O(this.viewportMatrix)}patchContentMatrix(t){this.contentMatrix={scale:t.scale??this.contentMatrix.scale,x:t.x??this.contentMatrix.x,y:t.y??this.contentMatrix.y},this.viewportMatrix=O(this.contentMatrix)}}class vt{constructor(t){this.transformer=t}getViewportMatrix(){return{...this.transformer.getViewportMatrix()}}getContentMatrix(){return{...this.transformer.getContentMatrix()}}}const xt=()=>{const e=document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.position="relative",e.style.overflow="hidden",e},St=()=>{const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="0",e.style.height="0",e},Et=()=>{const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.visibility="hidden",e};class At{constructor(t,o){n(this,"canvasWrapper",null);n(this,"host",xt());n(this,"container",St());n(this,"nodeIdToWrapperElementMap",new Map);n(this,"edgeIdToElementMap",new Map);this.graphStore=t,this.viewportTransformer=o,this.host.appendChild(this.container)}attach(t){this.detach(),this.canvasWrapper=t,this.canvasWrapper.appendChild(this.host)}detach(){this.canvasWrapper!==null&&(this.canvasWrapper.removeChild(this.host),this.canvasWrapper=null)}applyTransform(){const t=this.viewportTransformer.getContentMatrix();this.container.style.transform=`matrix(${t.scale}, 0, 0, ${t.scale}, ${t.x}, ${t.y})`}attachNode(t){const o=this.graphStore.getNode(t),r=Et();r.appendChild(o.element),this.container.appendChild(r),this.nodeIdToWrapperElementMap.set(t,r),this.updateNodeCoordinates(t),this.updateNodePriority(t),r.style.visibility="visible"}detachNode(t){const o=this.graphStore.getNode(t),r=this.nodeIdToWrapperElementMap.get(t);r.removeChild(o.element),this.container.removeChild(r),this.nodeIdToWrapperElementMap.delete(t)}attachEdge(t){const o=this.graphStore.getEdge(t);this.edgeIdToElementMap.set(t,o.shape.svg),this.container.appendChild(o.shape.svg),this.renderEdge(t),this.updateEdgePriority(t)}detachEdge(t){const o=this.graphStore.getEdge(t);this.container.removeChild(o.shape.svg),this.edgeIdToElementMap.delete(t)}clear(){this.edgeIdToElementMap.forEach((t,o)=>{this.detachEdge(o)}),this.nodeIdToWrapperElementMap.forEach((t,o)=>{this.detachNode(o)})}destroy(){this.clear(),this.detach(),this.host.removeChild(this.container)}updateNodeCoordinates(t){const o=this.nodeIdToWrapperElementMap.get(t),r=this.graphStore.getNode(t),{width:i,height:s}=r.element.getBoundingClientRect(),h=this.viewportTransformer.getViewportMatrix().scale,c=r.centerFn(i,s),d=r.x-h*c.x,l=r.y-h*c.y;o.style.transform=`translate(${d}px, ${l}px)`}updateNodePriority(t){const o=this.graphStore.getNode(t),r=this.nodeIdToWrapperElementMap.get(t);r.style.zIndex=`${o.priority}`}updateEdgeShape(t){const o=this.edgeIdToElementMap.get(t);this.container.removeChild(o);const r=this.graphStore.getEdge(t);this.edgeIdToElementMap.set(t,r.shape.svg),this.container.appendChild(r.shape.svg)}renderEdge(t){const o=this.graphStore.getEdge(t),r=this.graphStore.getPort(o.from),i=this.graphStore.getPort(o.to),s=r.element.getBoundingClientRect(),h=i.element.getBoundingClientRect(),c=this.host.getBoundingClientRect(),d=this.viewportTransformer.getViewportMatrix(),l={x:d.scale*(s.left-c.left)+d.x,y:d.scale*(s.top-c.top)+d.y},a={x:d.scale*(h.left-c.left)+d.x,y:d.scale*(h.top-c.top)+d.y},g={x:l.x,y:l.y,width:s.width*d.scale,height:s.height*d.scale,direction:r.direction,portId:o.from,nodeId:this.graphStore.getPortNodeId(o.from)},y={x:a.x,y:a.y,width:h.width*d.scale,height:h.height*d.scale,direction:i.direction,portId:o.to,nodeId:this.graphStore.getPortNodeId(o.to)};o.shape.render({from:g,to:y})}updateEdgePriority(t){const o=this.graphStore.getEdge(t);o.shape.svg.style.zIndex=`${o.priority}`}}class I{constructor(t){n(this,"counter",0);this.checkExists=t}create(t){if(t!==void 0)return t;for(;this.checkExists(this.counter);)this.counter++;return this.counter}reset(){this.counter=0}}class A extends Error{constructor(){super(...arguments);n(this,"name","HtmlGraphError")}}class Tt{constructor(t,o,r,i,s,h,c){n(this,"nodeIdGenerator",new I(t=>this.graphStore.getNode(t)!==void 0));n(this,"portIdGenerator",new I(t=>this.graphStore.getPort(t)!==void 0));n(this,"edgeIdGenerator",new I(t=>this.graphStore.getEdge(t)!==void 0));this.graphStore=t,this.htmlController=o,this.viewportTransformer=r,this.defaultNodesCenterFn=i,this.defaultPortsDirection=s,this.defaultNodesPriorityFn=h,this.defaultEdgesPriorityFn=c}attach(t){this.htmlController.attach(t)}detach(){this.htmlController.detach()}addNode(t){const o=this.nodeIdGenerator.create(t.nodeId);if(this.graphStore.getNode(o)!==void 0)throw new A("failed to add node with existing id");this.graphStore.addNode({nodeId:o,element:t.element,x:t.x,y:t.y,centerFn:t.centerFn??this.defaultNodesCenterFn,priority:t.priority??this.defaultNodesPriorityFn()}),this.htmlController.attachNode(o),Array.from(t.ports??[]).forEach(r=>{this.markPort({portId:r.id,element:r.element,nodeId:o,direction:r.direction})})}markPort(t){const o=this.portIdGenerator.create(t.portId);if(this.graphStore.getPort(o)!==void 0)throw new A("failed to add port with existing id");if(this.graphStore.getNode(t.nodeId)===void 0)throw new A("failed to set port on nonexisting node");this.graphStore.addPort({portId:o,element:t.element,nodeId:t.nodeId,direction:t.direction??this.defaultPortsDirection})}addEdge(t){const o=this.edgeIdGenerator.create(t.edgeId);if(this.graphStore.getEdge(o)!==void 0)throw new A("failed to add edge with existing id");if(this.graphStore.getPort(t.from)===void 0)throw new A("failed to add edge from nonexisting port");if(this.graphStore.getPort(t.to)===void 0)throw new A("failed to add edge to nonexisting port");this.graphStore.addEdge({edgeId:o,from:t.from,to:t.to,shape:t.shape,priority:t.priority??this.defaultEdgesPriorityFn()}),this.htmlController.attachEdge(o)}updateEdge(t){const o=this.graphStore.getEdge(t.edgeId);if(o===void 0)throw new A("failed to update nonexisting edge");t.shape!==void 0&&(o.shape=t.shape,this.htmlController.updateEdgeShape(t.edgeId)),t.priority!==void 0&&(o.priority=t.priority,this.htmlController.updateEdgePriority(t.edgeId)),t.from!==void 0&&this.graphStore.updateEdgeFrom(t.edgeId,t.from),t.to!==void 0&&this.graphStore.updateEdgeTo(t.edgeId,t.to),this.htmlController.renderEdge(t.edgeId)}updatePort(t,o){const r=this.graphStore.getPort(t);if(r===void 0)throw new A("failed to unset nonexisting port");r.direction=o.direction??r.direction,this.graphStore.getPortAdjacentEdgeIds(t).forEach(s=>{this.htmlController.renderEdge(s)})}updateNode(t,o){const r=this.graphStore.getNode(t);if(r===void 0)throw new A("failed to update nonexisting node");r.x=(o==null?void 0:o.x)??r.x,r.y=(o==null?void 0:o.y)??r.y,r.centerFn=(o==null?void 0:o.centerFn)??r.centerFn,r.priority=(o==null?void 0:o.priority)??r.priority,this.htmlController.updateNodeCoordinates(t),this.htmlController.updateNodePriority(t),this.graphStore.getNodeAdjacentEdgeIds(t).forEach(s=>{this.htmlController.renderEdge(s)})}removeEdge(t){if(this.graphStore.getEdge(t)===void 0)throw new A("failed to remove nonexisting edge");this.htmlController.detachEdge(t),this.graphStore.removeEdge(t)}unmarkPort(t){if(this.graphStore.getPort(t)===void 0)throw new A("failed to unset nonexisting port");this.graphStore.getPortAdjacentEdgeIds(t).forEach(o=>{this.removeEdge(o)}),this.graphStore.removePort(t)}removeNode(t){if(this.graphStore.getNode(t)===void 0)throw new A("failed to remove nonexisting node");this.graphStore.getNodePortIds(t).forEach(o=>{this.unmarkPort(o)}),this.htmlController.detachNode(t),this.graphStore.removeNode(t)}patchViewportMatrix(t){this.viewportTransformer.patchViewportMatrix(t),this.htmlController.applyTransform()}patchContentMatrix(t){this.viewportTransformer.patchContentMatrix(t),this.htmlController.applyTransform()}clear(){this.htmlController.clear(),this.graphStore.clear(),this.nodeIdGenerator.reset(),this.portIdGenerator.reset(),this.edgeIdGenerator.reset()}destroy(){this.clear(),this.htmlController.destroy()}}class Mt{constructor(t){this.graphStore=t}getNode(t){const o=this.graphStore.getNode(t);return o===void 0?null:{element:o.element,x:o.x,y:o.y,centerFn:o.centerFn,priority:o.priority}}getAllNodeIds(){return this.graphStore.getAllNodeIds()}getPort(t){const o=this.graphStore.getPort(t);return o===void 0?null:{element:o.element,direction:o.direction}}getAllPortIds(){return this.graphStore.getAllPortIds()}getNodePortIds(t){return this.graphStore.getNode(t)===void 0?null:this.graphStore.getNodePortIds(t)}getPortNodeId(t){return this.graphStore.getPortNodeId(t)??null}getAllEdgeIds(){return this.graphStore.getAllEdgeIds()}getEdge(t){const o=this.graphStore.getEdge(t);return o===void 0?null:{from:o.from,to:o.to,priority:o.priority}}getPortIncomingEdgeIds(t){return this.graphStore.getPort(t)===void 0?null:this.graphStore.getPortIncomingEdgeIds(t)}getPortOutcomingEdgeIds(t){return this.graphStore.getPort(t)===void 0?null:this.graphStore.getPortOutcomingEdgeIds(t)}getPortCycleEdgeIds(t){return this.graphStore.getPort(t)===void 0?null:this.graphStore.getPortCycleEdgeIds(t)}getPortAdjacentEdgeIds(t){return this.graphStore.getPort(t)===void 0?null:this.graphStore.getPortAdjacentEdgeIds(t)}getNodeIncomingEdgeIds(t){return this.graphStore.getNode(t)===void 0?null:this.graphStore.getNodeIncomingEdgeIds(t)}getNodeOutcomingEdgeIds(t){return this.graphStore.getNode(t)===void 0?null:this.graphStore.getNodeOutcomingEdgeIds(t)}getNodeCycleEdgeIds(t){return this.graphStore.getNode(t)===void 0?null:this.graphStore.getNodeCycleEdgeIds(t)}getNodeAdjacentEdgeIds(t){return this.graphStore.getNode(t)===void 0?null:this.graphStore.getNodeAdjacentEdgeIds(t)}}class tt{constructor(t){n(this,"transformation");n(this,"model");n(this,"canvasController");n(this,"edgeShapeFactory");this.apiOptions=t;const o=wt(this.apiOptions),r=new ft,i=new yt;this.model=new Mt(i),this.transformation=new vt(r);const s=new At(i,r);this.canvasController=new Tt(i,s,r,o.nodes.centerFn,o.ports.direction,o.nodes.priorityFn,o.edges.priorityFn),this.edgeShapeFactory=o.edges.shapeFactory}attach(t){return this.canvasController.attach(t),this}detach(){return this.canvasController.detach(),this}addNode(t){return this.canvasController.addNode({nodeId:t.id,element:t.element,x:t.x,y:t.y,ports:t.ports,centerFn:t.centerFn,priority:t.priority}),this}updateNode(t,o){return this.canvasController.updateNode(t,{x:o==null?void 0:o.x,y:o==null?void 0:o.y,priority:o==null?void 0:o.priority,centerFn:o==null?void 0:o.centerFn}),this}removeNode(t){return this.canvasController.removeNode(t),this}addEdge(t){return this.canvasController.addEdge({edgeId:t.id,from:t.from,to:t.to,shape:t.shape??this.edgeShapeFactory(),priority:t.priority}),this}updateEdge(t,o){return this.canvasController.updateEdge({edgeId:t,shape:o==null?void 0:o.shape,priority:o==null?void 0:o.priority,from:o==null?void 0:o.from,to:o==null?void 0:o.to}),this}removeEdge(t){return this.canvasController.removeEdge(t),this}markPort(t){return this.canvasController.markPort({portId:t.id,element:t.element,nodeId:t.nodeId,direction:t.direction}),this}updatePort(t,o){return this.canvasController.updatePort(t,{direction:o==null?void 0:o.direction}),this}unmarkPort(t){return this.canvasController.unmarkPort(t),this}patchViewportMatrix(t){return this.canvasController.patchViewportMatrix(t),this}patchContentMatrix(t){return this.canvasController.patchContentMatrix(t),this}clear(){return this.canvasController.clear(),this}destroy(){this.clear(),this.canvasController.destroy()}}const Y=(e,t,o)=>{const{x:r,y:i,width:s,height:h}=e.getBoundingClientRect();return t>=r&&t<=r+s&&o>=i&&o<=i+h},X=(e,t,o)=>t>=0&&t<=e.innerWidth&&o>=0&&o<=e.innerHeight,k=(e,t)=>{t!==null?e.style.cursor=t:e.style.removeProperty("cursor")},Ct=e=>{var g,y,x,v,M,T;const t=((g=e==null?void 0:e.events)==null?void 0:g.onNodeDrag)??(()=>{}),o=((y=e==null?void 0:e.events)==null?void 0:y.onBeforeNodeDrag)??(()=>!0),r=((x=e==null?void 0:e.events)==null?void 0:x.onNodeDragFinished)??(()=>{}),i=(e==null?void 0:e.moveOnTop)===!1,s=(v=e==null?void 0:e.mouse)==null?void 0:v.dragCursor,h=s!==void 0?s:"grab",c=(M=e==null?void 0:e.mouse)==null?void 0:M.mouseDownEventVerifier,d=c!==void 0?c:C=>C.button===0,l=(T=e==null?void 0:e.mouse)==null?void 0:T.mouseUpEventVerifier;return{freezePriority:i,dragCursor:h,mouseDownEventVerifier:d,mouseUpEventVerifier:l!==void 0?l:C=>C.button===0,onNodeDrag:t,onBeforeNodeDrag:o,onNodeDragFinished:r}};class et{constructor(t,o){n(this,"model");n(this,"transformation");n(this,"maxNodePriority",0);n(this,"nodes",new Map);n(this,"grabbedNodeId",null);n(this,"nodeIdGenerator",new I(t=>this.nodes.has(t)));n(this,"element",null);n(this,"onWindowMouseMove",t=>{if(this.element!==null&&(!Y(this.element,t.clientX,t.clientY)||!X(this.window,t.clientX,t.clientY))){this.cancelMouseDrag();return}this.grabbedNodeId!==null&&this.dragNode(this.grabbedNodeId,t.movementX,t.movementY)});n(this,"onWindowMouseUp",t=>{this.options.mouseUpEventVerifier(t)&&this.cancelMouseDrag()});n(this,"onWindowTouchMove",t=>{if(t.touches.length!==1)return;const o=t.touches[0];if(this.element!==null&&(!Y(this.element,o.clientX,o.clientY)||!X(this.window,o.clientX,o.clientY))){this.cancelTouchDrag();return}if(this.grabbedNodeId!==null&&this.previousTouchCoords!==null){const r=o.clientX-this.previousTouchCoords.x,i=o.clientY-this.previousTouchCoords.y;this.dragNode(this.grabbedNodeId,r,i),this.previousTouchCoords={x:t.touches[0].clientX,y:t.touches[0].clientY}}});n(this,"onWindowTouchFinish",()=>{this.previousTouchCoords=null,this.cancelTouchDrag()});n(this,"previousTouchCoords",null);n(this,"window",window);n(this,"options");this.canvas=t,this.transformation=this.canvas.transformation,this.model=this.canvas.model,this.options=Ct(o??{})}attach(t){return this.detach(),this.element=t,this.canvas.attach(this.element),this}detach(){return this.canvas.detach(),this.element!==null&&(this.element=null),this}addNode(t){const o=this.nodeIdGenerator.create(t.id);this.canvas.addNode({...t,id:o}),this.updateMaxNodePriority(o);const r=s=>{if(this.element===null||!this.options.mouseDownEventVerifier(s))return;const h=this.model.getNode(o);this.options.onBeforeNodeDrag({nodeId:o,element:t.element,x:h.x,y:h.y})&&(s.stopImmediatePropagation(),this.grabbedNodeId=o,k(this.element,this.options.dragCursor),this.moveNodeOnTop(o),this.window.addEventListener("mouseup",this.onWindowMouseUp),this.window.addEventListener("mousemove",this.onWindowMouseMove))},i=s=>{if(s.touches.length!==1)return;s.stopImmediatePropagation(),this.previousTouchCoords={x:s.touches[0].clientX,y:s.touches[0].clientY};const h=this.model.getNode(o);this.options.onBeforeNodeDrag({nodeId:o,element:t.element,x:h.x,y:h.y})&&(this.grabbedNodeId=o,this.moveNodeOnTop(o),this.window.addEventListener("touchmove",this.onWindowTouchMove),this.window.addEventListener("touchend",this.onWindowTouchFinish),this.window.addEventListener("touchcancel",this.onWindowTouchFinish))};return this.nodes.set(o,{element:t.element,onMouseDown:r,onTouchStart:i}),t.element.addEventListener("mousedown",r),t.element.addEventListener("touchstart",i),this}updateNode(t,o){return this.canvas.updateNode(t,o),this.updateMaxNodePriority(t),this}removeNode(t){const o=this.nodes.get(t);return o!==void 0&&(o.element.removeEventListener("mousedown",o.onMouseDown),o.element.removeEventListener("touchstart",o.onTouchStart)),this.nodes.delete(t),this.canvas.removeNode(t),this}markPort(t){return this.canvas.markPort(t),this}updatePort(t,o){return this.canvas.updatePort(t,o),this}unmarkPort(t){return this.canvas.unmarkPort(t),this}addEdge(t){return this.canvas.addEdge(t),this}updateEdge(t,o){return this.canvas.updateEdge(t,o),this}removeEdge(t){return this.canvas.removeEdge(t),this}patchViewportMatrix(t){return this.canvas.patchViewportMatrix(t),this}patchContentMatrix(t){return this.canvas.patchContentMatrix(t),this}clear(){return this.canvas.clear(),this.nodes.forEach(t=>{t.element.removeEventListener("mousedown",t.onMouseDown),t.element.removeEventListener("touchstart",t.onTouchStart)}),this.nodes.clear(),this.maxNodePriority=0,this}destroy(){this.detach(),this.clear(),this.removeMouseDragListeners(),this.removeTouchDragListeners(),this.canvas.destroy()}dragNode(t,o,r){const i=this.model.getNode(t);if(i===null)return;const s=this.canvas.transformation.getContentMatrix(),h=s.scale*i.x+s.x,c=s.scale*i.y+s.y,d=h+o,l=c+r,a=this.canvas.transformation.getViewportMatrix(),g=a.scale*d+a.x,y=a.scale*l+a.y;this.canvas.updateNode(t,{x:g,y}),this.options.onNodeDrag({nodeId:t,element:i.element,x:g,y})}updateMaxNodePriority(t){const o=this.model.getNode(t).priority;this.maxNodePriority=Math.max(this.maxNodePriority,o)}moveNodeOnTop(t){if(this.options.freezePriority)return;this.maxNodePriority+=2,this.updateNode(t,{priority:this.maxNodePriority});const o=this.maxNodePriority-1;this.model.getNodeAdjacentEdgeIds(t).forEach(i=>{this.updateEdge(i,{priority:o})})}cancelMouseDrag(){const t=this.model.getNode(this.grabbedNodeId);t!==null&&this.options.onNodeDragFinished({nodeId:this.grabbedNodeId,element:t.element,x:t.x,y:t.y}),this.grabbedNodeId=null,this.element!==null&&k(this.element,null),this.removeMouseDragListeners()}removeMouseDragListeners(){this.window.removeEventListener("mouseup",this.onWindowMouseUp),this.window.removeEventListener("mousemove",this.onWindowMouseMove)}cancelTouchDrag(){this.previousTouchCoords=null;const t=this.model.getNode(this.grabbedNodeId);t!==null&&this.options.onNodeDragFinished({nodeId:this.grabbedNodeId,element:t.element,x:t.x,y:t.y}),this.grabbedNodeId=null,this.removeTouchDragListeners()}removeTouchDragListeners(){this.window.removeEventListener("touchmove",this.onWindowTouchMove),this.window.removeEventListener("touchend",this.onWindowTouchFinish),this.window.removeEventListener("touchcancel",this.onWindowTouchFinish)}}const Nt=e=>{const t=e.minX!==null?e.minX:-1/0,o=e.maxX!==null?e.maxX:1/0,r=e.minY!==null?e.minY:-1/0,i=e.maxY!==null?e.maxY:1/0;return s=>{let h=s.nextTransform.x,c=s.nextTransform.y;h<t&&h<s.prevTransform.x&&(h=Math.min(s.prevTransform.x,t));const d=s.canvasWidth*s.prevTransform.scale,l=o-d;h>l&&h>s.prevTransform.x&&(h=Math.max(s.prevTransform.x,l)),c<r&&c<s.prevTransform.y&&(c=Math.min(s.prevTransform.y,r));const a=s.canvasHeight*s.prevTransform.scale,g=i-a;return c>g&&c>s.prevTransform.y&&(c=Math.max(s.prevTransform.y,g)),{scale:s.nextTransform.scale,x:h,y:c}}},Pt=e=>{const t=e.maxContentScale,o=e.minContentScale,r=t!==null?1/t:0,i=o!==null?1/o:1/0;return s=>{const h=s.prevTransform,c=s.nextTransform;let d=c.scale,l=c.x,a=c.y;if(c.scale>i&&c.scale>h.scale){d=Math.max(h.scale,i),l=h.x,a=h.y;const g=(d-h.scale)/(c.scale-h.scale);l=h.x+(c.x-h.x)*g,a=h.y+(c.y-h.y)*g}if(c.scale<r&&c.scale<h.scale){d=Math.min(h.scale,r),l=h.x,a=h.y;const g=(d-h.scale)/(c.scale-h.scale);l=h.x+(c.x-h.x)*g,a=h.y+(c.y-h.y)*g}return{scale:d,x:l,y:a}}},Lt=e=>t=>e.reduce((o,r)=>r({prevTransform:t.prevTransform,nextTransform:o,canvasWidth:t.canvasWidth,canvasHeight:t.canvasHeight}),t.nextTransform),ot=e=>{if(typeof e=="function")return e;switch(e.type){case"scale-limit":return Pt({minContentScale:e.minContentScale??0,maxContentScale:e.maxContentScale??1/0});case"shift-limit":return Nt({minX:e.minX??-1/0,maxX:e.maxX??1/0,minY:e.minY??-1/0,maxY:e.maxY??1/0})}},mt=e=>{var v,M,T,C,j,$,b,p,nt;const t=(v=e==null?void 0:e.scale)==null?void 0:v.mouseWheelSensitivity,o=t!==void 0?t:1.2,r=e==null?void 0:e.transformPreprocessor;let i;r!==void 0?Array.isArray(r)?i=Lt(r.map(m=>ot(m))):i=ot(r):i=m=>m.nextTransform;const s=((M=e==null?void 0:e.shift)==null?void 0:M.cursor)!==void 0?e.shift.cursor:"grab",h=((T=e==null?void 0:e.events)==null?void 0:T.onBeforeTransformChange)??(()=>{}),c=((C=e==null?void 0:e.events)==null?void 0:C.onTransformChange)??(()=>{}),d=(j=e==null?void 0:e.shift)==null?void 0:j.mouseDownEventVerifier,l=d!==void 0?d:m=>m.button===0,a=($=e==null?void 0:e.shift)==null?void 0:$.mouseUpEventVerifier,g=a!==void 0?a:m=>m.button===0,y=(b=e==null?void 0:e.scale)==null?void 0:b.mouseWheelEventVerifier,x=y!==void 0?y:()=>!0;return{wheelSensitivity:o,onTransformStarted:((p=e==null?void 0:e.events)==null?void 0:p.onTransformStarted)??(()=>{}),onTransformFinished:((nt=e==null?void 0:e.events)==null?void 0:nt.onTransformFinished)??(()=>{}),onBeforeTransformChange:h,onTransformChange:c,transformPreprocessor:i,shiftCursor:s,mouseDownEventVerifier:l,mouseUpEventVerifier:g,mouseWheelEventVerifier:x}},H=e=>{const t=[],o=e.touches.length;for(let c=0;c<o;c++)t.push([e.touches[c].clientX,e.touches[c].clientY]);const r=t.reduce((c,d)=>[c[0]+d[0],c[1]+d[1]],[0,0]),i=[r[0]/o,r[1]/o],h=t.map(c=>[c[0]-i[0],c[1]-i[1]]).reduce((c,d)=>c+Math.sqrt(d[0]*d[0]+d[1]*d[1]),0);return{x:i[0],y:i[1],scale:h/o,touchesCnt:o,touches:t}},Dt=(e,t,o)=>({scale:e.scale,x:e.x+e.scale*t,y:e.y+e.scale*o}),It=(e,t,o,r)=>({scale:e.scale*t,x:e.scale*(1-t)*o+e.x,y:e.scale*(1-t)*r+e.y});class rt{constructor(t,o){n(this,"model");n(this,"transformation");n(this,"element",null);n(this,"prevTouches",null);n(this,"window",window);n(this,"onMouseDown",t=>{this.element===null||!this.options.mouseDownEventVerifier(t)||(k(this.element,this.options.shiftCursor),this.window.addEventListener("mousemove",this.onWindowMouseMove),this.window.addEventListener("mouseup",this.onWindowMouseUp),this.options.onTransformStarted())});n(this,"onWindowMouseMove",t=>{if(this.element===null||!Y(this.element,t.clientX,t.clientY)||!X(this.window,t.clientX,t.clientY)){this.stopMouseDrag();return}const o=-t.movementX,r=-t.movementY;this.moveViewport(this.element,o,r)});n(this,"onWindowMouseUp",t=>{this.element===null||!this.options.mouseUpEventVerifier(t)||this.stopMouseDrag()});n(this,"onWheelScroll",t=>{if(!this.options.mouseWheelEventVerifier(t))return;t.preventDefault(),this.options.onTransformStarted();const{left:o,top:r}=this.element.getBoundingClientRect(),i=t.clientX-o,s=t.clientY-r,c=1/(t.deltaY<0?this.options.wheelSensitivity:1/this.options.wheelSensitivity);this.scaleViewport(this.element,c,i,s),this.options.onTransformFinished()});n(this,"onTouchStart",t=>{this.prevTouches=H(t),this.window.addEventListener("touchmove",this.onWindowTouchMove),this.window.addEventListener("touchend",this.onWindowTouchFinish),this.window.addEventListener("touchcancel",this.onWindowTouchFinish),this.options.onTransformStarted()});n(this,"onWindowTouchMove",t=>{const o=this.element;if(o===null)return;const r=H(t);if(!r.touches.every(s=>Y(o,s[0],s[1])&&X(this.window,s[0],s[1]))){this.stopTouchDrag();return}if((r.touchesCnt===1||r.touchesCnt===2)&&this.moveViewport(o,-(r.x-this.prevTouches.x),-(r.y-this.prevTouches.y)),r.touchesCnt===2){const{left:s,top:h}=o.getBoundingClientRect(),c=this.prevTouches.x-s,d=this.prevTouches.y-h,a=1/(r.scale/this.prevTouches.scale);this.scaleViewport(o,a,c,d)}this.prevTouches=r});n(this,"onWindowTouchFinish",t=>{t.touches.length>0?this.prevTouches=H(t):this.stopTouchDrag()});n(this,"observer",new ResizeObserver(()=>{const t=this.canvas.transformation.getViewportMatrix(),{width:o,height:r}=this.element.getBoundingClientRect(),i=this.options.transformPreprocessor({prevTransform:t,nextTransform:t,canvasWidth:o,canvasHeight:r});this.canvas.patchViewportMatrix(i),this.options.onTransformChange()}));n(this,"options");this.canvas=t,this.options=mt(o),this.transformation=this.canvas.transformation,this.model=this.canvas.model}attach(t){return this.detach(),this.element=t,this.observer.observe(this.element),this.element.addEventListener("mousedown",this.onMouseDown),this.element.addEventListener("wheel",this.onWheelScroll),this.element.addEventListener("touchstart",this.onTouchStart),this.canvas.attach(this.element),this}detach(){return this.canvas.detach(),this.element!==null&&(this.observer.unobserve(this.element),this.element.removeEventListener("mousedown",this.onMouseDown),this.element.removeEventListener("wheel",this.onWheelScroll),this.element.removeEventListener("touchstart",this.onTouchStart),this.element=null),this}addNode(t){return this.canvas.addNode(t),this}updateNode(t,o){return this.canvas.updateNode(t,o),this}removeNode(t){return this.canvas.removeNode(t),this}markPort(t){return this.canvas.markPort(t),this}updatePort(t,o){return this.canvas.updatePort(t,o),this}unmarkPort(t){return this.canvas.unmarkPort(t),this}addEdge(t){return this.canvas.addEdge(t),this}updateEdge(t,o){return this.canvas.updateEdge(t,o),this}removeEdge(t){return this.canvas.removeEdge(t),this}patchViewportMatrix(t){return this.canvas.patchViewportMatrix(t),this}patchContentMatrix(t){return this.canvas.patchContentMatrix(t),this}clear(){return this.canvas.clear(),this}destroy(){this.detach(),this.removeMouseDragListeners(),this.removeTouchDragListeners(),this.canvas.destroy()}moveViewport(t,o,r){this.options.onBeforeTransformChange();const i=this.transformation.getViewportMatrix(),s=Dt(i,o,r),{width:h,height:c}=t.getBoundingClientRect(),d=this.options.transformPreprocessor({prevTransform:i,nextTransform:s,canvasWidth:h,canvasHeight:c});this.canvas.patchViewportMatrix(d),this.options.onTransformChange()}scaleViewport(t,o,r,i){this.options.onBeforeTransformChange();const s=this.canvas.transformation.getViewportMatrix(),h=It(s,o,r,i),{width:c,height:d}=t.getBoundingClientRect(),l=this.options.transformPreprocessor({prevTransform:s,nextTransform:h,canvasWidth:c,canvasHeight:d});this.canvas.patchViewportMatrix(l),this.options.onTransformChange()}stopMouseDrag(){this.element!==null&&k(this.element,null),this.removeMouseDragListeners(),this.options.onTransformFinished()}removeMouseDragListeners(){this.window.removeEventListener("mousemove",this.onWindowMouseMove),this.window.removeEventListener("mouseup",this.onWindowMouseUp)}stopTouchDrag(){this.prevTouches=null,this.removeTouchDragListeners(),this.options.onTransformFinished()}removeTouchDragListeners(){this.window.removeEventListener("touchmove",this.onWindowTouchMove),this.window.removeEventListener("touchend",this.onWindowTouchFinish),this.window.removeEventListener("touchcancel",this.onWindowTouchFinish)}}class $t{constructor(){n(this,"keyMap",new Map);n(this,"valueMap",new Map)}set(t,o){this.keyMap.set(t,o),this.valueMap.set(o,t)}hasKey(t){return this.keyMap.has(t)}hasValue(t){return this.valueMap.has(t)}getByKey(t){return this.keyMap.get(t)}getByValue(t){return this.valueMap.get(t)}deleteByKey(t){const o=this.keyMap.get(t);o!==void 0&&this.valueMap.delete(o),this.keyMap.delete(t)}deleteByValue(t){const o=this.valueMap.get(t);o!==void 0&&this.keyMap.delete(o),this.valueMap.delete(t)}forEach(t){this.keyMap.forEach((o,r)=>{t(o,r)})}clear(){this.keyMap.clear(),this.valueMap.clear()}}class it{constructor(t){n(this,"transformation");n(this,"model");n(this,"nodes",new $t);n(this,"nodeIdGenerator",new I(t=>this.nodes.hasKey(t)));n(this,"nodesResizeObserver");this.canvas=t,this.nodesResizeObserver=new window.ResizeObserver(o=>{o.forEach(r=>{const i=r.target;this.reactNodeChange(i)})}),this.transformation=this.canvas.transformation,this.model=this.canvas.model}attach(t){return this.canvas.attach(t),this}detach(){return this.canvas.detach(),this}addNode(t){const o=this.nodeIdGenerator.create(t.id);return this.canvas.addNode({...t,id:o}),this.nodes.set(o,t.element),this.nodesResizeObserver.observe(t.element),this}updateNode(t,o){return this.canvas.updateNode(t,o),this}removeNode(t){this.canvas.removeNode(t);const o=this.nodes.getByKey(t);return this.nodes.deleteByKey(t),this.nodesResizeObserver.unobserve(o),this}markPort(t){return this.canvas.markPort(t),this}updatePort(t,o){return this.canvas.updatePort(t,o),this}unmarkPort(t){return this.canvas.unmarkPort(t),this}addEdge(t){return this.canvas.addEdge(t),this}updateEdge(t,o){return this.canvas.updateEdge(t,o),this}removeEdge(t){return this.canvas.removeEdge(t),this}patchViewportMatrix(t){return this.canvas.patchViewportMatrix(t),this}patchContentMatrix(t){return this.canvas.patchContentMatrix(t),this}clear(){return this.canvas.clear(),this.nodesResizeObserver.disconnect(),this.nodes.clear(),this}destroy(){this.clear(),this.canvas.destroy()}reactNodeChange(t){const o=this.nodes.getByValue(t);this.canvas.updateNode(o),this.model.getNodeAdjacentEdgeIds(o).forEach(i=>{this.canvas.updateEdge(i)})}}class bt{constructor(){n(this,"coreOptions");n(this,"dragOptions");n(this,"transformOptions");n(this,"isDraggable",!1);n(this,"isTransformable",!1);n(this,"hasResizeReactiveNodes",!1)}setOptions(t){return this.coreOptions=t,this}setUserDraggableNodes(t){return this.isDraggable=!0,this.dragOptions=t,this}setUserTransformableCanvas(t){return this.isTransformable=!0,this.transformOptions=t,this}setResizeReactiveNodes(){return this.hasResizeReactiveNodes=!0,this}build(){let t=new tt(this.coreOptions);return this.hasResizeReactiveNodes&&(t=new it(t)),this.isDraggable&&(t=new et(t,this.dragOptions)),this.isTransformable&&(t=new rt(t,this.transformOptions)),t}}S.BezierEdgeShape=K,S.CanvasCore=tt,S.HorizontalEdgeShape=_,S.HtmlGraphBuilder=bt,S.HtmlGraphError=A,S.ResizeReactiveNodesCanvas=it,S.StraightEdgeShape=J,S.UserDraggableNodesCanvas=et,S.UserTransformableCanvas=rt,S.VerticalEdgeShape=Q,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
1
+ (function(A,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(A=typeof globalThis<"u"?globalThis:A||self,E(A.HtmlGraph={}))})(this,function(A){"use strict";var ke=Object.defineProperty;var Ye=(A,E,y)=>E in A?ke(A,E,{enumerable:!0,configurable:!0,writable:!0,value:y}):A[E]=y;var i=(A,E,y)=>Ye(A,typeof E!="symbol"?E+"":E,y);const E=(t,e)=>({x:t/2,y:e/2}),y=(t,e,r)=>({x:e.x*t.x-e.y*t.y+((1-e.x)*r.x+e.y*r.y),y:e.y*t.x+e.x*t.y+((1-e.x)*r.y-e.y*r.x)}),p=(t,e,r)=>({x:e*Math.cos(t),y:r*Math.sin(t)}),g={x:0,y:0},b=(t,e,r,o)=>{const d=[g,{x:r,y:o},{x:r,y:-o}].map(a=>y(a,t,g)).map(a=>({x:a.x+e.x,y:a.y+e.y})),s=`M ${d[0].x} ${d[0].y}`,h=`L ${d[1].x} ${d[1].y}`,c=`L ${d[2].x} ${d[2].y}`;return`${s} ${h} ${c}`},L=(t,e)=>{const r=[];if(t.length>0&&r.push(`M ${t[0].x} ${t[0].y}`),t.length===2&&r.push(`L ${t[1].x} ${t[1].y}`),t.length>2){const o=t.length-1;let n=0,d=0,s=0;t.forEach((h,c)=>{let a=0,l=0,u=0;const f=c>0,x=c<o,v=f&&x;if(f&&(a=-n,l=-d,u=s),x){const W=t[c+1];n=W.x-h.x,d=W.y-h.y,s=Math.sqrt(n*n+d*d)}const C=s!==0?Math.min((v?e:0)/s,c<o-1?.5:1):0,T=v?{x:h.x+n*C,y:h.y+d*C}:h,$=u!==0?Math.min((v?e:0)/u,c>1?.5:1):0,I=v?{x:h.x+a*$,y:h.y+l*$}:h;c>0&&r.push(`L ${I.x} ${I.y}`),v&&r.push(`C ${h.x} ${h.y} ${h.x} ${h.y} ${T.x} ${T.y}`)})}return r.join(" ")},R=()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.style.pointerEvents="none",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.overflow="visible",t},F=()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.style.transformOrigin="50% 50%",t},B=(t,e)=>{const r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("stroke",t),r.setAttribute("stroke-width",`${e}`),r.setAttribute("fill","none"),r},M=t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",t),e},k=(t,e)=>{const r={x:t.x+t.width/2,y:t.y+t.height/2},o={x:e.x+e.width/2,y:e.y+e.height/2},n=Math.min(r.x,o.x),d=Math.min(r.y,o.y),s=Math.abs(o.x-r.x),h=Math.abs(o.y-r.y),c=r.x<=o.x?1:-1,a=r.y<=o.y?1:-1;return{x:n,y:d,width:s,height:h,flipX:c,flipY:a}},ge=t=>{const e=y({x:t.arrowLength,y:g.y},t.fromVect,g),r=y({x:t.to.x-t.arrowLength,y:t.to.y},t.toVect,t.to),o={x:e.x+t.fromVect.x*t.curvature,y:e.y+t.fromVect.y*t.curvature},n={x:r.x-t.toVect.x*t.curvature,y:r.y-t.toVect.y*t.curvature},d=`M ${e.x} ${e.y} C ${o.x} ${o.y}, ${n.x} ${n.y}, ${r.x} ${r.y}`,s=t.hasSourceArrow?"":`M ${g.x} ${g.y} L ${e.x} ${e.y} `,h=t.hasTargetArrow?"":` M ${r.x} ${r.y} L ${t.to.x} ${t.to.y}`;return`${s}${d}${h}`},we=t=>{const e=t.hasSourceArrow?y({x:t.arrowLength,y:g.y},t.fromVect,g):g,r=t.hasTargetArrow?y({x:t.to.x-t.arrowLength,y:t.to.y},t.toVect,t.to):t.to,o=t.arrowLength,n=Math.cos(t.detourDirection)*t.detourDistance,d=Math.sin(t.detourDirection)*t.detourDistance,s=n*t.flipX,h=d*t.flipY,c=y({x:o,y:g.y},t.fromVect,g),a={x:c.x+s,y:c.y+h},l=y({x:t.to.x-o,y:t.to.y},t.toVect,t.to),u={x:l.x+s,y:l.y+h},f={x:(a.x+u.x)/2,y:(a.y+u.y)/2},x={x:c.x+t.curvature*t.fromVect.x,y:c.y+t.curvature*t.fromVect.y},v={x:l.x-t.curvature*t.toVect.x,y:l.y-t.curvature*t.toVect.y},N={x:c.x+s,y:c.y+h},C={x:l.x+s,y:l.y+h};return[`M ${e.x} ${e.y}`,`L ${c.x} ${c.y}`,`C ${x.x} ${x.y} ${N.x} ${N.y} ${f.x} ${f.y}`,`C ${C.x} ${C.y} ${v.x} ${v.y} ${l.x} ${l.y}`,`L ${r.x} ${r.y}`].join(" ")},fe=t=>{const e=t.hasSourceArrow?y({x:t.arrowLength,y:g.y},t.fromVect,g):g,r=t.hasTargetArrow?y({x:t.to.x-t.arrowLength,y:t.to.y},t.toVect,t.to):t.to,o=t.arrowLength+t.arrowOffset,n=o-t.roundness,d=y({x:n,y:g.y},t.fromVect,g),s=y({x:t.to.x-n,y:t.to.y},t.toVect,t.to),h=Math.max((d.x+s.x)/2,o),c=t.to.y/2,a={x:t.flipX>0?h:-o,y:d.y},l={x:a.x,y:c},u={x:t.flipX>0?t.to.x-h:t.to.x+o,y:s.y},f={x:u.x,y:c};return L([e,d,a,l,f,u,s,r],t.roundness)},j=t=>{const e=t.hasSourceArrow?y({x:t.arrowLength,y:g.y},t.fromVect,g):g,r=t.hasTargetArrow?y({x:t.to.x-t.arrowLength,y:t.to.y},t.toVect,t.to):t.to,o=t.arrowLength+t.arrowOffset,n=y({x:o,y:g.y},t.fromVect,g),d=Math.cos(t.detourDirection)*t.detourDistance,s=Math.sin(t.detourDirection)*t.detourDistance,h=d*t.flipX,c=s*t.flipY,a={x:n.x+h,y:n.y+c},l=y({x:t.to.x-o,y:t.to.y},t.toVect,t.to),u={x:l.x+h,y:l.y+c};return L([e,n,a,u,l,r],t.roundness)},ye=t=>{const e=t.hasSourceArrow?y({x:t.arrowLength,y:g.y},t.fromVect,g):g,r=t.hasTargetArrow?y({x:t.to.x-t.arrowLength,y:t.to.y},t.toVect,t.to):t.to,o=t.arrowLength+t.arrowOffset,n=y({x:o,y:g.y},t.fromVect,g),d=y({x:t.to.x-o,y:t.to.y},t.toVect,t.to);return L([e,n,d,r],t.roundness)},ve=t=>{const e=t.hasSourceArrow?y({x:t.arrowLength,y:g.y},t.fromVect,g):g,r=t.hasTargetArrow?y({x:t.to.x-t.arrowLength,y:t.to.y},t.toVect,t.to):t.to,o=t.arrowLength+t.arrowOffset,n=o-t.roundness,d=y({x:n,y:g.y},t.fromVect,g),s=y({x:t.to.x-n,y:t.to.y},t.toVect,t.to),h=Math.max((d.y+s.y)/2,o),c=t.to.x/2,a={x:d.x,y:t.flipY>0?h:-o},l={x:c,y:a.y},u={x:s.x,y:t.flipY>0?t.to.y-h:t.to.y+o},f={x:c,y:u.y};return L([e,d,a,l,f,u,s,r],t.roundness)},H=t=>{const e=t.arrowOffset,r=t.side,o=t.arrowLength+e,n=o+2*r,s=[{x:t.arrowLength,y:g.y},{x:o,y:g.y},{x:o,y:t.side},{x:n,y:t.side},{x:n,y:-t.side},{x:o,y:-t.side},{x:o,y:g.y},{x:t.arrowLength,y:g.y}].map(c=>y(c,t.fromVect,g)),h=`M ${g.x} ${g.y} L ${s[0].x} ${s[0].y} `;return`${t.hasSourceArrow||t.hasTargetArrow?"":h}${L(s,t.roundness)}`},Ae=t=>{const e=t.smallRadius,r=t.radius,o=Math.sqrt(e*e+r*r),n=e+r,d=t.arrowLength+o*(1-r/n),s=e*r/n,c=[{x:t.arrowLength,y:g.y},{x:d,y:s},{x:d,y:-s}].map(u=>y(u,t.fromVect,g)),a=[`M ${c[0].x} ${c[0].y}`,`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,`A ${r} ${r} 0 1 0 ${c[2].x} ${c[2].y}`,`A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`].join(" "),l=`M 0 0 L ${c[0].x} ${c[0].y} `;return`${t.hasSourceArrow||t.hasTargetArrow?"":l}${a}`},w=Object.freeze({color:"#777777",width:1,arrowLength:15,arrowWidth:4,arrowOffset:15,hasSourceArrow:!1,hasTargetArrow:!1,cycleRadius:30,cycleSquareSide:30,roundness:10,detourDistance:100,detourDirection:-Math.PI/2,detourDirectionVertical:0,smallCycleRadius:15,curvature:90});class K{constructor(e){i(this,"svg",R());i(this,"group",F());i(this,"line");i(this,"sourceArrow",null);i(this,"targetArrow",null);i(this,"arrowLength");i(this,"arrowWidth");i(this,"curvature");i(this,"portCycleRadius");i(this,"portCycleSmallRadius");i(this,"detourDirection");i(this,"detourDistance");i(this,"hasSourceArrow");i(this,"hasTargetArrow");this.arrowLength=(e==null?void 0:e.arrowLength)??w.arrowLength,this.arrowWidth=(e==null?void 0:e.arrowWidth)??w.arrowWidth,this.curvature=(e==null?void 0:e.curvature)??w.curvature,this.portCycleRadius=(e==null?void 0:e.cycleRadius)??w.cycleRadius,this.portCycleSmallRadius=(e==null?void 0:e.smallCycleRadius)??w.smallCycleRadius,this.detourDirection=(e==null?void 0:e.detourDirection)??w.detourDirection,this.detourDistance=(e==null?void 0:e.detourDistance)??w.detourDistance,this.hasSourceArrow=(e==null?void 0:e.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(e==null?void 0:e.hasTargetArrow)??w.hasTargetArrow;const r=(e==null?void 0:e.color)??w.color,o=(e==null?void 0:e.width)??w.width;this.svg.appendChild(this.group),this.line=B(r,o),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=M(r),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=M(r),this.group.appendChild(this.targetArrow))}render(e){const{x:r,y:o,width:n,height:d,flipX:s,flipY:h}=k(e.from,e.to);this.svg.style.transform=`translate(${r}px, ${o}px)`,this.svg.style.width=`${n}px`,this.svg.style.height=`${d}px`,this.group.style.transform=`scale(${s}, ${h})`;const c=p(e.from.direction,s,h),a=p(e.to.direction,s,h),l={x:n,y:d};let u,f=a,x=-this.arrowLength;if(e.from.portId===e.to.portId?(u=Ae({fromVect:c,radius:this.portCycleRadius,smallRadius:this.portCycleSmallRadius,arrowLength:this.arrowLength,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),f=c,x=this.arrowLength):e.from.nodeId===e.to.nodeId?u=we({to:l,fromVect:c,toVect:a,flipX:s,flipY:h,arrowLength:this.arrowLength,detourDirection:this.detourDirection,detourDistance:this.detourDistance,curvature:this.curvature,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):u=ge({to:l,fromVect:c,toVect:a,arrowLength:this.arrowLength,curvature:this.curvature,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",u),this.sourceArrow){const v=b(c,g,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=b(f,l,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}class _{constructor(e){i(this,"svg",R());i(this,"group",F());i(this,"line");i(this,"sourceArrow",null);i(this,"targetArrow",null);i(this,"arrowLength");i(this,"arrowWidth");i(this,"arrowOffset");i(this,"roundness");i(this,"cycleSquareSide");i(this,"detourDirection");i(this,"detourDistance");i(this,"hasSourceArrow");i(this,"hasTargetArrow");this.arrowLength=(e==null?void 0:e.arrowLength)??w.arrowLength,this.arrowWidth=(e==null?void 0:e.arrowWidth)??w.arrowWidth,this.arrowOffset=(e==null?void 0:e.arrowOffset)??w.arrowOffset,this.cycleSquareSide=(e==null?void 0:e.cycleSquareSide)??w.cycleSquareSide;const r=(e==null?void 0:e.roundness)??w.roundness;this.roundness=Math.min(r,this.arrowOffset,this.cycleSquareSide/2),this.detourDirection=(e==null?void 0:e.detourDirection)??w.detourDirection,this.detourDistance=(e==null?void 0:e.detourDistance)??w.detourDistance,this.hasSourceArrow=(e==null?void 0:e.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(e==null?void 0:e.hasTargetArrow)??w.hasTargetArrow;const o=(e==null?void 0:e.color)??w.color,n=(e==null?void 0:e.width)??w.width;this.svg.appendChild(this.group),this.line=B(o,n),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=M(o),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=M(o),this.group.appendChild(this.targetArrow))}render(e){const{x:r,y:o,width:n,height:d,flipX:s,flipY:h}=k(e.from,e.to);this.svg.style.transform=`translate(${r}px, ${o}px)`,this.svg.style.width=`${n}px`,this.svg.style.height=`${d}px`,this.group.style.transform=`scale(${s}, ${h})`;const c=p(e.from.direction,s,h),a=p(e.to.direction,s,h),l={x:n,y:d};let u,f=a,x=-this.arrowLength;if(e.from.portId===e.to.portId?(u=H({fromVect:c,arrowLength:this.arrowLength,side:this.cycleSquareSide,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),f=c,x=this.arrowLength):e.from.nodeId===e.to.nodeId?u=j({to:l,fromVect:c,toVect:a,flipX:s,flipY:h,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,detourDirection:this.detourDirection,detourDistance:this.detourDistance,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):u=fe({to:l,fromVect:c,toVect:a,flipX:s,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",u),this.sourceArrow){const v=b(c,g,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=b(f,l,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}class J{constructor(e){i(this,"svg",R());i(this,"group",F());i(this,"line");i(this,"sourceArrow",null);i(this,"targetArrow",null);i(this,"arrowLength");i(this,"arrowWidth");i(this,"arrowOffset");i(this,"roundness");i(this,"cycleSquareSide");i(this,"detourDirection");i(this,"detourDistance");i(this,"hasSourceArrow");i(this,"hasTargetArrow");this.arrowLength=(e==null?void 0:e.arrowLength)??w.arrowLength,this.arrowWidth=(e==null?void 0:e.arrowWidth)??w.arrowWidth,this.arrowOffset=(e==null?void 0:e.arrowOffset)??w.arrowOffset,this.cycleSquareSide=(e==null?void 0:e.cycleSquareSide)??w.cycleSquareSide;const r=(e==null?void 0:e.roundness)??w.roundness;this.roundness=Math.min(r,this.arrowOffset,this.cycleSquareSide/2),this.detourDirection=(e==null?void 0:e.detourDirection)??w.detourDirection,this.detourDistance=(e==null?void 0:e.detourDistance)??w.detourDistance,this.hasSourceArrow=(e==null?void 0:e.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(e==null?void 0:e.hasTargetArrow)??w.hasTargetArrow;const o=(e==null?void 0:e.color)??w.color,n=(e==null?void 0:e.width)??w.width;this.svg.appendChild(this.group),this.line=B(o,n),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=M(o),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=M(o),this.group.appendChild(this.targetArrow))}render(e){const{x:r,y:o,width:n,height:d,flipX:s,flipY:h}=k(e.from,e.to);this.svg.style.transform=`translate(${r}px, ${o}px)`,this.svg.style.width=`${n}px`,this.svg.style.height=`${d}px`,this.group.style.transform=`scale(${s}, ${h})`;const c=p(e.from.direction,s,h),a=p(e.to.direction,s,h),l={x:n,y:d};let u,f=a,x=-this.arrowLength;if(e.from.portId===e.to.portId?(u=H({fromVect:c,arrowLength:this.arrowLength,side:this.cycleSquareSide,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),f=c,x=this.arrowLength):e.from.nodeId===e.to.nodeId?u=j({to:l,fromVect:c,toVect:a,flipX:s,flipY:h,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,detourDirection:this.detourDirection,detourDistance:this.detourDistance,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):u=ye({to:l,fromVect:c,toVect:a,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",u),this.sourceArrow){const v=b(c,g,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=b(f,l,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}class Q{constructor(e){i(this,"svg",R());i(this,"group",F());i(this,"line");i(this,"sourceArrow",null);i(this,"targetArrow",null);i(this,"arrowLength");i(this,"arrowWidth");i(this,"arrowOffset");i(this,"roundness");i(this,"cycleSquareSide");i(this,"detourDirection");i(this,"detourDistance");i(this,"hasSourceArrow");i(this,"hasTargetArrow");this.arrowLength=(e==null?void 0:e.arrowLength)??w.arrowLength,this.arrowWidth=(e==null?void 0:e.arrowWidth)??w.arrowWidth,this.arrowOffset=(e==null?void 0:e.arrowOffset)??w.arrowOffset,this.cycleSquareSide=(e==null?void 0:e.cycleSquareSide)??w.cycleSquareSide;const r=(e==null?void 0:e.roundness)??w.roundness;this.roundness=Math.min(r,this.arrowOffset,this.cycleSquareSide/2),this.detourDirection=(e==null?void 0:e.detourDirection)??w.detourDirectionVertical,this.detourDistance=(e==null?void 0:e.detourDistance)??w.detourDistance,this.hasSourceArrow=(e==null?void 0:e.hasSourceArrow)??w.hasSourceArrow,this.hasTargetArrow=(e==null?void 0:e.hasTargetArrow)??w.hasTargetArrow;const o=(e==null?void 0:e.color)??w.color,n=(e==null?void 0:e.width)??w.width;this.svg.appendChild(this.group),this.line=B(o,n),this.group.appendChild(this.line),this.hasSourceArrow&&(this.sourceArrow=M(o),this.group.appendChild(this.sourceArrow)),this.hasTargetArrow&&(this.targetArrow=M(o),this.group.appendChild(this.targetArrow))}render(e){const{x:r,y:o,width:n,height:d,flipX:s,flipY:h}=k(e.from,e.to);this.svg.style.transform=`translate(${r}px, ${o}px)`,this.svg.style.width=`${n}px`,this.svg.style.height=`${d}px`,this.group.style.transform=`scale(${s}, ${h})`;const c=p(e.from.direction,s,h),a=p(e.to.direction,s,h),l={x:n,y:d};let u,f=a,x=-this.arrowLength;if(e.from.portId===e.to.portId?(u=H({fromVect:c,arrowLength:this.arrowLength,side:this.cycleSquareSide,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),f=c,x=this.arrowLength):e.from.nodeId===e.to.nodeId?u=j({to:l,fromVect:c,toVect:a,flipX:s,flipY:h,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,detourDirection:this.detourDirection,detourDistance:this.detourDistance,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}):u=ve({to:l,fromVect:c,toVect:a,flipY:h,arrowLength:this.arrowLength,arrowOffset:this.arrowOffset,roundness:this.roundness,hasSourceArrow:this.hasSourceArrow,hasTargetArrow:this.hasTargetArrow}),this.line.setAttribute("d",u),this.sourceArrow){const v=b(c,g,this.arrowLength,this.arrowWidth);this.sourceArrow.setAttribute("d",v)}if(this.targetArrow){const v=b(f,l,x,this.arrowWidth);this.targetArrow.setAttribute("d",v)}}}const xe=t=>{if(typeof t=="function")return t;switch(t==null?void 0:t.type){case"straight":return()=>new J({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,arrowOffset:t.arrowOffset,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleSquareSide:t.cycleSquareSide,roundness:t.roundness,detourDistance:t.detourDistance,detourDirection:t.detourDirection});case"horizontal":return()=>new _({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,arrowOffset:t.arrowOffset,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleSquareSide:t.cycleSquareSide,roundness:t.roundness,detourDistance:t.detourDistance,detourDirection:t.detourDirection});case"vertical":return()=>new Q({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,arrowOffset:t.arrowOffset,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleSquareSide:t.cycleSquareSide,roundness:t.roundness,detourDistance:t.detourDistance,detourDirection:t.detourDirection});default:return()=>new K({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleRadius:t.cycleRadius,smallCycleRadius:t.smallCycleRadius,curvature:t.curvature,detourDistance:t.detourDistance,detourDirection:t.detourDirection})}},U=t=>()=>t,Y=U(0),D=()=>{let t=0;return()=>t++},Ee=(t,e)=>{let r=Y,o=Y;t==="incremental"&&(r=D()),e==="incremental"&&(o=D());const n=D();return t==="shared-incremental"&&(r=n),e==="shared-incremental"&&(o=n),typeof t=="number"&&(r=U(t)),typeof e=="number"&&(o=U(e)),typeof t=="function"&&(r=t),typeof e=="function"&&(o=e),{nodesPriorityFn:r,edgesPriorityFn:o}},Se=t=>{var r,o,n,d,s;const e=Ee((r=t==null?void 0:t.nodes)==null?void 0:r.priority,(o=t==null?void 0:t.edges)==null?void 0:o.priority);return{nodes:{centerFn:((n=t==null?void 0:t.nodes)==null?void 0:n.centerFn)??E,priorityFn:e.nodesPriorityFn},ports:{direction:((d=t==null?void 0:t.ports)==null?void 0:d.direction)??0},edges:{shapeFactory:xe(((s=t==null?void 0:t.edges)==null?void 0:s.shape)??{}),priorityFn:e.edgesPriorityFn}}};class ee{constructor(){i(this,"nodes",new Map);i(this,"ports",new Map);i(this,"nodePorts",new Map);i(this,"portNodeId",new Map);i(this,"edges",new Map);i(this,"incommingEdges",new Map);i(this,"outcommingEdges",new Map);i(this,"cycleEdges",new Map)}addNode(e){this.nodes.set(e.nodeId,{element:e.element,x:e.x,y:e.y,centerFn:e.centerFn,priority:e.priority}),this.nodePorts.set(e.nodeId,new Map)}getAllNodeIds(){return Array.from(this.nodes.keys())}getNode(e){return this.nodes.get(e)}removeNode(e){this.nodes.delete(e),this.nodePorts.delete(e)}addPort(e){this.ports.set(e.portId,{element:e.element,direction:e.direction}),this.cycleEdges.set(e.portId,new Set),this.incommingEdges.set(e.portId,new Set),this.outcommingEdges.set(e.portId,new Set),this.portNodeId.set(e.portId,e.nodeId),this.nodePorts.get(e.nodeId).set(e.portId,e.element)}getPort(e){return this.ports.get(e)}getAllPortIds(){return Array.from(this.ports.keys())}getNodePortIds(e){const r=this.nodePorts.get(e);if(r!==void 0)return Array.from(r.keys())}getPortNodeId(e){return this.portNodeId.get(e)}removePort(e){const r=this.portNodeId.get(e);this.portNodeId.delete(e),this.nodePorts.get(r).delete(e),this.ports.delete(e)}addEdge(e){this.edges.set(e.edgeId,{from:e.from,to:e.to,shape:e.shape,priority:e.priority}),e.from!==e.to?(this.outcommingEdges.get(e.from).add(e.edgeId),this.incommingEdges.get(e.to).add(e.edgeId)):this.cycleEdges.get(e.from).add(e.edgeId)}updateEdgeFrom(e,r){const o=this.edges.get(e);this.removeEdge(e),this.addEdge({edgeId:e,from:r,to:o.to,shape:o.shape,priority:o.priority})}updateEdgeTo(e,r){const o=this.edges.get(e);this.removeEdge(e),this.addEdge({edgeId:e,from:o.from,to:r,shape:o.shape,priority:o.priority})}getAllEdgeIds(){return Array.from(this.edges.keys())}getEdge(e){return this.edges.get(e)}removeEdge(e){const r=this.edges.get(e),o=r.from,n=r.to;this.cycleEdges.get(o).delete(e),this.cycleEdges.get(n).delete(e),this.incommingEdges.get(o).delete(e),this.incommingEdges.get(n).delete(e),this.outcommingEdges.get(o).delete(e),this.outcommingEdges.get(n).delete(e),this.edges.delete(e)}clear(){this.edges.clear(),this.incommingEdges.clear(),this.outcommingEdges.clear(),this.cycleEdges.clear(),this.ports.clear(),this.nodePorts.clear(),this.portNodeId.clear(),this.nodes.clear()}getPortIncomingEdgeIds(e){return Array.from(this.incommingEdges.get(e))}getPortOutcomingEdgeIds(e){return Array.from(this.outcommingEdges.get(e))}getPortCycleEdgeIds(e){return Array.from(this.cycleEdges.get(e))}getPortAdjacentEdgeIds(e){return[...this.getPortIncomingEdgeIds(e),...this.getPortOutcomingEdgeIds(e),...this.getPortCycleEdgeIds(e)]}getNodeIncomingEdgeIds(e){const r=Array.from(this.nodePorts.get(e).keys());let o=[];return r.forEach(n=>{o=[...o,...this.getPortIncomingEdgeIds(n)]}),o}getNodeOutcomingEdgeIds(e){const r=Array.from(this.nodePorts.get(e).keys());let o=[];return r.forEach(n=>{o=[...o,...this.getPortOutcomingEdgeIds(n)]}),o}getNodeCycleEdgeIds(e){const r=Array.from(this.nodePorts.get(e).keys());let o=[];return r.forEach(n=>{o=[...o,...this.getPortCycleEdgeIds(n)]}),o}getNodeAdjacentEdgeIds(e){return[...this.getNodeIncomingEdgeIds(e),...this.getNodeOutcomingEdgeIds(e),...this.getNodeCycleEdgeIds(e)]}}class me{constructor(){i(this,"callbacks",new Set)}subscribe(e){this.callbacks.add(e)}unsubscribe(e){this.callbacks.delete(e)}emit(e){this.callbacks.forEach(r=>{r(e)})}}const m=()=>{const t=new me;return[t,t]},te=t=>({scale:1/t.scale,x:-t.x/t.scale,y:-t.y/t.scale}),re={scale:1,x:0,y:0};class oe{constructor(){i(this,"viewportMatrix",re);i(this,"contentMatrix",re);i(this,"emitter");i(this,"onAfterUpdate");[this.emitter,this.onAfterUpdate]=m()}getViewportMatrix(){return this.viewportMatrix}getContentMatrix(){return this.contentMatrix}patchViewportMatrix(e){this.viewportMatrix={scale:e.scale??this.viewportMatrix.scale,x:e.x??this.viewportMatrix.x,y:e.y??this.viewportMatrix.y},this.contentMatrix=te(this.viewportMatrix),this.emitter.emit()}patchContentMatrix(e){this.contentMatrix={scale:e.scale??this.contentMatrix.scale,x:e.x??this.contentMatrix.x,y:e.y??this.contentMatrix.y},this.viewportMatrix=te(this.contentMatrix),this.emitter.emit()}}class ie{constructor(e){this.transformer=e}getViewportMatrix(){return{...this.transformer.getViewportMatrix()}}getContentMatrix(){return{...this.transformer.getContentMatrix()}}}const Ce=()=>{const t=document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="relative",t.style.overflow="hidden",t},Ne=()=>{const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="0",t.style.height="0",t},Te=()=>{const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.visibility="hidden",t};class ne{constructor(e,r){i(this,"canvasWrapper",null);i(this,"host",Ce());i(this,"container",Ne());i(this,"nodeIdToWrapperElementMap",new Map);i(this,"edgeIdToElementMap",new Map);this.graphStore=e,this.viewportTransformer=r,this.host.appendChild(this.container)}attach(e){this.detach(),this.canvasWrapper=e,this.canvasWrapper.appendChild(this.host)}detach(){this.canvasWrapper!==null&&(this.canvasWrapper.removeChild(this.host),this.canvasWrapper=null)}applyTransform(){const e=this.viewportTransformer.getContentMatrix();this.container.style.transform=`matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`}attachNode(e){const r=this.graphStore.getNode(e),o=Te();o.appendChild(r.element),this.container.appendChild(o),this.nodeIdToWrapperElementMap.set(e,o),this.updateNodeCoordinates(e),this.updateNodePriority(e),o.style.visibility="visible"}detachNode(e){const r=this.graphStore.getNode(e),o=this.nodeIdToWrapperElementMap.get(e);o.removeChild(r.element),this.container.removeChild(o),this.nodeIdToWrapperElementMap.delete(e)}attachEdge(e){const r=this.graphStore.getEdge(e);this.edgeIdToElementMap.set(e,r.shape.svg),this.container.appendChild(r.shape.svg),this.renderEdge(e),this.updateEdgePriority(e)}detachEdge(e){const r=this.graphStore.getEdge(e);this.container.removeChild(r.shape.svg),this.edgeIdToElementMap.delete(e)}clear(){this.edgeIdToElementMap.forEach((e,r)=>{this.detachEdge(r)}),this.nodeIdToWrapperElementMap.forEach((e,r)=>{this.detachNode(r)})}destroy(){this.clear(),this.detach(),this.host.removeChild(this.container)}updateNodeCoordinates(e){const r=this.nodeIdToWrapperElementMap.get(e),o=this.graphStore.getNode(e),{width:n,height:d}=o.element.getBoundingClientRect(),s=this.viewportTransformer.getViewportMatrix().scale,h=o.centerFn(n,d),c=o.x-s*h.x,a=o.y-s*h.y;r.style.transform=`translate(${c}px, ${a}px)`}updateNodePriority(e){const r=this.graphStore.getNode(e),o=this.nodeIdToWrapperElementMap.get(e);o.style.zIndex=`${r.priority}`}updateEdgeShape(e){const r=this.edgeIdToElementMap.get(e);this.container.removeChild(r);const o=this.graphStore.getEdge(e);this.edgeIdToElementMap.set(e,o.shape.svg),this.container.appendChild(o.shape.svg)}renderEdge(e){const r=this.graphStore.getEdge(e),o=this.graphStore.getPort(r.from),n=this.graphStore.getPort(r.to),d=o.element.getBoundingClientRect(),s=n.element.getBoundingClientRect(),h=this.host.getBoundingClientRect(),c=this.viewportTransformer.getViewportMatrix(),a={x:c.scale*(d.left-h.left)+c.x,y:c.scale*(d.top-h.top)+c.y},l={x:c.scale*(s.left-h.left)+c.x,y:c.scale*(s.top-h.top)+c.y},u={x:a.x,y:a.y,width:d.width*c.scale,height:d.height*c.scale,direction:o.direction,portId:r.from,nodeId:this.graphStore.getPortNodeId(r.from)},f={x:l.x,y:l.y,width:s.width*c.scale,height:s.height*c.scale,direction:n.direction,portId:r.to,nodeId:this.graphStore.getPortNodeId(r.to)};r.shape.render({from:u,to:f})}updateEdgePriority(e){const r=this.graphStore.getEdge(e);r.shape.svg.style.zIndex=`${r.priority}`}}class V{constructor(e){i(this,"counter",0);this.checkExists=e}create(e){if(e!==void 0)return e;for(;this.checkExists(this.counter);)this.counter++;return this.counter}reset(){this.counter=0}}class S extends Error{constructor(){super(...arguments);i(this,"name","HtmlGraphError")}}class se{constructor(e,r){i(this,"nodeIdGenerator",new V(e=>this.graphStore.getNode(e)!==void 0));i(this,"portIdGenerator",new V(e=>this.graphStore.getPort(e)!==void 0));i(this,"edgeIdGenerator",new V(e=>this.graphStore.getEdge(e)!==void 0));i(this,"onAfterNodeAdded");i(this,"onAfterNodeAddedEmitter");i(this,"onAfterEdgeAdded");i(this,"onAfterEdgeAddedEmitter");i(this,"onAfterEdgeShapeUpdated");i(this,"onAfterEdgeShapeUpdatedEmitter");i(this,"onAfterEdgePriorityUpdated");i(this,"onAfterEdgePriorityUpdatedEmitter");i(this,"onAfterEdgeUpdated");i(this,"onAfterEdgeUpdatedEmitter");i(this,"onAfterPortUpdated");i(this,"onAfterPortUpdatedEmitter");i(this,"onAfterNodePriorityUpdated");i(this,"onAfterNodePriorityUpdatedEmitter");i(this,"onAfterNodeUpdated");i(this,"onAfterNodeUpdatedEmitter");i(this,"onBeforeEdgeRemoved");i(this,"onBeforeEdgeRemovedEmitter");i(this,"onBeforeNodeRemoved");i(this,"onBeforeNodeRemovedEmitter");this.graphStore=e,this.options=r,[this.onAfterNodeAddedEmitter,this.onAfterNodeAdded]=m(),[this.onAfterEdgeAddedEmitter,this.onAfterEdgeAdded]=m(),[this.onAfterEdgeShapeUpdatedEmitter,this.onAfterEdgeShapeUpdated]=m(),[this.onAfterEdgePriorityUpdatedEmitter,this.onAfterEdgePriorityUpdated]=m(),[this.onAfterEdgeUpdatedEmitter,this.onAfterEdgeUpdated]=m(),[this.onAfterPortUpdatedEmitter,this.onAfterPortUpdated]=m(),[this.onAfterNodePriorityUpdatedEmitter,this.onAfterNodePriorityUpdated]=m(),[this.onAfterNodeUpdatedEmitter,this.onAfterNodeUpdated]=m(),[this.onBeforeEdgeRemovedEmitter,this.onBeforeEdgeRemoved]=m(),[this.onBeforeNodeRemovedEmitter,this.onBeforeNodeRemoved]=m()}addNode(e){const r=this.nodeIdGenerator.create(e.id);if(this.graphStore.getNode(r)!==void 0)throw new S("failed to add node with existing id");this.graphStore.addNode({nodeId:r,element:e.element,x:e.x,y:e.y,centerFn:e.centerFn??this.options.nodes.centerFn,priority:e.priority??this.options.nodes.priorityFn()}),this.onAfterNodeAddedEmitter.emit(r),Array.from(e.ports??[]).forEach(o=>{this.markPort({id:o.id,element:o.element,nodeId:r,direction:o.direction})})}markPort(e){const r=this.portIdGenerator.create(e.id);if(this.graphStore.getPort(r)!==void 0)throw new S("failed to add port with existing id");if(this.graphStore.getNode(e.nodeId)===void 0)throw new S("failed to set port on nonexisting node");this.graphStore.addPort({portId:r,element:e.element,nodeId:e.nodeId,direction:e.direction??this.options.ports.direction})}addEdge(e){const r=this.edgeIdGenerator.create(e.id);if(this.graphStore.getEdge(r)!==void 0)throw new S("failed to add edge with existing id");if(this.graphStore.getPort(e.from)===void 0)throw new S("failed to add edge from nonexisting port");if(this.graphStore.getPort(e.to)===void 0)throw new S("failed to add edge to nonexisting port");this.graphStore.addEdge({edgeId:r,from:e.from,to:e.to,shape:e.shape??this.options.edges.shapeFactory(),priority:e.priority??this.options.edges.priorityFn()}),this.onAfterEdgeAddedEmitter.emit(r)}updateEdge(e,r){const o=this.graphStore.getEdge(e);if(o===void 0)throw new S("failed to update nonexisting edge");r.shape!==void 0&&(o.shape=r.shape,this.onAfterEdgeShapeUpdatedEmitter.emit(e)),r.from!==void 0&&this.graphStore.updateEdgeFrom(e,r.from),r.to!==void 0&&this.graphStore.updateEdgeTo(e,r.to),this.onAfterEdgeUpdatedEmitter.emit(e),r.priority!==void 0&&(o.priority=r.priority,this.onAfterEdgePriorityUpdatedEmitter.emit(e))}updatePort(e,r){const o=this.graphStore.getPort(e);if(o===void 0)throw new S("failed to unset nonexisting port");o.direction=r.direction??o.direction,this.onAfterPortUpdatedEmitter.emit(e)}updateNode(e,r){const o=this.graphStore.getNode(e);if(o===void 0)throw new S("failed to update nonexisting node");o.x=(r==null?void 0:r.x)??o.x,o.y=(r==null?void 0:r.y)??o.y,o.centerFn=r.centerFn??o.centerFn,this.onAfterNodeUpdatedEmitter.emit(e),r.priority!==void 0&&(o.priority=r.priority,this.onAfterNodePriorityUpdatedEmitter.emit(e))}removeEdge(e){if(this.graphStore.getEdge(e)===void 0)throw new S("failed to remove nonexisting edge");this.onBeforeEdgeRemovedEmitter.emit(e),this.graphStore.removeEdge(e)}unmarkPort(e){if(this.graphStore.getPort(e)===void 0)throw new S("failed to unset nonexisting port");this.graphStore.getPortAdjacentEdgeIds(e).forEach(r=>{this.removeEdge(r)}),this.graphStore.removePort(e)}removeNode(e){if(this.graphStore.getNode(e)===void 0)throw new S("failed to remove nonexisting node");this.graphStore.getNodePortIds(e).forEach(r=>{this.unmarkPort(r)}),this.onBeforeNodeRemovedEmitter.emit(e),this.graphStore.removeNode(e)}clear(){this.graphStore.clear(),this.nodeIdGenerator.reset(),this.portIdGenerator.reset(),this.edgeIdGenerator.reset()}}class he{constructor(e){this.graphStore=e}getNode(e){const r=this.graphStore.getNode(e);return r===void 0?null:{element:r.element,x:r.x,y:r.y,centerFn:r.centerFn,priority:r.priority}}getAllNodeIds(){return this.graphStore.getAllNodeIds()}getPort(e){const r=this.graphStore.getPort(e);return r===void 0?null:{element:r.element,direction:r.direction}}getAllPortIds(){return this.graphStore.getAllPortIds()}getNodePortIds(e){return this.graphStore.getNode(e)===void 0?null:this.graphStore.getNodePortIds(e)}getPortNodeId(e){return this.graphStore.getPortNodeId(e)??null}getAllEdgeIds(){return this.graphStore.getAllEdgeIds()}getEdge(e){const r=this.graphStore.getEdge(e);return r===void 0?null:{from:r.from,to:r.to,priority:r.priority}}getPortIncomingEdgeIds(e){return this.graphStore.getPort(e)===void 0?null:this.graphStore.getPortIncomingEdgeIds(e)}getPortOutcomingEdgeIds(e){return this.graphStore.getPort(e)===void 0?null:this.graphStore.getPortOutcomingEdgeIds(e)}getPortCycleEdgeIds(e){return this.graphStore.getPort(e)===void 0?null:this.graphStore.getPortCycleEdgeIds(e)}getPortAdjacentEdgeIds(e){return this.graphStore.getPort(e)===void 0?null:this.graphStore.getPortAdjacentEdgeIds(e)}getNodeIncomingEdgeIds(e){return this.graphStore.getNode(e)===void 0?null:this.graphStore.getNodeIncomingEdgeIds(e)}getNodeOutcomingEdgeIds(e){return this.graphStore.getNode(e)===void 0?null:this.graphStore.getNodeOutcomingEdgeIds(e)}getNodeCycleEdgeIds(e){return this.graphStore.getNode(e)===void 0?null:this.graphStore.getNodeCycleEdgeIds(e)}getNodeAdjacentEdgeIds(e){return this.graphStore.getNode(e)===void 0?null:this.graphStore.getNodeAdjacentEdgeIds(e)}}class pe{constructor(e){i(this,"transformation");i(this,"model");i(this,"internalTransformation");i(this,"internalModel");i(this,"graphStoreController");i(this,"htmlController");i(this,"onAfterNodeAdded",e=>{this.htmlController.attachNode(e)});i(this,"onAfterEdgeAdded",e=>{this.htmlController.attachEdge(e)});i(this,"onAfterEdgeShapeUpdated",e=>{this.htmlController.updateEdgeShape(e)});i(this,"onAfterEdgePriorityUpdated",e=>{this.htmlController.updateEdgePriority(e)});i(this,"onAfterEdgeUpdated",e=>{this.htmlController.renderEdge(e)});i(this,"onAfterPortUpdated",e=>{this.internalModel.getPortAdjacentEdgeIds(e).forEach(o=>{this.htmlController.renderEdge(o)})});i(this,"onAfterNodePriorityUpdated",e=>{this.htmlController.updateNodePriority(e)});i(this,"onAfterNodeUpdated",e=>{this.htmlController.updateNodeCoordinates(e),this.internalModel.getNodeAdjacentEdgeIds(e).forEach(o=>{this.htmlController.renderEdge(o)})});i(this,"onBeforeEdgeRemoved",e=>{this.htmlController.detachEdge(e)});i(this,"onBeforeNodeRemoved",e=>{this.htmlController.detachNode(e)});i(this,"onAfterTransformUpdate",()=>{this.htmlController.applyTransform()});this.internalModel=new ee,this.model=new he(this.internalModel),this.internalTransformation=new oe,this.transformation=new ie(this.internalTransformation),this.htmlController=new ne(this.internalModel,this.internalTransformation),this.graphStoreController=new se(this.internalModel,Se(e)),this.internalTransformation.onAfterUpdate.subscribe(this.onAfterTransformUpdate),this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded),this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded),this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(this.onAfterEdgeShapeUpdated),this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(this.onAfterEdgePriorityUpdated),this.graphStoreController.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated),this.graphStoreController.onAfterPortUpdated.subscribe(this.onAfterPortUpdated),this.graphStoreController.onAfterNodePriorityUpdated.subscribe(this.onAfterNodePriorityUpdated),this.graphStoreController.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated),this.graphStoreController.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved),this.graphStoreController.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved)}attach(e){return this.htmlController.attach(e),this}detach(){return this.htmlController.detach(),this}addNode(e){return this.graphStoreController.addNode(e),this}updateNode(e,r){return this.graphStoreController.updateNode(e,r??{}),this}removeNode(e){return this.graphStoreController.removeNode(e),this}addEdge(e){return this.graphStoreController.addEdge(e),this}updateEdge(e,r){return this.graphStoreController.updateEdge(e,r??{}),this}removeEdge(e){return this.graphStoreController.removeEdge(e),this}markPort(e){return this.graphStoreController.markPort(e),this}updatePort(e,r){return this.graphStoreController.updatePort(e,r??{}),this}unmarkPort(e){return this.graphStoreController.unmarkPort(e),this}patchViewportMatrix(e){return this.internalTransformation.patchViewportMatrix(e),this}patchContentMatrix(e){return this.internalTransformation.patchContentMatrix(e),this}clear(){return this.htmlController.clear(),this.graphStoreController.clear(),this}destroy(){this.htmlController.destroy(),this.graphStoreController.clear(),this.internalTransformation.onAfterUpdate.unsubscribe(this.onAfterTransformUpdate),this.graphStoreController.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded),this.graphStoreController.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded),this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(this.onAfterEdgeShapeUpdated),this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(this.onAfterEdgePriorityUpdated),this.graphStoreController.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated),this.graphStoreController.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated),this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(this.onAfterNodePriorityUpdated),this.graphStoreController.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated),this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved),this.graphStoreController.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved)}}class be{constructor(e){i(this,"transformation");i(this,"model");i(this,"internalTransformation");i(this,"internalModel");i(this,"graphStoreController");i(this,"htmlController");i(this,"onAfterNodeAdded",e=>{this.htmlController.attachNode(e)});i(this,"onAfterEdgeAdded",e=>{this.htmlController.attachEdge(e)});i(this,"onAfterEdgeShapeUpdated",e=>{this.htmlController.updateEdgeShape(e)});i(this,"onAfterEdgePriorityUpdated",e=>{this.htmlController.updateEdgePriority(e)});i(this,"onAfterEdgeUpdated",e=>{this.htmlController.renderEdge(e)});i(this,"onAfterPortUpdated",e=>{this.internalModel.getPortAdjacentEdgeIds(e).forEach(o=>{this.htmlController.renderEdge(o)})});i(this,"onAfterNodePriorityUpdated",e=>{this.htmlController.updateNodePriority(e)});i(this,"onAfterNodeUpdated",e=>{this.htmlController.updateNodeCoordinates(e),this.internalModel.getNodeAdjacentEdgeIds(e).forEach(o=>{this.htmlController.renderEdge(o)})});i(this,"onBeforeEdgeRemoved",e=>{this.htmlController.detachEdge(e)});i(this,"onBeforeNodeRemoved",e=>{this.htmlController.detachNode(e)});i(this,"onAfterTransformUpdate",()=>{this.htmlController.applyTransform()});this.model=e.publicGraphStore,this.internalModel=e.graphStore,this.internalTransformation=e.viewportTransformer,this.transformation=e.publicViewportTransformer,this.htmlController=e.htmlController,this.graphStoreController=e.graphStoreController,this.internalTransformation.onAfterUpdate.subscribe(this.onAfterTransformUpdate),this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded),this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded),this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(this.onAfterEdgeShapeUpdated),this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(this.onAfterEdgePriorityUpdated),this.graphStoreController.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated),this.graphStoreController.onAfterPortUpdated.subscribe(this.onAfterPortUpdated),this.graphStoreController.onAfterNodePriorityUpdated.subscribe(this.onAfterNodePriorityUpdated),this.graphStoreController.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated),this.graphStoreController.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved),this.graphStoreController.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved)}attach(e){return this.htmlController.attach(e),this}detach(){return this.htmlController.detach(),this}addNode(e){return this.graphStoreController.addNode(e),this}updateNode(e,r){return this.graphStoreController.updateNode(e,r??{}),this}removeNode(e){return this.graphStoreController.removeNode(e),this}addEdge(e){return this.graphStoreController.addEdge(e),this}updateEdge(e,r){return this.graphStoreController.updateEdge(e,r??{}),this}removeEdge(e){return this.graphStoreController.removeEdge(e),this}markPort(e){return this.graphStoreController.markPort(e),this}updatePort(e,r){return this.graphStoreController.updatePort(e,r??{}),this}unmarkPort(e){return this.graphStoreController.unmarkPort(e),this}patchViewportMatrix(e){return this.internalTransformation.patchViewportMatrix(e),this}patchContentMatrix(e){return this.internalTransformation.patchContentMatrix(e),this}clear(){return this.htmlController.clear(),this.graphStoreController.clear(),this}destroy(){this.htmlController.destroy(),this.graphStoreController.clear(),this.internalTransformation.onAfterUpdate.unsubscribe(this.onAfterTransformUpdate),this.graphStoreController.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded),this.graphStoreController.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded),this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(this.onAfterEdgeShapeUpdated),this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(this.onAfterEdgePriorityUpdated),this.graphStoreController.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated),this.graphStoreController.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated),this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(this.onAfterNodePriorityUpdated),this.graphStoreController.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated),this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved),this.graphStoreController.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved)}}const Me=t=>{if(typeof t=="function")return t;switch(t==null?void 0:t.type){case"straight":return()=>new J({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,arrowOffset:t.arrowOffset,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleSquareSide:t.cycleSquareSide,roundness:t.roundness,detourDistance:t.detourDistance,detourDirection:t.detourDirection});case"horizontal":return()=>new _({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,arrowOffset:t.arrowOffset,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleSquareSide:t.cycleSquareSide,roundness:t.roundness,detourDistance:t.detourDistance,detourDirection:t.detourDirection});case"vertical":return()=>new Q({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,arrowOffset:t.arrowOffset,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleSquareSide:t.cycleSquareSide,roundness:t.roundness,detourDistance:t.detourDistance,detourDirection:t.detourDirection});default:return()=>new K({color:t.color,width:t.width,arrowLength:t.arrowLength,arrowWidth:t.arrowWidth,hasSourceArrow:t.hasSourceArrow,hasTargetArrow:t.hasTargetArrow,cycleRadius:t.cycleRadius,smallCycleRadius:t.smallCycleRadius,curvature:t.curvature,detourDistance:t.detourDistance,detourDirection:t.detourDirection})}},Pe=(t,e)=>{let r=Y,o=Y;t==="incremental"&&(r=D()),e==="incremental"&&(o=D());const n=D();return t==="shared-incremental"&&(r=n),e==="shared-incremental"&&(o=n),typeof t=="number"&&(r=U(t)),typeof e=="number"&&(o=U(e)),typeof t=="function"&&(r=t),typeof e=="function"&&(o=e),{nodesPriorityFn:r,edgesPriorityFn:o}},De=t=>{var r,o,n,d,s;const e=Pe((r=t==null?void 0:t.nodes)==null?void 0:r.priority,(o=t==null?void 0:t.edges)==null?void 0:o.priority);return{nodes:{centerFn:((n=t==null?void 0:t.nodes)==null?void 0:n.centerFn)??E,priorityFn:e.nodesPriorityFn},ports:{direction:((d=t==null?void 0:t.ports)==null?void 0:d.direction)??0},edges:{shapeFactory:Me(((s=t==null?void 0:t.edges)==null?void 0:s.shape)??{}),priorityFn:e.edgesPriorityFn}}};class Le{constructor(e){i(this,"publicViewportTransformer");i(this,"publicGraphStore");i(this,"viewportTransformer");i(this,"graphStore");i(this,"htmlController");i(this,"graphStoreController");this.graphStore=new ee,this.publicGraphStore=new he(this.graphStore),this.viewportTransformer=new oe,this.publicViewportTransformer=new ie(this.viewportTransformer),this.htmlController=new ne(this.graphStore,this.viewportTransformer),this.graphStoreController=new se(this.graphStore,De(e))}}const X=(t,e,r)=>{const{x:o,y:n,width:d,height:s}=t.getBoundingClientRect();return e>=o&&e<=o+d&&r>=n&&r<=n+s},z=(t,e,r)=>e>=0&&e<=t.innerWidth&&r>=0&&r<=t.innerHeight,G=(t,e)=>{e!==null?t.style.cursor=e:t.style.removeProperty("cursor")},Ue=t=>{var u,f,x,v,N,C;const e=((u=t==null?void 0:t.events)==null?void 0:u.onNodeDrag)??(()=>{}),r=((f=t==null?void 0:t.events)==null?void 0:f.onBeforeNodeDrag)??(()=>!0),o=((x=t==null?void 0:t.events)==null?void 0:x.onNodeDragFinished)??(()=>{}),n=(t==null?void 0:t.moveOnTop)===!1,d=(v=t==null?void 0:t.mouse)==null?void 0:v.dragCursor,s=d!==void 0?d:"grab",h=(N=t==null?void 0:t.mouse)==null?void 0:N.mouseDownEventVerifier,c=h!==void 0?h:T=>T.button===0,a=(C=t==null?void 0:t.mouse)==null?void 0:C.mouseUpEventVerifier;return{freezePriority:n,dragCursor:s,mouseDownEventVerifier:c,mouseUpEventVerifier:a!==void 0?a:T=>T.button===0,onNodeDrag:e,onBeforeNodeDrag:r,onNodeDragFinished:o}};class de{constructor(e,r){i(this,"model");i(this,"transformation");i(this,"maxNodePriority",0);i(this,"nodes",new Map);i(this,"grabbedNodeId",null);i(this,"nodeIdGenerator",new V(e=>this.nodes.has(e)));i(this,"element",null);i(this,"onWindowMouseMove",e=>{if(this.element!==null&&(!X(this.element,e.clientX,e.clientY)||!z(this.window,e.clientX,e.clientY))){this.cancelMouseDrag();return}this.grabbedNodeId!==null&&this.dragNode(this.grabbedNodeId,e.movementX,e.movementY)});i(this,"onWindowMouseUp",e=>{this.options.mouseUpEventVerifier(e)&&this.cancelMouseDrag()});i(this,"onWindowTouchMove",e=>{if(e.touches.length!==1)return;const r=e.touches[0];if(this.element!==null&&(!X(this.element,r.clientX,r.clientY)||!z(this.window,r.clientX,r.clientY))){this.cancelTouchDrag();return}if(this.grabbedNodeId!==null&&this.previousTouchCoords!==null){const o=r.clientX-this.previousTouchCoords.x,n=r.clientY-this.previousTouchCoords.y;this.dragNode(this.grabbedNodeId,o,n),this.previousTouchCoords={x:e.touches[0].clientX,y:e.touches[0].clientY}}});i(this,"onWindowTouchFinish",()=>{this.previousTouchCoords=null,this.cancelTouchDrag()});i(this,"previousTouchCoords",null);i(this,"window",window);i(this,"options");this.canvas=e,this.transformation=this.canvas.transformation,this.model=this.canvas.model,this.options=Ue(r??{})}attach(e){return this.detach(),this.element=e,this.canvas.attach(this.element),this}detach(){return this.canvas.detach(),this.element!==null&&(this.element=null),this}addNode(e){const r=this.nodeIdGenerator.create(e.id);this.canvas.addNode({...e,id:r}),this.updateMaxNodePriority(r);const o=d=>{if(this.element===null||!this.options.mouseDownEventVerifier(d))return;const s=this.model.getNode(r);this.options.onBeforeNodeDrag({nodeId:r,element:e.element,x:s.x,y:s.y})&&(d.stopImmediatePropagation(),this.grabbedNodeId=r,G(this.element,this.options.dragCursor),this.moveNodeOnTop(r),this.window.addEventListener("mouseup",this.onWindowMouseUp),this.window.addEventListener("mousemove",this.onWindowMouseMove))},n=d=>{if(d.touches.length!==1)return;d.stopImmediatePropagation(),this.previousTouchCoords={x:d.touches[0].clientX,y:d.touches[0].clientY};const s=this.model.getNode(r);this.options.onBeforeNodeDrag({nodeId:r,element:e.element,x:s.x,y:s.y})&&(this.grabbedNodeId=r,this.moveNodeOnTop(r),this.window.addEventListener("touchmove",this.onWindowTouchMove),this.window.addEventListener("touchend",this.onWindowTouchFinish),this.window.addEventListener("touchcancel",this.onWindowTouchFinish))};return this.nodes.set(r,{element:e.element,onMouseDown:o,onTouchStart:n}),e.element.addEventListener("mousedown",o),e.element.addEventListener("touchstart",n),this}updateNode(e,r){return this.canvas.updateNode(e,r),this.updateMaxNodePriority(e),this}removeNode(e){const r=this.nodes.get(e);return r!==void 0&&(r.element.removeEventListener("mousedown",r.onMouseDown),r.element.removeEventListener("touchstart",r.onTouchStart)),this.nodes.delete(e),this.canvas.removeNode(e),this}markPort(e){return this.canvas.markPort(e),this}updatePort(e,r){return this.canvas.updatePort(e,r),this}unmarkPort(e){return this.canvas.unmarkPort(e),this}addEdge(e){return this.canvas.addEdge(e),this}updateEdge(e,r){return this.canvas.updateEdge(e,r),this}removeEdge(e){return this.canvas.removeEdge(e),this}patchViewportMatrix(e){return this.canvas.patchViewportMatrix(e),this}patchContentMatrix(e){return this.canvas.patchContentMatrix(e),this}clear(){return this.canvas.clear(),this.nodes.forEach(e=>{e.element.removeEventListener("mousedown",e.onMouseDown),e.element.removeEventListener("touchstart",e.onTouchStart)}),this.nodes.clear(),this.maxNodePriority=0,this}destroy(){this.detach(),this.clear(),this.removeMouseDragListeners(),this.removeTouchDragListeners(),this.canvas.destroy()}dragNode(e,r,o){const n=this.model.getNode(e);if(n===null)return;const d=this.canvas.transformation.getContentMatrix(),s=d.scale*n.x+d.x,h=d.scale*n.y+d.y,c=s+r,a=h+o,l=this.canvas.transformation.getViewportMatrix(),u=l.scale*c+l.x,f=l.scale*a+l.y;this.canvas.updateNode(e,{x:u,y:f}),this.options.onNodeDrag({nodeId:e,element:n.element,x:u,y:f})}updateMaxNodePriority(e){const r=this.model.getNode(e).priority;this.maxNodePriority=Math.max(this.maxNodePriority,r)}moveNodeOnTop(e){if(this.options.freezePriority)return;this.maxNodePriority+=2,this.updateNode(e,{priority:this.maxNodePriority});const r=this.maxNodePriority-1;this.model.getNodeAdjacentEdgeIds(e).forEach(n=>{this.updateEdge(n,{priority:r})})}cancelMouseDrag(){const e=this.model.getNode(this.grabbedNodeId);e!==null&&this.options.onNodeDragFinished({nodeId:this.grabbedNodeId,element:e.element,x:e.x,y:e.y}),this.grabbedNodeId=null,this.element!==null&&G(this.element,null),this.removeMouseDragListeners()}removeMouseDragListeners(){this.window.removeEventListener("mouseup",this.onWindowMouseUp),this.window.removeEventListener("mousemove",this.onWindowMouseMove)}cancelTouchDrag(){this.previousTouchCoords=null;const e=this.model.getNode(this.grabbedNodeId);e!==null&&this.options.onNodeDragFinished({nodeId:this.grabbedNodeId,element:e.element,x:e.x,y:e.y}),this.grabbedNodeId=null,this.removeTouchDragListeners()}removeTouchDragListeners(){this.window.removeEventListener("touchmove",this.onWindowTouchMove),this.window.removeEventListener("touchend",this.onWindowTouchFinish),this.window.removeEventListener("touchcancel",this.onWindowTouchFinish)}}const Ve=t=>{const e=t.minX!==null?t.minX:-1/0,r=t.maxX!==null?t.maxX:1/0,o=t.minY!==null?t.minY:-1/0,n=t.maxY!==null?t.maxY:1/0;return d=>{let s=d.nextTransform.x,h=d.nextTransform.y;s<e&&s<d.prevTransform.x&&(s=Math.min(d.prevTransform.x,e));const c=d.canvasWidth*d.prevTransform.scale,a=r-c;s>a&&s>d.prevTransform.x&&(s=Math.max(d.prevTransform.x,a)),h<o&&h<d.prevTransform.y&&(h=Math.min(d.prevTransform.y,o));const l=d.canvasHeight*d.prevTransform.scale,u=n-l;return h>u&&h>d.prevTransform.y&&(h=Math.max(d.prevTransform.y,u)),{scale:d.nextTransform.scale,x:s,y:h}}},$e=t=>{const e=t.maxContentScale,r=t.minContentScale,o=e!==null?1/e:0,n=r!==null?1/r:1/0;return d=>{const s=d.prevTransform,h=d.nextTransform;let c=h.scale,a=h.x,l=h.y;if(h.scale>n&&h.scale>s.scale){c=Math.max(s.scale,n),a=s.x,l=s.y;const u=(c-s.scale)/(h.scale-s.scale);a=s.x+(h.x-s.x)*u,l=s.y+(h.y-s.y)*u}if(h.scale<o&&h.scale<s.scale){c=Math.min(s.scale,o),a=s.x,l=s.y;const u=(c-s.scale)/(h.scale-s.scale);a=s.x+(h.x-s.x)*u,l=s.y+(h.y-s.y)*u}return{scale:c,x:a,y:l}}},Ie=t=>e=>t.reduce((r,o)=>o({prevTransform:e.prevTransform,nextTransform:r,canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight}),e.nextTransform),ce=t=>{if(typeof t=="function")return t;switch(t.type){case"scale-limit":return $e({minContentScale:t.minContentScale??0,maxContentScale:t.maxContentScale??1/0});case"shift-limit":return Ve({minX:t.minX??-1/0,maxX:t.maxX??1/0,minY:t.minY??-1/0,maxY:t.maxY??1/0})}},We=t=>{var v,N,C,T,O,$,I,W,ue;const e=(v=t==null?void 0:t.scale)==null?void 0:v.mouseWheelSensitivity,r=e!==void 0?e:1.2,o=t==null?void 0:t.transformPreprocessor;let n;o!==void 0?Array.isArray(o)?n=Ie(o.map(P=>ce(P))):n=ce(o):n=P=>P.nextTransform;const d=((N=t==null?void 0:t.shift)==null?void 0:N.cursor)!==void 0?t.shift.cursor:"grab",s=((C=t==null?void 0:t.events)==null?void 0:C.onBeforeTransformChange)??(()=>{}),h=((T=t==null?void 0:t.events)==null?void 0:T.onTransformChange)??(()=>{}),c=(O=t==null?void 0:t.shift)==null?void 0:O.mouseDownEventVerifier,a=c!==void 0?c:P=>P.button===0,l=($=t==null?void 0:t.shift)==null?void 0:$.mouseUpEventVerifier,u=l!==void 0?l:P=>P.button===0,f=(I=t==null?void 0:t.scale)==null?void 0:I.mouseWheelEventVerifier,x=f!==void 0?f:()=>!0;return{wheelSensitivity:r,onTransformStarted:((W=t==null?void 0:t.events)==null?void 0:W.onTransformStarted)??(()=>{}),onTransformFinished:((ue=t==null?void 0:t.events)==null?void 0:ue.onTransformFinished)??(()=>{}),onBeforeTransformChange:s,onTransformChange:h,transformPreprocessor:n,shiftCursor:d,mouseDownEventVerifier:a,mouseUpEventVerifier:u,mouseWheelEventVerifier:x}},Z=t=>{const e=[],r=t.touches.length;for(let h=0;h<r;h++)e.push([t.touches[h].clientX,t.touches[h].clientY]);const o=e.reduce((h,c)=>[h[0]+c[0],h[1]+c[1]],[0,0]),n=[o[0]/r,o[1]/r],s=e.map(h=>[h[0]-n[0],h[1]-n[1]]).reduce((h,c)=>h+Math.sqrt(c[0]*c[0]+c[1]*c[1]),0);return{x:n[0],y:n[1],scale:s/r,touchesCnt:r,touches:e}},Re=(t,e,r)=>({scale:t.scale,x:t.x+t.scale*e,y:t.y+t.scale*r}),Fe=(t,e,r,o)=>({scale:t.scale*e,x:t.scale*(1-e)*r+t.x,y:t.scale*(1-e)*o+t.y});class q{constructor(e,r){i(this,"model");i(this,"transformation");i(this,"element",null);i(this,"prevTouches",null);i(this,"window",window);i(this,"onMouseDown",e=>{this.element===null||!this.options.mouseDownEventVerifier(e)||(G(this.element,this.options.shiftCursor),this.window.addEventListener("mousemove",this.onWindowMouseMove),this.window.addEventListener("mouseup",this.onWindowMouseUp),this.options.onTransformStarted())});i(this,"onWindowMouseMove",e=>{if(this.element===null||!X(this.element,e.clientX,e.clientY)||!z(this.window,e.clientX,e.clientY)){this.stopMouseDrag();return}const r=-e.movementX,o=-e.movementY;this.moveViewport(this.element,r,o)});i(this,"onWindowMouseUp",e=>{this.element===null||!this.options.mouseUpEventVerifier(e)||this.stopMouseDrag()});i(this,"onWheelScroll",e=>{if(!this.options.mouseWheelEventVerifier(e))return;e.preventDefault(),this.options.onTransformStarted();const{left:r,top:o}=this.element.getBoundingClientRect(),n=e.clientX-r,d=e.clientY-o,h=1/(e.deltaY<0?this.options.wheelSensitivity:1/this.options.wheelSensitivity);this.scaleViewport(this.element,h,n,d),this.options.onTransformFinished()});i(this,"onTouchStart",e=>{this.prevTouches=Z(e),this.window.addEventListener("touchmove",this.onWindowTouchMove),this.window.addEventListener("touchend",this.onWindowTouchFinish),this.window.addEventListener("touchcancel",this.onWindowTouchFinish),this.options.onTransformStarted()});i(this,"onWindowTouchMove",e=>{const r=this.element;if(r===null)return;const o=Z(e);if(!o.touches.every(d=>X(r,d[0],d[1])&&z(this.window,d[0],d[1]))){this.stopTouchDrag();return}if((o.touchesCnt===1||o.touchesCnt===2)&&this.moveViewport(r,-(o.x-this.prevTouches.x),-(o.y-this.prevTouches.y)),o.touchesCnt===2){const{left:d,top:s}=r.getBoundingClientRect(),h=this.prevTouches.x-d,c=this.prevTouches.y-s,l=1/(o.scale/this.prevTouches.scale);this.scaleViewport(r,l,h,c)}this.prevTouches=o});i(this,"onWindowTouchFinish",e=>{e.touches.length>0?this.prevTouches=Z(e):this.stopTouchDrag()});i(this,"observer",new ResizeObserver(()=>{const e=this.canvas.transformation.getViewportMatrix(),{width:r,height:o}=this.element.getBoundingClientRect(),n=this.options.transformPreprocessor({prevTransform:e,nextTransform:e,canvasWidth:r,canvasHeight:o});this.canvas.patchViewportMatrix(n),this.options.onTransformChange()}));i(this,"options");this.canvas=e,this.options=We(r),this.transformation=this.canvas.transformation,this.model=this.canvas.model}attach(e){return this.detach(),this.element=e,this.observer.observe(this.element),this.element.addEventListener("mousedown",this.onMouseDown),this.element.addEventListener("wheel",this.onWheelScroll),this.element.addEventListener("touchstart",this.onTouchStart),this.canvas.attach(this.element),this}detach(){return this.canvas.detach(),this.element!==null&&(this.observer.unobserve(this.element),this.element.removeEventListener("mousedown",this.onMouseDown),this.element.removeEventListener("wheel",this.onWheelScroll),this.element.removeEventListener("touchstart",this.onTouchStart),this.element=null),this}addNode(e){return this.canvas.addNode(e),this}updateNode(e,r){return this.canvas.updateNode(e,r),this}removeNode(e){return this.canvas.removeNode(e),this}markPort(e){return this.canvas.markPort(e),this}updatePort(e,r){return this.canvas.updatePort(e,r),this}unmarkPort(e){return this.canvas.unmarkPort(e),this}addEdge(e){return this.canvas.addEdge(e),this}updateEdge(e,r){return this.canvas.updateEdge(e,r),this}removeEdge(e){return this.canvas.removeEdge(e),this}patchViewportMatrix(e){return this.canvas.patchViewportMatrix(e),this}patchContentMatrix(e){return this.canvas.patchContentMatrix(e),this}clear(){return this.canvas.clear(),this}destroy(){this.detach(),this.removeMouseDragListeners(),this.removeTouchDragListeners(),this.canvas.destroy()}moveViewport(e,r,o){this.options.onBeforeTransformChange();const n=this.transformation.getViewportMatrix(),d=Re(n,r,o),{width:s,height:h}=e.getBoundingClientRect(),c=this.options.transformPreprocessor({prevTransform:n,nextTransform:d,canvasWidth:s,canvasHeight:h});this.canvas.patchViewportMatrix(c),this.options.onTransformChange()}scaleViewport(e,r,o,n){this.options.onBeforeTransformChange();const d=this.canvas.transformation.getViewportMatrix(),s=Fe(d,r,o,n),{width:h,height:c}=e.getBoundingClientRect(),a=this.options.transformPreprocessor({prevTransform:d,nextTransform:s,canvasWidth:h,canvasHeight:c});this.canvas.patchViewportMatrix(a),this.options.onTransformChange()}stopMouseDrag(){this.element!==null&&G(this.element,null),this.removeMouseDragListeners(),this.options.onTransformFinished()}removeMouseDragListeners(){this.window.removeEventListener("mousemove",this.onWindowMouseMove),this.window.removeEventListener("mouseup",this.onWindowMouseUp)}stopTouchDrag(){this.prevTouches=null,this.removeTouchDragListeners(),this.options.onTransformFinished()}removeTouchDragListeners(){this.window.removeEventListener("touchmove",this.onWindowTouchMove),this.window.removeEventListener("touchend",this.onWindowTouchFinish),this.window.removeEventListener("touchcancel",this.onWindowTouchFinish)}}class Be{constructor(){i(this,"keyMap",new Map);i(this,"valueMap",new Map)}set(e,r){this.keyMap.set(e,r),this.valueMap.set(r,e)}hasKey(e){return this.keyMap.has(e)}hasValue(e){return this.valueMap.has(e)}getByKey(e){return this.keyMap.get(e)}getByValue(e){return this.valueMap.get(e)}deleteByKey(e){const r=this.keyMap.get(e);r!==void 0&&this.valueMap.delete(r),this.keyMap.delete(e)}deleteByValue(e){const r=this.valueMap.get(e);r!==void 0&&this.keyMap.delete(r),this.valueMap.delete(e)}forEach(e){this.keyMap.forEach((r,o)=>{e(r,o)})}clear(){this.keyMap.clear(),this.valueMap.clear()}}class ae{constructor(e){i(this,"transformation");i(this,"model");i(this,"nodes",new Be);i(this,"nodeIdGenerator",new V(e=>this.nodes.hasKey(e)));i(this,"nodesResizeObserver");this.canvas=e,this.nodesResizeObserver=new window.ResizeObserver(r=>{r.forEach(o=>{const n=o.target;this.handleNodeResize(n)})}),this.transformation=this.canvas.transformation,this.model=this.canvas.model}attach(e){return this.canvas.attach(e),this}detach(){return this.canvas.detach(),this}addNode(e){const r=this.nodeIdGenerator.create(e.id);return this.canvas.addNode({...e,id:r}),this.nodes.set(r,e.element),this.nodesResizeObserver.observe(e.element),this}updateNode(e,r){return this.canvas.updateNode(e,r),this}removeNode(e){this.canvas.removeNode(e);const r=this.nodes.getByKey(e);return this.nodes.deleteByKey(e),this.nodesResizeObserver.unobserve(r),this}markPort(e){return this.canvas.markPort(e),this}updatePort(e,r){return this.canvas.updatePort(e,r),this}unmarkPort(e){return this.canvas.unmarkPort(e),this}addEdge(e){return this.canvas.addEdge(e),this}updateEdge(e,r){return this.canvas.updateEdge(e,r),this}removeEdge(e){return this.canvas.removeEdge(e),this}patchViewportMatrix(e){return this.canvas.patchViewportMatrix(e),this}patchContentMatrix(e){return this.canvas.patchContentMatrix(e),this}clear(){return this.canvas.clear(),this.nodesResizeObserver.disconnect(),this.nodes.clear(),this}destroy(){this.clear(),this.canvas.destroy()}handleNodeResize(e){const r=this.nodes.getByValue(e);this.canvas.updateNode(r),this.model.getNodeAdjacentEdgeIds(r).forEach(n=>{this.canvas.updateEdge(n)})}}class le{constructor(){i(this,"coreOptions",{});i(this,"dragOptions");i(this,"transformOptions");i(this,"hasDraggableNode",!1);i(this,"hasTransformableViewport",!1);i(this,"hasResizeReactiveNodes",!1)}setOptions(e){return this.coreOptions=e,this}setUserDraggableNodes(e){return this.hasDraggableNode=!0,this.dragOptions=e,this}setUserTransformableCanvas(e){return this.setUserTransformableViewport(e)}setUserTransformableViewport(e){return this.hasTransformableViewport=!0,this.transformOptions=e,this}setResizeReactiveNodes(){return this.hasResizeReactiveNodes=!0,this}build(){const e=new Le(this.coreOptions);let r=new be(e);return this.hasResizeReactiveNodes&&(r=new ae(r)),this.hasDraggableNode&&(r=new de(r,this.dragOptions)),this.hasTransformableViewport&&(r=new q(r,this.transformOptions)),r}}A.BezierEdgeShape=K,A.CanvasBuilder=le,A.CanvasCore=pe,A.HorizontalEdgeShape=_,A.HtmlGraphBuilder=le,A.HtmlGraphError=S,A.ResizeReactiveNodesCanvas=ae,A.StraightEdgeShape=J,A.UserDraggableNodesCanvas=de,A.UserTransformableCanvas=q,A.UserTransformableViewportCanvas=q,A.VerticalEdgeShape=Q,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@html-graph/html-graph",
3
3
  "author": "Dmitry Marov <d.marov94@gmail.com>",
4
4
  "private": false,
5
- "version": "1.0.0",
5
+ "version": "1.1.1",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",
@@ -34,13 +34,11 @@
34
34
  "lint": "eslint .",
35
35
  "fix-lint": "eslint . --fix",
36
36
  "build": "tsc --p ./tsconfig-build-library.json && vite build",
37
- "build-docs": "tsc && vite build --config ./vite-docs.config.ts",
38
37
  "preview": "vite preview",
39
38
  "before-build": "npm run check-formatting && npm run lint && npm run test:ci",
40
39
  "release-next-version": "tsx ./scripts/release-next-version.ts",
41
40
  "release-next-version:minor": "tsx ./scripts/release-next-version.ts -- --minor",
42
41
  "release-next-version:major": "tsx ./scripts/release-next-version.ts -- --major",
43
- "deploy-docs": "tsx ./scripts/deploy-docs.ts",
44
42
  "make-deps-graph": "npx depcruise lib --include-only \"^lib\" --output-type dot > ./deps-graph/deps-graph.dot",
45
43
  "test": "jest",
46
44
  "test:watch": "jest --watch",