@linkurious/ogma-annotations-react 1.1.25 → 1.1.27

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/index.js CHANGED
@@ -1,15 +1,15 @@
1
- (function(H,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("react"),require("@linkurious/ogma-react")):typeof define=="function"&&define.amd?define(["exports","react","@linkurious/ogma-react"],V):(H=typeof globalThis<"u"?globalThis:H||self,V((H["/home/jenkins/agent/workspace/_ogma-annotations-control_master/packages/ogma-annotations-react/src/index"]=H["/home/jenkins/agent/workspace/_ogma-annotations-control_master/packages/ogma-annotations-react/src/index"]||{},H["/home/jenkins/agent/workspace/_ogma-annotations-control_master/packages/ogma-annotations-react/src/index"].ts={}),H.React,H.OgmaReact))})(this,function(H,V,fr){"use strict";var gr=Object.defineProperty,pr=(l,t,s)=>t in l?gr(l,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[t]=s,m=(l,t,s)=>pr(l,typeof t!="symbol"?t+"":t,s);let Ht=(l=21)=>crypto.getRandomValues(new Uint8Array(l)).reduce((t,s)=>(s&=63,s<36?t+=s.toString(36):s<62?t+=(s-26).toString(36).toUpperCase():s>62?t+="-":t+="_",t),"");const It={strokeType:"plain",strokeColor:"#202020",strokeWidth:1,head:"none",tail:"none"},ke={id:0,type:"Feature",properties:{type:"arrow",style:{...It}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},yr=(l=0,t=0,s=0,r=0,a={...It})=>({id:Ht(),type:"Feature",properties:{type:"arrow",style:{...It,...a}},geometry:{type:"LineString",coordinates:[[l,t],[s,r]]}}),mr="http://www.w3.org/2000/svg";function vt(l){return document.createElementNS(mr,l)}function Ee(l){return l.geometry.bbox||vr(l),l.geometry.bbox}function ut(l){const t=Ee(l);return{width:t[2]-t[0],height:t[3]-t[1]}}function ct(l){const t=Ee(l);return{x:t[0],y:t[1]}}function vr(l){const[t,s]=l.geometry.coordinates[0][0],[r,a]=l.geometry.coordinates[0][2];l.geometry.bbox=[t,s,r,a]}function wr(l,t,s,r,a){l.geometry.bbox=[t,s,t+r,s+a],l.geometry.coordinates=[[[t,s],[t+r,s],[t+r,s+a],[t,s+a],[t,s]]]}function $t(l){const[t,s]=l.geometry.coordinates[0];return{x:t,y:s}}function jt(l,t){const[s,r]=l.geometry.coordinates[t==="start"?0:1];return{x:s,y:r}}function Nt(l){const[t,s]=l.geometry.coordinates[1];return{x:t,y:s}}function Se(l,t,s){l.geometry.coordinates[0]=[t,s]}function Ce(l,t,s){l.geometry.coordinates[1]=[t,s]}function Bt(l){return{start:$t(l),end:Nt(l)}}function kt(l,t,s,r){t==="start"?Se(l,s,r):Ce(l,s,r)}const _e=l=>parseInt(l.getAttribute("data-handle-id")||"-1");function xr(l){return Array.isArray(l)&&l.length===2&&l.every(isFinite)}function br(l,t,s,r){for(let a=0;a<l.coordinates.length;a++){const h=l.coordinates[a];if(xr(h))h[0]=s+(h[0]-s)*t,h[1]=r+(h[1]-r)*t;else for(let c=0;c<h.length;c++){const f=h[c];f[0]=s+(f[0]-s)*t,f[1]=r+(f[1]-r)*t}}return l}function qt(l,t,s){const r=Math.atan2(l.y-t.y,l.x-t.x);return{x:t.x+s*Math.cos(r),y:t.y+s*Math.sin(r)}}function Rt(l,t){if(!t)return{x:l.clientX,y:l.clientY};const s=t.getBoundingClientRect();return{x:l.clientX-s.left-t.clientLeft,y:l.clientY-s.top-t.clientTop}}const wt=(l,t)=>({x:l.x-t.x,y:l.y-t.y}),Et=l=>Math.sqrt(l.x*l.x+l.y*l.y),De=l=>({x:-l.x,y:-l.y}),Le=l=>{const t=Et(l);return t===0?{x:0,y:0}:{x:l.x/t,y:l.y/t}},St=(l,t)=>({x:l.x+t.x,y:l.y+t.y}),Te=(l,t)=>({x:l.x*t,y:l.y*t}),Wt=(l,t)=>({x:l.x*t.x,y:l.y*t.y}),rt=(l,t)=>{const s=Math.sin(t),r=Math.cos(t);return{x:l.x*r-l.y*s,y:l.x*s+l.y*r}},Ar=(l,t)=>({x:l.x/t,y:l.y/t}),Ie=(l,t)=>l.x*t.x+l.y*t.y,kr=.5;function $e(l,t=5,s=30){var r;const{start:a,end:h}=Bt(l),c=wt(h,a),f=l.properties.style&&l.properties.style.strokeWidth?(r=l.properties.style)==null?void 0:r.strokeWidth:0;return Math.min(s,Math.max(3*f,Et(c)*.01,t))}function Me(l,t,s,r){const a=Te(De(Le(t)),r);if(!s||s!=="arrow"&&s!=="arrow-plain")return"";const h=St(l,rt(a,Math.PI/10)),c=St(l,rt(a,-Math.PI/10)),f=`${l.x} ${l.y}`;return`M ${h.x} ${h.y} L ${f} ${c.x} ${c.y} ${s==="arrow"?"":`${h.x} ${h.y}`}`}function Er(l,t,s,r,a){const{start:h,end:c}=Bt(l),{tail:f,head:d,strokeColor:g,strokeWidth:p=0}=l.properties.style||s,b=wt(c,h),A=$e(l,r,a),k=vt("g"),E=vt("path");k.setAttribute("data-annotation",`${l.id}`),k.setAttribute("data-annotation-type","arrow");const x=d==="arrow-plain"||f==="arrow",L=g||"none";E.setAttribute("stroke",L),E.setAttribute("stroke-width",`${p}`),E.setAttribute("fill",x?g||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const O=Me(h,De(b),f,A),C=Me(c,b,d,A),P=O+`M ${h.x} ${h.y} ${c.x} ${c.y}`+C;E.setAttribute("d",P),k.appendChild(E),Oe(k,h,L,f,p),Oe(k,c,L,d,p),t.appendChild(k)}function Oe(l,t,s,r,a){r==="halo-dot"&&ze(l,t,Sr(s),kr,a*4),(r==="dot"||r==="halo-dot")&&ze(l,t,s,1,a*2)}function Sr(l){return l==="none"?"none":l}function ze(l,t,s,r,a){const h=vt("circle");h.setAttribute("cx",`${t.x}`),h.setAttribute("cy",`${t.y}`),h.setAttribute("r",`${a}`),h.setAttribute("fill-opacity",`${r}`),h.setAttribute("fill",s),l.appendChild(h)}const U=-1,Ut="dragging",Xt="dragstart",Ct="dragend",Qt="select",te="unselect",Cr="hover",_r="unhover",ee="remove",re="add",Dr="cancelDrawing",ne="update",Lr="link";function Pe(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Fe={exports:{}},He;function Tr(){return He||(He=1,function(l){var t=Object.prototype.hasOwnProperty,s="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(s=!1));function a(d,g,p){this.fn=d,this.context=g,this.once=p||!1}function h(d,g,p,b,A){if(typeof p!="function")throw new TypeError("The listener must be a function");var k=new a(p,b||d,A),E=s?s+g:g;return d._events[E]?d._events[E].fn?d._events[E]=[d._events[E],k]:d._events[E].push(k):(d._events[E]=k,d._eventsCount++),d}function c(d,g){--d._eventsCount===0?d._events=new r:delete d._events[g]}function f(){this._events=new r,this._eventsCount=0}f.prototype.eventNames=function(){var d=[],g,p;if(this._eventsCount===0)return d;for(p in g=this._events)t.call(g,p)&&d.push(s?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(g)):d},f.prototype.listeners=function(d){var g=s?s+d:d,p=this._events[g];if(!p)return[];if(p.fn)return[p.fn];for(var b=0,A=p.length,k=new Array(A);b<A;b++)k[b]=p[b].fn;return k},f.prototype.listenerCount=function(d){var g=s?s+d:d,p=this._events[g];return p?p.fn?1:p.length:0},f.prototype.emit=function(d,g,p,b,A,k){var E=s?s+d:d;if(!this._events[E])return!1;var x=this._events[E],L=arguments.length,O,C;if(x.fn){switch(x.once&&this.removeListener(d,x.fn,void 0,!0),L){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,g),!0;case 3:return x.fn.call(x.context,g,p),!0;case 4:return x.fn.call(x.context,g,p,b),!0;case 5:return x.fn.call(x.context,g,p,b,A),!0;case 6:return x.fn.call(x.context,g,p,b,A,k),!0}for(C=1,O=new Array(L-1);C<L;C++)O[C-1]=arguments[C];x.fn.apply(x.context,O)}else{var P=x.length,N;for(C=0;C<P;C++)switch(x[C].once&&this.removeListener(d,x[C].fn,void 0,!0),L){case 1:x[C].fn.call(x[C].context);break;case 2:x[C].fn.call(x[C].context,g);break;case 3:x[C].fn.call(x[C].context,g,p);break;case 4:x[C].fn.call(x[C].context,g,p,b);break;default:if(!O)for(N=1,O=new Array(L-1);N<L;N++)O[N-1]=arguments[N];x[C].fn.apply(x[C].context,O)}}return!0},f.prototype.on=function(d,g,p){return h(this,d,g,p,!1)},f.prototype.once=function(d,g,p){return h(this,d,g,p,!0)},f.prototype.removeListener=function(d,g,p,b){var A=s?s+d:d;if(!this._events[A])return this;if(!g)return c(this,A),this;var k=this._events[A];if(k.fn)k.fn===g&&(!b||k.once)&&(!p||k.context===p)&&c(this,A);else{for(var E=0,x=[],L=k.length;E<L;E++)(k[E].fn!==g||b&&!k[E].once||p&&k[E].context!==p)&&x.push(k[E]);x.length?this._events[A]=x.length===1?x[0]:x:c(this,A)}return this},f.prototype.removeAllListeners=function(d){var g;return d?(g=s?s+d:d,this._events[g]&&c(this,g)):(this._events=new r,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=s,f.EventEmitter=f,l.exports=f}(Fe)),Fe.exports}var Ir=Tr();const je=Pe(Ir);class Ne extends je{constructor(t,s){super(),m(this,"ogma"),m(this,"elements"),m(this,"layer"),m(this,"editor"),m(this,"selectedId",U),m(this,"hoveredId",U),m(this,"ogmaOptions"),m(this,"shouldDetect"),m(this,"isDragging"),m(this,"showeditorOnHover"),m(this,"_onKeyUp",r=>{r.code===27&&this.selectedId!==U?this.unselect():(r.code===46||r.code===8)&&this.selectedId!==U&&this._canRemove()&&this.remove(this.selectedId)}),m(this,"_onClickMouseMove",r=>{if(!r.domEvent||this.isDragging||!this.shouldDetect||r.domEvent.type!=="mousemove"&&r.domEvent.target&&r.domEvent.target.tagName==="a")return;const a=this.ogma.view.screenToGraphCoordinates(r),h=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(a,0):void 0;r.domEvent.type==="mousemove"?h?this.hover(h.id):this.hoveredId!==U&&this.unhover():h?this.select(h.id):this.selectedId!==U&&this.unselect()}),this.ogma=t,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=t.getOptions(),t.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("frame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=t.layers.addSVGLayer({draw:r=>this.draw(r)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(s),this.editor.hide()}_canRemove(){return!0}add(t){const s=this.getDefaultOptions(),r=Object.assign(t,{id:t.id===void 0?Ht():t.id,type:t.type,properties:{...s.properties,...t.properties||{},style:{...s.properties.style,...t.properties.style||{}}},geometry:{...s.geometry,...t.geometry}});return this.elements.push(r),this.layer.refresh(),this.emit(re,r),r}updateStyle(t,s){this.updateAnnotation(t,{properties:{style:s}})}updateGeometry(t,s){this.updateAnnotation(t,{geometry:s})}scale(t,s,r,a){this.updateGeometry(t,br(t.geometry,s,r,a))}update(t,s){const r=this.getById(t);this.updateAnnotation(r,s)}updateAnnotation(t,s){if(!t)return;const r=t.id;Object.keys(s).forEach(a=>{if(a!=="id")if(a==="properties"){const h=s.properties||{style:{}};t.properties={...t.properties||{},...h||{},style:{...t.properties.style||{},...h.style||{}}}}else a==="geometry"?t.geometry={...t.geometry,...s.geometry}:t[a]=s[a]}),r===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){const s=Number(t);for(let r=0;r<this.elements.length;r++){const a=this.elements[r];if(!(a.id!==t&&a.id!==s))return a}}select(t){const s=this.getById(t);s&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Qt,s))}hover(t){const s=this.getById(t);s&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Cr,s))}getSelectedFeature(){return this.selectedId===U?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(te,t),this.selectedId=U,this.hoveredId===U&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit(_r,t),this.hoveredId=U,this.selectedId===U&&this.editor.hide(),this.layer.refresh(),this}remove(t){const s=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(r=>r.id!==t),s&&this.emit(ee,s),this.layer.refresh()}disableDragging(){this.ogma.setOptions({interactions:{drag:{enabled:!1},pan:{enabled:!1}},detect:{nodes:!1,edges:!1,nodeTexts:!1,edgeTexts:!1}})}restoreDragging(){this.ogma.setOptions(this.ogmaOptions)}enableDetection(){this.shouldDetect=!0}disableDetection(){this.shouldDetect=!1}refreshLayer(){this.layer.refresh()}refreshDrawing(){}getElements(){return[...this.elements]}destroy(){this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp),this.layer.destroy()}}const Be="handle-line",qe="handle-start",Re="handle-end";class $r extends Ne{constructor(t,s={}){super(t,`
1
+ (function(H,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("react"),require("@linkurious/ogma-react")):typeof define=="function"&&define.amd?define(["exports","react","@linkurious/ogma-react"],V):(H=typeof globalThis<"u"?globalThis:H||self,V((H["/home/jenkins/agent/workspace/_ogma-annotations-control_master/packages/ogma-annotations-react/src/index"]=H["/home/jenkins/agent/workspace/_ogma-annotations-control_master/packages/ogma-annotations-react/src/index"]||{},H["/home/jenkins/agent/workspace/_ogma-annotations-control_master/packages/ogma-annotations-react/src/index"].ts={}),H.React,H.OgmaReact))})(this,function(H,V,fr){"use strict";var gr=Object.defineProperty,pr=(l,t,i)=>t in l?gr(l,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[t]=i,m=(l,t,i)=>pr(l,typeof t!="symbol"?t+"":t,i);let Ht=(l=21)=>crypto.getRandomValues(new Uint8Array(l)).reduce((t,i)=>(i&=63,i<36?t+=i.toString(36):i<62?t+=(i-26).toString(36).toUpperCase():i>62?t+="-":t+="_",t),"");const It={strokeType:"plain",strokeColor:"#202020",strokeWidth:1,head:"none",tail:"none"},ke={id:0,type:"Feature",properties:{type:"arrow",style:{...It}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},yr=(l=0,t=0,i=0,r=0,a={...It})=>({id:Ht(),type:"Feature",properties:{type:"arrow",style:{...It,...a}},geometry:{type:"LineString",coordinates:[[l,t],[i,r]]}}),mr="http://www.w3.org/2000/svg";function vt(l){return document.createElementNS(mr,l)}function Ee(l){return l.geometry.bbox||vr(l),l.geometry.bbox}function ut(l){const t=Ee(l);return{width:t[2]-t[0],height:t[3]-t[1]}}function ct(l){const t=Ee(l);return{x:t[0],y:t[1]}}function vr(l){const[t,i]=l.geometry.coordinates[0][0],[r,a]=l.geometry.coordinates[0][2];l.geometry.bbox=[t,i,r,a]}function wr(l,t,i,r,a){l.geometry.bbox=[t,i,t+r,i+a],l.geometry.coordinates=[[[t,i],[t+r,i],[t+r,i+a],[t,i+a],[t,i]]]}function $t(l){const[t,i]=l.geometry.coordinates[0];return{x:t,y:i}}function jt(l,t){const[i,r]=l.geometry.coordinates[t==="start"?0:1];return{x:i,y:r}}function Nt(l){const[t,i]=l.geometry.coordinates[1];return{x:t,y:i}}function Se(l,t,i){l.geometry.coordinates[0]=[t,i]}function Ce(l,t,i){l.geometry.coordinates[1]=[t,i]}function Bt(l){return{start:$t(l),end:Nt(l)}}function kt(l,t,i,r){t==="start"?Se(l,i,r):Ce(l,i,r)}const _e=l=>parseInt(l.getAttribute("data-handle-id")||"-1");function xr(l){return Array.isArray(l)&&l.length===2&&l.every(isFinite)}function br(l,t,i,r){for(let a=0;a<l.coordinates.length;a++){const h=l.coordinates[a];if(xr(h))h[0]=i+(h[0]-i)*t,h[1]=r+(h[1]-r)*t;else for(let c=0;c<h.length;c++){const d=h[c];d[0]=i+(d[0]-i)*t,d[1]=r+(d[1]-r)*t}}return l}function qt(l,t,i){const r=Math.atan2(l.y-t.y,l.x-t.x);return{x:t.x+i*Math.cos(r),y:t.y+i*Math.sin(r)}}function Rt(l,t){if(!t)return{x:l.clientX,y:l.clientY};const i=t.getBoundingClientRect();return{x:l.clientX-i.left-t.clientLeft,y:l.clientY-i.top-t.clientTop}}const wt=(l,t)=>({x:l.x-t.x,y:l.y-t.y}),Et=l=>Math.sqrt(l.x*l.x+l.y*l.y),De=l=>({x:-l.x,y:-l.y}),Le=l=>{const t=Et(l);return t===0?{x:0,y:0}:{x:l.x/t,y:l.y/t}},St=(l,t)=>({x:l.x+t.x,y:l.y+t.y}),Te=(l,t)=>({x:l.x*t,y:l.y*t}),Wt=(l,t)=>({x:l.x*t.x,y:l.y*t.y}),rt=(l,t)=>{const i=Math.sin(t),r=Math.cos(t);return{x:l.x*r-l.y*i,y:l.x*i+l.y*r}},Ar=(l,t)=>({x:l.x/t,y:l.y/t}),Ie=(l,t)=>l.x*t.x+l.y*t.y,kr=.5;function $e(l,t=5,i=30){var r;const{start:a,end:h}=Bt(l),c=wt(h,a),d=l.properties.style&&l.properties.style.strokeWidth?(r=l.properties.style)==null?void 0:r.strokeWidth:0;return Math.min(i,Math.max(3*d,Et(c)*.01,t))}function Me(l,t,i,r){const a=Te(De(Le(t)),r);if(!i||i!=="arrow"&&i!=="arrow-plain")return"";const h=St(l,rt(a,Math.PI/10)),c=St(l,rt(a,-Math.PI/10)),d=`${l.x} ${l.y}`;return`M ${h.x} ${h.y} L ${d} ${c.x} ${c.y} ${i==="arrow"?"":`${h.x} ${h.y}`}`}function Er(l,t,i,r,a){const{start:h,end:c}=Bt(l),{tail:d,head:f,strokeColor:g,strokeWidth:p=0}=l.properties.style||i,w=wt(c,h),b=$e(l,r,a),A=vt("g"),E=vt("path");A.setAttribute("data-annotation",`${l.id}`),A.setAttribute("data-annotation-type","arrow");const k=f==="arrow-plain"||d==="arrow",L=g||"none";E.setAttribute("stroke",L),E.setAttribute("stroke-width",`${p}`),E.setAttribute("fill",k?g||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const M=Me(h,De(w),d,b),C=Me(c,w,f,b),N=M+`M ${h.x} ${h.y} ${c.x} ${c.y}`+C;E.setAttribute("d",N),A.appendChild(E),Oe(A,h,L,d,p),Oe(A,c,L,f,p),t.appendChild(A)}function Oe(l,t,i,r,a){r==="halo-dot"&&ze(l,t,Sr(i),kr,a*4),(r==="dot"||r==="halo-dot")&&ze(l,t,i,1,a*2)}function Sr(l){return l==="none"?"none":l}function ze(l,t,i,r,a){const h=vt("circle");h.setAttribute("cx",`${t.x}`),h.setAttribute("cy",`${t.y}`),h.setAttribute("r",`${a}`),h.setAttribute("fill-opacity",`${r}`),h.setAttribute("fill",i),l.appendChild(h)}const U=-1,Ut="dragging",Xt="dragstart",Ct="dragend",Qt="select",te="unselect",Cr="hover",_r="unhover",ee="remove",re="add",Dr="cancelDrawing",ne="update",Lr="link";function Pe(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Fe={exports:{}},He;function Tr(){return He||(He=1,function(l){var t=Object.prototype.hasOwnProperty,i="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(i=!1));function a(f,g,p){this.fn=f,this.context=g,this.once=p||!1}function h(f,g,p,w,b){if(typeof p!="function")throw new TypeError("The listener must be a function");var A=new a(p,w||f,b),E=i?i+g:g;return f._events[E]?f._events[E].fn?f._events[E]=[f._events[E],A]:f._events[E].push(A):(f._events[E]=A,f._eventsCount++),f}function c(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function d(){this._events=new r,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],g,p;if(this._eventsCount===0)return f;for(p in g=this._events)t.call(g,p)&&f.push(i?p.slice(1):p);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(g)):f},d.prototype.listeners=function(f){var g=i?i+f:f,p=this._events[g];if(!p)return[];if(p.fn)return[p.fn];for(var w=0,b=p.length,A=new Array(b);w<b;w++)A[w]=p[w].fn;return A},d.prototype.listenerCount=function(f){var g=i?i+f:f,p=this._events[g];return p?p.fn?1:p.length:0},d.prototype.emit=function(f,g,p,w,b,A){var E=i?i+f:f;if(!this._events[E])return!1;var k=this._events[E],L=arguments.length,M,C;if(k.fn){switch(k.once&&this.removeListener(f,k.fn,void 0,!0),L){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,g),!0;case 3:return k.fn.call(k.context,g,p),!0;case 4:return k.fn.call(k.context,g,p,w),!0;case 5:return k.fn.call(k.context,g,p,w,b),!0;case 6:return k.fn.call(k.context,g,p,w,b,A),!0}for(C=1,M=new Array(L-1);C<L;C++)M[C-1]=arguments[C];k.fn.apply(k.context,M)}else{var N=k.length,P;for(C=0;C<N;C++)switch(k[C].once&&this.removeListener(f,k[C].fn,void 0,!0),L){case 1:k[C].fn.call(k[C].context);break;case 2:k[C].fn.call(k[C].context,g);break;case 3:k[C].fn.call(k[C].context,g,p);break;case 4:k[C].fn.call(k[C].context,g,p,w);break;default:if(!M)for(P=1,M=new Array(L-1);P<L;P++)M[P-1]=arguments[P];k[C].fn.apply(k[C].context,M)}}return!0},d.prototype.on=function(f,g,p){return h(this,f,g,p,!1)},d.prototype.once=function(f,g,p){return h(this,f,g,p,!0)},d.prototype.removeListener=function(f,g,p,w){var b=i?i+f:f;if(!this._events[b])return this;if(!g)return c(this,b),this;var A=this._events[b];if(A.fn)A.fn===g&&(!w||A.once)&&(!p||A.context===p)&&c(this,b);else{for(var E=0,k=[],L=A.length;E<L;E++)(A[E].fn!==g||w&&!A[E].once||p&&A[E].context!==p)&&k.push(A[E]);k.length?this._events[b]=k.length===1?k[0]:k:c(this,b)}return this},d.prototype.removeAllListeners=function(f){var g;return f?(g=i?i+f:f,this._events[g]&&c(this,g)):(this._events=new r,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=i,d.EventEmitter=d,l.exports=d}(Fe)),Fe.exports}var Ir=Tr();const je=Pe(Ir);class Ne extends je{constructor(t,i){super(),m(this,"ogma"),m(this,"elements"),m(this,"layer"),m(this,"editor"),m(this,"selectedId",U),m(this,"hoveredId",U),m(this,"ogmaOptions"),m(this,"shouldDetect"),m(this,"isDragging"),m(this,"showeditorOnHover"),m(this,"_onKeyUp",r=>{r.code===27&&this.selectedId!==U?this.unselect():(r.code===46||r.code===8)&&this.selectedId!==U&&this._canRemove()&&this.remove(this.selectedId)}),m(this,"_onClickMouseMove",r=>{if(!r.domEvent||this.isDragging||!this.shouldDetect||r.domEvent.type!=="mousemove"&&r.domEvent.target&&r.domEvent.target.tagName==="a")return;const a=this.ogma.view.screenToGraphCoordinates(r),h=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(a,0):void 0;r.domEvent.type==="mousemove"?h?this.hover(h.id):this.hoveredId!==U&&this.unhover():h?this.select(h.id):this.selectedId!==U&&this.unselect()}),this.ogma=t,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=t.getOptions(),t.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("frame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=t.layers.addSVGLayer({draw:r=>this.draw(r)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(i),this.editor.hide()}_canRemove(){return!0}add(t){const i=this.getDefaultOptions(),r=Object.assign(t,{id:t.id===void 0?Ht():t.id,type:t.type,properties:{...i.properties,...t.properties||{},style:{...i.properties.style,...t.properties.style||{}}},geometry:{...i.geometry,...t.geometry}});return this.elements.push(r),this.layer.refresh(),this.emit(re,r),r}updateStyle(t,i){this.updateAnnotation(t,{properties:{style:i}})}updateGeometry(t,i){this.updateAnnotation(t,{geometry:i})}scale(t,i,r,a){this.updateGeometry(t,br(t.geometry,i,r,a))}update(t,i){const r=this.getById(t);this.updateAnnotation(r,i)}updateAnnotation(t,i){if(!t)return;const r=t.id;Object.keys(i).forEach(a=>{if(a!=="id")if(a==="properties"){const h=i.properties||{style:{}};t.properties={...t.properties||{},...h||{},style:{...t.properties.style||{},...h.style||{}}}}else a==="geometry"?t.geometry={...t.geometry,...i.geometry}:t[a]=i[a]}),r===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){const i=Number(t);for(let r=0;r<this.elements.length;r++){const a=this.elements[r];if(!(a.id!==t&&a.id!==i))return a}}select(t){const i=this.getById(t);i&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Qt,i))}hover(t){const i=this.getById(t);i&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Cr,i))}getSelectedFeature(){return this.selectedId===U?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(te,t),this.selectedId=U,this.hoveredId===U&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit(_r,t),this.hoveredId=U,this.selectedId===U&&this.editor.hide(),this.layer.refresh(),this}remove(t){const i=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(r=>r.id!==t),i&&this.emit(ee,i),this.layer.refresh()}disableDragging(){this.ogma.setOptions({interactions:{drag:{enabled:!1},pan:{enabled:!1}},detect:{nodes:!1,edges:!1,nodeTexts:!1,edgeTexts:!1}})}restoreDragging(){this.ogma.setOptions(this.ogmaOptions)}enableDetection(){this.shouldDetect=!0}disableDetection(){this.shouldDetect=!1}refreshLayer(){this.layer.refresh()}refreshDrawing(){}getElements(){return[...this.elements]}destroy(){this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp),this.layer.destroy()}}const Be="handle-line",qe="handle-start",Re="handle-end";class $r extends Ne{constructor(t,i={}){super(t,`
2
2
  <div class="arrow-handle">
3
3
  <div id="${Be}" data-handle-id="0" class="handle line"></div>
4
4
  <div id="${qe}" data-handle-id="1" class="handle point"></div>
5
5
  <div id="${Re}" data-handle-id="2" class="handle point"></div>
6
6
  </div>
7
- `),m(this,"draggedHandle",U),m(this,"start",{x:0,y:0}),m(this,"end",{x:0,y:0}),m(this,"arrow",{...ke}),m(this,"startX",0),m(this,"startY",0),m(this,"minArrowHeight",0),m(this,"maxArrowHeight",0),m(this,"handles",[]),m(this,"onHandleMouseDown",r=>{const a=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!a)return;const{x:h,y:c}=Rt(r,this.ogma.getContainer());this.startDragging(a,h,c),this.draggedHandle=_e(r.target)}),m(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=U,this.emit(Ct,this.arrow))}),m(this,"onMouseMove",r=>{if(!this.isDragging||this.draggedHandle===U)return;const{x:a,y:h}=Rt(r,this.ogma.getContainer()),c=this.handles[this.draggedHandle],f=this.ogma.view.getAngle(),{x:d,y:g}=rt(Ar({x:a-this.startX,y:h-this.startY},this.ogma.view.getZoom()),f),p=c.id===Be,b=c.id===qe,A=c.id===Re;(p||b)&&Se(this.arrow,this.start.x+d,this.start.y+g),(p||A)&&Ce(this.arrow,this.end.x+d,this.end.y+g),this.emit(Ut,this.arrow,p?"line":b?"start":"end"),this.refreshEditor(),this.layer.refresh()}),this.minArrowHeight=s.minArrowHeight||0,this.maxArrowHeight=s.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(r=>r.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,s,r=yr(t,s,t,s,It)){var a;this.disableDragging(),this.add(r),this.hoveredId=r.id;const h=this.ogma.view.graphToScreenCoordinates({x:t,y:s}),c=((a=this.ogma.getContainer())==null?void 0:a.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(r.id),h.x+(c==null?void 0:c.left),h.y+c.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Ct,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=U)}startDragging(t,s,r){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=s,this.startY=r,this.start=$t(this.arrow),this.end=Nt(this.arrow),this.disableDragging(),this.emit(Xt,this.arrow),this.isDragging=!0}detect(t,s=0){return this.elements.find(r=>{const{start:a,end:h}=Bt(r),c=wt(t,{x:(a.x+h.x)/2,y:(a.y+h.y)/2}),f=wt(h,a),d=Et(f),g=Le(f),p=$e(r);return Math.abs(Ie(g,c))<d/2+s&&Math.abs(Ie(rt(g,Math.PI/2),c))<p/2+s})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==U?this.getById(this.selectedId):this.getById(this.hoveredId),s=Bt(t),r=this.ogma.view.graphToScreenCoordinates(s.start),a=this.ogma.view.graphToScreenCoordinates(s.end),[h,c,f]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));c.style.transform=`translate(${r.x}px, ${r.y}px) translate(-50%, -50%)`,f.style.transform=`translate(${a.x}px, ${a.y}px) translate(-50%, -50%)`;const d={x:(a.x+r.x)/2,y:(a.y+r.y)/2},g=wt(a,r),p=Te(g,1/Et(g)),b=Math.atan2(p.y,p.x);h.style.width=`${Et(g)}px`,h.style.left=`${d.x}px`,h.style.top=`${d.y}px`,h.style.transform=`translate(-50%, -50%) rotate(${b}rad)`}getDefaultOptions(){return ke}draw(t){t.innerHTML="";const s=vt("g"),r=this.ogma.view.getAngle();r!==0&&s.setAttribute("transform",`rotate(${-r*(180/Math.PI)})`),this.elements.forEach(a=>Er(a,s,It,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(s)}refreshDrawing(){const t=this.ogma.view.getAngle();this.layer.element!==null&&t!==0&&this.layer.element.children[0].setAttribute("transform",`rotate(${-t*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const _t={font:"sans-serif",fontSize:18,color:"#505050",background:"#f5f5f5",strokeWidth:0,borderRadius:8,padding:16,strokeType:"plain"},ie={id:0,type:"Feature",properties:{type:"text",content:"",style:{..._t}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},We={handleSize:3.5,placeholder:"Your text..."},Mr=(l=0,t=0,s=100,r=50,a="",h={..._t})=>({id:Ht(),type:"Feature",properties:{type:"text",content:a,style:{..._t,...h}},geometry:{type:"Polygon",coordinates:[[[l,t],[l+s,t],[l+s,t+r],[l,t+r],[l,t]]]}});var se={exports:{}},Or=se.exports,Ue;function zr(){return Ue||(Ue=1,function(l,t){(function(s,r){l.exports=r()})(Or,()=>(()=>{var s={d:(e,n)=>{for(var o in n)s.o(n,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function a(e){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},a(e)}s.d(r,{default:()=>Ln});var h=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,c=/\bsmall-caps\b/,f=/\b(?:italic|oblique)\b/,d=/\bbold(?:er)?\b/,g=13.3333333,p={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32};function b(e){var n="",o=this;return o.style&&o.style!=="normal"&&(n+=o.style),o.variant&&o.variant!=="normal"&&(n+=(n?" ":"")+o.variant),o.weight&&o.weight!=="normal"&&(n+=(n?" ":"")+o.weight),o.size&&(n+=(n?" ":"")+o.size+"px",o.height!==o.size&&(n+="/"+o.height+"px")),o.family&&(n+=(n?" ":"")+o.family),e&&(n+="::"+o.baseline),e&&(n+="::"+o.color),n}var A={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:b,valueOf:b};function k(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=h.exec(e);n.family=(o[6]||"").trim();var i=p[o[2]]||parseFloat(o[2]);o[3]==="%"?i*=.16:o[3]==="em"?i*=16:o[3]==="pt"&&(i*=g),n.size=i;var u=parseFloat(o[4]);if(u!=="normal"&&u!=="inherit"&&u?o[5]&&o[5]!=="em"?o[5]==="pt"?n.height=u*g:o[5]==="%"?n.height=.01*i:n.height=u:n.height=u*i:n.height=Math.round(i*(7/6)),c.test(o[1])&&(n.variant="small-caps"),f.test(o[1])&&(n.style="italic"),d.test(o[1]))n.weight="bold";else{var y=parseInt(/\b(\d+)\b/.exec(o[1]),10);y>=100&&y!==400&&(n.weight=y)}return n}function E(){var e,n,o,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=14,w=12,v=null,S=null,_="";if(i&&i.nodeType){var I=i&&(i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView),$=I.getComputedStyle(i,null);e=$.getPropertyValue("font-family")||"",w=parseFloat($.getPropertyValue("font-size")),y=$.getPropertyValue("line-height"),v=$.getPropertyValue("font-weight"),S=$.getPropertyValue("font-style"),_=$.getPropertyValue("font-variant")||""}else if(typeof i=="string"){var D=k(i);e=D.family,w=D.size,y=D.height,_=D.variant,S=D.style,v=D.weight}else a(i)==="object"&&(e=i.family,w=i.size,y=i.height,_=i.variant,v=i.weight,S=i.style,n=i.baseline,o=i.color);u.size&&u.size<3&&(w*=u.size),y=y!=="normal"&&y?parseFloat(y):w*(7/6),u.height&&u.height<3&&(y*=u.height);var M=Object.create(A);return M.family=u.family||e||"sans-serif",M.height=y??14,M.size=w??12,M.variant=u.variant||_||"",M.style=u.style||S||"",M.weight=u.weight||v||"",M.baseline=n||0,u.baseline!=null&&(M.baseline=u.baseline),M.color=u.color||o||"",M.id=b.call(M,!0),M}const x={"\n":.28,"\r":.28," ":.28," ":.28," ":.28,"᠎":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"​":0," ":.16," ":.22," ":1,"\uFEFF":0};var L,O=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var o=n.getContext("2d");if(o&&typeof o.measureText=="function")return function(i,u){return o.font=String(u),o.measureText(i).width}}}(typeof document<"u"?document:null)||(L={},function(e,n){if(!L[n]){var o=E(n);L[n]=o,/\bmonospace\b/.test(o.family)?o.size*=.6:(o.size*=.45,o.weight&&(o.size*=1.18))}return e.length*L[n].size}),C={},P={trim:!0,collapse:!0};function N(e,n,o){var i=Object.assign({},P,o),u=String(e);if(!u)return 0;if(u in x){var y=n.id+"/"+u;return y in C||(C[y]=O("_".concat(u,"_"),n)-O("__",n)),C[y]}return i.trim&&i.collapse?i.trim?u=u.trim():i.collapse&&(u=u.replace(/\s+/g," ")):u=u.replace(/\n/g," "),O(u,n)+n.size*(e.tracking||0)}function nt(e){return nt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},nt(e)}function at(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&de(e,n)}function de(e,n){return de=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,i){return o.__proto__=i,o},de(e,n)}function fe(e){var n=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var o,i=Gt(e);if(n){var u=Gt(this).constructor;o=Reflect.construct(i,arguments,u)}else o=i.apply(this,arguments);return Yr(this,o)}}function Yr(e,n){if(n&&(nt(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}(e)}function Gt(e){return Gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Gt(e)}function Vt(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Jr(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(u=function(y,w){if(nt(y)!=="object"||y===null)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var S=v.call(y,w);if(nt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),nt(u)==="symbol"?u:String(u)),i)}var u}function Zt(e,n,o){return n&&Jr(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var B=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Vt(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return Zt(e,[{key:"clone",value:function(){var n=new e(this.value);return n.value=this.value,n.weight=this.weight,n.style=this.style,n.font=this.font,n.href=this.href,n.sub=this.sub,n.sup=this.sup,n}},{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}}]),e}(),Mt=function(e){at(o,e);var n=fe(o);function o(){return Vt(this,o),n.apply(this,arguments)}return Zt(o)}(B),it=function(e){at(o,e);var n=fe(o);function o(){return Vt(this,o),n.apply(this,arguments)}return Zt(o)}(B),xt=function(e){at(o,e);var n=fe(o);function o(){return Vt(this,o),n.apply(this,arguments)}return Zt(o)}(B),ge=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,Kr=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,er=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Qr=/^(?:[;\xAD%?…]|,(?!\d))/,tn=/^[´±°¢£¤$¥\u2212]/;function Yt(e,n){n!==!1&&(e=e.trim());for(var o,i,u=[],y=e.charAt(0),w=0,v=1,S=e.length;v<S;v++){o=e.charAt(v),i=e.charAt(v+1);var _=ge.test(y),I=ge.test(o),$=I||_,D=void 0;if((tn.test(o)&&!er.test(y)||Qr.test(y+i)&&!er.test(o))&&($=!0),y!=="-"&&y!=="‐"&&y!=="–"&&y!=="—"||((D=ge.test(e.charAt(v-2)))&&!I&&($=!1),!D&&Kr.test(o+i)&&($=!0)),$){var M=e.slice(w,v);/\u00AD$/.test(M)?(u.push(new B(M.slice(0,-1))),u.push(new xt)):(u.push(new B(M)),u.push(new Mt)),w=v}y=o}return u.push(new B(e.slice(w))),u}const rr={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"⊥",or:"⊦",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›"};var en=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,rn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,nn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,sn=/^<!--(.+?)-->/,on=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,nr={b:function(e){e.weight="bold"},strong:function(e){e.weight="bold"},i:function(e){e.style="italic"},em:function(e){e.style="italic"},dfn:function(e){e.style="italic"},cite:function(e){e.style="italic"},code:function(e){e.family="monospace"},kbd:function(e){e.family="monospace"},samp:function(e){e.family="monospace"},var:function(e){e.family="monospace"},tt:function(e){e.family="monospace"},sub:function(e){e.sub=!0},sup:function(e){e.sup=!0}},an={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function ir(e){return e.replace(on,function(n,o,i,u){if(o||i){var y=o?10:16;return String.fromCharCode(parseInt(o||i,y))}return u in rr?rr[u]:n})}function ln(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var hn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function un(e){var n,o={};if(e){do if(n=hn.exec(e)){var i=ir(ln(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(o[n[1]]=i,(e=e.slice(n[0].length)).length&&/^\S/.test(e[0]))throw new Error("Attribute error")}while(n&&e.length);if(/\S/.test(e))throw new Error("Attribute error")}return o}const sr={copyright:"©",textcopyright:"©",dag:"†",textdagger:"†",ddag:"‡",textdaggerdbl:"‡",guillemotleft:"«",guillemotright:"»",guilsinglleft:"‹",guilsinglright:"›",ldots:"…",dots:"…",textellipsis:"…",lq:"‘",P:"¶",textparagraph:"¶",pounds:"£",textsterling:"£",quotedblbase:"„",quotesinglbase:"‚",rq:"’",S:"§",sim:"~",textasciicircum:"^",textasciitilde:"˜",texttildelow:"~",textasteriskcentered:"*",textbackslash:"'",textbar:"|",textbardbl:"╎",textbigcircle:"◯",textbraceleft:"{",textbraceright:"}",textbullet:"•",textdollar:"$",textemdash:"—",textendash:"—",texteuro:"€",eurosym:"€",euro:"€",textexclamdown:"¡",textgreater:">",textless:"<",textordfeminine:"ª",textordmasculine:"º",textperiodcentered:"·",cdot:"·",textquestiondown:"¿",textquotedblleft:"“",textquotedblright:"”",textquoteleft:"‘",textquoteright:"’",textquotestraightbase:"‚",textquotestraightdblbase:"„",textregistered:"®",textthreequartersemdash:"-",texttrademark:"™",texttwelveudash:"-",textunderscore:"_",textvisiblespace:"␣",gets:"←",textleftarrow:"←",to:"→",textrightarrow:"→",textdegree:"°",infty:"∞",triangle:"△",triangledown:"▽",blacktriangle:"▲",blacktriangledown:"▼",angle:"∠",sphericalangle:"∢",aleph:"ℵ",hbar:"ħ",imath:"𝚤",jmath:"𝚥",ell:"ℓ",wp:"℘",Re:"ℜ",Im:"ℑ",mho:"℧",prime:"′",emptyset:"∅",nabla:"∇",surd:"√",partial:"∂",top:"⟙",bot:"⟂",vdash:"⟝",dashv:"⟞",forall:"∀",exists:"∃",nexists:"∄",neg:"¬",lnot:"¬",flat:"♭",natural:"♮",sharp:"♯",backslash:"\\",Box:"□",Diamond:"♢",clubsuit:"♣",diamondsuit:"♦",heartsuit:"♥",spadesuit:"♠",Join:"⨝",blacksquare:"■",bigstar:"★",diagdown:"╲",diagup:"╱",blacklozenge:"⧫",rfloor:"⌋",lfloor:"⌊",rceil:"⌉",lceil:"⌈",rangle:"⟩",langle:"⟨",sum:"∑",int:"∫",oint:"∮",prod:"∏",coprod:"∏",bigcap:"∩",bigcup:"∪",bigsqcup:"⊔",bigvee:"∨",bigwedge:"∧",bigodot:"⊙",bigotimes:"⊗",bigoplus:"⊕",biguplus:"⊎",alpha:"α",beta:"β",chi:"χ",delta:"δ",epsilon:"ε",eta:"η",gamma:"γ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",omega:"ω",phi:"φ",pi:"π",psi:"ψ",rho:"ρ",sigma:"σ",tau:"τ",theta:"θ",upsilon:"υ",xi:"ξ",zeta:"ζ",Alpha:"Α",Beta:"Β",Chi:"Χ",Delta:"Δ",Epsilon:"Ε",Eta:"Η",Gamma:"Γ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Omega:"Ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Theta:"Θ",Upsilon:"Υ",Xi:"Ξ",Zeta:"Ζ",aa:"å",AA:"Å",ae:"æ",AE:"Æ",dh:"ð",DH:"Ð",dj:"đ",DJ:"Đ",ij:"ij",IJ:"IJ",l:"ł",L:"Ł",ng:"ŋ",NG:"Ŋ",o:"ø",O:"Ø",oe:"œ",OE:"Œ",ss:"ß",SS:"SS",th:"þ",TH:"Þ"};var cn=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,dn=/^%[^\n]+(?:\n|$)/,fn=/^[^#$%&~_^\\{}]+/,gn=/^\\([&{}$%#_])/,pn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,yn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},G={bf:function(e){e.weight="bold"},it:function(e){e.style="italic"},sl:function(e){e.style="italic"},color:function(e,n){e.color=n},href:function(e,n){e.href=n},"^":function(e){e.sup=!0},_:function(e){e.sub=!0},par:function(e){this.tokens.push(new it,new it)},newline:function(e){this.tokens.push(new it)},url:function(e,n){this.open_context().href=n,this.add_token(new B(n)),this.close_context()}};G.textsuperscript=G["^"],G.textsubscript=G._,G.textsl=G.sl,G.mathbf=G.bf,G.mathit=G.it,G.textbf=G.bf,G.textit=G.it,G.textcolor=G.color;var mn=/[\r\n\xA0]+/g;function vn(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var o=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(o=E(n,e)),o}function or(e,n,o){for(var i,u,y=e.width;y+o.width>n&&e.length;)u=(i=e[e.length-1]).width,i.width>o.width?(i.value=i.value.slice(0,-1),i.width=N(i,i.font),y+=i.width):e.pop(),y-=u;e[e.length-1]instanceof xt&&e.pop(),i=e[e.length-1]||i||{},o.font=E(o.font,i.bold,i.italic,""),o.href=e.length?i.href:null,o.rel=e.length?i.rel:null,o.target=e.length?i.target:null,e.push(o)}function Dt(e){return Math.round(1e6*e)/1e6}function ar(e){return function(n){if(Array.isArray(n))return pe(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,o){if(n){if(typeof n=="string")return pe(n,o);var i=Object.prototype.toString.call(n).slice(8,-1);return i==="Object"&&n.constructor&&(i=n.constructor.name),i==="Map"||i==="Set"?Array.from(n):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pe(n,o):void 0}}(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function pe(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}var wn={center:"middle",right:"end"},xn={middle:.5,center:.5,bottom:1,end:1},ye=function(e,n){return!e&&!n||e===n};function bn(e,n){var o=[],i=n.font(),u=i.size,y=i.family,w=n.align(),v=n.createElement();if(e.length){var S=i.height,_=n.valign(),I=n.height()(),$=n.width()(0),D=!isFinite($)&&e.length===1,M=D?null:n.x(),q=Dt(S/u),Q=D?null:Dt(S/(1.15*u+(S-u)/2));if(xn[_]&&isFinite(I)){var F=_==="bottom"?1:.5;Q+=(I*F-S*e.length*F)/u}var z=w==="justify",R=0;w==="right"?R=$:w==="center"&&(R=$/2);for(var j=[],tt="tspan",Z=null,W="",T=function(){if(W){var bt=v(tt,Z,W);j.push(bt)}tt="tspan",Z=null,W=""},st=0,et=e.length;st<et;st++){var ft="",yt="",ht=0,gt=e[st];if(gt.length){j=[];for(var Lt=0,Pt=0,pt=void 0,Y=0,Jt=gt.length;Y<Jt;Y++){var X=gt[Y],J=X.font;X.whitespace&&Lt++,Pt+=X.width,Y&&!X.tracking&&!ht&&ye(J.id,ft)&&ye(X.class,yt)&&ye(pt,X.href)?W+=X.value:(T(),W=X.value,Z={fontFamily:J.family!==y?J.family:null,fontSize:J.size!==u?J.size:null,fontWeight:J.weight||null,fontStyle:J.style||null,fontVariant:J.variant!=="normal"&&J.variant||null,fill:J.color||null,baselineShift:J.baseline?100*J.baseline+"%":null,className:X.class||null},ht&&(Z.dx=Dt(ht),ht=0),X.tracking&&(ht=J.size*X.tracking),X.href&&!pt?(pt=X.href,tt="a",Z.href=pt,Z.rel=X.rel,Z.target=X.target):pt=null,ft=J.id,yt=X.class)}if(T(),D)o.push.apply(o,ar(j));else{var Kt=null,Ft=st===et-1||gt[gt.length-1]instanceof it;z&&gt.length>1&&!Ft&&(Kt=Dt(($-Pt)/Lt)),o.push(v.apply(void 0,["tspan",{wordSpacing:Kt,x:M(st)+R,dy:Dt(st?q:Q)+"em"}].concat(ar(j))))}}else o.push(v("tspan",{x:M(st),dy:Dt(st?q:Q)+"em"}," "))}}return v.apply(void 0,["text",{fontFamily:y,fontSize:u,textAnchor:wn[w]||"start"}].concat(o))}var An={middle:.5,center:.5,bottom:1,end:1};function kn(e,n,o){if(e.length){o.textBaseline="middle";var i=n.font(),u=i.height,y=i.size,w=n.valign(),v=n.height()(),S=n.width()(0),_=n.align(),I=_==="justify",$=.5*u,D=An[w];if(D&&isFinite(v)){var M=e.length*u;$+=v*D-M*D}e.forEach(function(q,Q){var F=n.x()(Q),z=Q*u+$,R=0,j=0;q.forEach(function(W){W.whitespace&&R++,j+=W.width});var tt=0,Z=Q===e.length-1||q[q.length-1]instanceof it;I&&q.length>1&&!Z&&(tt=(S-j)/R),q.forEach(function(W){o.font=W.font;var T=W.font,st=T.baseline?y*-T.baseline+.15*y:0;o.fillStyle=function(yt,ht){return yt.color?yt.color:ht.href?"#00C":"#000"}(T,W);var et=0;if(_==="right"?et+=S-j:_==="center"?et+=S/2-j/2:_==="justify"&&(W.whitespace||W instanceof it)&&(F+=tt),o.fillText(W.value,F+et,z+st),W.href){o.beginPath(),o.strokeStyle=o.fillStyle;var ft=Math.floor(z+.45*y)+.5;o.moveTo(F+et,ft),o.lineTo(F+et+W.width,ft),o.stroke()}F+=W.width})})}}function me(e){return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},me(e)}function lr(e){for(var n={},o=0;o<e.length;o++){var i=e[o];typeof i!="number"&&i!=null&&(typeof i=="string"?n.text=i:typeof i=="function"?n.fn=i:me(i)==="object"&&i._groups?n.d3=i:i&&i.nodeType&&i.getContext?n.ctx=i.getContext("2d"):i&&i.fillText&&i.beginPath?n.ctx=i:i&&(n.text=i))}return n}function Ot(e){return Ot=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ot(e)}function En(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(u=function(y,w){if(Ot(y)!=="object"||y===null)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var S=v.call(y,w);if(Ot(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),Ot(u)==="symbol"?u:String(u)),i)}var u}var Sn=E(),ve=function(e){return typeof e=="function"?e:function(){return e}},lt=function(){function e(i){if(function(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={overflow:"ellipsis",lineclamp:null,align:"left",wordBreak:null,valign:"top",width:function(){return 1/0},height:function(){return 1/0},x:function(){return 0},font:null,tAnchor:0,parser:e.defaultparser},i)for(var u in i)typeof this[u]=="function"&&this[u](i[u])}var n,o;return n=e,o=[{key:"linebreak",value:function(i){var u=this,y=this.props.parser(String(i)),w=this.font(),v=function(S,_,I){if(!S.length)return[];var $=_.height(),D=_.width(),M=_.overflowLine(),q=_.overflowWrap(),Q=E(I,!0,!1),F=isFinite($())?Math.floor($()/I.height):1/0;if(!$()&&!D(0)||!F)return[];for(var z=0,R=0,j=0,tt=[],Z=[],W=!1;z<S.length&&R<F;){var T=S[z],st=vn(T,I);if(T.width=N(T,st),T.font=st,T.line=R,T.whitespace=T.value in x,T.value&&(T.value=T.value.replace(mn," ")),!(!j&&T.whitespace||W&&T.whitespace))if(T instanceof it)j=0,Z=[],tt.push(z+1),R++;else if(T instanceof Mt||T instanceof xt)Z.push({index:z,width:j});else if(T.whitespace||j+T.width<D(R))j+=T.width;else if(Z.length){var et=void 0,ft=void 0;do{ft=!0,et=Z.pop();var yt=S[et.index],ht=void 0;yt instanceof xt&&(ht=N("-",yt.font),et.width+ht>D(R)&&(ft=!Z.length))}while(!ft);tt.push(et.index+1),j=0,R++,z=et.index,Z=[]}else if(q==="break-word"){var gt=D(R);if(j+T.width>gt){var Lt=T.clone();do T.value=T.value.slice(0,-1),T.width=N(T,T.font),j+=T.width;while(T.value&&T.width>gt);Lt.value=Lt.value.slice(T.value.length),S.splice(z+1,0,new Mt,Lt)}tt.push(z+1),j=0,R++}else j+=T.width;z++,W=T.whitespace}z!==tt[tt.length-1]&&tt.push(z);var Pt=0,pt=0,Y=tt.map(function(bt){for(var K,At=Pt;(K=S[At])&&(K.whitespace||!K.value);)At++;for(var mt=bt,be=null;mt>At&&(K=S[mt-1])&&(K.whitespace||!(K.value||K instanceof xt));)K instanceof it&&(be=K),mt--;K instanceof xt&&(K.value="-",K.width=N("-",K.font)),Pt=bt;var Tt=S.slice(At,mt).filter(function(Ae){return Ae.value});return be&&Tt.push(be),Tt.width=Tt.reduce(function(Ae,Tn){return Ae+Tn.width},0),Tt.width>pt&&(pt=Tt.width),Tt});if(Y.hasLineOverflow=!1,M){var Jt=M==="ellipsis"?"…":M;Y.forEach(function(bt,K){var At=D(K);if(bt.width>At){var mt=new B(Jt);mt.font=I,mt.width=N(Jt,Q),or(bt,At,mt),Y.hasLineOverflow=!0}})}var X=_.overflow()==="ellipsis"?"…":_.overflow();if(X&&z!==S.length){var J=D(Y.length-1),Kt=Y[Y.length-1],Ft=new B(X);Ft.font=I,Ft.width=N(X,Q),or(Kt,J,Ft),Y.hasOverflow=!0}else Y.hasOverflow=!1;return Y.font=I,Y.width=pt,Y}(y,this,w);return v.height=v.length*w.height,v.render=function(S){return u.render(v,S)},v.svg=v.render,v.draw=v.render,v}},{key:"font",value:function(i){return arguments.length?(this.props.font=E(i),this):this.props.font||E(Sn)}},{key:"overflow",value:function(i){return arguments.length?(this.props.overflow=String(i),this):this.props.overflow}},{key:"overflowLine",value:function(i){return arguments.length?(this.props.lineclamp=String(i),this):this.props.lineclamp}},{key:"valign",value:function(i){return arguments.length?(this.props.valign=i,this):this.props.valign}},{key:"align",value:function(i){if(!arguments.length)return this.props.align;var u=String(i).toLowerCase();return u==="left"||u==="start"?(this.props.align="left",this.props.tAnchor=0):u==="center"||u==="middle"?(this.props.align="center",this.props.tAnchor=-.5):u==="end"||u==="right"?(this.props.align="right",this.props.tAnchor=-1):u==="justify"&&(this.props.align=i,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(i){if(!arguments.length)return this.props.overflowWrap||"normal";var u=String(i).toLowerCase();return u==="break-word"?this.props.overflowWrap="break-word":u!=="normal"&&i!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(i){return arguments.length?(this.props.width=ve(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=ve(i),this):this.props.height}},{key:"x",value:function(i){return arguments.length?(this.props.x=ve(i),this):this.props.x}},{key:"parser",value:function(i){if(!arguments.length)return this.props.parser;if(typeof i=="string"){var u=e[i]||e[i+"parser"];typeof u=="function"&&(i=u)}if(typeof i!="function")throw new Error("Unknown parser: "+i);return this.props.parser=i,this}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"render",value:function(){var i=lr(arguments);return typeof i.text=="string"&&(i.text=this.linebreak(i.text)),i.ctx?kn(i.text,this,i.ctx):bn(i.text,this)}}],o&&En(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function zt(e){return zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},zt(e)}function we(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}function Cn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(u=function(y,w){if(zt(y)!=="object"||y===null)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var S=v.call(y,w);if(zt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),zt(u)==="symbol"?u:String(u)),i)}var u}var hr=function(e){return typeof e=="function"?e:function(){return e}},ur=function(){function e(i){if(function(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},i)for(var u in i)typeof this[u]=="function"&&this[u](i[u]);this.render=this.render.bind(this)}var n,o;return n=e,o=[{key:"anchor",value:function(i){var u=this.props,y=u.hAnchor,w=u.vAnchor,v=u.width,S=u.height;if(!arguments.length)return[y*v(0),w*S(0)];if(typeof i=="string"){var _=this.props;i.toLowerCase().trim().split(/\s+/).forEach(function(I){I==="top"&&(_.vAnchor=-0),I==="middle"&&(_.vAnchor=-.5),I==="bottom"&&(_.vAnchor=-1),I==="left"&&(_.hAnchor=-0),I==="center"&&(_.hAnchor=-.5),I==="right"&&(_.hAnchor=-1)})}return this}},{key:"width",value:function(i){return arguments.length?(this.props.width=hr(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=hr(i),this):this.props.height}},{key:"rotate",value:function(i){return arguments.length?(this.props.rotation=i,this):this.props.rotation}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"canvas",value:function(i,u){var y,w=i.getContext?i.getContext("2d"):i;return w.save(),w.rotate(this.rotate()*Math.PI/180),w.translate.apply(w,function(v){if(Array.isArray(v))return we(v)}(y=this.anchor())||function(v){if(typeof Symbol<"u"&&v[Symbol.iterator]!=null||v["@@iterator"]!=null)return Array.from(v)}(y)||function(v,S){if(v){if(typeof v=="string")return we(v,S);var _=Object.prototype.toString.call(v).slice(8,-1);return _==="Object"&&v.constructor&&(_=v.constructor.name),_==="Map"||_==="Set"?Array.from(v):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?we(v,S):void 0}}(y)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
9
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),u(w),w.restore(),w}},{key:"render",value:function(){var i=lr(arguments);if(i.d3)return i.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(i.ctx)return this.canvas(i.ctx,i.fn);if(i.text){var u=typeof i.text.render=="function"?i.text.render():i.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},u)}}}],o&&Cn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}(),_n=Object.prototype.hasOwnProperty,xe={};function Dn(e){return xe[e]||(xe[e]=e.replace(/([a-z])([A-Z])/g,function(n,o,i){return o+"-"+i.toLowerCase()})),xe[e]}function cr(e,n){if(Array.isArray(n))return n.forEach(function(o){return cr(e,o)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function dr(e,n){if(typeof document<"u"){var o=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&o.setAttribute)for(var i in n)_n.call(n,i)&&n[i]!=null&&o.setAttribute(i==="className"?"class":Dn(i),n[i]);for(var u=arguments.length,y=new Array(u>2?u-2:0),w=2;w<u;w++)y[w-2]=arguments[w];return y!=null&&y.length&&y.forEach(function(v){cr(o,v)}),o}}lt.createElement=dr,lt.textparser=Yt,lt.defaultparser=Yt,lt.htmlparser=function(e){e=String(e||"").trim();for(var n,o,i={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},u=[],y=[],w=function($){for(var D in i)i[D]&&($[D]=i[D]);u.push($)},v=function($){var D=u.length,M=an[$];if(D&&M){for(var q=D-1;u[q]&&(u[q]instanceof Mt||en.test(u[q].value));)q--;for(;M&&u[q]&&u[q]instanceof it;)q--,M--;for(;M-- >0;)u.push(new it)}};e.length;){if(n=/^[^<]+/.exec(e))Yt(ir(n[0]),!1).forEach(w);else if(!(n=sn.exec(e)))if(n=rn.exec(e))y.length&&(i=y.pop()),v(n[1]);else if(n=nn.exec(e)){var S=n[1];v(S),y.push(i),i=Object.create(i),nr[S]&&nr[S](i,"");var _=un(n[2]);S==="a"&&(_.href&&(i.href=_.href),_.rel&&(i.rel=_.rel),_.target&&(i.target=_.target)),_.class&&(i.class=i.class?i.class+" "+_.class:_.class),_.style&&(o=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(_.style))&&o[1]&&(i.color=o[1]),S==="br"&&u.push(new it)}else n=[e.slice(0,1)],w(new B(n[0]));e=e.slice(n[0].length)}for(var I=u[u.length-1];I instanceof it;)u.pop(),I=u[u.length-1];return u},lt.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function(F,z){return n.push(z),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(pn,function(F,z,R){return R.charAt(z-1)==="\\"?F:yn[F]}).replace(/\n\s+/g,function(F){return/\n/.test(F.slice(1))?"\\par ":F}).replace(/\\symbol\{(\d+)\}/,function(F,z,R,j){return j.charAt(R-1)==="\\"?F:String.fromCharCode(1*z)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(F,z,R,j){return z+R+"{"+j+"}"}).replace(/\\verb,(.*?),/,function(F,z){return"\\verb,".concat(n[+z],",")});for(var o,i={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},u=[],y=[],w=function(F){for(var z in i)i[z]&&(F[z]=i[z]);return u.push(F),F},v=function(){y.push(i),i=Object.create(i)},S=function(){if(!y.length)throw new Error("Unexpected }");i=y.pop()},_={tokens:u,open_context:v,close_context:S,add_token:w};e.length;){if(o=fn.exec(e))Yt(o[0],!1).forEach(w);else if(o=gn.exec(e))w(new B(o[1]));else if(!(o=dn.exec(e))){if(o=/^\{/.exec(e))v();else if(o=/^\}/.exec(e))S();else if(!(o=/^\$/.exec(e)))if(o=/^\\verb,([^,]+),/.exec(e))w(new B(o[1]));else if(o=cn.exec(e)){var I=o[1].slice(1)||o[1],$=!!o[2];if(/^(La)?TeX$/i.test(I)){v(),i.family="serif";var D=void 0;I==="LaTeX"&&((D=w(new B("L"))).tracking=-.25,(D=w(new B("A"))).size=.7,D.baseline=.3,D.tracking=-.1),(D=w(new B("T"))).tracking=-.17,(D=w(new B("E"))).baseline=-.22,D.tracking=-.13,D=w(new B("X")),S()}else if(I in sr)w(new B(sr[I])),$&&v();else if(I in G){var M=[],q=G[I].length-1,Q=void 0;if(q){for($=!1,e=e.slice(o[0].length-1);q--;){if(!(Q=/^\{([^}]+)\}/.exec(e)))throw new Error(I+" is missing an argument");M.push(Q[1]),e=e.slice(Q[0].length)}o[0]=/^\{/.exec(e)?"{":"",$=!!o[0]}$&&v(),G[I].apply(_,[i].concat(M))}else console.warn("unknown latex command",I),w(new B(o[1])),$&&v()}else o=[e.slice(0,1)],w(new B(o[0]))}e=e.slice(o[0].length)}return u},lt.measureText=function(e,n,o){return N(e,E(n),o)},lt.Token=B,lt.Break=Mt,lt.LineBreak=it,lt.SoftHyphen=xt,lt.Rotator=ur,ur.createElement=dr;const Ln=lt;return r.default})())}(se)),se.exports}var Pr=zr();const Xe=Pe(Pr);function oe(l){return l.replace(/…$/,"")}function ae(l){return l.children[0].innerHTML}function Fr(l,t){const s=ut(l),{fontSize:r,font:a,padding:h=0}=l.properties.style||{};if(s.width===s.height&&s.width===0)return;const c=new Xe({font:`${r}px/${r}px ${a}`.replace(/(px)+/g,"px"),width:s.width-h*2,height:s.height-h*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Xe.createElement});c.overflowWrap("break-word");const f=c.linebreak(l.properties.content.replaceAll(`
10
- `,"<br>")).render(),d=[...f.children];let g=0;const p=[];l.properties.content.split(`
11
- `).forEach(k=>{let E=k;for(;E.length&&g<d.length;){if(d[g].innerHTML==="&nbsp;"){E.startsWith(`
12
- `)||p.push(g),g++;break}const x=oe(ae(d[g]));E.startsWith(x)&&(E=E.slice(x.length).trim()),g++}}),p.forEach(k=>f.removeChild(d[k]));const b=l.properties.content.match(/(https?:\/\/.*)/gm),A=b?b.map(k=>k.split(" ")[0]):[];f.setAttribute("transform",`translate(${h}, ${h})`),A.forEach(k=>{let E=k;const x=[];for(;E.length>0;){const L=d.find(C=>!!C.children[0]&&C.children[0].tagName==="tspan"&&E.startsWith(oe(ae(C))));if(!L)break;x.push(L);const O=oe(L.children[0].innerHTML).length;if(!O)break;E=E.slice(O)}x.forEach(L=>{const O=document.createElementNS("http://www.w3.org/2000/svg","a");O.setAttribute("href",k),O.setAttribute("target","_blank"),O.innerHTML=ae(L),L.children[0].innerHTML="",L.children[0].appendChild(O)})}),t.appendChild(f)}const Ge=20;class Hr extends Ne{constructor(t,s={}){super(t,`
7
+ `),m(this,"draggedHandle",U),m(this,"start",{x:0,y:0}),m(this,"end",{x:0,y:0}),m(this,"arrow",{...ke}),m(this,"startX",0),m(this,"startY",0),m(this,"minArrowHeight",0),m(this,"maxArrowHeight",0),m(this,"handles",[]),m(this,"onHandleMouseDown",r=>{const a=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!a)return;const{x:h,y:c}=Rt(r,this.ogma.getContainer());this.startDragging(a,h,c),this.draggedHandle=_e(r.target)}),m(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=U,this.emit(Ct,this.arrow))}),m(this,"onMouseMove",r=>{if(!this.isDragging||this.draggedHandle===U)return;const{x:a,y:h}=Rt(r,this.ogma.getContainer()),c=this.handles[this.draggedHandle],d=this.ogma.view.getAngle(),{x:f,y:g}=rt(Ar({x:a-this.startX,y:h-this.startY},this.ogma.view.getZoom()),d),p=c.id===Be,w=c.id===qe,b=c.id===Re;(p||w)&&Se(this.arrow,this.start.x+f,this.start.y+g),(p||b)&&Ce(this.arrow,this.end.x+f,this.end.y+g),this.emit(Ut,this.arrow,p?"line":w?"start":"end"),this.refreshEditor(),this.layer.refresh()}),this.minArrowHeight=i.minArrowHeight||0,this.maxArrowHeight=i.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(r=>r.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,i,r=yr(t,i,t,i,It)){var a;this.disableDragging(),this.add(r),this.hoveredId=r.id;const h=this.ogma.view.graphToScreenCoordinates({x:t,y:i}),c=((a=this.ogma.getContainer())==null?void 0:a.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(r.id),h.x+(c==null?void 0:c.left),h.y+c.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Ct,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=U)}startDragging(t,i,r){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=i,this.startY=r,this.start=$t(this.arrow),this.end=Nt(this.arrow),this.disableDragging(),this.emit(Xt,this.arrow),this.isDragging=!0}detect(t,i=0){return this.elements.find(r=>{const{start:a,end:h}=Bt(r),c=wt(t,{x:(a.x+h.x)/2,y:(a.y+h.y)/2}),d=wt(h,a),f=Et(d),g=Le(d),p=$e(r);return Math.abs(Ie(g,c))<f/2+i&&Math.abs(Ie(rt(g,Math.PI/2),c))<p/2+i})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==U?this.getById(this.selectedId):this.getById(this.hoveredId),i=Bt(t),r=this.ogma.view.graphToScreenCoordinates(i.start),a=this.ogma.view.graphToScreenCoordinates(i.end),[h,c,d]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));c.style.transform=`translate(${r.x}px, ${r.y}px) translate(-50%, -50%)`,d.style.transform=`translate(${a.x}px, ${a.y}px) translate(-50%, -50%)`;const f={x:(a.x+r.x)/2,y:(a.y+r.y)/2},g=wt(a,r),p=Te(g,1/Et(g)),w=Math.atan2(p.y,p.x);h.style.width=`${Et(g)}px`,h.style.left=`${f.x}px`,h.style.top=`${f.y}px`,h.style.transform=`translate(-50%, -50%) rotate(${w}rad)`}getDefaultOptions(){return ke}draw(t){t.innerHTML="";const i=vt("g"),r=this.ogma.view.getAngle();r!==0&&i.setAttribute("transform",`rotate(${-r*(180/Math.PI)})`),this.elements.forEach(a=>Er(a,i,It,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(i)}refreshDrawing(){const t=this.ogma.view.getAngle();this.layer.element!==null&&t!==0&&this.layer.element.children[0].setAttribute("transform",`rotate(${-t*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const _t={font:"sans-serif",fontSize:18,color:"#505050",background:"#f5f5f5",strokeWidth:0,borderRadius:8,padding:16,strokeType:"plain"},ie={id:0,type:"Feature",properties:{type:"text",content:"",style:{..._t}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},We={handleSize:3.5,placeholder:"Your text..."},Mr=(l=0,t=0,i=100,r=50,a="",h={..._t})=>({id:Ht(),type:"Feature",properties:{type:"text",content:a,style:{..._t,...h}},geometry:{type:"Polygon",coordinates:[[[l,t],[l+i,t],[l+i,t+r],[l,t+r],[l,t]]]}});var se={exports:{}},Or=se.exports,Ue;function zr(){return Ue||(Ue=1,function(l,t){(function(i,r){l.exports=r()})(Or,()=>(()=>{var i={d:(e,n)=>{for(var o in n)i.o(n,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function a(e){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},a(e)}i.d(r,{default:()=>Ln});var h=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,c=/\bsmall-caps\b/,d=/\b(?:italic|oblique)\b/,f=/\bbold(?:er)?\b/,g=13.3333333,p={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32};function w(e){var n="",o=this;return o.style&&o.style!=="normal"&&(n+=o.style),o.variant&&o.variant!=="normal"&&(n+=(n?" ":"")+o.variant),o.weight&&o.weight!=="normal"&&(n+=(n?" ":"")+o.weight),o.size&&(n+=(n?" ":"")+o.size+"px",o.height!==o.size&&(n+="/"+o.height+"px")),o.family&&(n+=(n?" ":"")+o.family),e&&(n+="::"+o.baseline),e&&(n+="::"+o.color),n}var b={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:w,valueOf:w};function A(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=h.exec(e);n.family=(o[6]||"").trim();var s=p[o[2]]||parseFloat(o[2]);o[3]==="%"?s*=.16:o[3]==="em"?s*=16:o[3]==="pt"&&(s*=g),n.size=s;var u=parseFloat(o[4]);if(u!=="normal"&&u!=="inherit"&&u?o[5]&&o[5]!=="em"?o[5]==="pt"?n.height=u*g:o[5]==="%"?n.height=.01*s:n.height=u:n.height=u*s:n.height=Math.round(s*(7/6)),c.test(o[1])&&(n.variant="small-caps"),d.test(o[1])&&(n.style="italic"),f.test(o[1]))n.weight="bold";else{var y=parseInt(/\b(\d+)\b/.exec(o[1]),10);y>=100&&y!==400&&(n.weight=y)}return n}function E(){var e,n,o,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=14,x=12,v=null,S=null,_="";if(s&&s.nodeType){var I=s&&(s.ownerDocument&&s.ownerDocument.defaultView||s.document&&s||s.defaultView),$=I.getComputedStyle(s,null);e=$.getPropertyValue("font-family")||"",x=parseFloat($.getPropertyValue("font-size")),y=$.getPropertyValue("line-height"),v=$.getPropertyValue("font-weight"),S=$.getPropertyValue("font-style"),_=$.getPropertyValue("font-variant")||""}else if(typeof s=="string"){var D=A(s);e=D.family,x=D.size,y=D.height,_=D.variant,S=D.style,v=D.weight}else a(s)==="object"&&(e=s.family,x=s.size,y=s.height,_=s.variant,v=s.weight,S=s.style,n=s.baseline,o=s.color);u.size&&u.size<3&&(x*=u.size),y=y!=="normal"&&y?parseFloat(y):x*(7/6),u.height&&u.height<3&&(y*=u.height);var O=Object.create(b);return O.family=u.family||e||"sans-serif",O.height=y??14,O.size=x??12,O.variant=u.variant||_||"",O.style=u.style||S||"",O.weight=u.weight||v||"",O.baseline=n||0,u.baseline!=null&&(O.baseline=u.baseline),O.color=u.color||o||"",O.id=w.call(O,!0),O}const k={"\n":.28,"\r":.28," ":.28," ":.28," ":.28,"᠎":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"​":0," ":.16," ":.22," ":1,"\uFEFF":0};var L,M=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var o=n.getContext("2d");if(o&&typeof o.measureText=="function")return function(s,u){return o.font=String(u),o.measureText(s).width}}}(typeof document<"u"?document:null)||(L={},function(e,n){if(!L[n]){var o=E(n);L[n]=o,/\bmonospace\b/.test(o.family)?o.size*=.6:(o.size*=.45,o.weight&&(o.size*=1.18))}return e.length*L[n].size}),C={},N={trim:!0,collapse:!0};function P(e,n,o){var s=Object.assign({},N,o),u=String(e);if(!u)return 0;if(u in k){var y=n.id+"/"+u;return y in C||(C[y]=M("_".concat(u,"_"),n)-M("__",n)),C[y]}return s.trim&&s.collapse?s.trim?u=u.trim():s.collapse&&(u=u.replace(/\s+/g," ")):u=u.replace(/\n/g," "),M(u,n)+n.size*(e.tracking||0)}function nt(e){return nt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},nt(e)}function at(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&de(e,n)}function de(e,n){return de=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,s){return o.__proto__=s,o},de(e,n)}function fe(e){var n=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var o,s=Gt(e);if(n){var u=Gt(this).constructor;o=Reflect.construct(s,arguments,u)}else o=s.apply(this,arguments);return Yr(this,o)}}function Yr(e,n){if(n&&(nt(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}(e)}function Gt(e){return Gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Gt(e)}function Vt(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Jr(e,n){for(var o=0;o<n.length;o++){var s=n[o];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,(u=function(y,x){if(nt(y)!=="object"||y===null)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var S=v.call(y,x);if(nt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(s.key,"string"),nt(u)==="symbol"?u:String(u)),s)}var u}function Zt(e,n,o){return n&&Jr(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var B=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Vt(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return Zt(e,[{key:"clone",value:function(){var n=new e(this.value);return n.value=this.value,n.weight=this.weight,n.style=this.style,n.font=this.font,n.href=this.href,n.sub=this.sub,n.sup=this.sup,n}},{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}}]),e}(),Mt=function(e){at(o,e);var n=fe(o);function o(){return Vt(this,o),n.apply(this,arguments)}return Zt(o)}(B),it=function(e){at(o,e);var n=fe(o);function o(){return Vt(this,o),n.apply(this,arguments)}return Zt(o)}(B),xt=function(e){at(o,e);var n=fe(o);function o(){return Vt(this,o),n.apply(this,arguments)}return Zt(o)}(B),ge=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,Kr=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,er=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Qr=/^(?:[;\xAD%?…]|,(?!\d))/,tn=/^[´±°¢£¤$¥\u2212]/;function Yt(e,n){n!==!1&&(e=e.trim());for(var o,s,u=[],y=e.charAt(0),x=0,v=1,S=e.length;v<S;v++){o=e.charAt(v),s=e.charAt(v+1);var _=ge.test(y),I=ge.test(o),$=I||_,D=void 0;if((tn.test(o)&&!er.test(y)||Qr.test(y+s)&&!er.test(o))&&($=!0),y!=="-"&&y!=="‐"&&y!=="–"&&y!=="—"||((D=ge.test(e.charAt(v-2)))&&!I&&($=!1),!D&&Kr.test(o+s)&&($=!0)),$){var O=e.slice(x,v);/\u00AD$/.test(O)?(u.push(new B(O.slice(0,-1))),u.push(new xt)):(u.push(new B(O)),u.push(new Mt)),x=v}y=o}return u.push(new B(e.slice(x))),u}const rr={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"⊥",or:"⊦",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›"};var en=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,rn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,nn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,sn=/^<!--(.+?)-->/,on=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,nr={b:function(e){e.weight="bold"},strong:function(e){e.weight="bold"},i:function(e){e.style="italic"},em:function(e){e.style="italic"},dfn:function(e){e.style="italic"},cite:function(e){e.style="italic"},code:function(e){e.family="monospace"},kbd:function(e){e.family="monospace"},samp:function(e){e.family="monospace"},var:function(e){e.family="monospace"},tt:function(e){e.family="monospace"},sub:function(e){e.sub=!0},sup:function(e){e.sup=!0}},an={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function ir(e){return e.replace(on,function(n,o,s,u){if(o||s){var y=o?10:16;return String.fromCharCode(parseInt(o||s,y))}return u in rr?rr[u]:n})}function ln(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var hn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function un(e){var n,o={};if(e){do if(n=hn.exec(e)){var s=ir(ln(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(o[n[1]]=s,(e=e.slice(n[0].length)).length&&/^\S/.test(e[0]))throw new Error("Attribute error")}while(n&&e.length);if(/\S/.test(e))throw new Error("Attribute error")}return o}const sr={copyright:"©",textcopyright:"©",dag:"†",textdagger:"†",ddag:"‡",textdaggerdbl:"‡",guillemotleft:"«",guillemotright:"»",guilsinglleft:"‹",guilsinglright:"›",ldots:"…",dots:"…",textellipsis:"…",lq:"‘",P:"¶",textparagraph:"¶",pounds:"£",textsterling:"£",quotedblbase:"„",quotesinglbase:"‚",rq:"’",S:"§",sim:"~",textasciicircum:"^",textasciitilde:"˜",texttildelow:"~",textasteriskcentered:"*",textbackslash:"'",textbar:"|",textbardbl:"╎",textbigcircle:"◯",textbraceleft:"{",textbraceright:"}",textbullet:"•",textdollar:"$",textemdash:"—",textendash:"—",texteuro:"€",eurosym:"€",euro:"€",textexclamdown:"¡",textgreater:">",textless:"<",textordfeminine:"ª",textordmasculine:"º",textperiodcentered:"·",cdot:"·",textquestiondown:"¿",textquotedblleft:"“",textquotedblright:"”",textquoteleft:"‘",textquoteright:"’",textquotestraightbase:"‚",textquotestraightdblbase:"„",textregistered:"®",textthreequartersemdash:"-",texttrademark:"™",texttwelveudash:"-",textunderscore:"_",textvisiblespace:"␣",gets:"←",textleftarrow:"←",to:"→",textrightarrow:"→",textdegree:"°",infty:"∞",triangle:"△",triangledown:"▽",blacktriangle:"▲",blacktriangledown:"▼",angle:"∠",sphericalangle:"∢",aleph:"ℵ",hbar:"ħ",imath:"𝚤",jmath:"𝚥",ell:"ℓ",wp:"℘",Re:"ℜ",Im:"ℑ",mho:"℧",prime:"′",emptyset:"∅",nabla:"∇",surd:"√",partial:"∂",top:"⟙",bot:"⟂",vdash:"⟝",dashv:"⟞",forall:"∀",exists:"∃",nexists:"∄",neg:"¬",lnot:"¬",flat:"♭",natural:"♮",sharp:"♯",backslash:"\\",Box:"□",Diamond:"♢",clubsuit:"♣",diamondsuit:"♦",heartsuit:"♥",spadesuit:"♠",Join:"⨝",blacksquare:"■",bigstar:"★",diagdown:"╲",diagup:"╱",blacklozenge:"⧫",rfloor:"⌋",lfloor:"⌊",rceil:"⌉",lceil:"⌈",rangle:"⟩",langle:"⟨",sum:"∑",int:"∫",oint:"∮",prod:"∏",coprod:"∏",bigcap:"∩",bigcup:"∪",bigsqcup:"⊔",bigvee:"∨",bigwedge:"∧",bigodot:"⊙",bigotimes:"⊗",bigoplus:"⊕",biguplus:"⊎",alpha:"α",beta:"β",chi:"χ",delta:"δ",epsilon:"ε",eta:"η",gamma:"γ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",omega:"ω",phi:"φ",pi:"π",psi:"ψ",rho:"ρ",sigma:"σ",tau:"τ",theta:"θ",upsilon:"υ",xi:"ξ",zeta:"ζ",Alpha:"Α",Beta:"Β",Chi:"Χ",Delta:"Δ",Epsilon:"Ε",Eta:"Η",Gamma:"Γ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Omega:"Ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Theta:"Θ",Upsilon:"Υ",Xi:"Ξ",Zeta:"Ζ",aa:"å",AA:"Å",ae:"æ",AE:"Æ",dh:"ð",DH:"Ð",dj:"đ",DJ:"Đ",ij:"ij",IJ:"IJ",l:"ł",L:"Ł",ng:"ŋ",NG:"Ŋ",o:"ø",O:"Ø",oe:"œ",OE:"Œ",ss:"ß",SS:"SS",th:"þ",TH:"Þ"};var cn=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,dn=/^%[^\n]+(?:\n|$)/,fn=/^[^#$%&~_^\\{}]+/,gn=/^\\([&{}$%#_])/,pn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,yn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},G={bf:function(e){e.weight="bold"},it:function(e){e.style="italic"},sl:function(e){e.style="italic"},color:function(e,n){e.color=n},href:function(e,n){e.href=n},"^":function(e){e.sup=!0},_:function(e){e.sub=!0},par:function(e){this.tokens.push(new it,new it)},newline:function(e){this.tokens.push(new it)},url:function(e,n){this.open_context().href=n,this.add_token(new B(n)),this.close_context()}};G.textsuperscript=G["^"],G.textsubscript=G._,G.textsl=G.sl,G.mathbf=G.bf,G.mathit=G.it,G.textbf=G.bf,G.textit=G.it,G.textcolor=G.color;var mn=/[\r\n\xA0]+/g;function vn(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var o=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(o=E(n,e)),o}function or(e,n,o){for(var s,u,y=e.width;y+o.width>n&&e.length;)u=(s=e[e.length-1]).width,s.width>o.width?(s.value=s.value.slice(0,-1),s.width=P(s,s.font),y+=s.width):e.pop(),y-=u;e[e.length-1]instanceof xt&&e.pop(),s=e[e.length-1]||s||{},o.font=E(o.font,s.bold,s.italic,""),o.href=e.length?s.href:null,o.rel=e.length?s.rel:null,o.target=e.length?s.target:null,e.push(o)}function Dt(e){return Math.round(1e6*e)/1e6}function ar(e){return function(n){if(Array.isArray(n))return pe(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,o){if(n){if(typeof n=="string")return pe(n,o);var s=Object.prototype.toString.call(n).slice(8,-1);return s==="Object"&&n.constructor&&(s=n.constructor.name),s==="Map"||s==="Set"?Array.from(n):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?pe(n,o):void 0}}(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function pe(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,s=new Array(n);o<n;o++)s[o]=e[o];return s}var wn={center:"middle",right:"end"},xn={middle:.5,center:.5,bottom:1,end:1},ye=function(e,n){return!e&&!n||e===n};function bn(e,n){var o=[],s=n.font(),u=s.size,y=s.family,x=n.align(),v=n.createElement();if(e.length){var S=s.height,_=n.valign(),I=n.height()(),$=n.width()(0),D=!isFinite($)&&e.length===1,O=D?null:n.x(),q=Dt(S/u),Q=D?null:Dt(S/(1.15*u+(S-u)/2));if(xn[_]&&isFinite(I)){var F=_==="bottom"?1:.5;Q+=(I*F-S*e.length*F)/u}var z=x==="justify",R=0;x==="right"?R=$:x==="center"&&(R=$/2);for(var j=[],tt="tspan",Z=null,W="",T=function(){if(W){var bt=v(tt,Z,W);j.push(bt)}tt="tspan",Z=null,W=""},st=0,et=e.length;st<et;st++){var ft="",yt="",ht=0,gt=e[st];if(gt.length){j=[];for(var Lt=0,Pt=0,pt=void 0,Y=0,Jt=gt.length;Y<Jt;Y++){var X=gt[Y],J=X.font;X.whitespace&&Lt++,Pt+=X.width,Y&&!X.tracking&&!ht&&ye(J.id,ft)&&ye(X.class,yt)&&ye(pt,X.href)?W+=X.value:(T(),W=X.value,Z={fontFamily:J.family!==y?J.family:null,fontSize:J.size!==u?J.size:null,fontWeight:J.weight||null,fontStyle:J.style||null,fontVariant:J.variant!=="normal"&&J.variant||null,fill:J.color||null,baselineShift:J.baseline?100*J.baseline+"%":null,className:X.class||null},ht&&(Z.dx=Dt(ht),ht=0),X.tracking&&(ht=J.size*X.tracking),X.href&&!pt?(pt=X.href,tt="a",Z.href=pt,Z.rel=X.rel,Z.target=X.target):pt=null,ft=J.id,yt=X.class)}if(T(),D)o.push.apply(o,ar(j));else{var Kt=null,Ft=st===et-1||gt[gt.length-1]instanceof it;z&&gt.length>1&&!Ft&&(Kt=Dt(($-Pt)/Lt)),o.push(v.apply(void 0,["tspan",{wordSpacing:Kt,x:O(st)+R,dy:Dt(st?q:Q)+"em"}].concat(ar(j))))}}else o.push(v("tspan",{x:O(st),dy:Dt(st?q:Q)+"em"}," "))}}return v.apply(void 0,["text",{fontFamily:y,fontSize:u,textAnchor:wn[x]||"start"}].concat(o))}var An={middle:.5,center:.5,bottom:1,end:1};function kn(e,n,o){if(e.length){o.textBaseline="middle";var s=n.font(),u=s.height,y=s.size,x=n.valign(),v=n.height()(),S=n.width()(0),_=n.align(),I=_==="justify",$=.5*u,D=An[x];if(D&&isFinite(v)){var O=e.length*u;$+=v*D-O*D}e.forEach(function(q,Q){var F=n.x()(Q),z=Q*u+$,R=0,j=0;q.forEach(function(W){W.whitespace&&R++,j+=W.width});var tt=0,Z=Q===e.length-1||q[q.length-1]instanceof it;I&&q.length>1&&!Z&&(tt=(S-j)/R),q.forEach(function(W){o.font=W.font;var T=W.font,st=T.baseline?y*-T.baseline+.15*y:0;o.fillStyle=function(yt,ht){return yt.color?yt.color:ht.href?"#00C":"#000"}(T,W);var et=0;if(_==="right"?et+=S-j:_==="center"?et+=S/2-j/2:_==="justify"&&(W.whitespace||W instanceof it)&&(F+=tt),o.fillText(W.value,F+et,z+st),W.href){o.beginPath(),o.strokeStyle=o.fillStyle;var ft=Math.floor(z+.45*y)+.5;o.moveTo(F+et,ft),o.lineTo(F+et+W.width,ft),o.stroke()}F+=W.width})})}}function me(e){return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},me(e)}function lr(e){for(var n={},o=0;o<e.length;o++){var s=e[o];typeof s!="number"&&s!=null&&(typeof s=="string"?n.text=s:typeof s=="function"?n.fn=s:me(s)==="object"&&s._groups?n.d3=s:s&&s.nodeType&&s.getContext?n.ctx=s.getContext("2d"):s&&s.fillText&&s.beginPath?n.ctx=s:s&&(n.text=s))}return n}function Ot(e){return Ot=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ot(e)}function En(e,n){for(var o=0;o<n.length;o++){var s=n[o];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,(u=function(y,x){if(Ot(y)!=="object"||y===null)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var S=v.call(y,x);if(Ot(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(s.key,"string"),Ot(u)==="symbol"?u:String(u)),s)}var u}var Sn=E(),ve=function(e){return typeof e=="function"?e:function(){return e}},lt=function(){function e(s){if(function(y,x){if(!(y instanceof x))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={overflow:"ellipsis",lineclamp:null,align:"left",wordBreak:null,valign:"top",width:function(){return 1/0},height:function(){return 1/0},x:function(){return 0},font:null,tAnchor:0,parser:e.defaultparser},s)for(var u in s)typeof this[u]=="function"&&this[u](s[u])}var n,o;return n=e,o=[{key:"linebreak",value:function(s){var u=this,y=this.props.parser(String(s)),x=this.font(),v=function(S,_,I){if(!S.length)return[];var $=_.height(),D=_.width(),O=_.overflowLine(),q=_.overflowWrap(),Q=E(I,!0,!1),F=isFinite($())?Math.floor($()/I.height):1/0;if(!$()&&!D(0)||!F)return[];for(var z=0,R=0,j=0,tt=[],Z=[],W=!1;z<S.length&&R<F;){var T=S[z],st=vn(T,I);if(T.width=P(T,st),T.font=st,T.line=R,T.whitespace=T.value in k,T.value&&(T.value=T.value.replace(mn," ")),!(!j&&T.whitespace||W&&T.whitespace))if(T instanceof it)j=0,Z=[],tt.push(z+1),R++;else if(T instanceof Mt||T instanceof xt)Z.push({index:z,width:j});else if(T.whitespace||j+T.width<D(R))j+=T.width;else if(Z.length){var et=void 0,ft=void 0;do{ft=!0,et=Z.pop();var yt=S[et.index],ht=void 0;yt instanceof xt&&(ht=P("-",yt.font),et.width+ht>D(R)&&(ft=!Z.length))}while(!ft);tt.push(et.index+1),j=0,R++,z=et.index,Z=[]}else if(q==="break-word"){var gt=D(R);if(j+T.width>gt){var Lt=T.clone();do T.value=T.value.slice(0,-1),T.width=P(T,T.font),j+=T.width;while(T.value&&T.width>gt);Lt.value=Lt.value.slice(T.value.length),S.splice(z+1,0,new Mt,Lt)}tt.push(z+1),j=0,R++}else j+=T.width;z++,W=T.whitespace}z!==tt[tt.length-1]&&tt.push(z);var Pt=0,pt=0,Y=tt.map(function(bt){for(var K,At=Pt;(K=S[At])&&(K.whitespace||!K.value);)At++;for(var mt=bt,be=null;mt>At&&(K=S[mt-1])&&(K.whitespace||!(K.value||K instanceof xt));)K instanceof it&&(be=K),mt--;K instanceof xt&&(K.value="-",K.width=P("-",K.font)),Pt=bt;var Tt=S.slice(At,mt).filter(function(Ae){return Ae.value});return be&&Tt.push(be),Tt.width=Tt.reduce(function(Ae,Tn){return Ae+Tn.width},0),Tt.width>pt&&(pt=Tt.width),Tt});if(Y.hasLineOverflow=!1,O){var Jt=O==="ellipsis"?"…":O;Y.forEach(function(bt,K){var At=D(K);if(bt.width>At){var mt=new B(Jt);mt.font=I,mt.width=P(Jt,Q),or(bt,At,mt),Y.hasLineOverflow=!0}})}var X=_.overflow()==="ellipsis"?"…":_.overflow();if(X&&z!==S.length){var J=D(Y.length-1),Kt=Y[Y.length-1],Ft=new B(X);Ft.font=I,Ft.width=P(X,Q),or(Kt,J,Ft),Y.hasOverflow=!0}else Y.hasOverflow=!1;return Y.font=I,Y.width=pt,Y}(y,this,x);return v.height=v.length*x.height,v.render=function(S){return u.render(v,S)},v.svg=v.render,v.draw=v.render,v}},{key:"font",value:function(s){return arguments.length?(this.props.font=E(s),this):this.props.font||E(Sn)}},{key:"overflow",value:function(s){return arguments.length?(this.props.overflow=String(s),this):this.props.overflow}},{key:"overflowLine",value:function(s){return arguments.length?(this.props.lineclamp=String(s),this):this.props.lineclamp}},{key:"valign",value:function(s){return arguments.length?(this.props.valign=s,this):this.props.valign}},{key:"align",value:function(s){if(!arguments.length)return this.props.align;var u=String(s).toLowerCase();return u==="left"||u==="start"?(this.props.align="left",this.props.tAnchor=0):u==="center"||u==="middle"?(this.props.align="center",this.props.tAnchor=-.5):u==="end"||u==="right"?(this.props.align="right",this.props.tAnchor=-1):u==="justify"&&(this.props.align=s,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(s){if(!arguments.length)return this.props.overflowWrap||"normal";var u=String(s).toLowerCase();return u==="break-word"?this.props.overflowWrap="break-word":u!=="normal"&&s!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(s){return arguments.length?(this.props.width=ve(s),this):this.props.width}},{key:"height",value:function(s){return arguments.length?(this.props.height=ve(s),this):this.props.height}},{key:"x",value:function(s){return arguments.length?(this.props.x=ve(s),this):this.props.x}},{key:"parser",value:function(s){if(!arguments.length)return this.props.parser;if(typeof s=="string"){var u=e[s]||e[s+"parser"];typeof u=="function"&&(s=u)}if(typeof s!="function")throw new Error("Unknown parser: "+s);return this.props.parser=s,this}},{key:"createElement",value:function(s){return arguments.length?(this.props.createElement=s,this):this.props.createElement||e.createElement}},{key:"render",value:function(){var s=lr(arguments);return typeof s.text=="string"&&(s.text=this.linebreak(s.text)),s.ctx?kn(s.text,this,s.ctx):bn(s.text,this)}}],o&&En(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function zt(e){return zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},zt(e)}function we(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,s=new Array(n);o<n;o++)s[o]=e[o];return s}function Cn(e,n){for(var o=0;o<n.length;o++){var s=n[o];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,(u=function(y,x){if(zt(y)!=="object"||y===null)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var S=v.call(y,x);if(zt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(s.key,"string"),zt(u)==="symbol"?u:String(u)),s)}var u}var hr=function(e){return typeof e=="function"?e:function(){return e}},ur=function(){function e(s){if(function(y,x){if(!(y instanceof x))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},s)for(var u in s)typeof this[u]=="function"&&this[u](s[u]);this.render=this.render.bind(this)}var n,o;return n=e,o=[{key:"anchor",value:function(s){var u=this.props,y=u.hAnchor,x=u.vAnchor,v=u.width,S=u.height;if(!arguments.length)return[y*v(0),x*S(0)];if(typeof s=="string"){var _=this.props;s.toLowerCase().trim().split(/\s+/).forEach(function(I){I==="top"&&(_.vAnchor=-0),I==="middle"&&(_.vAnchor=-.5),I==="bottom"&&(_.vAnchor=-1),I==="left"&&(_.hAnchor=-0),I==="center"&&(_.hAnchor=-.5),I==="right"&&(_.hAnchor=-1)})}return this}},{key:"width",value:function(s){return arguments.length?(this.props.width=hr(s),this):this.props.width}},{key:"height",value:function(s){return arguments.length?(this.props.height=hr(s),this):this.props.height}},{key:"rotate",value:function(s){return arguments.length?(this.props.rotation=s,this):this.props.rotation}},{key:"createElement",value:function(s){return arguments.length?(this.props.createElement=s,this):this.props.createElement||e.createElement}},{key:"canvas",value:function(s,u){var y,x=s.getContext?s.getContext("2d"):s;return x.save(),x.rotate(this.rotate()*Math.PI/180),x.translate.apply(x,function(v){if(Array.isArray(v))return we(v)}(y=this.anchor())||function(v){if(typeof Symbol<"u"&&v[Symbol.iterator]!=null||v["@@iterator"]!=null)return Array.from(v)}(y)||function(v,S){if(v){if(typeof v=="string")return we(v,S);var _=Object.prototype.toString.call(v).slice(8,-1);return _==="Object"&&v.constructor&&(_=v.constructor.name),_==="Map"||_==="Set"?Array.from(v):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?we(v,S):void 0}}(y)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
9
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),u(x),x.restore(),x}},{key:"render",value:function(){var s=lr(arguments);if(s.d3)return s.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(s.ctx)return this.canvas(s.ctx,s.fn);if(s.text){var u=typeof s.text.render=="function"?s.text.render():s.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},u)}}}],o&&Cn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}(),_n=Object.prototype.hasOwnProperty,xe={};function Dn(e){return xe[e]||(xe[e]=e.replace(/([a-z])([A-Z])/g,function(n,o,s){return o+"-"+s.toLowerCase()})),xe[e]}function cr(e,n){if(Array.isArray(n))return n.forEach(function(o){return cr(e,o)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function dr(e,n){if(typeof document<"u"){var o=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&o.setAttribute)for(var s in n)_n.call(n,s)&&n[s]!=null&&o.setAttribute(s==="className"?"class":Dn(s),n[s]);for(var u=arguments.length,y=new Array(u>2?u-2:0),x=2;x<u;x++)y[x-2]=arguments[x];return y!=null&&y.length&&y.forEach(function(v){cr(o,v)}),o}}lt.createElement=dr,lt.textparser=Yt,lt.defaultparser=Yt,lt.htmlparser=function(e){e=String(e||"").trim();for(var n,o,s={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},u=[],y=[],x=function($){for(var D in s)s[D]&&($[D]=s[D]);u.push($)},v=function($){var D=u.length,O=an[$];if(D&&O){for(var q=D-1;u[q]&&(u[q]instanceof Mt||en.test(u[q].value));)q--;for(;O&&u[q]&&u[q]instanceof it;)q--,O--;for(;O-- >0;)u.push(new it)}};e.length;){if(n=/^[^<]+/.exec(e))Yt(ir(n[0]),!1).forEach(x);else if(!(n=sn.exec(e)))if(n=rn.exec(e))y.length&&(s=y.pop()),v(n[1]);else if(n=nn.exec(e)){var S=n[1];v(S),y.push(s),s=Object.create(s),nr[S]&&nr[S](s,"");var _=un(n[2]);S==="a"&&(_.href&&(s.href=_.href),_.rel&&(s.rel=_.rel),_.target&&(s.target=_.target)),_.class&&(s.class=s.class?s.class+" "+_.class:_.class),_.style&&(o=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(_.style))&&o[1]&&(s.color=o[1]),S==="br"&&u.push(new it)}else n=[e.slice(0,1)],x(new B(n[0]));e=e.slice(n[0].length)}for(var I=u[u.length-1];I instanceof it;)u.pop(),I=u[u.length-1];return u},lt.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function(F,z){return n.push(z),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(pn,function(F,z,R){return R.charAt(z-1)==="\\"?F:yn[F]}).replace(/\n\s+/g,function(F){return/\n/.test(F.slice(1))?"\\par ":F}).replace(/\\symbol\{(\d+)\}/,function(F,z,R,j){return j.charAt(R-1)==="\\"?F:String.fromCharCode(1*z)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(F,z,R,j){return z+R+"{"+j+"}"}).replace(/\\verb,(.*?),/,function(F,z){return"\\verb,".concat(n[+z],",")});for(var o,s={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},u=[],y=[],x=function(F){for(var z in s)s[z]&&(F[z]=s[z]);return u.push(F),F},v=function(){y.push(s),s=Object.create(s)},S=function(){if(!y.length)throw new Error("Unexpected }");s=y.pop()},_={tokens:u,open_context:v,close_context:S,add_token:x};e.length;){if(o=fn.exec(e))Yt(o[0],!1).forEach(x);else if(o=gn.exec(e))x(new B(o[1]));else if(!(o=dn.exec(e))){if(o=/^\{/.exec(e))v();else if(o=/^\}/.exec(e))S();else if(!(o=/^\$/.exec(e)))if(o=/^\\verb,([^,]+),/.exec(e))x(new B(o[1]));else if(o=cn.exec(e)){var I=o[1].slice(1)||o[1],$=!!o[2];if(/^(La)?TeX$/i.test(I)){v(),s.family="serif";var D=void 0;I==="LaTeX"&&((D=x(new B("L"))).tracking=-.25,(D=x(new B("A"))).size=.7,D.baseline=.3,D.tracking=-.1),(D=x(new B("T"))).tracking=-.17,(D=x(new B("E"))).baseline=-.22,D.tracking=-.13,D=x(new B("X")),S()}else if(I in sr)x(new B(sr[I])),$&&v();else if(I in G){var O=[],q=G[I].length-1,Q=void 0;if(q){for($=!1,e=e.slice(o[0].length-1);q--;){if(!(Q=/^\{([^}]+)\}/.exec(e)))throw new Error(I+" is missing an argument");O.push(Q[1]),e=e.slice(Q[0].length)}o[0]=/^\{/.exec(e)?"{":"",$=!!o[0]}$&&v(),G[I].apply(_,[s].concat(O))}else console.warn("unknown latex command",I),x(new B(o[1])),$&&v()}else o=[e.slice(0,1)],x(new B(o[0]))}e=e.slice(o[0].length)}return u},lt.measureText=function(e,n,o){return P(e,E(n),o)},lt.Token=B,lt.Break=Mt,lt.LineBreak=it,lt.SoftHyphen=xt,lt.Rotator=ur,ur.createElement=dr;const Ln=lt;return r.default})())}(se)),se.exports}var Pr=zr();const Xe=Pe(Pr);function oe(l){return l.replace(/…$/,"")}function ae(l){return l.children[0].innerHTML}function Fr(l,t){const i=ut(l),{fontSize:r,font:a,padding:h=0}=l.properties.style||{};if(i.width===i.height&&i.width===0)return;const c=new Xe({font:`${r}px/${r}px ${a}`.replace(/(px)+/g,"px"),width:i.width-h*2,height:i.height-h*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Xe.createElement});c.overflowWrap("break-word");const d=c.linebreak(l.properties.content.replaceAll(`
10
+ `,"<br>")).render(),f=[...d.children];let g=0;const p=[];l.properties.content.split(`
11
+ `).forEach(A=>{let E=A;for(;E.length&&g<f.length;){if(f[g].innerHTML==="&nbsp;"){E.startsWith(`
12
+ `)||p.push(g),g++;break}const k=oe(ae(f[g]));E.startsWith(k)&&(E=E.slice(k.length).trim()),g++}}),p.forEach(A=>d.removeChild(f[A]));const w=l.properties.content.match(/(https?:\/\/.*)/gm),b=w?w.map(A=>A.split(" ")[0]):[];d.setAttribute("transform",`translate(${h}, ${h})`),b.forEach(A=>{let E=A;const k=[];for(;E.length>0;){const L=f.find(C=>!!C.children[0]&&C.children[0].tagName==="tspan"&&E.startsWith(oe(ae(C))));if(!L)break;k.push(L);const M=oe(L.children[0].innerHTML).length;if(!M)break;E=E.slice(M)}k.forEach(L=>{const M=document.createElementNS("http://www.w3.org/2000/svg","a");M.setAttribute("href",A),M.setAttribute("target","_blank"),M.innerHTML=ae(L),L.children[0].innerHTML="",L.children[0].appendChild(M)})}),t.appendChild(d)}const Ge=20;class Hr extends Ne{constructor(t,i={}){super(t,`
13
13
  <div class="annotation-text-handle" data-handle-id="8">
14
14
  <span class="handle line-handle top" data-handle-id="0"></span>
15
15
  <span class="handle line-handle bottom" data-handle-id="1"></span>
@@ -21,4 +21,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
21
21
  <span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
22
22
  <textarea wrap="on"></textarea>
23
23
  </div>
24
- `),m(this,"textArea"),m(this,"handleSize"),m(this,"rect",{x:0,y:0,width:0,height:0}),m(this,"annotation",{...ie}),m(this,"startX",0),m(this,"startY",0),m(this,"handles",[]),m(this,"draggedHandle",U),m(this,"isFocused",!1),m(this,"placeholder","Type your text here..."),m(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0}),m(this,"_onBlur",()=>{this.isFocused=!1}),m(this,"startDrawing",(a,h,c=Mr(a,h,0,0,"",_t))=>{this.add(c);const f=this.ogma.view.graphToScreenCoordinates({x:a,y:h});this.select(c.id),this.startDragging(this.getById(c.id),f.x,f.y),this.draggedHandle=6}),m(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...ie},this.draggedHandle=U,this.isDragging=!1,this.emit(Ct,this.annotation))}),m(this,"startDragging",(a,h,c)=>{this.annotation=a;const f=ct(this.annotation),d=ut(this.annotation);this.rect.x=f.x,this.rect.y=f.y,this.rect.width=d.width,this.rect.height=d.height,this.startX=h,this.startY=c,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Xt,this.annotation),this.isDragging=!0}),m(this,"onHandleMouseDown",a=>{const h=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!h)return;this.selectedId!==h.id&&this.select(this.hoveredId);const{x:c,y:f}=Rt(a,this.ogma.getContainer());this.startDragging(h,c,f),this.draggedHandle=_e(a.target)}),m(this,"onMouseMove",a=>{requestAnimationFrame(()=>this._onMouseMove(a))}),m(this,"_onMouseMove",a=>{if(!this.isDragging)return;a.stopPropagation(),a.preventDefault();const h=this.handles[this.draggedHandle];let c=h.classList.contains("top");const f=h.classList.contains("left"),d=h.classList.contains("right"),g=h.classList.contains("bottom");let p=h.classList.contains("line-handle");!p&&!c&&!g&&!f&&!d&&(c=!0,p=!0);const{x:b,y:A}=Rt(a,this.ogma.getContainer());let k=this.rect.x,E=this.rect.y,x=Math.max(this.rect.width,Ge),L=Math.max(this.rect.height,Ge);const O=this.ogma.view.getZoom(),C=(b-this.startX)/O,P=(A-this.startY)/O,N=this.ogma.view.getAngle(),nt=rt({x:C,y:P},N),at=rt({x:C,y:P},-N);p?(k=this.rect.x+nt.x,E=this.rect.y+nt.y):f&&c?(k+=nt.x,E+=nt.y,x-=C,L-=P):d&&g?(x+=C,L+=P):f&&g?(k+=at.x,x-=at.x,L+=at.y):d&&c&&(E+=at.y,x+=at.x,L-=at.y),wr(this.annotation,k,E,x,L),this.emit(Ut,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()}),m(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===U||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Ct,this.annotation),this.isDragging=!1,this.draggedHandle=U)}),m(this,"_onMousedown",a=>{a.stopPropagation()}),m(this,"onViewChanged",()=>{const a=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/a}`),this.ogma.view.getAngle()===0?this.editor.element.classList.remove("rotated"):this.editor.element.classList.add("rotated")}),m(this,"_onInput",()=>{const a=this.getById(this.selectedId);a&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),a.properties.content=this.textArea.value,this.emit(ne,a),this.layer.refresh())}),this.showeditorOnHover=!1,this.handleSize=We.handleSize,this.placeholder=We.placeholder;const r=this.textArea=this.editor.element.querySelector("textarea");r.addEventListener("input",this._onInput),r.addEventListener("focus",this._onFocus),r.addEventListener("blur",this._onBlur),r.addEventListener("mousedown",this._onMousedown),r.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.push(this.editor.element),this.handles.forEach(a=>a.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),t.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:t,y:s},r=0){const a={x:t,y:s},h=this.ogma.view.getAngle();return this.elements.find(c=>{const{x:f,y:d}=ct(c),{width:g,height:p}=ut(c),b={x:f,y:d},{x:A,y:k}=rt(wt(a,b),-h);return A>-r&&A<g+r&&k>-r&&k<p+r})}draw(t){t.innerHTML="";const s="",r=this.ogma.view.getAngle();for(let h=0;h<this.elements.length;h++){const c=this.elements[h],f=`class${h}`,d=ut(c),g=ct(c);if(c.id===this.selectedId)continue;const{color:p,fontSize:b,font:A,strokeColor:k,strokeWidth:E,strokeType:x,background:L,borderRadius:O}=c.properties.style||_t,C=vt("g");C.classList.add("annotation-text"),C.setAttribute("fill",`${p}`),C.setAttribute("font-size",`${b}px`),C.setAttribute("font-family",`${A}`);const P=vt("rect");O&&(P.setAttribute("rx",`${O}`),P.setAttribute("ry",`${O}`));let N=!1;x&&x!=="none"&&(N=!0,P.setAttribute("stroke",k||"black"),P.setAttribute("stroke-width",`${E}`),x==="dashed"&&P.setAttribute("stroke-dasharray","5,5")),(L&&L.length||N)&&(N=!0,P.setAttribute("fill",L||"transparent")),N&&(P.setAttribute("width",`${d.width}`),P.setAttribute("height",`${d.height}`)),C.appendChild(P),Fr(c,C);const{x:nt,y:at}=rt(g,-r);C.setAttribute("transform",`translate(${nt},${at})`),C.classList.add(f),C.setAttribute("data-annotation",`${c.id}`),C.setAttribute("data-annotation-type","text"),t.appendChild(C)}const a=vt("style");a.innerHTML=s,t.firstChild&&t.insertBefore(a,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle(),s=this.layer.element.children;for(let r=0;r<s.length;r++){const a=s[r];if(!a.hasAttribute("data-annotation"))continue;const h=a.getAttribute("data-annotation"),c=ct(this.getById(h)),{x:f,y:d}=rt(c,-t);a.setAttribute("transform",`translate(${f},${d})`)}}getDefaultOptions(){return ie}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),s=ut(t),r=this.ogma.view.graphToScreenCoordinates(ct(t)),a=this.ogma.view.getZoom(),{font:h,fontSize:c,color:f,background:d,padding:g=0}=t.properties.style||_t,p=(c||1)*a;this.textArea.value=t.properties.content;const b=this.editor.element.style;b.transform=`translate(${r.x}px, ${r.y}px)translate(-50%, -50%)translate(${s.width/2*a}px, ${s.height/2*a}px)`,b.width=`${s.width*a}px`,b.height=`${s.height*a}px`;const A=this.textArea.style;A.font=`${p} ${h}`,A.fontFamily=h||"sans-serif",A.fontSize=`${p}px`,A.padding=`${a*g}px`,A.lineHeight=`${p}px`,A.boxSizing="border-box",A.color=f||"black",A.background=d||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.classList.add("noevents")}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class jr{constructor(){m(this,"links",{}),m(this,"linksByTargetId",{}),m(this,"linksByArrowId",{})}add(t,s,r,a,h){const c=Ht(),f=t.id,d={id:c,arrow:f,target:r,targetType:a,connectionPoint:h,side:s};return this.links[c]=d,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(c),this.linksByArrowId[f]||(this.linksByArrowId[f]={}),this.linksByArrowId[f][s]=c,t.properties.link=t.properties.link||{},t.properties.link[s]={id:r,side:s,type:a,magnet:h},this}arrowIsLinked(t,s){var r;return!!((r=this.linksByArrowId[t])!=null&&r[s])}remove(t,s){var r,a;const h=t.id,c=(r=this.linksByArrowId[h])==null?void 0:r[s];if((a=t.properties.link)==null||delete a[s],!c)return this;const f=this.links[c];delete this.links[c];const d=this.linksByTargetId[f.target];for(let g=0;g<d.length;g++)if(d[g]===c){d.splice(g,1);break}return delete this.linksByArrowId[h][s],this}getArrowLink(t,s){var r;const a=(r=this.linksByArrowId[t])==null?void 0:r[s];return a?this.links[a]:null}getTargetLinks(t,s){var r;return((r=this.linksByTargetId[t])==null?void 0:r.map(a=>this.links[a]).filter(a=>a.targetType===s))??[]}forEach(t){Object.values(this.links).forEach(t)}}const ot=l=>l.properties.type==="arrow",dt=l=>l.properties.type==="text",Ve=l=>l.type==="FeatureCollection",Nr={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Ze=["start","end"],Ye=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:0,y:.5},{x:1,y:.5},{x:0,y:1},{x:.5,y:1},{x:1,y:1}];class Br extends je{constructor(t,s={}){super(),m(this,"arrows"),m(this,"texts"),m(this,"links",new jr),m(this,"layer"),m(this,"annotations"),m(this,"ogma"),m(this,"options"),m(this,"selected",null),m(this,"updateTimeout",0),m(this,"hoveredNode",null),m(this,"dragged",null),m(this,"textToMagnet"),m(this,"activeLinks",[]),m(this,"_render",r=>{if(!this.dragged||this.textToMagnet===void 0)return;r.beginPath(),r.fillStyle="green";const a=this.ogma.view.getZoom();Ye.forEach(h=>{if(!this.textToMagnet)return;const c=ut(this.textToMagnet),f=ct(this.textToMagnet),d=Wt(h,{x:c.width,y:c.height}),g=rt(d,this.ogma.view.getAngle()),{x:p,y:b}=St(g,f);r.moveTo(p,b),r.arc(p,b,this.options.magnetHandleRadius/a,0,Math.PI*2)}),r.fill(),r.closePath()}),m(this,"_onFeatureDrag",(r,a)=>{const h=a;if(ot(r)&&h==="line")["start","end"].find(c=>{const f=c==="start"?$t(r):Nt(r);return this._snapToText(r,h,f)||this._findAndSnapToNode(r,c,f)});else if(ot(r)&&h!=="line"){const c=h==="start"?$t(r):Nt(r);this._snapToText(r,h,c)||this._findAndSnapToNode(r,h,c)}else dt(r)&&(this.activeLinks.forEach(({arrow:c,side:f,connectionPoint:d})=>{const g=this.getAnnotation(c),p=ut(r),b=ct(r),A=Wt(d,{x:p.width,y:p.height}),k=rt(A,this.ogma.view.getAngle()),E=St(k,b);g.geometry.coordinates[f==="start"?0:1]=[E.x,E.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(Ut,r,a)}),m(this,"_onFeatureDragEnd",r=>{this.dragged!==null&&ot(r)&&$t(this.dragged)&&Ze.forEach(a=>{this.links.getArrowLink(r.id,a)&&this.emit(Lr,{arrow:r,link:this.links.getArrowLink(r.id,a)})}),(dt(r)||ot(r))&&this.onUpdate(r),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(a=>a.enableDetection()),this.layer.refresh(),this.emit(Ct,r)}),m(this,"_onFeatureDragStart",r=>{this.textToMagnet=void 0,ot(r)?this.dragged=r:dt(r)&&this.activeLinks.push(...this.links.getTargetLinks(r.id,"text")),this.annotations.forEach(a=>{const h=a.getSelectedFeature();h&&h!==r&&a.unhover().unselect(),a.disableDetection()}),this.emit(Xt,r)}),m(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()}),m(this,"_onNodesDrag",r=>{const{dx:a,dy:h}=r;this._moveNodes(r.nodes,a,h)}),m(this,"_onLayoutEnd",r=>{r.ids.forEach((a,h)=>{this.links.getTargetLinks(a,"node").forEach(c=>{const f=this.getAnnotation(c.arrow),d=c.side,g=jt(f,d==="start"?"end":"start"),p=r.positions.current[h],b=this.ogma.getNode(a).getAttribute("radius"),A=qt(g,p,+b);kt(f,d,A.x,A.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()}),m(this,"_onAdded",r=>{this.emit(re,r)}),m(this,"_onRemoved",r=>{this.emit(ee,r)}),m(this,"_onUnselect",r=>{this.selected=null,this.emit(te,r)}),m(this,"_onSelect",r=>{this.selected!==r&&(this.selected=r,this.emit(Qt,this.selected))}),m(this,"onUpdate",r=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(r))}),m(this,"_onUpdate",r=>{this.emit(ne,r)}),this.options=this.setOptions({...Nr,...s}),this.ogma=t,this.arrows=new $r(t,this.options),this.texts=new Hr(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(r=>{r.on(Xt,this._onFeatureDragStart).on(Ut,this._onFeatureDrag).on(Ct,this._onFeatureDragEnd).on(ne,this.onUpdate).on(te,this._onUnselect).on(Qt,this._onSelect).on(re,this._onAdded).on(ee,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=t.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(t,s,r){t.forEach(a=>{const h=this.links.getTargetLinks(a.getId(),"node"),c=a.getPosition();h.forEach(f=>{const d=this.getAnnotation(f.arrow),g=f.side,p=jt(d,g==="start"?"end":"start");let b=c;const A=+a.getAttribute("radius"),k=1e-6;(f.connectionPoint.x-(c.x-s)>k||f.connectionPoint.y-(c.y-r)>k)&&(b=qt(p,c,A)),kt(d,g,b.x,b.y)})}),this.arrows.refreshLayer()}_snapToText(t,s,r){const a=this.texts.detect(r,this.options.detectMargin);if(this.links.remove(t,s),!a)return!1;this.textToMagnet=a;const h=this.findMagnetPoint(Ye,a,r);return h?(kt(t,s,h.point.x,h.point.y),this.links.add(t,s,a.id,"text",h.magnet),!0):!1}_findAndSnapToNode(t,s,r){var a,h;const c=this.ogma.view.graphToScreenCoordinates(r),f=this.ogma.view.getElementAt(c);this.links.remove(t,s),f&&f.isNode?((a=this.hoveredNode)==null||a.setSelected(!1),this.hoveredNode=f,f.setSelected(!0),this._snapToNode(t,s,f,c)):((h=this.hoveredNode)==null||h.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,s,r,a){const h=r.getPositionOnScreen(),c=+r.getAttribute("radius"),f=c*this.ogma.view.getZoom(),d=a.x-h.x,g=a.y-h.y,p=Math.sqrt(d*d+g*g),b=r.getPosition();if(p<f+this.options.detectMargin){let A=b;if(p>f/2){const k=jt(t,s==="end"?"start":"end");A=qt(k,A,c)}kt(t,s,A.x,A.y),this.links.add(t,s,r.getId(),"node",A)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:s,targetType:r,target:a,arrow:h,side:c})=>{if(r!=="text")return;t=!0;const f=this.getAnnotation(a),d=this.getAnnotation(h),g=ut(f),p=ct(f),b=Wt(s,{x:g.width,y:g.height}),A=rt(b,this.ogma.view.getAngle()),k=St(A,p);kt(d,c,k.x,k.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,s,r){let a;for(const h of t){const c=ut(s),f=ct(s),d=Wt(h,{x:c.width,y:c.height}),g=rt(d,this.ogma.view.getAngle()),p=St(g,f),b=Et(wt(p,r)),A=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),c.width/2,c.height/2);if(b<Math.max(A,this.options.magnetHandleRadius)){a={point:p,magnet:h};break}}return a}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const s=this.getAnnotations().features.find(r=>r.id===t);return s?(ot(s)?this.arrows.select(s.id):dt(s)&&this.texts.select(s.id),this):this}unselect(){return this.selected?(ot(this.selected)?this.arrows.unselect():dt(this.selected)&&this.texts.unselect(),this):this}add(t){if(Ve(t)){const[s,r]=t.features.reduce((a,h)=>(ot(h)?a[1].push(h):dt(h)&&a[0].push(h),a),[[],[]]);return s.forEach(a=>this.add(a)),r.forEach(a=>this.add(a)),this.arrows.refreshLayer(),this}switch(t.properties.type){case"text":this.texts.add(t);break;default:this.arrows.add(t),this.loadLink(t);break}return this}remove(t){return Ve(t)?(t.features.forEach(s=>this.remove(s)),this):(ot(t)?(this.links.remove(t,"start"),this.links.remove(t,"end"),this.arrows.remove(t.id)):this.texts.remove(t.id),this)}loadLink(t){if(t.properties.link)for(const s of Ze){const r=t.properties.link[s];if(!r)continue;const a=this.getAnnotation(r.id);if(r.type==="text"&&a)this.links.add(t,s,r.id,r.type,r.magnet);else if(r.type==="node"){const h=this.ogma.getNode(r.id);if(!h)continue;this.links.add(t,s,r.id,r.type,r.magnet);const c=h.getPosition(),f=h.getAttribute("radius")||0,d=jt(t,s==="start"?"end":"start"),g=qt(d,c,+f);kt(t,s,g.x,g.y)}}}startArrow(t,s,r){this.cancelDrawing(),this.arrows.startDrawing(t,s,r)}startText(t,s,r){this.cancelDrawing(),this.texts.startDrawing(t,s,r)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(Dr)}updateStyle(t,s){const r=this.getAnnotations().features.find(a=>a.id===t);return r?(ot(r)?this.arrows.updateStyle(r,s):dt(r)&&this.texts.updateStyle(r,s),this.onUpdate(r),this):this}setScale(t,s,r,a){const h=this.getAnnotations().features.find(c=>c.id===t);return h?(ot(h)?this.arrows.scale(h,s,r,a):dt(h)&&this.texts.scale(h,s,r,a),this.onUpdate(h),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(s=>{t.features=[...t.features,...s.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(s=>s.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}const le=[8,10,12,14,16,24,32,48,64,72],he="none",ue="#333333",qr=["#FFFFFF","#F44E3B","#FE9200","#FCDC00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#1E88E5","#333333","#808080","#cccccc"],Rr=["Roboto","Helvetica Neue","Helvetica","Arial","sans-serif","Georgia, serif","Menlo","Monaco","Consolas","Courier New","monospace"].sort((l,t)=>l.toLocaleLowerCase().localeCompare(t.toLocaleLowerCase())),Je={head:"arrow",strokeColor:ue,strokeWidth:5},Ke=.25,Qe={font:"Roboto",fontSize:le[2],padding:le[2]*Ke,color:ue,strokeType:he,background:he};function tr(l){return l.reduce((t,s)=>t+s,0)/l.length}function Wr(l,t=0,s=1){return t+(s-t)*l}function Ur(l,t=0,s=1){return(l-t)/(s-t)}function Xr(){return V.createContext(null)}const ce=V.createContext(void 0),Gr=()=>V.useContext(ce),Vr=(l,t)=>{switch(t.type){case"add":return{...l,features:[...l.features,t.payload]};case"remove":return{...l,features:l.features.filter(s=>s.id!==t.payload.id)};case"update":return{...l,features:l.features.map(s=>s.id===t.payload.id?t.payload:s)};default:return l}},Zr=({children:l})=>{const t=fr.useOgma(),[s,r]=V.useReducer(Vr,{type:"FeatureCollection",features:[]}),[a,h]=V.useState(null),[c,f]=V.useState(Je),[d,g]=V.useState(Qe),[p,b]=V.useState(),[A,k]=V.useState(1),[E,x]=V.useState(1);return V.useEffect(()=>{if(!t)return;const L=new Br(t,{minArrowHeight:1}),O=tr(t.getNodes().getAttribute("radius"))/5,C=A;return f({...c,strokeWidth:(c.strokeWidth||1)*C}),k(C),x(O),L.on("select",P=>{ot(P)?f({...P.properties.style||{}}):dt(P)&&g({...P.properties.style||{}}),h(P)}).on("unselect",()=>{h(null)}),b(L),()=>{L.destroy()}},[t]),V.useEffect(()=>{p&&a&&(a==null?void 0:a.properties.type)==="arrow"&&p.updateStyle(a.id,c)},[p,c,a]),V.useEffect(()=>{p&&a&&(a==null?void 0:a.properties.type)==="text"&&p.updateStyle(a.id,d)},[p,d,a]),V.createElement(ce.Provider,{value:{annotations:s,updateAnnotations:r,currentAnnotation:a,setCurrentAnnotation:h,textStyle:d,setTextStyle:g,arrowStyle:c,setArrowStyle:f,arrowWidthFactor:A,setArrowWidthFactor:k,textSizeFactor:E,setTextSizeFactor:x,editor:p,setEditor:b}},l)};H.AnnotationsContext=ce,H.AnnotationsContextProvider=Zr,H.BLACK=ue,H.RELATIVE_PADDING=Ke,H.TRANSPARENT=he,H.createAnnotationsContext=Xr,H.defaultArrowStyle=Je,H.defaultColors=qr,H.defaultTextStyle=Qe,H.fontSizes=le,H.fonts=Rr,H.interpolate=Wr,H.mean=tr,H.normalize=Ur,H.useAnnotationsContext=Gr,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
24
+ `),m(this,"textArea"),m(this,"handleSize"),m(this,"rect",{x:0,y:0,width:0,height:0}),m(this,"annotation",{...ie}),m(this,"startX",0),m(this,"startY",0),m(this,"handles",[]),m(this,"draggedHandle",U),m(this,"isFocused",!1),m(this,"placeholder","Type your text here..."),m(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0}),m(this,"_onBlur",()=>{this.isFocused=!1}),m(this,"startDrawing",(a,h,c=Mr(a,h,0,0,"",_t))=>{this.add(c);const d=this.ogma.view.graphToScreenCoordinates({x:a,y:h});this.select(c.id),this.startDragging(this.getById(c.id),d.x,d.y),this.draggedHandle=6}),m(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...ie},this.draggedHandle=U,this.isDragging=!1,this.emit(Ct,this.annotation))}),m(this,"startDragging",(a,h,c)=>{this.annotation=a;const d=ct(this.annotation),f=ut(this.annotation);this.rect.x=d.x,this.rect.y=d.y,this.rect.width=f.width,this.rect.height=f.height,this.startX=h,this.startY=c,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Xt,this.annotation),this.isDragging=!0}),m(this,"onHandleMouseDown",a=>{const h=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!h)return;this.selectedId!==h.id&&this.select(this.hoveredId);const{x:c,y:d}=Rt(a,this.ogma.getContainer());this.startDragging(h,c,d),this.draggedHandle=_e(a.target)}),m(this,"onMouseMove",a=>{requestAnimationFrame(()=>this._onMouseMove(a))}),m(this,"_onMouseMove",a=>{if(!this.isDragging)return;a.stopPropagation(),a.preventDefault();const h=this.handles[this.draggedHandle];let c=h.classList.contains("top");const d=h.classList.contains("left"),f=h.classList.contains("right"),g=h.classList.contains("bottom");let p=h.classList.contains("line-handle");!p&&!c&&!g&&!d&&!f&&(c=!0,p=!0);const{x:w,y:b}=Rt(a,this.ogma.getContainer());let A=this.rect.x,E=this.rect.y,k=Math.max(this.rect.width,Ge),L=Math.max(this.rect.height,Ge);const M=this.ogma.view.getZoom(),C=(w-this.startX)/M,N=(b-this.startY)/M,P=this.ogma.view.getAngle(),nt=rt({x:C,y:N},P),at=rt({x:C,y:N},-P);p?(A=this.rect.x+nt.x,E=this.rect.y+nt.y):d&&c?(A+=nt.x,E+=nt.y,k-=C,L-=N):f&&g?(k+=C,L+=N):d&&g?(A+=at.x,k-=at.x,L+=at.y):f&&c&&(E+=at.y,k+=at.x,L-=at.y),wr(this.annotation,A,E,k,L),this.emit(Ut,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()}),m(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===U||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Ct,this.annotation),this.isDragging=!1,this.draggedHandle=U)}),m(this,"_onMousedown",a=>{a.stopPropagation()}),m(this,"onViewChanged",()=>{const a=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/a}`),this.ogma.view.getAngle()===0?this.editor.element.classList.remove("rotated"):this.editor.element.classList.add("rotated")}),m(this,"_onInput",()=>{const a=this.getById(this.selectedId);a&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),a.properties.content=this.textArea.value,this.emit(ne,a),this.layer.refresh())}),this.showeditorOnHover=!1,this.handleSize=We.handleSize,this.placeholder=We.placeholder;const r=this.textArea=this.editor.element.querySelector("textarea");r.addEventListener("input",this._onInput),r.addEventListener("focus",this._onFocus),r.addEventListener("blur",this._onBlur),r.addEventListener("mousedown",this._onMousedown),r.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.push(this.editor.element),this.handles.forEach(a=>a.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),t.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:t,y:i},r=0){const a={x:t,y:i},h=this.ogma.view.getAngle();return this.elements.find(c=>{const{x:d,y:f}=ct(c),{width:g,height:p}=ut(c),w={x:d,y:f},{x:b,y:A}=rt(wt(a,w),-h);return b>-r&&b<g+r&&A>-r&&A<p+r})}draw(t){t.innerHTML="";const i="",r=this.ogma.view.getAngle();for(let h=0;h<this.elements.length;h++){const c=this.elements[h],d=`class${h}`,f=ut(c),g=ct(c);if(c.id===this.selectedId)continue;const{color:p,fontSize:w,font:b,strokeColor:A,strokeWidth:E,strokeType:k,background:L,borderRadius:M}=c.properties.style||_t,C=vt("g");C.classList.add("annotation-text"),C.setAttribute("fill",`${p}`),C.setAttribute("font-size",`${w}px`),C.setAttribute("font-family",`${b}`);const N=vt("rect");M&&(N.setAttribute("rx",`${M}`),N.setAttribute("ry",`${M}`));let P=!1;k&&k!=="none"&&(P=!0,N.setAttribute("stroke",A||"black"),N.setAttribute("stroke-width",`${E}`),k==="dashed"&&N.setAttribute("stroke-dasharray","5,5")),(L&&L.length||P)&&(P=!0,N.setAttribute("fill",L||"transparent")),P&&(N.setAttribute("width",`${f.width}`),N.setAttribute("height",`${f.height}`)),C.appendChild(N),Fr(c,C);const{x:nt,y:at}=rt(g,-r);C.setAttribute("transform",`translate(${nt},${at})`),C.classList.add(d),C.setAttribute("data-annotation",`${c.id}`),C.setAttribute("data-annotation-type","text"),t.appendChild(C)}const a=vt("style");a.innerHTML=i,t.firstChild&&t.insertBefore(a,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle(),i=this.layer.element.children;for(let r=0;r<i.length;r++){const a=i[r];if(!a.hasAttribute("data-annotation"))continue;const h=a.getAttribute("data-annotation"),c=ct(this.getById(h)),{x:d,y:f}=rt(c,-t);a.setAttribute("transform",`translate(${d},${f})`)}}getDefaultOptions(){return ie}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),i=ut(t),r=this.ogma.view.graphToScreenCoordinates(ct(t)),a=this.ogma.view.getZoom(),{font:h,fontSize:c,color:d,background:f,padding:g=0}=t.properties.style||_t,p=(c||1)*a;this.textArea.value=t.properties.content;const w=this.editor.element.style;w.transform=`translate(${r.x}px, ${r.y}px)translate(-50%, -50%)translate(${i.width/2*a}px, ${i.height/2*a}px)`,w.width=`${i.width*a}px`,w.height=`${i.height*a}px`;const b=this.textArea.style;b.font=`${p} ${h}`,b.fontFamily=h||"sans-serif",b.fontSize=`${p}px`,b.padding=`${a*g}px`,b.lineHeight=`${p}px`,b.boxSizing="border-box",b.color=d||"black",b.background=f||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.classList.add("noevents")}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class jr{constructor(){m(this,"links",{}),m(this,"linksByTargetId",{}),m(this,"linksByArrowId",{})}add(t,i,r,a,h){const c=Ht(),d=t.id,f={id:c,arrow:d,target:r,targetType:a,connectionPoint:h,side:i};return this.links[c]=f,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(c),this.linksByArrowId[d]||(this.linksByArrowId[d]={}),this.linksByArrowId[d][i]=c,t.properties.link=t.properties.link||{},t.properties.link[i]={id:r,side:i,type:a,magnet:h},this}arrowIsLinked(t,i){var r;return!!((r=this.linksByArrowId[t])!=null&&r[i])}remove(t,i){var r,a;const h=t.id,c=(r=this.linksByArrowId[h])==null?void 0:r[i];if((a=t.properties.link)==null||delete a[i],!c)return this;const d=this.links[c];delete this.links[c];const f=this.linksByTargetId[d.target];for(let g=0;g<f.length;g++)if(f[g]===c){f.splice(g,1);break}return delete this.linksByArrowId[h][i],this}getArrowLink(t,i){var r;const a=(r=this.linksByArrowId[t])==null?void 0:r[i];return a?this.links[a]:null}getTargetLinks(t,i){var r;return((r=this.linksByTargetId[t])==null?void 0:r.map(a=>this.links[a]).filter(a=>a.targetType===i))??[]}forEach(t){Object.values(this.links).forEach(t)}}const ot=l=>l.properties.type==="arrow",dt=l=>l.properties.type==="text",Ve=l=>l.type==="FeatureCollection",Nr={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Ze=["start","end"],Ye=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:0,y:.5},{x:1,y:.5},{x:0,y:1},{x:.5,y:1},{x:1,y:1}];class Br extends je{constructor(t,i={}){super(),m(this,"arrows"),m(this,"texts"),m(this,"links",new jr),m(this,"layer"),m(this,"annotations"),m(this,"ogma"),m(this,"options"),m(this,"selected",null),m(this,"updateTimeout",0),m(this,"hoveredNode",null),m(this,"dragged",null),m(this,"textToMagnet"),m(this,"activeLinks",[]),m(this,"_render",r=>{if(!this.dragged||this.textToMagnet===void 0)return;r.beginPath(),r.fillStyle="green";const a=this.ogma.view.getZoom();Ye.forEach(h=>{if(!this.textToMagnet)return;const c=ut(this.textToMagnet),d=ct(this.textToMagnet),f=Wt(h,{x:c.width,y:c.height}),g=rt(f,this.ogma.view.getAngle()),{x:p,y:w}=St(g,d);r.moveTo(p,w),r.arc(p,w,this.options.magnetHandleRadius/a,0,Math.PI*2)}),r.fill(),r.closePath()}),m(this,"_onFeatureDrag",(r,a)=>{const h=a;if(ot(r)&&h==="line")["start","end"].find(c=>{const d=c==="start"?$t(r):Nt(r);return this._snapToText(r,h,d)||this._findAndSnapToNode(r,c,d)});else if(ot(r)&&h!=="line"){const c=h==="start"?$t(r):Nt(r);this._snapToText(r,h,c)||this._findAndSnapToNode(r,h,c)}else dt(r)&&(this.activeLinks.forEach(({arrow:c,side:d,connectionPoint:f})=>{const g=this.getAnnotation(c),p=ut(r),w=ct(r),b=Wt(f,{x:p.width,y:p.height}),A=rt(b,this.ogma.view.getAngle()),E=St(A,w);g.geometry.coordinates[d==="start"?0:1]=[E.x,E.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(Ut,r,a)}),m(this,"_onFeatureDragEnd",r=>{this.dragged!==null&&ot(r)&&$t(this.dragged)&&Ze.forEach(a=>{this.links.getArrowLink(r.id,a)&&this.emit(Lr,{arrow:r,link:this.links.getArrowLink(r.id,a)})}),(dt(r)||ot(r))&&this.onUpdate(r),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(a=>a.enableDetection()),this.layer.refresh(),this.emit(Ct,r)}),m(this,"_onFeatureDragStart",r=>{this.textToMagnet=void 0,ot(r)?this.dragged=r:dt(r)&&this.activeLinks.push(...this.links.getTargetLinks(r.id,"text")),this.annotations.forEach(a=>{const h=a.getSelectedFeature();h&&h!==r&&a.unhover().unselect(),a.disableDetection()}),this.emit(Xt,r)}),m(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()}),m(this,"_onNodesDrag",r=>{const{dx:a,dy:h}=r;this._moveNodes(r.nodes,a,h)}),m(this,"_onLayoutEnd",r=>{r.ids.forEach((a,h)=>{this.links.getTargetLinks(a,"node").forEach(c=>{const d=this.getAnnotation(c.arrow),f=c.side,g=jt(d,f==="start"?"end":"start"),p=r.positions.current[h],w=this.ogma.getNode(a).getAttribute("radius"),b=qt(g,p,+w);kt(d,f,b.x,b.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()}),m(this,"_onAdded",r=>{this.emit(re,r)}),m(this,"_onRemoved",r=>{this.emit(ee,r)}),m(this,"_onUnselect",r=>{this.selected=null,this.emit(te,r)}),m(this,"_onSelect",r=>{this.selected!==r&&(this.selected=r,this.emit(Qt,this.selected))}),m(this,"onUpdate",r=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(r))}),m(this,"_onUpdate",r=>{this.emit(ne,r)}),this.options=this.setOptions({...Nr,...i}),this.ogma=t,this.arrows=new $r(t,this.options),this.texts=new Hr(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(r=>{r.on(Xt,this._onFeatureDragStart).on(Ut,this._onFeatureDrag).on(Ct,this._onFeatureDragEnd).on(ne,this.onUpdate).on(te,this._onUnselect).on(Qt,this._onSelect).on(re,this._onAdded).on(ee,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=t.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(t,i,r){t.forEach(a=>{const h=this.links.getTargetLinks(a.getId(),"node"),c=a.getPosition();h.forEach(d=>{const f=this.getAnnotation(d.arrow),g=d.side,p=jt(f,g==="start"?"end":"start");let w=c;const b=+a.getAttribute("radius"),A=1e-6;(d.connectionPoint.x-(c.x-i)>A||d.connectionPoint.y-(c.y-r)>A)&&(w=qt(p,c,b)),kt(f,g,w.x,w.y)})}),this.arrows.refreshLayer()}_snapToText(t,i,r){const a=this.texts.detect(r,this.options.detectMargin);if(this.links.remove(t,i),!a)return!1;this.textToMagnet=a;const h=this.findMagnetPoint(Ye,a,r);return h?(kt(t,i,h.point.x,h.point.y),this.links.add(t,i,a.id,"text",h.magnet),!0):!1}_findAndSnapToNode(t,i,r){var a,h;const c=this.ogma.view.graphToScreenCoordinates(r),d=this.ogma.view.getElementAt(c);this.links.remove(t,i),d&&d.isNode?((a=this.hoveredNode)==null||a.setSelected(!1),this.hoveredNode=d,d.setSelected(!0),this._snapToNode(t,i,d,c)):((h=this.hoveredNode)==null||h.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,i,r,a){const h=r.getPositionOnScreen(),c=+r.getAttribute("radius"),d=c*this.ogma.view.getZoom(),f=a.x-h.x,g=a.y-h.y,p=Math.sqrt(f*f+g*g),w=r.getPosition();if(p<d+this.options.detectMargin){let b=w;if(p>d/2){const A=jt(t,i==="end"?"start":"end");b=qt(A,b,c)}kt(t,i,b.x,b.y),this.links.add(t,i,r.getId(),"node",b)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:i,targetType:r,target:a,arrow:h,side:c})=>{if(r!=="text")return;t=!0;const d=this.getAnnotation(a),f=this.getAnnotation(h),g=ut(d),p=ct(d),w=Wt(i,{x:g.width,y:g.height}),b=rt(w,this.ogma.view.getAngle()),A=St(b,p);kt(f,c,A.x,A.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,i,r){let a;for(const h of t){const c=ut(i),d=ct(i),f=Wt(h,{x:c.width,y:c.height}),g=rt(f,this.ogma.view.getAngle()),p=St(g,d),w=Et(wt(p,r)),b=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),c.width/2,c.height/2);if(w<Math.max(b,this.options.magnetHandleRadius)){a={point:p,magnet:h};break}}return a}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const i=this.getAnnotations().features.find(r=>r.id===t);return i?(ot(i)?this.arrows.select(i.id):dt(i)&&this.texts.select(i.id),this):this}unselect(){return this.selected?(ot(this.selected)?this.arrows.unselect():dt(this.selected)&&this.texts.unselect(),this):this}add(t){if(Ve(t)){const[i,r]=t.features.reduce((a,h)=>(ot(h)?a[1].push(h):dt(h)&&a[0].push(h),a),[[],[]]);return i.forEach(a=>this.add(a)),r.forEach(a=>this.add(a)),this.arrows.refreshLayer(),this}switch(t.properties.type){case"text":this.texts.add(t);break;default:this.arrows.add(t),this.loadLink(t);break}return this}remove(t){return Ve(t)?(t.features.forEach(i=>this.remove(i)),this):(ot(t)?(this.links.remove(t,"start"),this.links.remove(t,"end"),this.arrows.remove(t.id)):this.texts.remove(t.id),this)}loadLink(t){if(t.properties.link)for(const i of Ze){const r=t.properties.link[i];if(!r)continue;const a=this.getAnnotation(r.id);if(r.type==="text"&&a)this.links.add(t,i,r.id,r.type,r.magnet);else if(r.type==="node"){const h=this.ogma.getNode(r.id);if(!h)continue;this.links.add(t,i,r.id,r.type,r.magnet);const c=h.getPosition(),d=h.getAttribute("radius")||0,f=jt(t,i==="start"?"end":"start"),g=qt(f,c,+d);kt(t,i,g.x,g.y)}}}startArrow(t,i,r){this.cancelDrawing(),this.arrows.startDrawing(t,i,r)}startText(t,i,r){this.cancelDrawing(),this.texts.startDrawing(t,i,r)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(Dr)}updateStyle(t,i){const r=this.getAnnotations().features.find(a=>a.id===t);return r?(ot(r)?this.arrows.updateStyle(r,i):dt(r)&&this.texts.updateStyle(r,i),this.onUpdate(r),this):this}setScale(t,i,r,a){const h=this.getAnnotations().features.find(c=>c.id===t);return h?(ot(h)?this.arrows.scale(h,i,r,a):dt(h)&&this.texts.scale(h,i,r,a),this.onUpdate(h),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(i=>{t.features=[...t.features,...i.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(i=>i.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}const le=[8,10,12,14,16,24,32,48,64,72],he="none",ue="#333333",qr=["#FFFFFF","#F44E3B","#FE9200","#FCDC00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#1E88E5","#333333","#808080","#cccccc"],Rr=["Roboto","Helvetica Neue","Helvetica","Arial","sans-serif","Georgia, serif","Menlo","Monaco","Consolas","Courier New","monospace"].sort((l,t)=>l.toLocaleLowerCase().localeCompare(t.toLocaleLowerCase())),Je={head:"arrow",strokeColor:ue,strokeWidth:5},Ke=.25,Qe={font:"Roboto",fontSize:le[2],padding:le[2]*Ke,color:ue,strokeType:he,background:he};function tr(l){return l.reduce((t,i)=>t+i,0)/l.length}function Wr(l,t=0,i=1){return t+(i-t)*l}function Ur(l,t=0,i=1){return(l-t)/(i-t)}function Xr(){return V.createContext(null)}const ce=V.createContext(void 0),Gr=()=>V.useContext(ce),Vr=(l,t)=>{switch(t.type){case"add":return{...l,features:[...l.features,t.payload]};case"remove":return{...l,features:l.features.filter(i=>i.id!==t.payload.id)};case"update":return{...l,features:l.features.map(i=>i.id===t.payload.id?t.payload:i)};default:return l}},Zr=({children:l,annotations:t})=>{const i=fr.useOgma(),[r,a]=V.useReducer(Vr,t||{type:"FeatureCollection",features:[]}),[h,c]=V.useState(null),[d,f]=V.useState(Je),[g,p]=V.useState(Qe),[w,b]=V.useState(),[A,E]=V.useState(1),[k,L]=V.useState(1);return V.useEffect(()=>{if(!i)return;const M=new Br(i,{minArrowHeight:1}),C=tr(i.getNodes().getAttribute("radius"))/5,N=A;return f({...d,strokeWidth:(d.strokeWidth||1)*N}),E(N),L(C),M.on("select",P=>{ot(P)?f({...P.properties.style||{}}):dt(P)&&p({...P.properties.style||{}}),c(P)}).on("unselect",()=>{c(null)}),b(M),t&&M.add(t),()=>{M.destroy()}},[i]),V.useEffect(()=>{w&&h&&(h==null?void 0:h.properties.type)==="arrow"&&w.updateStyle(h.id,d)},[w,d,h]),V.useEffect(()=>{w&&h&&(h==null?void 0:h.properties.type)==="text"&&w.updateStyle(h.id,g)},[w,g,h]),V.createElement(ce.Provider,{value:{annotations:r,updateAnnotations:a,currentAnnotation:h,setCurrentAnnotation:c,textStyle:g,setTextStyle:p,arrowStyle:d,setArrowStyle:f,arrowWidthFactor:A,setArrowWidthFactor:E,textSizeFactor:k,setTextSizeFactor:L,editor:w,setEditor:b}},l)};H.AnnotationsContext=ce,H.AnnotationsContextProvider=Zr,H.BLACK=ue,H.RELATIVE_PADDING=Ke,H.TRANSPARENT=he,H.createAnnotationsContext=Xr,H.defaultArrowStyle=Je,H.defaultColors=qr,H.defaultTextStyle=Qe,H.fontSizes=le,H.fonts=Rr,H.interpolate=Wr,H.mean=tr,H.normalize=Ur,H.useAnnotationsContext=Gr,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});