@linkurious/ogma-annotations 1.1.18 → 1.1.19

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,12 +1,12 @@
1
- (function(A,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(A=typeof globalThis<"u"?globalThis:A||self,X(A["@linkurious/ogma-annotations"]={}))})(this,function(A){"use strict";var si=Object.defineProperty;var oi=(A,X,st)=>X in A?si(A,X,{enumerable:!0,configurable:!0,writable:!0,value:st}):A[X]=st;var m=(A,X,st)=>(oi(A,typeof X!="symbol"?X+"":X,st),st);let X=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((h,t)=>(t&=63,t<36?h+=t.toString(36):t<62?h+=(t-26).toString(36).toUpperCase():t>62?h+="-":h+="_",h),"");const st={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},oe={id:0,type:"Feature",properties:{type:"arrow",style:{...st}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},Se=(a=0,h=0,t=0,r=0,o={...st})=>({id:X(),type:"Feature",properties:{type:"arrow",style:{...st,...o}},geometry:{type:"LineString",coordinates:[[a,h],[t,r]]}}),fn="http://www.w3.org/2000/svg";function St(a){return document.createElementNS(fn,a)}function ae(a){return a.geometry.bbox||Te(a),a.geometry.bbox}function ht(a){const h=ae(a);return{width:h[2]-h[0],height:h[3]-h[1]}}function ct(a){const h=ae(a);return{x:h[0],y:h[1]}}function Te(a){const[h,t]=a.geometry.coordinates[0][0],[r,o]=a.geometry.coordinates[0][2];a.geometry.bbox=[h,t,r,o]}function _e(a,h,t,r,o){a.geometry.bbox=[h,t,h+r,t+o],a.geometry.coordinates=[[[h,t],[h+r,t],[h+r,t+o],[h,t+o],[h,t]]]}function Tt(a){const[h,t]=a.geometry.coordinates[0];return{x:h,y:t}}function Ct(a,h){const[t,r]=a.geometry.coordinates[h==="start"?0:1];return{x:t,y:r}}function Lt(a){const[h,t]=a.geometry.coordinates[1];return{x:h,y:t}}function le(a,h,t){a.geometry.coordinates[0]=[h,t]}function he(a,h,t){a.geometry.coordinates[1]=[h,t]}function Pt(a){return{start:Tt(a),end:Lt(a)}}function vt(a,h,t,r){h==="start"?le(a,t,r):he(a,t,r)}const ce=a=>parseInt(a.getAttribute("data-handle-id")||"-1");function gn(a){return Gt(a).reduce((h,t)=>(h[0]=Math.min(t[0],h[0]),h[1]=Math.min(t[1],h[1]),h[2]=Math.max(t[0],h[2]),h[3]=Math.max(t[1],h[3]),h),[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY])}function pn(a){return Array.isArray(a)&&a.length===2&&a.every(isFinite)}function Ie(a,h,t,r){for(let o=0;o<a.coordinates.length;o++){const l=a.coordinates[o];if(pn(l))l[0]=t+(l[0]-t)*h,l[1]=r+(l[1]-r)*h;else for(let u=0;u<l.length;u++){const d=l[u];d[0]=t+(d[0]-t)*h,d[1]=r+(d[1]-r)*h}}return a}function Gt(a){let h=[];return a.type=="Point"?h=[a.coordinates]:a.type=="LineString"||a.type=="MultiPoint"?h=a.coordinates:a.type=="Polygon"||a.type=="MultiLineString"?h=a.coordinates.reduce(function(t,r){return t.concat(r)},[]):a.type=="MultiPolygon"?h=a.coordinates.reduce((t,r)=>t.concat(r.reduce((o,l)=>o.concat(l),[])),[]):a.type=="Feature"?h=Gt(a.geometry):a.type=="GeometryCollection"?h=a.geometries.reduce((t,r)=>t.concat(Gt(r)),[]):a.type=="FeatureCollection"&&(h=a.features.reduce((t,r)=>t.concat(Gt(r)),[])),h}function Nt(a,h,t){const r=Math.atan2(a.y-h.y,a.x-h.x);return{x:h.x+t*Math.cos(r),y:h.y+t*Math.sin(r)}}function $t(a,h){if(!h)return{x:a.clientX,y:a.clientY};const t=h.getBoundingClientRect();return{x:a.clientX-t.left-h.clientLeft,y:a.clientY-t.top-h.clientTop}}const wt=(a,h)=>({x:a.x-h.x,y:a.y-h.y}),_t=a=>Math.sqrt(a.x*a.x+a.y*a.y),De=a=>({x:-a.x,y:-a.y}),Oe=a=>{const h=_t(a);return h===0?{x:0,y:0}:{x:a.x/h,y:a.y/h}},It=(a,h)=>({x:a.x+h.x,y:a.y+h.y}),Me=(a,h)=>({x:a.x*h,y:a.y*h}),Wt=(a,h)=>({x:a.x*h.x,y:a.y*h.y}),ot=(a,h)=>{const t=Math.sin(h),r=Math.cos(h);return{x:a.x*r-a.y*t,y:a.x*t+a.y*r}},yn=(a,h)=>({x:a.x/h,y:a.y/h}),Ce=(a,h)=>a.x*h.x+a.y*h.y;function Le(a,h=5,t=30){var d;const{start:r,end:o}=Pt(a),l=wt(o,r),u=a.properties.style&&a.properties.style.strokeWidth?(d=a.properties.style)==null?void 0:d.strokeWidth:0;return Math.min(t,Math.max(3*u,_t(l)*.1,h))}function Pe(a,h,t,r){const o=Me(De(Oe(h)),r);if(!t||t==="none")return"";const l=It(a,ot(o,Math.PI/8)),u=It(a,ot(o,-Math.PI/8)),d=`${a.x} ${a.y}`;return`M ${l.x} ${l.y} L ${d} ${u.x} ${u.y} ${t==="arrow"?"":`${l.x} ${l.y}`}`}function mn(a,h,t,r,o){const{start:l,end:u}=Pt(a),{tail:d,head:p,strokeColor:f,strokeWidth:y}=a.properties.style||t,v=wt(u,l),_=Le(a,r,o),E=St("path");E.setAttribute("data-annotation",`${a.id}`),E.setAttribute("data-annotation-type","arrow");const b=p==="arrow-plain"||d==="arrow";E.setAttribute("stroke",f||"none"),E.setAttribute("stroke-width",`${y}`),E.setAttribute("fill",b?f||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const P=Pe(l,De(v),d,_),k=Pe(u,v,p,_),$=P+`M ${l.x} ${l.y} ${u.x} ${u.y}`+k;E.setAttribute("d",$),h.appendChild(E)}const F=-1,zt="dragging",Ht="dragstart",xt="dragend",Yt="select",Xt="unselect",Ne="hover",$e="unhover",Zt="remove",Kt="add",ze="cancelDrawing",Jt="update",He="link";var vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ve(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Fe={exports:{}};(function(a){var h=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function o(p,f,y){this.fn=p,this.context=f,this.once=y||!1}function l(p,f,y,v,_){if(typeof y!="function")throw new TypeError("The listener must be a function");var E=new o(y,v||p,_),b=t?t+f:f;return p._events[b]?p._events[b].fn?p._events[b]=[p._events[b],E]:p._events[b].push(E):(p._events[b]=E,p._eventsCount++),p}function u(p,f){--p._eventsCount===0?p._events=new r:delete p._events[f]}function d(){this._events=new r,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],y,v;if(this._eventsCount===0)return f;for(v in y=this._events)h.call(y,v)&&f.push(t?v.slice(1):v);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(y)):f},d.prototype.listeners=function(f){var y=t?t+f:f,v=this._events[y];if(!v)return[];if(v.fn)return[v.fn];for(var _=0,E=v.length,b=new Array(E);_<E;_++)b[_]=v[_].fn;return b},d.prototype.listenerCount=function(f){var y=t?t+f:f,v=this._events[y];return v?v.fn?1:v.length:0},d.prototype.emit=function(f,y,v,_,E,b){var P=t?t+f:f;if(!this._events[P])return!1;var k=this._events[P],$=arguments.length,H,I;if(k.fn){switch(k.once&&this.removeListener(f,k.fn,void 0,!0),$){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,y),!0;case 3:return k.fn.call(k.context,y,v),!0;case 4:return k.fn.call(k.context,y,v,_),!0;case 5:return k.fn.call(k.context,y,v,_,E),!0;case 6:return k.fn.call(k.context,y,v,_,E,b),!0}for(I=1,H=new Array($-1);I<$;I++)H[I-1]=arguments[I];k.fn.apply(k.context,H)}else{var W=k.length,Y;for(I=0;I<W;I++)switch(k[I].once&&this.removeListener(f,k[I].fn,void 0,!0),$){case 1:k[I].fn.call(k[I].context);break;case 2:k[I].fn.call(k[I].context,y);break;case 3:k[I].fn.call(k[I].context,y,v);break;case 4:k[I].fn.call(k[I].context,y,v,_);break;default:if(!H)for(Y=1,H=new Array($-1);Y<$;Y++)H[Y-1]=arguments[Y];k[I].fn.apply(k[I].context,H)}}return!0},d.prototype.on=function(f,y,v){return l(this,f,y,v,!1)},d.prototype.once=function(f,y,v){return l(this,f,y,v,!0)},d.prototype.removeListener=function(f,y,v,_){var E=t?t+f:f;if(!this._events[E])return this;if(!y)return u(this,E),this;var b=this._events[E];if(b.fn)b.fn===y&&(!_||b.once)&&(!v||b.context===v)&&u(this,E);else{for(var P=0,k=[],$=b.length;P<$;P++)(b[P].fn!==y||_&&!b[P].once||v&&b[P].context!==v)&&k.push(b[P]);k.length?this._events[E]=k.length===1?k[0]:k:u(this,E)}return this},d.prototype.removeAllListeners=function(f){var y;return f?(y=t?t+f:f,this._events[y]&&u(this,y)):(this._events=new r,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=t,d.EventEmitter=d,a.exports=d})(Fe);var wn=Fe.exports;const Re=Ve(wn);class Be extends Re{constructor(t,r){super();m(this,"ogma");m(this,"elements");m(this,"layer");m(this,"editor");m(this,"selectedId",F);m(this,"hoveredId",F);m(this,"ogmaOptions");m(this,"shouldDetect");m(this,"isDragging");m(this,"showeditorOnHover");m(this,"_onKeyUp",t=>{t.code===27&&this.selectedId!==F?this.unselect():(t.code===46||t.code===8)&&this.selectedId!==F&&this._canRemove()&&this.remove(this.selectedId)});m(this,"_onClickMouseMove",t=>{if(!t.domEvent||this.isDragging||!this.shouldDetect||t.domEvent.type!=="mousemove"&&t.domEvent.target&&t.domEvent.target.tagName==="a")return;const r=this.ogma.view.screenToGraphCoordinates(t),o=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(r,0):void 0;t.domEvent.type==="mousemove"?o?this.hover(o.id):this.hoveredId!==F&&this.unhover():o?this.select(o.id):this.selectedId!==F&&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:o=>this.draw(o)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(r),this.editor.hide()}_canRemove(){return!0}add(t){const r=this.getDefaultOptions(),o=Object.assign(t,{id:t.id===void 0?X():t.id,type:t.type,properties:{...r.properties,...t.properties||{},style:{...r.properties.style,...t.properties.style||{}}},geometry:{...r.geometry,...t.geometry}});return this.elements.push(o),this.layer.refresh(),this.emit(Kt,o),o}updateStyle(t,r){this.updateAnnotation(t,{properties:{style:r}})}updateGeometry(t,r){this.updateAnnotation(t,{geometry:r})}scale(t,r,o,l){this.updateGeometry(t,Ie(t.geometry,r,o,l))}update(t,r){const o=this.getById(t);this.updateAnnotation(o,r)}updateAnnotation(t,r){if(!t)return;const o=t.id;Object.keys(r).forEach(l=>{if(l!=="id")if(l==="properties"){const u=r.properties||{style:{}};t.properties={...t.properties||{},...u||{},style:{...t.properties.style||{},...u.style||{}}}}else l==="geometry"?t.geometry={...t.geometry,...r.geometry}:t[l]=r[l]}),o===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){const r=Number(t);for(let o=0;o<this.elements.length;o++){const l=this.elements[o];if(!(l.id!==t&&l.id!==r))return l}}select(t){const r=this.getById(t);r&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Yt,r))}hover(t){const r=this.getById(t);r&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Ne,r))}getSelectedFeature(){return this.selectedId===F?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(Xt,t),this.selectedId=F,this.hoveredId===F&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit($e,t),this.hoveredId=F,this.selectedId===F&&this.editor.hide(),this.layer.refresh(),this}remove(t){const r=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(o=>o.id!==t),r&&this.emit(Zt,r),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 je="handle-line",qe="handle-start",Ue="handle-end";class Ge extends Be{constructor(t,r={}){super(t,`
1
+ (function(A,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(A=typeof globalThis<"u"?globalThis:A||self,X(A["@linkurious/ogma-annotations"]={}))})(this,function(A){"use strict";var si=Object.defineProperty;var oi=(A,X,st)=>X in A?si(A,X,{enumerable:!0,configurable:!0,writable:!0,value:st}):A[X]=st;var m=(A,X,st)=>(oi(A,typeof X!="symbol"?X+"":X,st),st);let X=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((h,t)=>(t&=63,t<36?h+=t.toString(36):t<62?h+=(t-26).toString(36).toUpperCase():t>62?h+="-":h+="_",h),"");const st={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},oe={id:0,type:"Feature",properties:{type:"arrow",style:{...st}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},Se=(a=0,h=0,t=0,r=0,o={...st})=>({id:X(),type:"Feature",properties:{type:"arrow",style:{...st,...o}},geometry:{type:"LineString",coordinates:[[a,h],[t,r]]}}),fn="http://www.w3.org/2000/svg";function St(a){return document.createElementNS(fn,a)}function ae(a){return a.geometry.bbox||Te(a),a.geometry.bbox}function ht(a){const h=ae(a);return{width:h[2]-h[0],height:h[3]-h[1]}}function ct(a){const h=ae(a);return{x:h[0],y:h[1]}}function Te(a){const[h,t]=a.geometry.coordinates[0][0],[r,o]=a.geometry.coordinates[0][2];a.geometry.bbox=[h,t,r,o]}function _e(a,h,t,r,o){a.geometry.bbox=[h,t,h+r,t+o],a.geometry.coordinates=[[[h,t],[h+r,t],[h+r,t+o],[h,t+o],[h,t]]]}function Tt(a){const[h,t]=a.geometry.coordinates[0];return{x:h,y:t}}function Ct(a,h){const[t,r]=a.geometry.coordinates[h==="start"?0:1];return{x:t,y:r}}function Lt(a){const[h,t]=a.geometry.coordinates[1];return{x:h,y:t}}function le(a,h,t){a.geometry.coordinates[0]=[h,t]}function he(a,h,t){a.geometry.coordinates[1]=[h,t]}function Pt(a){return{start:Tt(a),end:Lt(a)}}function vt(a,h,t,r){h==="start"?le(a,t,r):he(a,t,r)}const ce=a=>parseInt(a.getAttribute("data-handle-id")||"-1");function gn(a){return Ut(a).reduce((h,t)=>(h[0]=Math.min(t[0],h[0]),h[1]=Math.min(t[1],h[1]),h[2]=Math.max(t[0],h[2]),h[3]=Math.max(t[1],h[3]),h),[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY])}function pn(a){return Array.isArray(a)&&a.length===2&&a.every(isFinite)}function Ie(a,h,t,r){for(let o=0;o<a.coordinates.length;o++){const l=a.coordinates[o];if(pn(l))l[0]=t+(l[0]-t)*h,l[1]=r+(l[1]-r)*h;else for(let u=0;u<l.length;u++){const d=l[u];d[0]=t+(d[0]-t)*h,d[1]=r+(d[1]-r)*h}}return a}function Ut(a){let h=[];return a.type=="Point"?h=[a.coordinates]:a.type=="LineString"||a.type=="MultiPoint"?h=a.coordinates:a.type=="Polygon"||a.type=="MultiLineString"?h=a.coordinates.reduce(function(t,r){return t.concat(r)},[]):a.type=="MultiPolygon"?h=a.coordinates.reduce((t,r)=>t.concat(r.reduce((o,l)=>o.concat(l),[])),[]):a.type=="Feature"?h=Ut(a.geometry):a.type=="GeometryCollection"?h=a.geometries.reduce((t,r)=>t.concat(Ut(r)),[]):a.type=="FeatureCollection"&&(h=a.features.reduce((t,r)=>t.concat(Ut(r)),[])),h}function Nt(a,h,t){const r=Math.atan2(a.y-h.y,a.x-h.x);return{x:h.x+t*Math.cos(r),y:h.y+t*Math.sin(r)}}function Gt(a,h){if(!h)return{x:a.clientX,y:a.clientY};const t=h.getBoundingClientRect();return{x:a.clientX-t.left-h.clientLeft,y:a.clientY-t.top-h.clientTop}}const wt=(a,h)=>({x:a.x-h.x,y:a.y-h.y}),_t=a=>Math.sqrt(a.x*a.x+a.y*a.y),De=a=>({x:-a.x,y:-a.y}),Oe=a=>{const h=_t(a);return h===0?{x:0,y:0}:{x:a.x/h,y:a.y/h}},It=(a,h)=>({x:a.x+h.x,y:a.y+h.y}),Me=(a,h)=>({x:a.x*h,y:a.y*h}),Wt=(a,h)=>({x:a.x*h.x,y:a.y*h.y}),ot=(a,h)=>{const t=Math.sin(h),r=Math.cos(h);return{x:a.x*r-a.y*t,y:a.x*t+a.y*r}},yn=(a,h)=>({x:a.x/h,y:a.y/h}),Ce=(a,h)=>a.x*h.x+a.y*h.y;function Le(a,h=5,t=30){var d;const{start:r,end:o}=Pt(a),l=wt(o,r),u=a.properties.style&&a.properties.style.strokeWidth?(d=a.properties.style)==null?void 0:d.strokeWidth:0;return Math.min(t,Math.max(3*u,_t(l)*.1,h))}function Pe(a,h,t,r){const o=Me(De(Oe(h)),r);if(!t||t==="none")return"";const l=It(a,ot(o,Math.PI/8)),u=It(a,ot(o,-Math.PI/8)),d=`${a.x} ${a.y}`;return`M ${l.x} ${l.y} L ${d} ${u.x} ${u.y} ${t==="arrow"?"":`${l.x} ${l.y}`}`}function mn(a,h,t,r,o){const{start:l,end:u}=Pt(a),{tail:d,head:p,strokeColor:f,strokeWidth:y}=a.properties.style||t,v=wt(u,l),_=Le(a,r,o),E=St("path");E.setAttribute("data-annotation",`${a.id}`),E.setAttribute("data-annotation-type","arrow");const b=p==="arrow-plain"||d==="arrow";E.setAttribute("stroke",f||"none"),E.setAttribute("stroke-width",`${y}`),E.setAttribute("fill",b?f||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const P=Pe(l,De(v),d,_),k=Pe(u,v,p,_),$=P+`M ${l.x} ${l.y} ${u.x} ${u.y}`+k;E.setAttribute("d",$),h.appendChild(E)}const F=-1,$t="dragging",zt="dragstart",xt="dragend",Yt="select",Xt="unselect",Ne="hover",$e="unhover",Zt="remove",Kt="add",ze="cancelDrawing",Jt="update",He="link";var vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ve(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Fe={exports:{}};(function(a){var h=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function o(p,f,y){this.fn=p,this.context=f,this.once=y||!1}function l(p,f,y,v,_){if(typeof y!="function")throw new TypeError("The listener must be a function");var E=new o(y,v||p,_),b=t?t+f:f;return p._events[b]?p._events[b].fn?p._events[b]=[p._events[b],E]:p._events[b].push(E):(p._events[b]=E,p._eventsCount++),p}function u(p,f){--p._eventsCount===0?p._events=new r:delete p._events[f]}function d(){this._events=new r,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],y,v;if(this._eventsCount===0)return f;for(v in y=this._events)h.call(y,v)&&f.push(t?v.slice(1):v);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(y)):f},d.prototype.listeners=function(f){var y=t?t+f:f,v=this._events[y];if(!v)return[];if(v.fn)return[v.fn];for(var _=0,E=v.length,b=new Array(E);_<E;_++)b[_]=v[_].fn;return b},d.prototype.listenerCount=function(f){var y=t?t+f:f,v=this._events[y];return v?v.fn?1:v.length:0},d.prototype.emit=function(f,y,v,_,E,b){var P=t?t+f:f;if(!this._events[P])return!1;var k=this._events[P],$=arguments.length,H,I;if(k.fn){switch(k.once&&this.removeListener(f,k.fn,void 0,!0),$){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,y),!0;case 3:return k.fn.call(k.context,y,v),!0;case 4:return k.fn.call(k.context,y,v,_),!0;case 5:return k.fn.call(k.context,y,v,_,E),!0;case 6:return k.fn.call(k.context,y,v,_,E,b),!0}for(I=1,H=new Array($-1);I<$;I++)H[I-1]=arguments[I];k.fn.apply(k.context,H)}else{var W=k.length,Y;for(I=0;I<W;I++)switch(k[I].once&&this.removeListener(f,k[I].fn,void 0,!0),$){case 1:k[I].fn.call(k[I].context);break;case 2:k[I].fn.call(k[I].context,y);break;case 3:k[I].fn.call(k[I].context,y,v);break;case 4:k[I].fn.call(k[I].context,y,v,_);break;default:if(!H)for(Y=1,H=new Array($-1);Y<$;Y++)H[Y-1]=arguments[Y];k[I].fn.apply(k[I].context,H)}}return!0},d.prototype.on=function(f,y,v){return l(this,f,y,v,!1)},d.prototype.once=function(f,y,v){return l(this,f,y,v,!0)},d.prototype.removeListener=function(f,y,v,_){var E=t?t+f:f;if(!this._events[E])return this;if(!y)return u(this,E),this;var b=this._events[E];if(b.fn)b.fn===y&&(!_||b.once)&&(!v||b.context===v)&&u(this,E);else{for(var P=0,k=[],$=b.length;P<$;P++)(b[P].fn!==y||_&&!b[P].once||v&&b[P].context!==v)&&k.push(b[P]);k.length?this._events[E]=k.length===1?k[0]:k:u(this,E)}return this},d.prototype.removeAllListeners=function(f){var y;return f?(y=t?t+f:f,this._events[y]&&u(this,y)):(this._events=new r,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=t,d.EventEmitter=d,a.exports=d})(Fe);var wn=Fe.exports;const Re=Ve(wn);class Be extends Re{constructor(t,r){super();m(this,"ogma");m(this,"elements");m(this,"layer");m(this,"editor");m(this,"selectedId",F);m(this,"hoveredId",F);m(this,"ogmaOptions");m(this,"shouldDetect");m(this,"isDragging");m(this,"showeditorOnHover");m(this,"_onKeyUp",t=>{t.code===27&&this.selectedId!==F?this.unselect():(t.code===46||t.code===8)&&this.selectedId!==F&&this._canRemove()&&this.remove(this.selectedId)});m(this,"_onClickMouseMove",t=>{if(!t.domEvent||this.isDragging||!this.shouldDetect||t.domEvent.type!=="mousemove"&&t.domEvent.target&&t.domEvent.target.tagName==="a")return;const r=this.ogma.view.screenToGraphCoordinates(t),o=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(r,0):void 0;t.domEvent.type==="mousemove"?o?this.hover(o.id):this.hoveredId!==F&&this.unhover():o?this.select(o.id):this.selectedId!==F&&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:o=>this.draw(o)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(r),this.editor.hide()}_canRemove(){return!0}add(t){const r=this.getDefaultOptions(),o=Object.assign(t,{id:t.id===void 0?X():t.id,type:t.type,properties:{...r.properties,...t.properties||{},style:{...r.properties.style,...t.properties.style||{}}},geometry:{...r.geometry,...t.geometry}});return this.elements.push(o),this.layer.refresh(),this.emit(Kt,o),o}updateStyle(t,r){this.updateAnnotation(t,{properties:{style:r}})}updateGeometry(t,r){this.updateAnnotation(t,{geometry:r})}scale(t,r,o,l){this.updateGeometry(t,Ie(t.geometry,r,o,l))}update(t,r){const o=this.getById(t);this.updateAnnotation(o,r)}updateAnnotation(t,r){if(!t)return;const o=t.id;Object.keys(r).forEach(l=>{if(l!=="id")if(l==="properties"){const u=r.properties||{style:{}};t.properties={...t.properties||{},...u||{},style:{...t.properties.style||{},...u.style||{}}}}else l==="geometry"?t.geometry={...t.geometry,...r.geometry}:t[l]=r[l]}),o===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){const r=Number(t);for(let o=0;o<this.elements.length;o++){const l=this.elements[o];if(!(l.id!==t&&l.id!==r))return l}}select(t){const r=this.getById(t);r&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Yt,r))}hover(t){const r=this.getById(t);r&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Ne,r))}getSelectedFeature(){return this.selectedId===F?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(Xt,t),this.selectedId=F,this.hoveredId===F&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit($e,t),this.hoveredId=F,this.selectedId===F&&this.editor.hide(),this.layer.refresh(),this}remove(t){const r=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(o=>o.id!==t),r&&this.emit(Zt,r),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 je="handle-line",qe="handle-start",Ue="handle-end";class Ge extends Be{constructor(t,r={}){super(t,`
2
2
  <div class="arrow-handle">
3
3
  <div id="${je}" 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="${Ue}" data-handle-id="2" class="handle point"></div>
6
6
  </div>
7
- `);m(this,"draggedHandle",F);m(this,"start",{x:0,y:0});m(this,"end",{x:0,y:0});m(this,"arrow",{...oe});m(this,"startX",0);m(this,"startY",0);m(this,"minArrowHeight",0);m(this,"maxArrowHeight",0);m(this,"handles",[]);m(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!r)return;const{x:o,y:l}=$t(t,this.ogma.getContainer());this.startDragging(r,o,l),this.draggedHandle=ce(t.target)});m(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=F,this.emit(xt,this.arrow))});m(this,"onMouseMove",t=>{if(!this.isDragging||this.draggedHandle===F)return;const r=this.handles[this.draggedHandle],o=this.ogma.view.getAngle(),l=$t(t,this.ogma.getContainer()),{x:u,y:d}=ot(yn({x:l.x-this.startX,y:l.y-this.startY},this.ogma.view.getZoom()),o),p=r.id===je,f=r.id===qe,y=r.id===Ue;(p||f)&&le(this.arrow,this.start.x+u,this.start.y+d),(p||y)&&he(this.arrow,this.end.x+u,this.end.y+d),this.emit(zt,this.arrow,p?"line":f?"start":"end"),this.refreshEditor(),this.layer.refresh()});this.minArrowHeight=r.minArrowHeight||0,this.maxArrowHeight=r.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(o=>o.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,r,o=Se(t,r,t,r,st)){var d;this.disableDragging(),this.add(o),this.hoveredId=o.id;const l=this.ogma.view.graphToScreenCoordinates({x:t,y:r}),u=((d=this.ogma.getContainer())==null?void 0:d.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(o.id),l.x+(u==null?void 0:u.left),l.y+u.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(xt,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=F)}startDragging(t,r,o){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=r,this.startY=o,this.start=Tt(this.arrow),this.end=Lt(this.arrow),this.disableDragging(),this.emit(Ht,this.arrow),this.isDragging=!0}detect(t,r=0){return this.elements.find(o=>{const{start:l,end:u}=Pt(o),d=wt(t,{x:(l.x+u.x)/2,y:(l.y+u.y)/2}),p=wt(u,l),f=_t(p),y=Oe(p),v=Le(o);return Math.abs(Ce(y,d))<f/2+r&&Math.abs(Ce(ot(y,Math.PI/2),d))<v/2+r})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==F?this.getById(this.selectedId):this.getById(this.hoveredId),r=Pt(t),o=this.ogma.view.graphToScreenCoordinates(r.start),l=this.ogma.view.graphToScreenCoordinates(r.end),[u,d,p]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));d.style.transform=`translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`,p.style.transform=`translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`;const f={x:(l.x+o.x)/2,y:(l.y+o.y)/2},y=wt(l,o),v=Me(y,1/_t(y)),_=Math.atan2(v.y,v.x);u.style.width=`${_t(y)}px`,u.style.left=`${f.x}px`,u.style.top=`${f.y}px`,u.style.transform=`translate(-50%, -50%) rotate(${_}rad)`}getDefaultOptions(){return oe}draw(t){t.innerHTML="";const r=St("g"),o=this.ogma.view.getAngle();r.setAttribute("transform",`rotate(${-o*(180/Math.PI)})`),this.elements.forEach(l=>mn(l,r,st,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(r)}refreshDrawing(){const t=this.ogma.view.getAngle();this.layer.element!==null&&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 bt={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},Qt={id:0,type:"Feature",properties:{type:"text",content:"",style:{...bt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},ue={handleSize:3.5,placeholder:"Your text..."},We=(a=0,h=0,t=100,r=50,o="",l={...bt})=>({id:X(),type:"Feature",properties:{type:"text",content:o,style:{...bt,...l}},geometry:{type:"Polygon",coordinates:[[[a,h],[a+t,h],[a+t,h+r],[a,h+r],[a,h]]]}});var Ye={exports:{}};(function(a,h){(function(t,r){a.exports=r()})(vn,()=>(()=>{var t={d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function o(e){return o=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},o(e)}t.d(r,{default:()=>ii});var l=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,u=/\bsmall-caps\b/,d=/\b(?:italic|oblique)\b/,p=/\bbold(?:er)?\b/,f=13.3333333,y={"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 v(e){var n="",s=this;return s.style&&s.style!=="normal"&&(n+=s.style),s.variant&&s.variant!=="normal"&&(n+=(n?" ":"")+s.variant),s.weight&&s.weight!=="normal"&&(n+=(n?" ":"")+s.weight),s.size&&(n+=(n?" ":"")+s.size+"px",s.height!==s.size&&(n+="/"+s.height+"px")),s.family&&(n+=(n?" ":"")+s.family),e&&(n+="::"+s.baseline),e&&(n+="::"+s.color),n}var _={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:v,valueOf:v};function E(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=l.exec(e);n.family=(s[6]||"").trim();var i=y[s[2]]||parseFloat(s[2]);s[3]==="%"?i*=.16:s[3]==="em"?i*=16:s[3]==="pt"&&(i*=f),n.size=i;var c=parseFloat(s[4]);if(c!=="normal"&&c!=="inherit"&&c?s[5]&&s[5]!=="em"?s[5]==="pt"?n.height=c*f:s[5]==="%"?n.height=.01*i:n.height=c:n.height=c*i:n.height=Math.round(i*(7/6)),u.test(s[1])&&(n.variant="small-caps"),d.test(s[1])&&(n.style="italic"),p.test(s[1]))n.weight="bold";else{var g=parseInt(/\b(\d+)\b/.exec(s[1]),10);g>=100&&g!==400&&(n.weight=g)}return n}function b(){var e,n,s,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=14,x=12,w=null,S=null,T="";if(i&&i.nodeType){var M=i&&(i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView),C=M.getComputedStyle(i,null);e=C.getPropertyValue("font-family")||"",x=parseFloat(C.getPropertyValue("font-size")),g=C.getPropertyValue("line-height"),w=C.getPropertyValue("font-weight"),S=C.getPropertyValue("font-style"),T=C.getPropertyValue("font-variant")||""}else if(typeof i=="string"){var D=E(i);e=D.family,x=D.size,g=D.height,T=D.variant,S=D.style,w=D.weight}else o(i)==="object"&&(e=i.family,x=i.size,g=i.height,T=i.variant,w=i.weight,S=i.style,n=i.baseline,s=i.color);c.size&&c.size<3&&(x*=c.size),g=g!=="normal"&&g?parseFloat(g):x*(7/6),c.height&&c.height<3&&(g*=c.height);var L=Object.create(_);return L.family=c.family||e||"sans-serif",L.height=g??14,L.size=x??12,L.variant=c.variant||T||"",L.style=c.style||S||"",L.weight=c.weight||w||"",L.baseline=n||0,c.baseline!=null&&(L.baseline=c.baseline),L.color=c.color||s||"",L.id=v.call(L,!0),L}const P={"\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 k,$=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var s=n.getContext("2d");if(s&&typeof s.measureText=="function")return function(i,c){return s.font=String(c),s.measureText(i).width}}}(typeof document<"u"?document:null)||(k={},function(e,n){if(!k[n]){var s=b(n);k[n]=s,/\bmonospace\b/.test(s.family)?s.size*=.6:(s.size*=.45,s.weight&&(s.size*=1.18))}return e.length*k[n].size}),H={},I={trim:!0,collapse:!0};function W(e,n,s){var i=Object.assign({},I,s),c=String(e);if(!c)return 0;if(c in P){var g=n.id+"/"+c;return g in H||(H[g]=$("_".concat(c,"_"),n)-$("__",n)),H[g]}return i.trim&&i.collapse?i.trim?c=c.trim():i.collapse&&(c=c.replace(/\s+/g," ")):c=c.replace(/\n/g," "),$(c,n)+n.size*(e.tracking||0)}function Y(e){return Y=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},Y(e)}function Vt(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&&Ft(e,n)}function Ft(e,n){return Ft=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,i){return s.__proto__=i,s},Ft(e,n)}function pe(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 s,i=te(e);if(n){var c=te(this).constructor;s=Reflect.construct(i,arguments,c)}else s=i.apply(this,arguments);return Sn(this,s)}}function Sn(e,n){if(n&&(Y(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}(e)}function te(e){return te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},te(e)}function ee(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Tn(e,n){for(var s=0;s<n.length;s++){var i=n[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(g,x){if(Y(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var S=w.call(g,x);if(Y(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Y(c)==="symbol"?c:String(c)),i)}var c}function ne(e,n,s){return n&&Tn(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var R=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";ee(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return ne(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}(),Rt=function(e){Vt(s,e);var n=pe(s);function s(){return ee(this,s),n.apply(this,arguments)}return ne(s)}(R),it=function(e){Vt(s,e);var n=pe(s);function s(){return ee(this,s),n.apply(this,arguments)}return ne(s)}(R),At=function(e){Vt(s,e);var n=pe(s);function s(){return ee(this,s),n.apply(this,arguments)}return ne(s)}(R),ye=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,_n=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,tn=/^[\xA0\u2011\u202F\u2060\uFEFF]/,In=/^(?:[;\xAD%?…]|,(?!\d))/,Dn=/^[´±°¢£¤$¥\u2212]/;function ie(e,n){n!==!1&&(e=e.trim());for(var s,i,c=[],g=e.charAt(0),x=0,w=1,S=e.length;w<S;w++){s=e.charAt(w),i=e.charAt(w+1);var T=ye.test(g),M=ye.test(s),C=M||T,D=void 0;if((Dn.test(s)&&!tn.test(g)||In.test(g+i)&&!tn.test(s))&&(C=!0),g!=="-"&&g!=="‐"&&g!=="–"&&g!=="—"||((D=ye.test(e.charAt(w-2)))&&!M&&(C=!1),!D&&_n.test(s+i)&&(C=!0)),C){var L=e.slice(x,w);/\u00AD$/.test(L)?(c.push(new R(L.slice(0,-1))),c.push(new At)):(c.push(new R(L)),c.push(new Rt)),x=w}g=s}return c.push(new R(e.slice(x))),c}const en={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 On=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,Mn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,Cn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Ln=/^<!--(.+?)-->/,Pn=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,nn={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}},Nn={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 rn(e){return e.replace(Pn,function(n,s,i,c){if(s||i){var g=s?10:16;return String.fromCharCode(parseInt(s||i,g))}return c in en?en[c]:n})}function $n(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var zn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Hn(e){var n,s={};if(e){do if(n=zn.exec(e)){var i=rn($n(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(s[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 s}const sn={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 Vn=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Fn=/^%[^\n]+(?:\n|$)/,Rn=/^[^#$%&~_^\\{}]+/,Bn=/^\\([&{}$%#_])/,jn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,qn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\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 R(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 Un=/[\r\n\xA0]+/g;function Gn(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var s=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(s=b(n,e)),s}function on(e,n,s){for(var i,c,g=e.width;g+s.width>n&&e.length;)c=(i=e[e.length-1]).width,i.width>s.width?(i.value=i.value.slice(0,-1),i.width=W(i,i.font),g+=i.width):e.pop(),g-=c;e[e.length-1]instanceof At&&e.pop(),i=e[e.length-1]||i||{},s.font=b(s.font,i.bold,i.italic,""),s.href=e.length?i.href:null,s.rel=e.length?i.rel:null,s.target=e.length?i.target:null,e.push(s)}function Dt(e){return Math.round(1e6*e)/1e6}function an(e){return function(n){if(Array.isArray(n))return me(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,s){if(n){if(typeof n=="string")return me(n,s);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)?me(n,s):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 me(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,i=new Array(n);s<n;s++)i[s]=e[s];return i}var Wn={center:"middle",right:"end"},Yn={middle:.5,center:.5,bottom:1,end:1},ve=function(e,n){return!e&&!n||e===n};function Xn(e,n){var s=[],i=n.font(),c=i.size,g=i.family,x=n.align(),w=n.createElement();if(e.length){var S=i.height,T=n.valign(),M=n.height()(),C=n.width()(0),D=!isFinite(C)&&e.length===1,L=D?null:n.x(),B=Dt(S/c),tt=D?null:Dt(S/(1.15*c+(S-c)/2));if(Yn[T]&&isFinite(M)){var z=T==="bottom"?1:.5;tt+=(M*z-S*e.length*z)/c}var N=x==="justify",j=0;x==="right"?j=C:x==="center"&&(j=C/2);for(var V=[],et="tspan",Z=null,q="",O=function(){if(q){var Et=w(et,Z,q);V.push(Et)}et="tspan",Z=null,q=""},rt=0,nt=e.length;rt<nt;rt++){var ft="",yt="",ut=0,gt=e[rt];if(gt.length){V=[];for(var Ot=0,qt=0,pt=void 0,K=0,re=gt.length;K<re;K++){var U=gt[K],J=U.font;U.whitespace&&Ot++,qt+=U.width,K&&!U.tracking&&!ut&&ve(J.id,ft)&&ve(U.class,yt)&&ve(pt,U.href)?q+=U.value:(O(),q=U.value,Z={fontFamily:J.family!==g?J.family:null,fontSize:J.size!==c?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:U.class||null},ut&&(Z.dx=Dt(ut),ut=0),U.tracking&&(ut=J.size*U.tracking),U.href&&!pt?(pt=U.href,et="a",Z.href=pt,Z.rel=U.rel,Z.target=U.target):pt=null,ft=J.id,yt=U.class)}if(O(),D)s.push.apply(s,an(V));else{var se=null,Ut=rt===nt-1||gt[gt.length-1]instanceof it;N&&gt.length>1&&!Ut&&(se=Dt((C-qt)/Ot)),s.push(w.apply(void 0,["tspan",{wordSpacing:se,x:L(rt)+j,dy:Dt(rt?B:tt)+"em"}].concat(an(V))))}}else s.push(w("tspan",{x:L(rt),dy:Dt(rt?B:tt)+"em"}," "))}}return w.apply(void 0,["text",{fontFamily:g,fontSize:c,textAnchor:Wn[x]||"start"}].concat(s))}var Zn={middle:.5,center:.5,bottom:1,end:1};function Kn(e,n,s){if(e.length){s.textBaseline="middle";var i=n.font(),c=i.height,g=i.size,x=n.valign(),w=n.height()(),S=n.width()(0),T=n.align(),M=T==="justify",C=.5*c,D=Zn[x];if(D&&isFinite(w)){var L=e.length*c;C+=w*D-L*D}e.forEach(function(B,tt){var z=n.x()(tt),N=tt*c+C,j=0,V=0;B.forEach(function(q){q.whitespace&&j++,V+=q.width});var et=0,Z=tt===e.length-1||B[B.length-1]instanceof it;M&&B.length>1&&!Z&&(et=(S-V)/j),B.forEach(function(q){s.font=q.font;var O=q.font,rt=O.baseline?g*-O.baseline+.15*g:0;s.fillStyle=function(yt,ut){return yt.color?yt.color:ut.href?"#00C":"#000"}(O,q);var nt=0;if(T==="right"?nt+=S-V:T==="center"?nt+=S/2-V/2:T==="justify"&&(q.whitespace||q instanceof it)&&(z+=et),s.fillText(q.value,z+nt,N+rt),q.href){s.beginPath(),s.strokeStyle=s.fillStyle;var ft=Math.floor(N+.45*g)+.5;s.moveTo(z+nt,ft),s.lineTo(z+nt+q.width,ft),s.stroke()}z+=q.width})})}}function we(e){return we=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},we(e)}function ln(e){for(var n={},s=0;s<e.length;s++){var i=e[s];typeof i!="number"&&i!=null&&(typeof i=="string"?n.text=i:typeof i=="function"?n.fn=i:we(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 Bt(e){return Bt=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},Bt(e)}function Jn(e,n){for(var s=0;s<n.length;s++){var i=n[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(g,x){if(Bt(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var S=w.call(g,x);if(Bt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Bt(c)==="symbol"?c:String(c)),i)}var c}var Qn=b(),xe=function(e){return typeof e=="function"?e:function(){return e}},lt=function(){function e(i){if(function(g,x){if(!(g 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},i)for(var c in i)typeof this[c]=="function"&&this[c](i[c])}var n,s;return n=e,s=[{key:"linebreak",value:function(i){var c=this,g=this.props.parser(String(i)),x=this.font(),w=function(S,T,M){if(!S.length)return[];var C=T.height(),D=T.width(),L=T.overflowLine(),B=T.overflowWrap(),tt=b(M,!0,!1),z=isFinite(C())?Math.floor(C()/M.height):1/0;if(!C()&&!D(0)||!z)return[];for(var N=0,j=0,V=0,et=[],Z=[],q=!1;N<S.length&&j<z;){var O=S[N],rt=Gn(O,M);if(O.width=W(O,rt),O.font=rt,O.line=j,O.whitespace=O.value in P,O.value&&(O.value=O.value.replace(Un," ")),!(!V&&O.whitespace||q&&O.whitespace))if(O instanceof it)V=0,Z=[],et.push(N+1),j++;else if(O instanceof Rt||O instanceof At)Z.push({index:N,width:V});else if(O.whitespace||V+O.width<D(j))V+=O.width;else if(Z.length){var nt=void 0,ft=void 0;do{ft=!0,nt=Z.pop();var yt=S[nt.index],ut=void 0;yt instanceof At&&(ut=W("-",yt.font),nt.width+ut>D(j)&&(ft=!Z.length))}while(!ft);et.push(nt.index+1),V=0,j++,N=nt.index,Z=[]}else if(B==="break-word"){var gt=D(j);if(V+O.width>gt){var Ot=O.clone();do O.value=O.value.slice(0,-1),O.width=W(O,O.font),V+=O.width;while(O.value&&O.width>gt);Ot.value=Ot.value.slice(O.value.length),S.splice(N+1,0,new Rt,Ot)}et.push(N+1),V=0,j++}else V+=O.width;N++,q=O.whitespace}N!==et[et.length-1]&&et.push(N);var qt=0,pt=0,K=et.map(function(Et){for(var Q,kt=qt;(Q=S[kt])&&(Q.whitespace||!Q.value);)kt++;for(var mt=Et,Ee=null;mt>kt&&(Q=S[mt-1])&&(Q.whitespace||!(Q.value||Q instanceof At));)Q instanceof it&&(Ee=Q),mt--;Q instanceof At&&(Q.value="-",Q.width=W("-",Q.font)),qt=Et;var Mt=S.slice(kt,mt).filter(function(ke){return ke.value});return Ee&&Mt.push(Ee),Mt.width=Mt.reduce(function(ke,ri){return ke+ri.width},0),Mt.width>pt&&(pt=Mt.width),Mt});if(K.hasLineOverflow=!1,L){var re=L==="ellipsis"?"…":L;K.forEach(function(Et,Q){var kt=D(Q);if(Et.width>kt){var mt=new R(re);mt.font=M,mt.width=W(re,tt),on(Et,kt,mt),K.hasLineOverflow=!0}})}var U=T.overflow()==="ellipsis"?"…":T.overflow();if(U&&N!==S.length){var J=D(K.length-1),se=K[K.length-1],Ut=new R(U);Ut.font=M,Ut.width=W(U,tt),on(se,J,Ut),K.hasOverflow=!0}else K.hasOverflow=!1;return K.font=M,K.width=pt,K}(g,this,x);return w.height=w.length*x.height,w.render=function(S){return c.render(w,S)},w.svg=w.render,w.draw=w.render,w}},{key:"font",value:function(i){return arguments.length?(this.props.font=b(i),this):this.props.font||b(Qn)}},{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 c=String(i).toLowerCase();return c==="left"||c==="start"?(this.props.align="left",this.props.tAnchor=0):c==="center"||c==="middle"?(this.props.align="center",this.props.tAnchor=-.5):c==="end"||c==="right"?(this.props.align="right",this.props.tAnchor=-1):c==="justify"&&(this.props.align=i,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(i){if(!arguments.length)return this.props.overflowWrap||"normal";var c=String(i).toLowerCase();return c==="break-word"?this.props.overflowWrap="break-word":c!=="normal"&&i!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(i){return arguments.length?(this.props.width=xe(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=xe(i),this):this.props.height}},{key:"x",value:function(i){return arguments.length?(this.props.x=xe(i),this):this.props.x}},{key:"parser",value:function(i){if(!arguments.length)return this.props.parser;if(typeof i=="string"){var c=e[i]||e[i+"parser"];typeof c=="function"&&(i=c)}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=ln(arguments);return typeof i.text=="string"&&(i.text=this.linebreak(i.text)),i.ctx?Kn(i.text,this,i.ctx):Xn(i.text,this)}}],s&&Jn(n.prototype,s),Object.defineProperty(n,"prototype",{writable:!1}),e}();function jt(e){return jt=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},jt(e)}function be(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,i=new Array(n);s<n;s++)i[s]=e[s];return i}function ti(e,n){for(var s=0;s<n.length;s++){var i=n[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(g,x){if(jt(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var S=w.call(g,x);if(jt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),jt(c)==="symbol"?c:String(c)),i)}var c}var hn=function(e){return typeof e=="function"?e:function(){return e}},cn=function(){function e(i){if(function(g,x){if(!(g 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},i)for(var c in i)typeof this[c]=="function"&&this[c](i[c]);this.render=this.render.bind(this)}var n,s;return n=e,s=[{key:"anchor",value:function(i){var c=this.props,g=c.hAnchor,x=c.vAnchor,w=c.width,S=c.height;if(!arguments.length)return[g*w(0),x*S(0)];if(typeof i=="string"){var T=this.props;i.toLowerCase().trim().split(/\s+/).forEach(function(M){M==="top"&&(T.vAnchor=-0),M==="middle"&&(T.vAnchor=-.5),M==="bottom"&&(T.vAnchor=-1),M==="left"&&(T.hAnchor=-0),M==="center"&&(T.hAnchor=-.5),M==="right"&&(T.hAnchor=-1)})}return this}},{key:"width",value:function(i){return arguments.length?(this.props.width=hn(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=hn(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,c){var g,x=i.getContext?i.getContext("2d"):i;return x.save(),x.rotate(this.rotate()*Math.PI/180),x.translate.apply(x,function(w){if(Array.isArray(w))return be(w)}(g=this.anchor())||function(w){if(typeof Symbol<"u"&&w[Symbol.iterator]!=null||w["@@iterator"]!=null)return Array.from(w)}(g)||function(w,S){if(w){if(typeof w=="string")return be(w,S);var T=Object.prototype.toString.call(w).slice(8,-1);return T==="Object"&&w.constructor&&(T=w.constructor.name),T==="Map"||T==="Set"?Array.from(w):T==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(T)?be(w,S):void 0}}(g)||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.`)}()),c(x),x.restore(),x}},{key:"render",value:function(){var i=ln(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 c=typeof i.text.render=="function"?i.text.render():i.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},c)}}}],s&&ti(n.prototype,s),Object.defineProperty(n,"prototype",{writable:!1}),e}(),ei=Object.prototype.hasOwnProperty,Ae={};function ni(e){return Ae[e]||(Ae[e]=e.replace(/([a-z])([A-Z])/g,function(n,s,i){return s+"-"+i.toLowerCase()})),Ae[e]}function un(e,n){if(Array.isArray(n))return n.forEach(function(s){return un(e,s)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function dn(e,n){if(typeof document<"u"){var s=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&s.setAttribute)for(var i in n)ei.call(n,i)&&n[i]!=null&&s.setAttribute(i==="className"?"class":ni(i),n[i]);for(var c=arguments.length,g=new Array(c>2?c-2:0),x=2;x<c;x++)g[x-2]=arguments[x];return g!=null&&g.length&&g.forEach(function(w){un(s,w)}),s}}lt.createElement=dn,lt.textparser=ie,lt.defaultparser=ie,lt.htmlparser=function(e){e=String(e||"").trim();for(var n,s,i={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},c=[],g=[],x=function(C){for(var D in i)i[D]&&(C[D]=i[D]);c.push(C)},w=function(C){var D=c.length,L=Nn[C];if(D&&L){for(var B=D-1;c[B]&&(c[B]instanceof Rt||On.test(c[B].value));)B--;for(;L&&c[B]&&c[B]instanceof it;)B--,L--;for(;L-- >0;)c.push(new it)}};e.length;){if(n=/^[^<]+/.exec(e))ie(rn(n[0]),!1).forEach(x);else if(!(n=Ln.exec(e)))if(n=Mn.exec(e))g.length&&(i=g.pop()),w(n[1]);else if(n=Cn.exec(e)){var S=n[1];w(S),g.push(i),i=Object.create(i),nn[S]&&nn[S](i,"");var T=Hn(n[2]);S==="a"&&(T.href&&(i.href=T.href),T.rel&&(i.rel=T.rel),T.target&&(i.target=T.target)),T.class&&(i.class=i.class?i.class+" "+T.class:T.class),T.style&&(s=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(T.style))&&s[1]&&(i.color=s[1]),S==="br"&&c.push(new it)}else n=[e.slice(0,1)],x(new R(n[0]));e=e.slice(n[0].length)}for(var M=c[c.length-1];M instanceof it;)c.pop(),M=c[c.length-1];return c},lt.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function(z,N){return n.push(N),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(jn,function(z,N,j){return j.charAt(N-1)==="\\"?z:qn[z]}).replace(/\n\s+/g,function(z){return/\n/.test(z.slice(1))?"\\par ":z}).replace(/\\symbol\{(\d+)\}/,function(z,N,j,V){return V.charAt(j-1)==="\\"?z:String.fromCharCode(1*N)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(z,N,j,V){return N+j+"{"+V+"}"}).replace(/\\verb,(.*?),/,function(z,N){return"\\verb,".concat(n[+N],",")});for(var s,i={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},c=[],g=[],x=function(z){for(var N in i)i[N]&&(z[N]=i[N]);return c.push(z),z},w=function(){g.push(i),i=Object.create(i)},S=function(){if(!g.length)throw new Error("Unexpected }");i=g.pop()},T={tokens:c,open_context:w,close_context:S,add_token:x};e.length;){if(s=Rn.exec(e))ie(s[0],!1).forEach(x);else if(s=Bn.exec(e))x(new R(s[1]));else if(!(s=Fn.exec(e))){if(s=/^\{/.exec(e))w();else if(s=/^\}/.exec(e))S();else if(!(s=/^\$/.exec(e)))if(s=/^\\verb,([^,]+),/.exec(e))x(new R(s[1]));else if(s=Vn.exec(e)){var M=s[1].slice(1)||s[1],C=!!s[2];if(/^(La)?TeX$/i.test(M)){w(),i.family="serif";var D=void 0;M==="LaTeX"&&((D=x(new R("L"))).tracking=-.25,(D=x(new R("A"))).size=.7,D.baseline=.3,D.tracking=-.1),(D=x(new R("T"))).tracking=-.17,(D=x(new R("E"))).baseline=-.22,D.tracking=-.13,D=x(new R("X")),S()}else if(M in sn)x(new R(sn[M])),C&&w();else if(M in G){var L=[],B=G[M].length-1,tt=void 0;if(B){for(C=!1,e=e.slice(s[0].length-1);B--;){if(!(tt=/^\{([^}]+)\}/.exec(e)))throw new Error(M+" is missing an argument");L.push(tt[1]),e=e.slice(tt[0].length)}s[0]=/^\{/.exec(e)?"{":"",C=!!s[0]}C&&w(),G[M].apply(T,[i].concat(L))}else console.warn("unknown latex command",M),x(new R(s[1])),C&&w()}else s=[e.slice(0,1)],x(new R(s[0]))}e=e.slice(s[0].length)}return c},lt.measureText=function(e,n,s){return W(e,b(n),s)},lt.Token=R,lt.Break=Rt,lt.LineBreak=it,lt.SoftHyphen=At,lt.Rotator=cn,cn.createElement=dn;const ii=lt;return r.default})())})(Ye);var xn=Ye.exports;const Xe=Ve(xn);function de(a){return a.replace(/…$/,"")}function fe(a){return a.children[0].innerHTML}function bn(a,h){const t=ht(a),{fontSize:r,font:o,padding:l=0}=a.properties.style||{};if(t.width===t.height&&t.width===0)return;const u=new Xe({font:`${r}px/${r}px ${o}`.replace(/(px)+/g,"px"),width:t.width-l*2,height:t.height-l*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Xe.createElement});u.overflowWrap("break-word");const p=u.linebreak(a.properties.content.replaceAll(`
7
+ `);m(this,"draggedHandle",F);m(this,"start",{x:0,y:0});m(this,"end",{x:0,y:0});m(this,"arrow",{...oe});m(this,"startX",0);m(this,"startY",0);m(this,"minArrowHeight",0);m(this,"maxArrowHeight",0);m(this,"handles",[]);m(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!r)return;const{x:o,y:l}=Gt(t,this.ogma.getContainer());this.startDragging(r,o,l),this.draggedHandle=ce(t.target)});m(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=F,this.emit(xt,this.arrow))});m(this,"onMouseMove",t=>{if(!this.isDragging||this.draggedHandle===F)return;const r=this.handles[this.draggedHandle],o=this.ogma.view.getAngle(),{x:l,y:u}=ot(yn({x:t.x-this.startX,y:t.y-this.startY},this.ogma.view.getZoom()),o),d=r.id===je,p=r.id===qe,f=r.id===Ue;(d||p)&&le(this.arrow,this.start.x+l,this.start.y+u),(d||f)&&he(this.arrow,this.end.x+l,this.end.y+u),this.emit($t,this.arrow,d?"line":p?"start":"end"),this.refreshEditor(),this.layer.refresh()});this.minArrowHeight=r.minArrowHeight||0,this.maxArrowHeight=r.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(o=>o.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,r,o=Se(t,r,t,r,st)){var d;this.disableDragging(),this.add(o),this.hoveredId=o.id;const l=this.ogma.view.graphToScreenCoordinates({x:t,y:r}),u=((d=this.ogma.getContainer())==null?void 0:d.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(o.id),l.x+(u==null?void 0:u.left),l.y+u.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(xt,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=F)}startDragging(t,r,o){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=r,this.startY=o,this.start=Tt(this.arrow),this.end=Lt(this.arrow),this.disableDragging(),this.emit(zt,this.arrow),this.isDragging=!0}detect(t,r=0){return this.elements.find(o=>{const{start:l,end:u}=Pt(o),d=wt(t,{x:(l.x+u.x)/2,y:(l.y+u.y)/2}),p=wt(u,l),f=_t(p),y=Oe(p),v=Le(o);return Math.abs(Ce(y,d))<f/2+r&&Math.abs(Ce(ot(y,Math.PI/2),d))<v/2+r})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==F?this.getById(this.selectedId):this.getById(this.hoveredId),r=Pt(t),o=this.ogma.view.graphToScreenCoordinates(r.start),l=this.ogma.view.graphToScreenCoordinates(r.end),[u,d,p]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));d.style.transform=`translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`,p.style.transform=`translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`;const f={x:(l.x+o.x)/2,y:(l.y+o.y)/2},y=wt(l,o),v=Me(y,1/_t(y)),_=Math.atan2(v.y,v.x);u.style.width=`${_t(y)}px`,u.style.left=`${f.x}px`,u.style.top=`${f.y}px`,u.style.transform=`translate(-50%, -50%) rotate(${_}rad)`}getDefaultOptions(){return oe}draw(t){t.innerHTML="";const r=St("g"),o=this.ogma.view.getAngle();r.setAttribute("transform",`rotate(${-o*(180/Math.PI)})`),this.elements.forEach(l=>mn(l,r,st,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(r)}refreshDrawing(){const t=this.ogma.view.getAngle();this.layer.element!==null&&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 bt={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},Qt={id:0,type:"Feature",properties:{type:"text",content:"",style:{...bt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},ue={handleSize:3.5,placeholder:"Your text..."},We=(a=0,h=0,t=100,r=50,o="",l={...bt})=>({id:X(),type:"Feature",properties:{type:"text",content:o,style:{...bt,...l}},geometry:{type:"Polygon",coordinates:[[[a,h],[a+t,h],[a+t,h+r],[a,h+r],[a,h]]]}});var Ye={exports:{}};(function(a,h){(function(t,r){a.exports=r()})(vn,()=>(()=>{var t={d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function o(e){return o=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},o(e)}t.d(r,{default:()=>ii});var l=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,u=/\bsmall-caps\b/,d=/\b(?:italic|oblique)\b/,p=/\bbold(?:er)?\b/,f=13.3333333,y={"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 v(e){var n="",s=this;return s.style&&s.style!=="normal"&&(n+=s.style),s.variant&&s.variant!=="normal"&&(n+=(n?" ":"")+s.variant),s.weight&&s.weight!=="normal"&&(n+=(n?" ":"")+s.weight),s.size&&(n+=(n?" ":"")+s.size+"px",s.height!==s.size&&(n+="/"+s.height+"px")),s.family&&(n+=(n?" ":"")+s.family),e&&(n+="::"+s.baseline),e&&(n+="::"+s.color),n}var _={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:v,valueOf:v};function E(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=l.exec(e);n.family=(s[6]||"").trim();var i=y[s[2]]||parseFloat(s[2]);s[3]==="%"?i*=.16:s[3]==="em"?i*=16:s[3]==="pt"&&(i*=f),n.size=i;var c=parseFloat(s[4]);if(c!=="normal"&&c!=="inherit"&&c?s[5]&&s[5]!=="em"?s[5]==="pt"?n.height=c*f:s[5]==="%"?n.height=.01*i:n.height=c:n.height=c*i:n.height=Math.round(i*(7/6)),u.test(s[1])&&(n.variant="small-caps"),d.test(s[1])&&(n.style="italic"),p.test(s[1]))n.weight="bold";else{var g=parseInt(/\b(\d+)\b/.exec(s[1]),10);g>=100&&g!==400&&(n.weight=g)}return n}function b(){var e,n,s,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=14,x=12,w=null,S=null,T="";if(i&&i.nodeType){var M=i&&(i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView),C=M.getComputedStyle(i,null);e=C.getPropertyValue("font-family")||"",x=parseFloat(C.getPropertyValue("font-size")),g=C.getPropertyValue("line-height"),w=C.getPropertyValue("font-weight"),S=C.getPropertyValue("font-style"),T=C.getPropertyValue("font-variant")||""}else if(typeof i=="string"){var D=E(i);e=D.family,x=D.size,g=D.height,T=D.variant,S=D.style,w=D.weight}else o(i)==="object"&&(e=i.family,x=i.size,g=i.height,T=i.variant,w=i.weight,S=i.style,n=i.baseline,s=i.color);c.size&&c.size<3&&(x*=c.size),g=g!=="normal"&&g?parseFloat(g):x*(7/6),c.height&&c.height<3&&(g*=c.height);var L=Object.create(_);return L.family=c.family||e||"sans-serif",L.height=g??14,L.size=x??12,L.variant=c.variant||T||"",L.style=c.style||S||"",L.weight=c.weight||w||"",L.baseline=n||0,c.baseline!=null&&(L.baseline=c.baseline),L.color=c.color||s||"",L.id=v.call(L,!0),L}const P={"\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 k,$=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var s=n.getContext("2d");if(s&&typeof s.measureText=="function")return function(i,c){return s.font=String(c),s.measureText(i).width}}}(typeof document<"u"?document:null)||(k={},function(e,n){if(!k[n]){var s=b(n);k[n]=s,/\bmonospace\b/.test(s.family)?s.size*=.6:(s.size*=.45,s.weight&&(s.size*=1.18))}return e.length*k[n].size}),H={},I={trim:!0,collapse:!0};function W(e,n,s){var i=Object.assign({},I,s),c=String(e);if(!c)return 0;if(c in P){var g=n.id+"/"+c;return g in H||(H[g]=$("_".concat(c,"_"),n)-$("__",n)),H[g]}return i.trim&&i.collapse?i.trim?c=c.trim():i.collapse&&(c=c.replace(/\s+/g," ")):c=c.replace(/\n/g," "),$(c,n)+n.size*(e.tracking||0)}function Y(e){return Y=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},Y(e)}function Ht(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&&Vt(e,n)}function Vt(e,n){return Vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,i){return s.__proto__=i,s},Vt(e,n)}function pe(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 s,i=te(e);if(n){var c=te(this).constructor;s=Reflect.construct(i,arguments,c)}else s=i.apply(this,arguments);return Sn(this,s)}}function Sn(e,n){if(n&&(Y(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}(e)}function te(e){return te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},te(e)}function ee(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Tn(e,n){for(var s=0;s<n.length;s++){var i=n[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(g,x){if(Y(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var S=w.call(g,x);if(Y(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Y(c)==="symbol"?c:String(c)),i)}var c}function ne(e,n,s){return n&&Tn(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var R=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";ee(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return ne(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}(),Ft=function(e){Ht(s,e);var n=pe(s);function s(){return ee(this,s),n.apply(this,arguments)}return ne(s)}(R),it=function(e){Ht(s,e);var n=pe(s);function s(){return ee(this,s),n.apply(this,arguments)}return ne(s)}(R),At=function(e){Ht(s,e);var n=pe(s);function s(){return ee(this,s),n.apply(this,arguments)}return ne(s)}(R),ye=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,_n=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,tn=/^[\xA0\u2011\u202F\u2060\uFEFF]/,In=/^(?:[;\xAD%?…]|,(?!\d))/,Dn=/^[´±°¢£¤$¥\u2212]/;function ie(e,n){n!==!1&&(e=e.trim());for(var s,i,c=[],g=e.charAt(0),x=0,w=1,S=e.length;w<S;w++){s=e.charAt(w),i=e.charAt(w+1);var T=ye.test(g),M=ye.test(s),C=M||T,D=void 0;if((Dn.test(s)&&!tn.test(g)||In.test(g+i)&&!tn.test(s))&&(C=!0),g!=="-"&&g!=="‐"&&g!=="–"&&g!=="—"||((D=ye.test(e.charAt(w-2)))&&!M&&(C=!1),!D&&_n.test(s+i)&&(C=!0)),C){var L=e.slice(x,w);/\u00AD$/.test(L)?(c.push(new R(L.slice(0,-1))),c.push(new At)):(c.push(new R(L)),c.push(new Ft)),x=w}g=s}return c.push(new R(e.slice(x))),c}const en={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 On=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,Mn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,Cn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Ln=/^<!--(.+?)-->/,Pn=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,nn={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}},Nn={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 rn(e){return e.replace(Pn,function(n,s,i,c){if(s||i){var g=s?10:16;return String.fromCharCode(parseInt(s||i,g))}return c in en?en[c]:n})}function $n(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var zn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Hn(e){var n,s={};if(e){do if(n=zn.exec(e)){var i=rn($n(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(s[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 s}const sn={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 Vn=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Fn=/^%[^\n]+(?:\n|$)/,Rn=/^[^#$%&~_^\\{}]+/,Bn=/^\\([&{}$%#_])/,jn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,qn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\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 R(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 Un=/[\r\n\xA0]+/g;function Gn(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var s=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(s=b(n,e)),s}function on(e,n,s){for(var i,c,g=e.width;g+s.width>n&&e.length;)c=(i=e[e.length-1]).width,i.width>s.width?(i.value=i.value.slice(0,-1),i.width=W(i,i.font),g+=i.width):e.pop(),g-=c;e[e.length-1]instanceof At&&e.pop(),i=e[e.length-1]||i||{},s.font=b(s.font,i.bold,i.italic,""),s.href=e.length?i.href:null,s.rel=e.length?i.rel:null,s.target=e.length?i.target:null,e.push(s)}function Dt(e){return Math.round(1e6*e)/1e6}function an(e){return function(n){if(Array.isArray(n))return me(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,s){if(n){if(typeof n=="string")return me(n,s);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)?me(n,s):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 me(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,i=new Array(n);s<n;s++)i[s]=e[s];return i}var Wn={center:"middle",right:"end"},Yn={middle:.5,center:.5,bottom:1,end:1},ve=function(e,n){return!e&&!n||e===n};function Xn(e,n){var s=[],i=n.font(),c=i.size,g=i.family,x=n.align(),w=n.createElement();if(e.length){var S=i.height,T=n.valign(),M=n.height()(),C=n.width()(0),D=!isFinite(C)&&e.length===1,L=D?null:n.x(),B=Dt(S/c),tt=D?null:Dt(S/(1.15*c+(S-c)/2));if(Yn[T]&&isFinite(M)){var z=T==="bottom"?1:.5;tt+=(M*z-S*e.length*z)/c}var N=x==="justify",j=0;x==="right"?j=C:x==="center"&&(j=C/2);for(var V=[],et="tspan",Z=null,q="",O=function(){if(q){var Et=w(et,Z,q);V.push(Et)}et="tspan",Z=null,q=""},rt=0,nt=e.length;rt<nt;rt++){var ft="",yt="",ut=0,gt=e[rt];if(gt.length){V=[];for(var Ot=0,jt=0,pt=void 0,K=0,re=gt.length;K<re;K++){var U=gt[K],J=U.font;U.whitespace&&Ot++,jt+=U.width,K&&!U.tracking&&!ut&&ve(J.id,ft)&&ve(U.class,yt)&&ve(pt,U.href)?q+=U.value:(O(),q=U.value,Z={fontFamily:J.family!==g?J.family:null,fontSize:J.size!==c?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:U.class||null},ut&&(Z.dx=Dt(ut),ut=0),U.tracking&&(ut=J.size*U.tracking),U.href&&!pt?(pt=U.href,et="a",Z.href=pt,Z.rel=U.rel,Z.target=U.target):pt=null,ft=J.id,yt=U.class)}if(O(),D)s.push.apply(s,an(V));else{var se=null,qt=rt===nt-1||gt[gt.length-1]instanceof it;N&&gt.length>1&&!qt&&(se=Dt((C-jt)/Ot)),s.push(w.apply(void 0,["tspan",{wordSpacing:se,x:L(rt)+j,dy:Dt(rt?B:tt)+"em"}].concat(an(V))))}}else s.push(w("tspan",{x:L(rt),dy:Dt(rt?B:tt)+"em"}," "))}}return w.apply(void 0,["text",{fontFamily:g,fontSize:c,textAnchor:Wn[x]||"start"}].concat(s))}var Zn={middle:.5,center:.5,bottom:1,end:1};function Kn(e,n,s){if(e.length){s.textBaseline="middle";var i=n.font(),c=i.height,g=i.size,x=n.valign(),w=n.height()(),S=n.width()(0),T=n.align(),M=T==="justify",C=.5*c,D=Zn[x];if(D&&isFinite(w)){var L=e.length*c;C+=w*D-L*D}e.forEach(function(B,tt){var z=n.x()(tt),N=tt*c+C,j=0,V=0;B.forEach(function(q){q.whitespace&&j++,V+=q.width});var et=0,Z=tt===e.length-1||B[B.length-1]instanceof it;M&&B.length>1&&!Z&&(et=(S-V)/j),B.forEach(function(q){s.font=q.font;var O=q.font,rt=O.baseline?g*-O.baseline+.15*g:0;s.fillStyle=function(yt,ut){return yt.color?yt.color:ut.href?"#00C":"#000"}(O,q);var nt=0;if(T==="right"?nt+=S-V:T==="center"?nt+=S/2-V/2:T==="justify"&&(q.whitespace||q instanceof it)&&(z+=et),s.fillText(q.value,z+nt,N+rt),q.href){s.beginPath(),s.strokeStyle=s.fillStyle;var ft=Math.floor(N+.45*g)+.5;s.moveTo(z+nt,ft),s.lineTo(z+nt+q.width,ft),s.stroke()}z+=q.width})})}}function we(e){return we=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},we(e)}function ln(e){for(var n={},s=0;s<e.length;s++){var i=e[s];typeof i!="number"&&i!=null&&(typeof i=="string"?n.text=i:typeof i=="function"?n.fn=i:we(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 Rt(e){return Rt=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},Rt(e)}function Jn(e,n){for(var s=0;s<n.length;s++){var i=n[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(g,x){if(Rt(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var S=w.call(g,x);if(Rt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Rt(c)==="symbol"?c:String(c)),i)}var c}var Qn=b(),xe=function(e){return typeof e=="function"?e:function(){return e}},lt=function(){function e(i){if(function(g,x){if(!(g 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},i)for(var c in i)typeof this[c]=="function"&&this[c](i[c])}var n,s;return n=e,s=[{key:"linebreak",value:function(i){var c=this,g=this.props.parser(String(i)),x=this.font(),w=function(S,T,M){if(!S.length)return[];var C=T.height(),D=T.width(),L=T.overflowLine(),B=T.overflowWrap(),tt=b(M,!0,!1),z=isFinite(C())?Math.floor(C()/M.height):1/0;if(!C()&&!D(0)||!z)return[];for(var N=0,j=0,V=0,et=[],Z=[],q=!1;N<S.length&&j<z;){var O=S[N],rt=Gn(O,M);if(O.width=W(O,rt),O.font=rt,O.line=j,O.whitespace=O.value in P,O.value&&(O.value=O.value.replace(Un," ")),!(!V&&O.whitespace||q&&O.whitespace))if(O instanceof it)V=0,Z=[],et.push(N+1),j++;else if(O instanceof Ft||O instanceof At)Z.push({index:N,width:V});else if(O.whitespace||V+O.width<D(j))V+=O.width;else if(Z.length){var nt=void 0,ft=void 0;do{ft=!0,nt=Z.pop();var yt=S[nt.index],ut=void 0;yt instanceof At&&(ut=W("-",yt.font),nt.width+ut>D(j)&&(ft=!Z.length))}while(!ft);et.push(nt.index+1),V=0,j++,N=nt.index,Z=[]}else if(B==="break-word"){var gt=D(j);if(V+O.width>gt){var Ot=O.clone();do O.value=O.value.slice(0,-1),O.width=W(O,O.font),V+=O.width;while(O.value&&O.width>gt);Ot.value=Ot.value.slice(O.value.length),S.splice(N+1,0,new Ft,Ot)}et.push(N+1),V=0,j++}else V+=O.width;N++,q=O.whitespace}N!==et[et.length-1]&&et.push(N);var jt=0,pt=0,K=et.map(function(Et){for(var Q,kt=jt;(Q=S[kt])&&(Q.whitespace||!Q.value);)kt++;for(var mt=Et,Ee=null;mt>kt&&(Q=S[mt-1])&&(Q.whitespace||!(Q.value||Q instanceof At));)Q instanceof it&&(Ee=Q),mt--;Q instanceof At&&(Q.value="-",Q.width=W("-",Q.font)),jt=Et;var Mt=S.slice(kt,mt).filter(function(ke){return ke.value});return Ee&&Mt.push(Ee),Mt.width=Mt.reduce(function(ke,ri){return ke+ri.width},0),Mt.width>pt&&(pt=Mt.width),Mt});if(K.hasLineOverflow=!1,L){var re=L==="ellipsis"?"…":L;K.forEach(function(Et,Q){var kt=D(Q);if(Et.width>kt){var mt=new R(re);mt.font=M,mt.width=W(re,tt),on(Et,kt,mt),K.hasLineOverflow=!0}})}var U=T.overflow()==="ellipsis"?"…":T.overflow();if(U&&N!==S.length){var J=D(K.length-1),se=K[K.length-1],qt=new R(U);qt.font=M,qt.width=W(U,tt),on(se,J,qt),K.hasOverflow=!0}else K.hasOverflow=!1;return K.font=M,K.width=pt,K}(g,this,x);return w.height=w.length*x.height,w.render=function(S){return c.render(w,S)},w.svg=w.render,w.draw=w.render,w}},{key:"font",value:function(i){return arguments.length?(this.props.font=b(i),this):this.props.font||b(Qn)}},{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 c=String(i).toLowerCase();return c==="left"||c==="start"?(this.props.align="left",this.props.tAnchor=0):c==="center"||c==="middle"?(this.props.align="center",this.props.tAnchor=-.5):c==="end"||c==="right"?(this.props.align="right",this.props.tAnchor=-1):c==="justify"&&(this.props.align=i,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(i){if(!arguments.length)return this.props.overflowWrap||"normal";var c=String(i).toLowerCase();return c==="break-word"?this.props.overflowWrap="break-word":c!=="normal"&&i!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(i){return arguments.length?(this.props.width=xe(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=xe(i),this):this.props.height}},{key:"x",value:function(i){return arguments.length?(this.props.x=xe(i),this):this.props.x}},{key:"parser",value:function(i){if(!arguments.length)return this.props.parser;if(typeof i=="string"){var c=e[i]||e[i+"parser"];typeof c=="function"&&(i=c)}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=ln(arguments);return typeof i.text=="string"&&(i.text=this.linebreak(i.text)),i.ctx?Kn(i.text,this,i.ctx):Xn(i.text,this)}}],s&&Jn(n.prototype,s),Object.defineProperty(n,"prototype",{writable:!1}),e}();function Bt(e){return Bt=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},Bt(e)}function be(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,i=new Array(n);s<n;s++)i[s]=e[s];return i}function ti(e,n){for(var s=0;s<n.length;s++){var i=n[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(c=function(g,x){if(Bt(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var S=w.call(g,x);if(Bt(S)!=="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Bt(c)==="symbol"?c:String(c)),i)}var c}var hn=function(e){return typeof e=="function"?e:function(){return e}},cn=function(){function e(i){if(function(g,x){if(!(g 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},i)for(var c in i)typeof this[c]=="function"&&this[c](i[c]);this.render=this.render.bind(this)}var n,s;return n=e,s=[{key:"anchor",value:function(i){var c=this.props,g=c.hAnchor,x=c.vAnchor,w=c.width,S=c.height;if(!arguments.length)return[g*w(0),x*S(0)];if(typeof i=="string"){var T=this.props;i.toLowerCase().trim().split(/\s+/).forEach(function(M){M==="top"&&(T.vAnchor=-0),M==="middle"&&(T.vAnchor=-.5),M==="bottom"&&(T.vAnchor=-1),M==="left"&&(T.hAnchor=-0),M==="center"&&(T.hAnchor=-.5),M==="right"&&(T.hAnchor=-1)})}return this}},{key:"width",value:function(i){return arguments.length?(this.props.width=hn(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=hn(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,c){var g,x=i.getContext?i.getContext("2d"):i;return x.save(),x.rotate(this.rotate()*Math.PI/180),x.translate.apply(x,function(w){if(Array.isArray(w))return be(w)}(g=this.anchor())||function(w){if(typeof Symbol<"u"&&w[Symbol.iterator]!=null||w["@@iterator"]!=null)return Array.from(w)}(g)||function(w,S){if(w){if(typeof w=="string")return be(w,S);var T=Object.prototype.toString.call(w).slice(8,-1);return T==="Object"&&w.constructor&&(T=w.constructor.name),T==="Map"||T==="Set"?Array.from(w):T==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(T)?be(w,S):void 0}}(g)||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.`)}()),c(x),x.restore(),x}},{key:"render",value:function(){var i=ln(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 c=typeof i.text.render=="function"?i.text.render():i.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},c)}}}],s&&ti(n.prototype,s),Object.defineProperty(n,"prototype",{writable:!1}),e}(),ei=Object.prototype.hasOwnProperty,Ae={};function ni(e){return Ae[e]||(Ae[e]=e.replace(/([a-z])([A-Z])/g,function(n,s,i){return s+"-"+i.toLowerCase()})),Ae[e]}function un(e,n){if(Array.isArray(n))return n.forEach(function(s){return un(e,s)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function dn(e,n){if(typeof document<"u"){var s=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&s.setAttribute)for(var i in n)ei.call(n,i)&&n[i]!=null&&s.setAttribute(i==="className"?"class":ni(i),n[i]);for(var c=arguments.length,g=new Array(c>2?c-2:0),x=2;x<c;x++)g[x-2]=arguments[x];return g!=null&&g.length&&g.forEach(function(w){un(s,w)}),s}}lt.createElement=dn,lt.textparser=ie,lt.defaultparser=ie,lt.htmlparser=function(e){e=String(e||"").trim();for(var n,s,i={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},c=[],g=[],x=function(C){for(var D in i)i[D]&&(C[D]=i[D]);c.push(C)},w=function(C){var D=c.length,L=Nn[C];if(D&&L){for(var B=D-1;c[B]&&(c[B]instanceof Ft||On.test(c[B].value));)B--;for(;L&&c[B]&&c[B]instanceof it;)B--,L--;for(;L-- >0;)c.push(new it)}};e.length;){if(n=/^[^<]+/.exec(e))ie(rn(n[0]),!1).forEach(x);else if(!(n=Ln.exec(e)))if(n=Mn.exec(e))g.length&&(i=g.pop()),w(n[1]);else if(n=Cn.exec(e)){var S=n[1];w(S),g.push(i),i=Object.create(i),nn[S]&&nn[S](i,"");var T=Hn(n[2]);S==="a"&&(T.href&&(i.href=T.href),T.rel&&(i.rel=T.rel),T.target&&(i.target=T.target)),T.class&&(i.class=i.class?i.class+" "+T.class:T.class),T.style&&(s=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(T.style))&&s[1]&&(i.color=s[1]),S==="br"&&c.push(new it)}else n=[e.slice(0,1)],x(new R(n[0]));e=e.slice(n[0].length)}for(var M=c[c.length-1];M instanceof it;)c.pop(),M=c[c.length-1];return c},lt.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function(z,N){return n.push(N),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(jn,function(z,N,j){return j.charAt(N-1)==="\\"?z:qn[z]}).replace(/\n\s+/g,function(z){return/\n/.test(z.slice(1))?"\\par ":z}).replace(/\\symbol\{(\d+)\}/,function(z,N,j,V){return V.charAt(j-1)==="\\"?z:String.fromCharCode(1*N)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(z,N,j,V){return N+j+"{"+V+"}"}).replace(/\\verb,(.*?),/,function(z,N){return"\\verb,".concat(n[+N],",")});for(var s,i={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},c=[],g=[],x=function(z){for(var N in i)i[N]&&(z[N]=i[N]);return c.push(z),z},w=function(){g.push(i),i=Object.create(i)},S=function(){if(!g.length)throw new Error("Unexpected }");i=g.pop()},T={tokens:c,open_context:w,close_context:S,add_token:x};e.length;){if(s=Rn.exec(e))ie(s[0],!1).forEach(x);else if(s=Bn.exec(e))x(new R(s[1]));else if(!(s=Fn.exec(e))){if(s=/^\{/.exec(e))w();else if(s=/^\}/.exec(e))S();else if(!(s=/^\$/.exec(e)))if(s=/^\\verb,([^,]+),/.exec(e))x(new R(s[1]));else if(s=Vn.exec(e)){var M=s[1].slice(1)||s[1],C=!!s[2];if(/^(La)?TeX$/i.test(M)){w(),i.family="serif";var D=void 0;M==="LaTeX"&&((D=x(new R("L"))).tracking=-.25,(D=x(new R("A"))).size=.7,D.baseline=.3,D.tracking=-.1),(D=x(new R("T"))).tracking=-.17,(D=x(new R("E"))).baseline=-.22,D.tracking=-.13,D=x(new R("X")),S()}else if(M in sn)x(new R(sn[M])),C&&w();else if(M in G){var L=[],B=G[M].length-1,tt=void 0;if(B){for(C=!1,e=e.slice(s[0].length-1);B--;){if(!(tt=/^\{([^}]+)\}/.exec(e)))throw new Error(M+" is missing an argument");L.push(tt[1]),e=e.slice(tt[0].length)}s[0]=/^\{/.exec(e)?"{":"",C=!!s[0]}C&&w(),G[M].apply(T,[i].concat(L))}else console.warn("unknown latex command",M),x(new R(s[1])),C&&w()}else s=[e.slice(0,1)],x(new R(s[0]))}e=e.slice(s[0].length)}return c},lt.measureText=function(e,n,s){return W(e,b(n),s)},lt.Token=R,lt.Break=Ft,lt.LineBreak=it,lt.SoftHyphen=At,lt.Rotator=cn,cn.createElement=dn;const ii=lt;return r.default})())})(Ye);var xn=Ye.exports;const Xe=Ve(xn);function de(a){return a.replace(/…$/,"")}function fe(a){return a.children[0].innerHTML}function bn(a,h){const t=ht(a),{fontSize:r,font:o,padding:l=0}=a.properties.style||{};if(t.width===t.height&&t.width===0)return;const u=new Xe({font:`${r}px/${r}px ${o}`.replace(/(px)+/g,"px"),width:t.width-l*2,height:t.height-l*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Xe.createElement});u.overflowWrap("break-word");const p=u.linebreak(a.properties.content.replaceAll(`
10
10
  `,"<br>")).render(),f=[...p.children];let y=0;const v=[];a.properties.content.split(`
11
11
  `).forEach(b=>{let P=b;for(;P.length&&y<f.length;){if(f[y].innerHTML==="&nbsp;"){P.startsWith(`
12
12
  `)||v.push(y),y++;break}const k=de(fe(f[y]));P.startsWith(k)&&(P=P.slice(k.length).trim()),y++}}),v.forEach(b=>p.removeChild(f[b]));const _=a.properties.content.match(/(https?:\/\/.*)/gm),E=_?_.map(b=>b.split(" ")[0]):[];p.setAttribute("transform",`translate(${l}, ${l})`),E.forEach(b=>{let P=b;const k=[];for(;P.length>0;){const $=f.find(I=>!!I.children[0]&&I.children[0].tagName==="tspan"&&P.startsWith(de(fe(I))));if(!$)break;k.push($);const H=de($.children[0].innerHTML).length;if(!H)break;P=P.slice(H)}k.forEach($=>{const H=document.createElementNS("http://www.w3.org/2000/svg","a");H.setAttribute("href",b),H.setAttribute("target","_blank"),H.innerHTML=fe($),$.children[0].innerHTML="",$.children[0].appendChild(H)})}),h.appendChild(p)}const Ze=20;class Ke extends Be{constructor(t,r={}){super(t,`
@@ -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",{...Qt});m(this,"startX",0);m(this,"startY",0);m(this,"handles",[]);m(this,"draggedHandle",F);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",(t,r,o=We(t,r,0,0,"",bt))=>{this.add(o);const l=this.ogma.view.graphToScreenCoordinates({x:t,y:r});this.select(o.id),this.startDragging(this.getById(o.id),l.x,l.y),this.draggedHandle=6});m(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...Qt},this.draggedHandle=F,this.isDragging=!1,this.emit(xt,this.annotation))});m(this,"startDragging",(t,r,o)=>{this.annotation=t;const l=ct(this.annotation),u=ht(this.annotation);this.rect.x=l.x,this.rect.y=l.y,this.rect.width=u.width,this.rect.height=u.height,this.startX=r,this.startY=o,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Ht,this.annotation),this.isDragging=!0});m(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!r)return;this.selectedId!==r.id&&this.select(this.hoveredId);const{x:o,y:l}=$t(t,this.ogma.getContainer());this.startDragging(r,o,l),this.draggedHandle=ce(t.target)});m(this,"onMouseMove",t=>{requestAnimationFrame(()=>this._onMouseMove(t))});m(this,"_onMouseMove",t=>{if(!this.isDragging)return;t.stopPropagation(),t.preventDefault();const r=this.handles[this.draggedHandle],o=r.classList.contains("top"),l=r.classList.contains("left"),u=r.classList.contains("right"),d=r.classList.contains("bottom"),p=r.classList.contains("line-handle"),{x:f,y}=$t(t,this.ogma.getContainer()),v=this.ogma.view.getZoom(),_=(f-this.startX)/v,E=(y-this.startY)/v,b=this.ogma.view.getAngle(),P=ot({x:_,y:E},b);(d&&l||o&&u)&&(P.y=0,P.x=0);const k=l||p?this.rect.x+P.x:this.rect.x,$=o||p?this.rect.y+P.y:this.rect.y,H=Math.max(this.rect.width+_*(p||l?0:1),Ze),I=Math.max(this.rect.height+E*(p||o?0:1),Ze);_e(this.annotation,k,$,H,I),this.emit(zt,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()});m(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===F||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(xt,this.annotation),this.isDragging=!1,this.draggedHandle=F)});m(this,"_onMousedown",t=>{t.stopPropagation()});m(this,"onViewChanged",()=>{const t=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/t}`)});m(this,"_onInput",()=>{const t=this.getById(this.selectedId);t&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),t.properties.content=this.textArea.value,this.emit(Jt,t),this.layer.refresh())});this.showeditorOnHover=!1,this.handleSize=ue.handleSize||r.textHandleSize,this.placeholder=ue.placeholder||r.textPlaceholder||"";const o=this.textArea=this.editor.element.querySelector("textarea");o.addEventListener("input",this._onInput),o.addEventListener("focus",this._onFocus),o.addEventListener("blur",this._onBlur),o.addEventListener("mousedown",this._onMousedown),o.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(l=>l.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:r},o=0){const l={x:t,y:r},u=this.ogma.view.getAngle();return this.elements.find(d=>{const{x:p,y:f}=ct(d),{width:y,height:v}=ht(d),_={x:p,y:f},{x:E,y:b}=ot(wt(l,_),-u);return E>-o&&E<y+o&&b>-o&&b<v+o})}draw(t){t.innerHTML="";const r="",o=this.ogma.view.getAngle();this.elements.forEach((u,d)=>{const p=`class${d}`,f=ht(u),y=ct(u),v=u.id,{color:_,fontSize:E,font:b,strokeColor:P,strokeWidth:k,strokeType:$,background:H}=u.properties.style||bt;if(v===this.selectedId)return;const I=St("g");I.classList.add("annotation-text"),I.setAttribute("fill",`${_}`),I.setAttribute("font-size",`${E}px`),I.setAttribute("font-family",`${b}`);const W=St("rect");let Y=!1;$&&$!=="none"&&(Y=!0,W.setAttribute("stroke",P||"black"),W.setAttribute("stroke-width",`${k}`),$==="dashed"&&W.setAttribute("stroke-dasharray","5,5")),(H&&H.length||Y)&&(Y=!0,W.setAttribute("fill",H||"transparent")),Y&&(W.setAttribute("width",`${f.width}`),W.setAttribute("height",`${f.height}`)),I.appendChild(W),bn(u,I);const{x:Vt,y:Ft}=ot(y,-o);I.setAttribute("transform",`translate(${Vt},${Ft})`),I.classList.add(p),I.setAttribute("data-annotation",`${u.id}`),I.setAttribute("data-annotation-type","text"),t.appendChild(I)});const l=St("style");l.innerHTML=r,t.firstChild&&t.insertBefore(l,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle();[...this.layer.element.children].forEach(r=>{const o=r.getAttribute("data-annotation");if(!o)return;const l=ct(this.getById(o)),{x:u,y:d}=ot(l,-t);r.setAttribute("transform",`translate(${u},${d})`)})}getDefaultOptions(){return Qt}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),r=ht(t),o=this.ogma.view.graphToScreenCoordinates(ct(t)),l=this.ogma.view.getZoom(),{font:u,fontSize:d,color:p,background:f,padding:y=0}=t.properties.style||bt,v=(d||1)*l;this.textArea.value=t.properties.content,this.editor.element.style.transform=`translate(${o.x}px, ${o.y}px)translate(-50%, -50%)translate(${r.width/2*l}px, ${r.height/2*l}px)`,this.editor.element.style.width=`${r.width*l}px`,this.editor.element.style.height=`${r.height*l}px`,this.textArea.style.font=`${v} ${u}`,this.textArea.style.fontFamily=u||"sans-serif",this.textArea.style.fontSize=`${v}px`,this.textArea.style.padding=`${l*y}px`,this.textArea.style.lineHeight=`${v}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=p||"black",this.textArea.style.background=f||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class An{constructor(){m(this,"links",{});m(this,"linksByTargetId",{});m(this,"linksByArrowId",{})}add(h,t,r,o,l){const u=X(),d=h.id,p={id:u,arrow:d,target:r,targetType:o,connectionPoint:l,side:t};return this.links[u]=p,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(u),this.linksByArrowId[d]||(this.linksByArrowId[d]={}),this.linksByArrowId[d][t]=u,h.properties.link=h.properties.link||{},h.properties.link[t]={id:r,side:t,type:o,magnet:l},this}arrowIsLinked(h,t){var r;return!!((r=this.linksByArrowId[h])!=null&&r[t])}remove(h,t){var d,p;const r=h.id,o=(d=this.linksByArrowId[r])==null?void 0:d[t];if((p=h.properties.link)==null||delete p[t],!o)return this;const l=this.links[o];delete this.links[o];const u=this.linksByTargetId[l.target];for(let f=0;f<u.length;f++)if(u[f]===o){u.splice(f,1);break}return delete this.linksByArrowId[r][t],this}getArrowLink(h,t){var o;const r=(o=this.linksByArrowId[h])==null?void 0:o[t];return r?this.links[r]:null}getTargetLinks(h,t){var r;return((r=this.linksByTargetId[h])==null?void 0:r.map(o=>this.links[o]).filter(o=>o.targetType===t))??[]}forEach(h){Object.values(this.links).forEach(h)}}const at=a=>a.properties.type==="arrow",dt=a=>a.properties.type==="text",ge=a=>a.type==="FeatureCollection",En={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Je=["start","end"],Qe=[{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 kn extends Re{constructor(t,r={}){super();m(this,"arrows");m(this,"texts");m(this,"links",new An);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",t=>{if(!this.dragged||this.textToMagnet===void 0)return;t.beginPath(),t.fillStyle="green";const r=this.ogma.view.getZoom();Qe.forEach(o=>{if(!this.textToMagnet)return;const l=ht(this.textToMagnet),u=ct(this.textToMagnet),d=Wt(o,{x:l.width,y:l.height}),p=ot(d,this.ogma.view.getAngle()),{x:f,y}=It(p,u);t.moveTo(f,y),t.arc(f,y,this.options.magnetHandleRadius/r,0,Math.PI*2)}),t.fill(),t.closePath()});m(this,"_onFeatureDrag",(t,r)=>{const o=r;if(at(t)&&o==="line")["start","end"].find(l=>{const u=l==="start"?Tt(t):Lt(t);return this._snapToText(t,o,u)||this._findAndSnapToNode(t,l,u)});else if(at(t)&&o!=="line"){const l=o==="start"?Tt(t):Lt(t);this._snapToText(t,o,l)||this._findAndSnapToNode(t,o,l)}else dt(t)&&(this.activeLinks.forEach(({arrow:l,side:u,connectionPoint:d})=>{const p=this.getAnnotation(l),f=ht(t),y=ct(t),v=Wt(d,{x:f.width,y:f.height}),_=ot(v,this.ogma.view.getAngle()),E=It(_,y);p.geometry.coordinates[u==="start"?0:1]=[E.x,E.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(zt,t,r)});m(this,"_onFeatureDragEnd",t=>{this.dragged!==null&&at(t)&&Tt(this.dragged)&&Je.forEach(r=>{this.links.getArrowLink(t.id,r)&&this.emit(He,{arrow:t,link:this.links.getArrowLink(t.id,r)})}),(dt(t)||at(t))&&this.onUpdate(t),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(r=>r.enableDetection()),this.layer.refresh(),this.emit(xt,t)});m(this,"_onFeatureDragStart",t=>{this.textToMagnet=void 0,at(t)?this.dragged=t:dt(t)&&this.activeLinks.push(...this.links.getTargetLinks(t.id,"text")),this.annotations.forEach(r=>{const o=r.getSelectedFeature();o&&o!==t&&r.unhover().unselect(),r.disableDetection()}),this.emit(Ht,t)});m(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()});m(this,"_onNodesDrag",t=>{const{dx:r,dy:o}=t;this._moveNodes(t.nodes,r,o)});m(this,"_onLayoutEnd",t=>{t.ids.forEach((r,o)=>{this.links.getTargetLinks(r,"node").forEach(u=>{const d=this.getAnnotation(u.arrow),p=u.side,f=Ct(d,p==="start"?"end":"start"),y=t.positions.current[o],v=this.ogma.getNode(r).getAttribute("radius"),_=Nt(f,y,+v);vt(d,p,_.x,_.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()});m(this,"_onAdded",t=>{this.emit(Kt,t)});m(this,"_onRemoved",t=>{this.emit(Zt,t)});m(this,"_onUnselect",t=>{this.selected=null,this.emit(Xt,t)});m(this,"_onSelect",t=>{this.selected!==t&&(this.selected=t,this.emit(Yt,this.selected))});m(this,"onUpdate",t=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(t))});m(this,"_onUpdate",t=>{this.emit(Jt,t)});this.options=this.setOptions({...En,...r}),this.ogma=t,this.arrows=new Ge(t,this.options),this.texts=new Ke(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(o=>{o.on(Ht,this._onFeatureDragStart).on(zt,this._onFeatureDrag).on(xt,this._onFeatureDragEnd).on(Jt,this.onUpdate).on(Xt,this._onUnselect).on(Yt,this._onSelect).on(Kt,this._onAdded).on(Zt,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,r,o){t.forEach(l=>{const u=this.links.getTargetLinks(l.getId(),"node"),d=l.getPosition();u.forEach(p=>{const f=this.getAnnotation(p.arrow),y=p.side,v=Ct(f,y==="start"?"end":"start");let _=d;const E=+l.getAttribute("radius"),b=1e-6;(p.connectionPoint.x-(d.x-r)>b||p.connectionPoint.y-(d.y-o)>b)&&(_=Nt(v,d,E)),vt(f,y,_.x,_.y)})}),this.arrows.refreshLayer()}_snapToText(t,r,o){const l=this.texts.detect(o,this.options.detectMargin);if(this.links.remove(t,r),!l)return!1;this.textToMagnet=l;const u=this.findMagnetPoint(Qe,l,o);return u?(vt(t,r,u.point.x,u.point.y),this.links.add(t,r,l.id,"text",u.magnet),!0):!1}_findAndSnapToNode(t,r,o){var d,p;const l=this.ogma.view.graphToScreenCoordinates(o),u=this.ogma.view.getElementAt(l);this.links.remove(t,r),u&&u.isNode?((d=this.hoveredNode)==null||d.setSelected(!1),this.hoveredNode=u,u.setSelected(!0),this._snapToNode(t,r,u,l)):((p=this.hoveredNode)==null||p.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,r,o,l){const u=o.getPositionOnScreen(),d=+o.getAttribute("radius"),p=d*this.ogma.view.getZoom(),f=l.x-u.x,y=l.y-u.y,v=Math.sqrt(f*f+y*y),_=o.getPosition();if(v<p+this.options.detectMargin){let E=_;if(v>p/2){const b=Ct(t,r==="end"?"start":"end");E=Nt(b,E,d)}vt(t,r,E.x,E.y),this.links.add(t,r,o.getId(),"node",E)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:r,targetType:o,target:l,arrow:u,side:d})=>{if(o!=="text")return;t=!0;const p=this.getAnnotation(l),f=this.getAnnotation(u),y=ht(p),v=ct(p),_=Wt(r,{x:y.width,y:y.height}),E=ot(_,this.ogma.view.getAngle()),b=It(E,v);vt(f,d,b.x,b.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,r,o){let l;for(const u of t){const d=ht(r),p=ct(r),f=Wt(u,{x:d.width,y:d.height}),y=ot(f,this.ogma.view.getAngle()),v=It(y,p),_=_t(wt(v,o)),E=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),d.width/2,d.height/2);if(_<Math.max(E,this.options.magnetHandleRadius)){l={point:v,magnet:u};break}}return l}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const r=this.getAnnotations().features.find(o=>o.id===t);return r?(at(r)?this.arrows.select(r.id):dt(r)&&this.texts.select(r.id),this):this}unselect(){return this.selected?(at(this.selected)?this.arrows.unselect():dt(this.selected)&&this.texts.unselect(),this):this}add(t){if(ge(t)){const[r,o]=t.features.reduce((l,u)=>(at(u)?l[1].push(u):dt(u)&&l[0].push(u),l),[[],[]]);return r.forEach(l=>this.add(l)),o.forEach(l=>this.add(l)),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 ge(t)?(t.features.forEach(r=>this.remove(r)),this):(at(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 r of Je){const o=t.properties.link[r];if(!o)continue;const l=this.getAnnotation(o.id);if(o.type==="text"&&l)this.links.add(t,r,o.id,o.type,o.magnet);else if(o.type==="node"){const u=this.ogma.getNode(o.id);if(!u)continue;this.links.add(t,r,o.id,o.type,o.magnet);const d=u.getPosition(),p=u.getAttribute("radius")||0,f=Ct(t,r==="start"?"end":"start"),y=Nt(f,d,+p);vt(t,r,y.x,y.y)}}}startArrow(t,r,o){this.cancelDrawing(),this.arrows.startDrawing(t,r,o)}startText(t,r,o){this.cancelDrawing(),this.texts.startDrawing(t,r,o)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(ze)}updateStyle(t,r){const o=this.getAnnotations().features.find(l=>l.id===t);return o?(at(o)?this.arrows.updateStyle(o,r):dt(o)&&this.texts.updateStyle(o,r),this.onUpdate(o),this):this}setScale(t,r,o,l){const u=this.getAnnotations().features.find(d=>d.id===t);return u?(at(u)?this.arrows.scale(u,r,o,l):dt(u)&&this.texts.scale(u,r,o,l),this.onUpdate(u),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(r=>{t.features=[...t.features,...r.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(r=>r.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}A.Arrows=Ge,A.Control=kn,A.EVT_ADD=Kt,A.EVT_CANCEL_DRAWING=ze,A.EVT_DRAG=zt,A.EVT_DRAG_END=xt,A.EVT_DRAG_START=Ht,A.EVT_HOVER=Ne,A.EVT_LINK=He,A.EVT_REMOVE=Zt,A.EVT_SELECT=Yt,A.EVT_UNHOVER=$e,A.EVT_UNSELECT=Xt,A.EVT_UPDATE=Jt,A.NONE=F,A.Texts=Ke,A.clientToContainerPosition=$t,A.createArrow=Se,A.createSVGElement=St,A.createText=We,A.defaultArrowOptions=oe,A.defaultArrowStyle=st,A.defaultControllerOptions=ue,A.defaultTextOptions=Qt,A.defaultTextStyle=bt,A.getAnnotationsBounds=gn,A.getArrowEnd=Lt,A.getArrowEndPoints=Pt,A.getArrowSide=Ct,A.getArrowStart=Tt,A.getAttachmentPointOnNode=Nt,A.getHandleId=ce,A.getTextBbox=ae,A.getTextPosition=ct,A.getTextSize=ht,A.isAnnotationCollection=ge,A.isArrow=at,A.isText=dt,A.scaleGeometry=Ie,A.setArrowEnd=he,A.setArrowEndPoint=vt,A.setArrowStart=le,A.setTextBbox=_e,A.updateTextBbox=Te,Object.defineProperty(A,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",{...Qt});m(this,"startX",0);m(this,"startY",0);m(this,"handles",[]);m(this,"draggedHandle",F);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",(t,r,o=We(t,r,0,0,"",bt))=>{this.add(o);const l=this.ogma.view.graphToScreenCoordinates({x:t,y:r});this.select(o.id),this.startDragging(this.getById(o.id),l.x,l.y),this.draggedHandle=6});m(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...Qt},this.draggedHandle=F,this.isDragging=!1,this.emit(xt,this.annotation))});m(this,"startDragging",(t,r,o)=>{this.annotation=t;const l=ct(this.annotation),u=ht(this.annotation);this.rect.x=l.x,this.rect.y=l.y,this.rect.width=u.width,this.rect.height=u.height,this.startX=r,this.startY=o,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(zt,this.annotation),this.isDragging=!0});m(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!r)return;this.selectedId!==r.id&&this.select(this.hoveredId);const{x:o,y:l}=Gt(t,this.ogma.getContainer());this.startDragging(r,o,l),this.draggedHandle=ce(t.target)});m(this,"onMouseMove",t=>{requestAnimationFrame(()=>this._onMouseMove(t))});m(this,"_onMouseMove",t=>{if(!this.isDragging)return;t.stopPropagation(),t.preventDefault();const r=this.handles[this.draggedHandle],o=r.classList.contains("top"),l=r.classList.contains("left"),u=r.classList.contains("right"),d=r.classList.contains("bottom"),p=r.classList.contains("line-handle"),{x:f,y}=Gt(t,this.ogma.getContainer()),v=this.ogma.view.getZoom(),_=(f-this.startX)/v,E=(y-this.startY)/v,b=this.ogma.view.getAngle(),P=ot({x:_,y:E},b);(d&&l||o&&u)&&(P.y=0,P.x=0);const k=l||p?this.rect.x+P.x:this.rect.x,$=o||p?this.rect.y+P.y:this.rect.y,H=Math.max(this.rect.width+_*(p||l?0:1),Ze),I=Math.max(this.rect.height+E*(p||o?0:1),Ze);_e(this.annotation,k,$,H,I),this.emit($t,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()});m(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===F||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(xt,this.annotation),this.isDragging=!1,this.draggedHandle=F)});m(this,"_onMousedown",t=>{t.stopPropagation()});m(this,"onViewChanged",()=>{const t=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/t}`)});m(this,"_onInput",()=>{const t=this.getById(this.selectedId);t&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),t.properties.content=this.textArea.value,this.emit(Jt,t),this.layer.refresh())});this.showeditorOnHover=!1,this.handleSize=ue.handleSize||r.textHandleSize,this.placeholder=ue.placeholder||r.textPlaceholder||"";const o=this.textArea=this.editor.element.querySelector("textarea");o.addEventListener("input",this._onInput),o.addEventListener("focus",this._onFocus),o.addEventListener("blur",this._onBlur),o.addEventListener("mousedown",this._onMousedown),o.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(l=>l.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:r},o=0){const l={x:t,y:r},u=this.ogma.view.getAngle();return this.elements.find(d=>{const{x:p,y:f}=ct(d),{width:y,height:v}=ht(d),_={x:p,y:f},{x:E,y:b}=ot(wt(l,_),-u);return E>-o&&E<y+o&&b>-o&&b<v+o})}draw(t){t.innerHTML="";const r="",o=this.ogma.view.getAngle();this.elements.forEach((u,d)=>{const p=`class${d}`,f=ht(u),y=ct(u),v=u.id,{color:_,fontSize:E,font:b,strokeColor:P,strokeWidth:k,strokeType:$,background:H}=u.properties.style||bt;if(v===this.selectedId)return;const I=St("g");I.classList.add("annotation-text"),I.setAttribute("fill",`${_}`),I.setAttribute("font-size",`${E}px`),I.setAttribute("font-family",`${b}`);const W=St("rect");let Y=!1;$&&$!=="none"&&(Y=!0,W.setAttribute("stroke",P||"black"),W.setAttribute("stroke-width",`${k}`),$==="dashed"&&W.setAttribute("stroke-dasharray","5,5")),(H&&H.length||Y)&&(Y=!0,W.setAttribute("fill",H||"transparent")),Y&&(W.setAttribute("width",`${f.width}`),W.setAttribute("height",`${f.height}`)),I.appendChild(W),bn(u,I);const{x:Ht,y:Vt}=ot(y,-o);I.setAttribute("transform",`translate(${Ht},${Vt})`),I.classList.add(p),I.setAttribute("data-annotation",`${u.id}`),I.setAttribute("data-annotation-type","text"),t.appendChild(I)});const l=St("style");l.innerHTML=r,t.firstChild&&t.insertBefore(l,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle();[...this.layer.element.children].forEach(r=>{const o=r.getAttribute("data-annotation");if(!o)return;const l=ct(this.getById(o)),{x:u,y:d}=ot(l,-t);r.setAttribute("transform",`translate(${u},${d})`)})}getDefaultOptions(){return Qt}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),r=ht(t),o=this.ogma.view.graphToScreenCoordinates(ct(t)),l=this.ogma.view.getZoom(),{font:u,fontSize:d,color:p,background:f,padding:y=0}=t.properties.style||bt,v=(d||1)*l;this.textArea.value=t.properties.content,this.editor.element.style.transform=`translate(${o.x}px, ${o.y}px)translate(-50%, -50%)translate(${r.width/2*l}px, ${r.height/2*l}px)`,this.editor.element.style.width=`${r.width*l}px`,this.editor.element.style.height=`${r.height*l}px`,this.textArea.style.font=`${v} ${u}`,this.textArea.style.fontFamily=u||"sans-serif",this.textArea.style.fontSize=`${v}px`,this.textArea.style.padding=`${l*y}px`,this.textArea.style.lineHeight=`${v}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=p||"black",this.textArea.style.background=f||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class An{constructor(){m(this,"links",{});m(this,"linksByTargetId",{});m(this,"linksByArrowId",{})}add(h,t,r,o,l){const u=X(),d=h.id,p={id:u,arrow:d,target:r,targetType:o,connectionPoint:l,side:t};return this.links[u]=p,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(u),this.linksByArrowId[d]||(this.linksByArrowId[d]={}),this.linksByArrowId[d][t]=u,h.properties.link=h.properties.link||{},h.properties.link[t]={id:r,side:t,type:o,magnet:l},this}arrowIsLinked(h,t){var r;return!!((r=this.linksByArrowId[h])!=null&&r[t])}remove(h,t){var d,p;const r=h.id,o=(d=this.linksByArrowId[r])==null?void 0:d[t];if((p=h.properties.link)==null||delete p[t],!o)return this;const l=this.links[o];delete this.links[o];const u=this.linksByTargetId[l.target];for(let f=0;f<u.length;f++)if(u[f]===o){u.splice(f,1);break}return delete this.linksByArrowId[r][t],this}getArrowLink(h,t){var o;const r=(o=this.linksByArrowId[h])==null?void 0:o[t];return r?this.links[r]:null}getTargetLinks(h,t){var r;return((r=this.linksByTargetId[h])==null?void 0:r.map(o=>this.links[o]).filter(o=>o.targetType===t))??[]}forEach(h){Object.values(this.links).forEach(h)}}const at=a=>a.properties.type==="arrow",dt=a=>a.properties.type==="text",ge=a=>a.type==="FeatureCollection",En={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Je=["start","end"],Qe=[{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 kn extends Re{constructor(t,r={}){super();m(this,"arrows");m(this,"texts");m(this,"links",new An);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",t=>{if(!this.dragged||this.textToMagnet===void 0)return;t.beginPath(),t.fillStyle="green";const r=this.ogma.view.getZoom();Qe.forEach(o=>{if(!this.textToMagnet)return;const l=ht(this.textToMagnet),u=ct(this.textToMagnet),d=Wt(o,{x:l.width,y:l.height}),p=ot(d,this.ogma.view.getAngle()),{x:f,y}=It(p,u);t.moveTo(f,y),t.arc(f,y,this.options.magnetHandleRadius/r,0,Math.PI*2)}),t.fill(),t.closePath()});m(this,"_onFeatureDrag",(t,r)=>{const o=r;if(at(t)&&o==="line")["start","end"].find(l=>{const u=l==="start"?Tt(t):Lt(t);return this._snapToText(t,o,u)||this._findAndSnapToNode(t,l,u)});else if(at(t)&&o!=="line"){const l=o==="start"?Tt(t):Lt(t);this._snapToText(t,o,l)||this._findAndSnapToNode(t,o,l)}else dt(t)&&(this.activeLinks.forEach(({arrow:l,side:u,connectionPoint:d})=>{const p=this.getAnnotation(l),f=ht(t),y=ct(t),v=Wt(d,{x:f.width,y:f.height}),_=ot(v,this.ogma.view.getAngle()),E=It(_,y);p.geometry.coordinates[u==="start"?0:1]=[E.x,E.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit($t,t,r)});m(this,"_onFeatureDragEnd",t=>{this.dragged!==null&&at(t)&&Tt(this.dragged)&&Je.forEach(r=>{this.links.getArrowLink(t.id,r)&&this.emit(He,{arrow:t,link:this.links.getArrowLink(t.id,r)})}),(dt(t)||at(t))&&this.onUpdate(t),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(r=>r.enableDetection()),this.layer.refresh(),this.emit(xt,t)});m(this,"_onFeatureDragStart",t=>{this.textToMagnet=void 0,at(t)?this.dragged=t:dt(t)&&this.activeLinks.push(...this.links.getTargetLinks(t.id,"text")),this.annotations.forEach(r=>{const o=r.getSelectedFeature();o&&o!==t&&r.unhover().unselect(),r.disableDetection()}),this.emit(zt,t)});m(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()});m(this,"_onNodesDrag",t=>{const{dx:r,dy:o}=t;this._moveNodes(t.nodes,r,o)});m(this,"_onLayoutEnd",t=>{t.ids.forEach((r,o)=>{this.links.getTargetLinks(r,"node").forEach(u=>{const d=this.getAnnotation(u.arrow),p=u.side,f=Ct(d,p==="start"?"end":"start"),y=t.positions.current[o],v=this.ogma.getNode(r).getAttribute("radius"),_=Nt(f,y,+v);vt(d,p,_.x,_.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()});m(this,"_onAdded",t=>{this.emit(Kt,t)});m(this,"_onRemoved",t=>{this.emit(Zt,t)});m(this,"_onUnselect",t=>{this.selected=null,this.emit(Xt,t)});m(this,"_onSelect",t=>{this.selected!==t&&(this.selected=t,this.emit(Yt,this.selected))});m(this,"onUpdate",t=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(t))});m(this,"_onUpdate",t=>{this.emit(Jt,t)});this.options=this.setOptions({...En,...r}),this.ogma=t,this.arrows=new Ge(t,this.options),this.texts=new Ke(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(o=>{o.on(zt,this._onFeatureDragStart).on($t,this._onFeatureDrag).on(xt,this._onFeatureDragEnd).on(Jt,this.onUpdate).on(Xt,this._onUnselect).on(Yt,this._onSelect).on(Kt,this._onAdded).on(Zt,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,r,o){t.forEach(l=>{const u=this.links.getTargetLinks(l.getId(),"node"),d=l.getPosition();u.forEach(p=>{const f=this.getAnnotation(p.arrow),y=p.side,v=Ct(f,y==="start"?"end":"start");let _=d;const E=+l.getAttribute("radius"),b=1e-6;(p.connectionPoint.x-(d.x-r)>b||p.connectionPoint.y-(d.y-o)>b)&&(_=Nt(v,d,E)),vt(f,y,_.x,_.y)})}),this.arrows.refreshLayer()}_snapToText(t,r,o){const l=this.texts.detect(o,this.options.detectMargin);if(this.links.remove(t,r),!l)return!1;this.textToMagnet=l;const u=this.findMagnetPoint(Qe,l,o);return u?(vt(t,r,u.point.x,u.point.y),this.links.add(t,r,l.id,"text",u.magnet),!0):!1}_findAndSnapToNode(t,r,o){var d,p;const l=this.ogma.view.graphToScreenCoordinates(o),u=this.ogma.view.getElementAt(l);this.links.remove(t,r),u&&u.isNode?((d=this.hoveredNode)==null||d.setSelected(!1),this.hoveredNode=u,u.setSelected(!0),this._snapToNode(t,r,u,l)):((p=this.hoveredNode)==null||p.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,r,o,l){const u=o.getPositionOnScreen(),d=+o.getAttribute("radius"),p=d*this.ogma.view.getZoom(),f=l.x-u.x,y=l.y-u.y,v=Math.sqrt(f*f+y*y),_=o.getPosition();if(v<p+this.options.detectMargin){let E=_;if(v>p/2){const b=Ct(t,r==="end"?"start":"end");E=Nt(b,E,d)}vt(t,r,E.x,E.y),this.links.add(t,r,o.getId(),"node",E)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:r,targetType:o,target:l,arrow:u,side:d})=>{if(o!=="text")return;t=!0;const p=this.getAnnotation(l),f=this.getAnnotation(u),y=ht(p),v=ct(p),_=Wt(r,{x:y.width,y:y.height}),E=ot(_,this.ogma.view.getAngle()),b=It(E,v);vt(f,d,b.x,b.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,r,o){let l;for(const u of t){const d=ht(r),p=ct(r),f=Wt(u,{x:d.width,y:d.height}),y=ot(f,this.ogma.view.getAngle()),v=It(y,p),_=_t(wt(v,o)),E=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),d.width/2,d.height/2);if(_<Math.max(E,this.options.magnetHandleRadius)){l={point:v,magnet:u};break}}return l}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const r=this.getAnnotations().features.find(o=>o.id===t);return r?(at(r)?this.arrows.select(r.id):dt(r)&&this.texts.select(r.id),this):this}unselect(){return this.selected?(at(this.selected)?this.arrows.unselect():dt(this.selected)&&this.texts.unselect(),this):this}add(t){if(ge(t)){const[r,o]=t.features.reduce((l,u)=>(at(u)?l[1].push(u):dt(u)&&l[0].push(u),l),[[],[]]);return r.forEach(l=>this.add(l)),o.forEach(l=>this.add(l)),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 ge(t)?(t.features.forEach(r=>this.remove(r)),this):(at(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 r of Je){const o=t.properties.link[r];if(!o)continue;const l=this.getAnnotation(o.id);if(o.type==="text"&&l)this.links.add(t,r,o.id,o.type,o.magnet);else if(o.type==="node"){const u=this.ogma.getNode(o.id);if(!u)continue;this.links.add(t,r,o.id,o.type,o.magnet);const d=u.getPosition(),p=u.getAttribute("radius")||0,f=Ct(t,r==="start"?"end":"start"),y=Nt(f,d,+p);vt(t,r,y.x,y.y)}}}startArrow(t,r,o){this.cancelDrawing(),this.arrows.startDrawing(t,r,o)}startText(t,r,o){this.cancelDrawing(),this.texts.startDrawing(t,r,o)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(ze)}updateStyle(t,r){const o=this.getAnnotations().features.find(l=>l.id===t);return o?(at(o)?this.arrows.updateStyle(o,r):dt(o)&&this.texts.updateStyle(o,r),this.onUpdate(o),this):this}setScale(t,r,o,l){const u=this.getAnnotations().features.find(d=>d.id===t);return u?(at(u)?this.arrows.scale(u,r,o,l):dt(u)&&this.texts.scale(u,r,o,l),this.onUpdate(u),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(r=>{t.features=[...t.features,...r.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(r=>r.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}A.Arrows=Ge,A.Control=kn,A.EVT_ADD=Kt,A.EVT_CANCEL_DRAWING=ze,A.EVT_DRAG=$t,A.EVT_DRAG_END=xt,A.EVT_DRAG_START=zt,A.EVT_HOVER=Ne,A.EVT_LINK=He,A.EVT_REMOVE=Zt,A.EVT_SELECT=Yt,A.EVT_UNHOVER=$e,A.EVT_UNSELECT=Xt,A.EVT_UPDATE=Jt,A.NONE=F,A.Texts=Ke,A.clientToContainerPosition=Gt,A.createArrow=Se,A.createSVGElement=St,A.createText=We,A.defaultArrowOptions=oe,A.defaultArrowStyle=st,A.defaultControllerOptions=ue,A.defaultTextOptions=Qt,A.defaultTextStyle=bt,A.getAnnotationsBounds=gn,A.getArrowEnd=Lt,A.getArrowEndPoints=Pt,A.getArrowSide=Ct,A.getArrowStart=Tt,A.getAttachmentPointOnNode=Nt,A.getHandleId=ce,A.getTextBbox=ae,A.getTextPosition=ct,A.getTextSize=ht,A.isAnnotationCollection=ge,A.isArrow=at,A.isText=dt,A.scaleGeometry=Ie,A.setArrowEnd=he,A.setArrowEndPoint=vt,A.setArrowStart=le,A.setTextBbox=_e,A.updateTextBbox=Te,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var $n = Object.defineProperty;
2
2
  var zn = (a, h, t) => h in a ? $n(a, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[h] = t;
3
3
  var m = (a, h, t) => (zn(a, typeof h != "symbol" ? h + "" : h, t), t);
4
- let Jt = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((h, t) => (t &= 63, t < 36 ? h += t.toString(36) : t < 62 ? h += (t - 26).toString(36).toUpperCase() : t > 62 ? h += "-" : h += "_", h), "");
4
+ let Kt = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((h, t) => (t &= 63, t < 36 ? h += t.toString(36) : t < 62 ? h += (t - 26).toString(36).toUpperCase() : t > 62 ? h += "-" : h += "_", h), "");
5
5
  const zt = {
6
6
  strokeType: "plain",
7
7
  strokeColor: "black",
@@ -35,7 +35,7 @@ const zt = {
35
35
  // start: { x: 0, y: 0 },
36
36
  // end: { x: 100, y: 100 }
37
37
  }, Nn = (a = 0, h = 0, t = 0, r = 0, o = { ...zt }) => ({
38
- id: Jt(),
38
+ id: Kt(),
39
39
  type: "Feature",
40
40
  properties: {
41
41
  type: "arrow",
@@ -158,7 +158,7 @@ function Vt(a, h, t) {
158
158
  y: h.y + t * Math.sin(r)
159
159
  };
160
160
  }
161
- function Xt(a, h) {
161
+ function ue(a, h) {
162
162
  if (!h)
163
163
  return { x: a.clientX, y: a.clientY };
164
164
  const t = h.getBoundingClientRect();
@@ -218,7 +218,7 @@ function Vn(a, h, t, r, o) {
218
218
  const C = Oe(l, Ue(v), d, T), E = Oe(u, v, g, T), $ = C + `M ${l.x} ${l.y} ${u.x} ${u.y}` + E;
219
219
  A.setAttribute("d", $), h.appendChild(A);
220
220
  }
221
- const V = -1, Zt = "dragging", Kt = "dragstart", Tt = "dragend", de = "select", fe = "unselect", Un = "hover", Gn = "unhover", pe = "remove", ge = "add", Wn = "cancelDrawing", ye = "update", Yn = "link";
221
+ const V = -1, Xt = "dragging", Zt = "dragstart", Tt = "dragend", de = "select", fe = "unselect", Un = "hover", Gn = "unhover", pe = "remove", ge = "add", Wn = "cancelDrawing", ye = "update", Yn = "link";
222
222
  var Xn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
223
223
  function Xe(a) {
224
224
  return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
@@ -376,7 +376,7 @@ class Je extends Ke {
376
376
  */
377
377
  add(t) {
378
378
  const r = this.getDefaultOptions(), o = Object.assign(t, {
379
- id: t.id === void 0 ? Jt() : t.id,
379
+ id: t.id === void 0 ? Kt() : t.id,
380
380
  type: t.type,
381
381
  properties: {
382
382
  ...r.properties,
@@ -558,7 +558,7 @@ class Kn extends Je {
558
558
  const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
559
559
  if (!r)
560
560
  return;
561
- const { x: o, y: l } = Xt(t, this.ogma.getContainer());
561
+ const { x: o, y: l } = ue(t, this.ogma.getContainer());
562
562
  this.startDragging(r, o, l), this.draggedHandle = Ve(t.target);
563
563
  });
564
564
  m(this, "onMouseUp", () => {
@@ -567,20 +567,17 @@ class Kn extends Je {
567
567
  m(this, "onMouseMove", (t) => {
568
568
  if (!this.isDragging || this.draggedHandle === V)
569
569
  return;
570
- const r = this.handles[this.draggedHandle], o = this.ogma.view.getAngle(), l = Xt(
571
- t,
572
- this.ogma.getContainer()
573
- ), { x: u, y: d } = rt(
570
+ const r = this.handles[this.draggedHandle], o = this.ogma.view.getAngle(), { x: l, y: u } = rt(
574
571
  Rn(
575
- { x: l.x - this.startX, y: l.y - this.startY },
572
+ { x: t.x - this.startX, y: t.y - this.startY },
576
573
  this.ogma.view.getZoom()
577
574
  ),
578
575
  o
579
- ), g = r.id === Le, f = r.id === Ce, y = r.id === Pe;
580
- (g || f) && qe(this.arrow, this.start.x + u, this.start.y + d), (g || y) && Re(this.arrow, this.end.x + u, this.end.y + d), this.emit(
581
- Zt,
576
+ ), d = r.id === Le, g = r.id === Ce, f = r.id === Pe;
577
+ (d || g) && qe(this.arrow, this.start.x + l, this.start.y + u), (d || f) && Re(this.arrow, this.end.x + l, this.end.y + u), this.emit(
578
+ Xt,
582
579
  this.arrow,
583
- g ? "line" : f ? "start" : "end"
580
+ d ? "line" : g ? "start" : "end"
584
581
  ), this.refreshEditor(), this.layer.refresh();
585
582
  });
586
583
  this.minArrowHeight = r.minArrowHeight || 0, this.maxArrowHeight = r.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call(
@@ -612,7 +609,7 @@ class Kn extends Je {
612
609
  this.isDragging && (this.remove(this.arrow.id), this.emit(Tt, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = V);
613
610
  }
614
611
  startDragging(t, r, o) {
615
- this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = o, this.start = $t(this.arrow), this.end = Wt(this.arrow), this.disableDragging(), this.emit(Kt, this.arrow), this.isDragging = !0;
612
+ this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = o, this.start = $t(this.arrow), this.end = Wt(this.arrow), this.disableDragging(), this.emit(Zt, this.arrow), this.isDragging = !0;
616
613
  }
617
614
  detect(t, r = 0) {
618
615
  return this.elements.find((o) => {
@@ -665,7 +662,7 @@ const St = {
665
662
  strokeWidth: 1,
666
663
  strokeColor: "#000",
667
664
  strokeType: "plain"
668
- }, he = {
665
+ }, le = {
669
666
  id: 0,
670
667
  type: "Feature",
671
668
  properties: {
@@ -691,7 +688,7 @@ const St = {
691
688
  handleSize: 3.5,
692
689
  placeholder: "Your text..."
693
690
  }, Jn = (a = 0, h = 0, t = 100, r = 50, o = "", l = { ...St }) => ({
694
- id: Jt(),
691
+ id: Kt(),
695
692
  type: "Feature",
696
693
  properties: {
697
694
  type: "text",
@@ -806,7 +803,7 @@ var Qe = { exports: {} };
806
803
  return s.__proto__ = i, s;
807
804
  }, It(e, n);
808
805
  }
809
- function Qt(e) {
806
+ function Jt(e) {
810
807
  var n = function() {
811
808
  if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
812
809
  return !1;
@@ -885,32 +882,32 @@ var Qe = { exports: {} };
885
882
  } }]), e;
886
883
  }(), Dt = function(e) {
887
884
  _t(s, e);
888
- var n = Qt(s);
885
+ var n = Jt(s);
889
886
  function s() {
890
887
  return Ht(this, s), n.apply(this, arguments);
891
888
  }
892
889
  return Ft(s);
893
890
  }(F), et = function(e) {
894
891
  _t(s, e);
895
- var n = Qt(s);
892
+ var n = Jt(s);
896
893
  function s() {
897
894
  return Ht(this, s), n.apply(this, arguments);
898
895
  }
899
896
  return Ft(s);
900
897
  }(F), gt = function(e) {
901
898
  _t(s, e);
902
- var n = Qt(s);
899
+ var n = Jt(s);
903
900
  function s() {
904
901
  return Ht(this, s), n.apply(this, arguments);
905
902
  }
906
903
  return Ft(s);
907
- }(F), te = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, nn = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, me = /^[\xA0\u2011\u202F\u2060\uFEFF]/, rn = /^(?:[;\xAD%?…]|,(?!\d))/, sn = /^[´±°¢£¤$¥\u2212]/;
904
+ }(F), Qt = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, nn = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, me = /^[\xA0\u2011\u202F\u2060\uFEFF]/, rn = /^(?:[;\xAD%?…]|,(?!\d))/, sn = /^[´±°¢£¤$¥\u2212]/;
908
905
  function Bt(e, n) {
909
906
  n !== !1 && (e = e.trim());
910
907
  for (var s, i, c = [], p = e.charAt(0), w = 0, x = 1, k = e.length; x < k; x++) {
911
908
  s = e.charAt(x), i = e.charAt(x + 1);
912
- var S = te.test(p), M = te.test(s), O = M || S, I = void 0;
913
- if ((sn.test(s) && !me.test(p) || rn.test(p + i) && !me.test(s)) && (O = !0), p !== "-" && p !== "‐" && p !== "–" && p !== "—" || ((I = te.test(e.charAt(x - 2))) && !M && (O = !1), !I && nn.test(s + i) && (O = !0)), O) {
909
+ var S = Qt.test(p), M = Qt.test(s), O = M || S, I = void 0;
910
+ if ((sn.test(s) && !me.test(p) || rn.test(p + i) && !me.test(s)) && (O = !0), p !== "-" && p !== "‐" && p !== "–" && p !== "—" || ((I = Qt.test(e.charAt(x - 2))) && !M && (O = !1), !I && nn.test(s + i) && (O = !0)), O) {
914
911
  var L = e.slice(w, x);
915
912
  /\u00AD$/.test(L) ? (c.push(new F(L.slice(0, -1))), c.push(new gt())) : (c.push(new F(L)), c.push(new Dt())), w = x;
916
913
  }
@@ -1014,29 +1011,29 @@ var Qe = { exports: {} };
1014
1011
  function Ee(e) {
1015
1012
  return function(n) {
1016
1013
  if (Array.isArray(n))
1017
- return ee(n);
1014
+ return te(n);
1018
1015
  }(e) || function(n) {
1019
1016
  if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
1020
1017
  return Array.from(n);
1021
1018
  }(e) || function(n, s) {
1022
1019
  if (n) {
1023
1020
  if (typeof n == "string")
1024
- return ee(n, s);
1021
+ return te(n, s);
1025
1022
  var i = Object.prototype.toString.call(n).slice(8, -1);
1026
- 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) ? ee(n, s) : void 0;
1023
+ 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) ? te(n, s) : void 0;
1027
1024
  }
1028
1025
  }(e) || function() {
1029
1026
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
1030
1027
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
1031
1028
  }();
1032
1029
  }
1033
- function ee(e, n) {
1030
+ function te(e, n) {
1034
1031
  (n == null || n > e.length) && (n = e.length);
1035
1032
  for (var s = 0, i = new Array(n); s < n; s++)
1036
1033
  i[s] = e[s];
1037
1034
  return i;
1038
1035
  }
1039
- var En = { center: "middle", right: "end" }, kn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, ne = function(e, n) {
1036
+ var En = { center: "middle", right: "end" }, kn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, ee = function(e, n) {
1040
1037
  return !e && !n || e === n;
1041
1038
  };
1042
1039
  function Sn(e, n) {
@@ -1061,7 +1058,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1061
1058
  H = [];
1062
1059
  for (var wt = 0, Lt = 0, ht = void 0, X = 0, jt = lt.length; X < jt; X++) {
1063
1060
  var R = lt[X], Z = R.font;
1064
- R.whitespace && wt++, Lt += R.width, X && !R.tracking && !ot && ne(Z.id, at) && ne(R.class, dt) && ne(ht, R.href) ? q += R.value : (D(), q = R.value, Y = { fontFamily: Z.family !== p ? Z.family : null, fontSize: Z.size !== c ? Z.size : null, fontWeight: Z.weight || null, fontStyle: Z.style || null, fontVariant: Z.variant !== "normal" && Z.variant || null, fill: Z.color || null, baselineShift: Z.baseline ? 100 * Z.baseline + "%" : null, className: R.class || null }, ot && (Y.dx = xt(ot), ot = 0), R.tracking && (ot = Z.size * R.tracking), R.href && !ht ? (ht = R.href, Q = "a", Y.href = ht, Y.rel = R.rel, Y.target = R.target) : ht = null, at = Z.id, dt = R.class);
1061
+ R.whitespace && wt++, Lt += R.width, X && !R.tracking && !ot && ee(Z.id, at) && ee(R.class, dt) && ee(ht, R.href) ? q += R.value : (D(), q = R.value, Y = { fontFamily: Z.family !== p ? Z.family : null, fontSize: Z.size !== c ? Z.size : null, fontWeight: Z.weight || null, fontStyle: Z.style || null, fontVariant: Z.variant !== "normal" && Z.variant || null, fill: Z.color || null, baselineShift: Z.baseline ? 100 * Z.baseline + "%" : null, className: R.class || null }, ot && (Y.dx = xt(ot), ot = 0), R.tracking && (ot = Z.size * R.tracking), R.href && !ht ? (ht = R.href, Q = "a", Y.href = ht, Y.rel = R.rel, Y.target = R.target) : ht = null, at = Z.id, dt = R.class);
1065
1062
  }
1066
1063
  if (D(), I)
1067
1064
  s.push.apply(s, Ee(H));
@@ -1107,17 +1104,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1107
1104
  });
1108
1105
  }
1109
1106
  }
1110
- function ie(e) {
1111
- return ie = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
1107
+ function ne(e) {
1108
+ return ne = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
1112
1109
  return typeof n;
1113
1110
  } : function(n) {
1114
1111
  return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
1115
- }, ie(e);
1112
+ }, ne(e);
1116
1113
  }
1117
1114
  function ke(e) {
1118
1115
  for (var n = {}, s = 0; s < e.length; s++) {
1119
1116
  var i = e[s];
1120
- typeof i != "number" && i != null && (typeof i == "string" ? n.text = i : typeof i == "function" ? n.fn = i : ie(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));
1117
+ typeof i != "number" && i != null && (typeof i == "string" ? n.text = i : typeof i == "function" ? n.fn = i : ne(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));
1121
1118
  }
1122
1119
  return n;
1123
1120
  }
@@ -1146,7 +1143,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1146
1143
  }
1147
1144
  var c;
1148
1145
  }
1149
- var Dn = b(), re = function(e) {
1146
+ var Dn = b(), ie = function(e) {
1150
1147
  return typeof e == "function" ? e : function() {
1151
1148
  return e;
1152
1149
  };
@@ -1208,14 +1205,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1208
1205
  var Lt = 0, ht = 0, X = Q.map(function(yt) {
1209
1206
  for (var K, mt = Lt; (K = k[mt]) && (K.whitespace || !K.value); )
1210
1207
  mt++;
1211
- for (var ft = yt, ae = null; ft > mt && (K = k[ft - 1]) && (K.whitespace || !(K.value || K instanceof gt)); )
1212
- K instanceof et && (ae = K), ft--;
1208
+ for (var ft = yt, oe = null; ft > mt && (K = k[ft - 1]) && (K.whitespace || !(K.value || K instanceof gt)); )
1209
+ K instanceof et && (oe = K), ft--;
1213
1210
  K instanceof gt && (K.value = "-", K.width = G("-", K.font)), Lt = yt;
1214
- var bt = k.slice(mt, ft).filter(function(le) {
1215
- return le.value;
1211
+ var bt = k.slice(mt, ft).filter(function(ae) {
1212
+ return ae.value;
1216
1213
  });
1217
- return ae && bt.push(ae), bt.width = bt.reduce(function(le, Pn) {
1218
- return le + Pn.width;
1214
+ return oe && bt.push(oe), bt.width = bt.reduce(function(ae, Pn) {
1215
+ return ae + Pn.width;
1219
1216
  }, 0), bt.width > ht && (ht = bt.width), bt;
1220
1217
  });
1221
1218
  if (X.hasLineOverflow = !1, L) {
@@ -1258,11 +1255,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1258
1255
  var c = String(i).toLowerCase();
1259
1256
  return c === "break-word" ? this.props.overflowWrap = "break-word" : c !== "normal" && i != null || (this.props.overflowWrap = null), this;
1260
1257
  } }, { key: "width", value: function(i) {
1261
- return arguments.length ? (this.props.width = re(i), this) : this.props.width;
1258
+ return arguments.length ? (this.props.width = ie(i), this) : this.props.width;
1262
1259
  } }, { key: "height", value: function(i) {
1263
- return arguments.length ? (this.props.height = re(i), this) : this.props.height;
1260
+ return arguments.length ? (this.props.height = ie(i), this) : this.props.height;
1264
1261
  } }, { key: "x", value: function(i) {
1265
- return arguments.length ? (this.props.x = re(i), this) : this.props.x;
1262
+ return arguments.length ? (this.props.x = ie(i), this) : this.props.x;
1266
1263
  } }, { key: "parser", value: function(i) {
1267
1264
  if (!arguments.length)
1268
1265
  return this.props.parser;
@@ -1287,7 +1284,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1287
1284
  return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
1288
1285
  }, Ot(e);
1289
1286
  }
1290
- function se(e, n) {
1287
+ function re(e, n) {
1291
1288
  (n == null || n > e.length) && (n = e.length);
1292
1289
  for (var s = 0, i = new Array(n); s < n; s++)
1293
1290
  i[s] = e[s];
@@ -1353,16 +1350,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1353
1350
  var p, w = i.getContext ? i.getContext("2d") : i;
1354
1351
  return w.save(), w.rotate(this.rotate() * Math.PI / 180), w.translate.apply(w, function(x) {
1355
1352
  if (Array.isArray(x))
1356
- return se(x);
1353
+ return re(x);
1357
1354
  }(p = this.anchor()) || function(x) {
1358
1355
  if (typeof Symbol < "u" && x[Symbol.iterator] != null || x["@@iterator"] != null)
1359
1356
  return Array.from(x);
1360
1357
  }(p) || function(x, k) {
1361
1358
  if (x) {
1362
1359
  if (typeof x == "string")
1363
- return se(x, k);
1360
+ return re(x, k);
1364
1361
  var S = Object.prototype.toString.call(x).slice(8, -1);
1365
- return S === "Object" && x.constructor && (S = x.constructor.name), S === "Map" || S === "Set" ? Array.from(x) : S === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S) ? se(x, k) : void 0;
1362
+ return S === "Object" && x.constructor && (S = x.constructor.name), S === "Map" || S === "Set" ? Array.from(x) : S === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S) ? re(x, k) : void 0;
1366
1363
  }
1367
1364
  }(p) || function() {
1368
1365
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
@@ -1379,11 +1376,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1379
1376
  return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, c);
1380
1377
  }
1381
1378
  } }], s && Mn(n.prototype, s), Object.defineProperty(n, "prototype", { writable: !1 }), e;
1382
- }(), On = Object.prototype.hasOwnProperty, oe = {};
1379
+ }(), On = Object.prototype.hasOwnProperty, se = {};
1383
1380
  function Ln(e) {
1384
- return oe[e] || (oe[e] = e.replace(/([a-z])([A-Z])/g, function(n, s, i) {
1381
+ return se[e] || (se[e] = e.replace(/([a-z])([A-Z])/g, function(n, s, i) {
1385
1382
  return s + "-" + i.toLowerCase();
1386
- })), oe[e];
1383
+ })), se[e];
1387
1384
  }
1388
1385
  function _e(e, n) {
1389
1386
  if (Array.isArray(n))
@@ -1516,10 +1513,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1516
1513
  })(Qe);
1517
1514
  var Qn = Qe.exports;
1518
1515
  const ze = /* @__PURE__ */ Xe(Qn);
1519
- function ce(a) {
1516
+ function he(a) {
1520
1517
  return a.replace(/…$/, "");
1521
1518
  }
1522
- function ue(a) {
1519
+ function ce(a) {
1523
1520
  return a.children[0].innerHTML;
1524
1521
  }
1525
1522
  function ti(a, h) {
@@ -1553,7 +1550,7 @@ function ti(a, h) {
1553
1550
  `) || v.push(y), y++;
1554
1551
  break;
1555
1552
  }
1556
- const E = ce(ue(f[y]));
1553
+ const E = he(ce(f[y]));
1557
1554
  C.startsWith(E) && (C = C.slice(E.length).trim()), y++;
1558
1555
  }
1559
1556
  }), v.forEach((b) => g.removeChild(f[b]));
@@ -1562,18 +1559,18 @@ function ti(a, h) {
1562
1559
  let C = b;
1563
1560
  const E = [];
1564
1561
  for (; C.length > 0; ) {
1565
- const $ = f.find((_) => !!_.children[0] && _.children[0].tagName === "tspan" && C.startsWith(ce(ue(_))));
1562
+ const $ = f.find((_) => !!_.children[0] && _.children[0].tagName === "tspan" && C.startsWith(he(ce(_))));
1566
1563
  if (!$)
1567
1564
  break;
1568
1565
  E.push($);
1569
- const N = ce($.children[0].innerHTML).length;
1566
+ const N = he($.children[0].innerHTML).length;
1570
1567
  if (!N)
1571
1568
  break;
1572
1569
  C = C.slice(N);
1573
1570
  }
1574
1571
  E.forEach(($) => {
1575
1572
  const N = document.createElementNS("http://www.w3.org/2000/svg", "a");
1576
- N.setAttribute("href", b), N.setAttribute("target", "_blank"), N.innerHTML = ue($), $.children[0].innerHTML = "", $.children[0].appendChild(N);
1573
+ N.setAttribute("href", b), N.setAttribute("target", "_blank"), N.innerHTML = ce($), $.children[0].innerHTML = "", $.children[0].appendChild(N);
1577
1574
  });
1578
1575
  }), h.appendChild(g);
1579
1576
  }
@@ -1599,7 +1596,7 @@ class ei extends Je {
1599
1596
  m(this, "textArea");
1600
1597
  m(this, "handleSize");
1601
1598
  m(this, "rect", { x: 0, y: 0, width: 0, height: 0 });
1602
- m(this, "annotation", { ...he });
1599
+ m(this, "annotation", { ...le });
1603
1600
  m(this, "startX", 0);
1604
1601
  m(this, "startY", 0);
1605
1602
  m(this, "handles", []);
@@ -1618,19 +1615,19 @@ class ei extends Je {
1618
1615
  this.select(o.id), this.startDragging(this.getById(o.id), l.x, l.y), this.draggedHandle = 6;
1619
1616
  });
1620
1617
  m(this, "cancelDrawing", () => {
1621
- this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...he }, this.draggedHandle = V, this.isDragging = !1, this.emit(Tt, this.annotation));
1618
+ this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...le }, this.draggedHandle = V, this.isDragging = !1, this.emit(Tt, this.annotation));
1622
1619
  });
1623
1620
  m(this, "startDragging", (t, r, o) => {
1624
1621
  this.annotation = t;
1625
1622
  const l = ct(this.annotation), u = ut(this.annotation);
1626
- this.rect.x = l.x, this.rect.y = l.y, this.rect.width = u.width, this.rect.height = u.height, this.startX = r, this.startY = o, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Kt, this.annotation), this.isDragging = !0;
1623
+ this.rect.x = l.x, this.rect.y = l.y, this.rect.width = u.width, this.rect.height = u.height, this.startX = r, this.startY = o, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Zt, this.annotation), this.isDragging = !0;
1627
1624
  });
1628
1625
  m(this, "onHandleMouseDown", (t) => {
1629
1626
  const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
1630
1627
  if (!r)
1631
1628
  return;
1632
1629
  this.selectedId !== r.id && this.select(this.hoveredId);
1633
- const { x: o, y: l } = Xt(t, this.ogma.getContainer());
1630
+ const { x: o, y: l } = ue(t, this.ogma.getContainer());
1634
1631
  this.startDragging(r, o, l), this.draggedHandle = Ve(t.target);
1635
1632
  });
1636
1633
  m(this, "onMouseMove", (t) => {
@@ -1640,7 +1637,7 @@ class ei extends Je {
1640
1637
  if (!this.isDragging)
1641
1638
  return;
1642
1639
  t.stopPropagation(), t.preventDefault();
1643
- const r = this.handles[this.draggedHandle], o = r.classList.contains("top"), l = r.classList.contains("left"), u = r.classList.contains("right"), d = r.classList.contains("bottom"), g = r.classList.contains("line-handle"), { x: f, y } = Xt(
1640
+ const r = this.handles[this.draggedHandle], o = r.classList.contains("top"), l = r.classList.contains("left"), u = r.classList.contains("right"), d = r.classList.contains("bottom"), g = r.classList.contains("line-handle"), { x: f, y } = ue(
1644
1641
  t,
1645
1642
  this.ogma.getContainer()
1646
1643
  ), v = this.ogma.view.getZoom(), T = (f - this.startX) / v, A = (y - this.startY) / v, b = this.ogma.view.getAngle(), C = rt({ x: T, y: A }, b);
@@ -1652,7 +1649,7 @@ class ei extends Je {
1652
1649
  this.rect.height + A * (g || o ? 0 : 1),
1653
1650
  Ne
1654
1651
  );
1655
- Bn(this.annotation, E, $, N, _), this.emit(Zt, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
1652
+ Bn(this.annotation, E, $, N, _), this.emit(Xt, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
1656
1653
  });
1657
1654
  m(this, "onMouseUp", () => {
1658
1655
  !this.isDragging || this.draggedHandle === V || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(Tt, this.annotation), this.isDragging = !1, this.draggedHandle = V);
@@ -1723,7 +1720,7 @@ class ei extends Je {
1723
1720
  });
1724
1721
  }
1725
1722
  getDefaultOptions() {
1726
- return he;
1723
+ return le;
1727
1724
  }
1728
1725
  refreshEditor() {
1729
1726
  if (+this.selectedId < 0 && +this.hoveredId < 0)
@@ -1753,7 +1750,7 @@ class ni {
1753
1750
  m(this, "linksByArrowId", {});
1754
1751
  }
1755
1752
  add(h, t, r, o, l) {
1756
- const u = Jt(), d = h.id, g = {
1753
+ const u = Kt(), d = h.id, g = {
1757
1754
  id: u,
1758
1755
  arrow: d,
1759
1756
  target: r,
@@ -1864,7 +1861,7 @@ class oi extends Ke {
1864
1861
  const g = this.getAnnotation(l), f = ut(t), y = ct(t), v = Ut(d, { x: f.width, y: f.height }), T = rt(v, this.ogma.view.getAngle()), A = Et(T, y);
1865
1862
  g.geometry.coordinates[u === "start" ? 0 : 1] = [A.x, A.y];
1866
1863
  }), this.activeLinks.length && this.arrows.refreshLayer());
1867
- this.layer.refresh(), this.emit(Zt, t, r);
1864
+ this.layer.refresh(), this.emit(Xt, t, r);
1868
1865
  });
1869
1866
  m(this, "_onFeatureDragEnd", (t) => {
1870
1867
  this.dragged !== null && st(t) && $t(this.dragged) && Fe.forEach((r) => {
@@ -1878,7 +1875,7 @@ class oi extends Ke {
1878
1875
  this.textToMagnet = void 0, st(t) ? this.dragged = t : pt(t) && this.activeLinks.push(...this.links.getTargetLinks(t.id, "text")), this.annotations.forEach((r) => {
1879
1876
  const o = r.getSelectedFeature();
1880
1877
  o && o !== t && r.unhover().unselect(), r.disableDetection();
1881
- }), this.emit(Kt, t);
1878
+ }), this.emit(Zt, t);
1882
1879
  });
1883
1880
  m(this, "_onNodesDragStart", () => {
1884
1881
  this.arrows.unhover().unselect(), this.texts.unhover().unselect();
@@ -1923,7 +1920,7 @@ class oi extends Ke {
1923
1920
  this.emit(ye, t);
1924
1921
  });
1925
1922
  this.options = this.setOptions({ ...ii, ...r }), this.ogma = t, this.arrows = new Kn(t, this.options), this.texts = new ei(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((o) => {
1926
- o.on(Kt, this._onFeatureDragStart).on(Zt, this._onFeatureDrag).on(Tt, this._onFeatureDragEnd).on(ye, this.onUpdate).on(fe, this._onUnselect).on(de, this._onSelect).on(ge, this._onAdded).on(pe, this._onRemoved);
1923
+ o.on(Zt, this._onFeatureDragStart).on(Xt, this._onFeatureDrag).on(Tt, this._onFeatureDragEnd).on(ye, this.onUpdate).on(fe, this._onUnselect).on(de, this._onSelect).on(ge, this._onAdded).on(pe, this._onRemoved);
1927
1924
  }), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd).on(["viewChanged", "rotate"], () => {
1928
1925
  this.refreshTextLinks();
1929
1926
  }), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
@@ -2151,9 +2148,9 @@ export {
2151
2148
  oi as Control,
2152
2149
  ge as EVT_ADD,
2153
2150
  Wn as EVT_CANCEL_DRAWING,
2154
- Zt as EVT_DRAG,
2151
+ Xt as EVT_DRAG,
2155
2152
  Tt as EVT_DRAG_END,
2156
- Kt as EVT_DRAG_START,
2153
+ Zt as EVT_DRAG_START,
2157
2154
  Un as EVT_HOVER,
2158
2155
  Yn as EVT_LINK,
2159
2156
  pe as EVT_REMOVE,
@@ -2163,14 +2160,14 @@ export {
2163
2160
  ye as EVT_UPDATE,
2164
2161
  V as NONE,
2165
2162
  ei as Texts,
2166
- Xt as clientToContainerPosition,
2163
+ ue as clientToContainerPosition,
2167
2164
  Nn as createArrow,
2168
2165
  Pt as createSVGElement,
2169
2166
  Jn as createText,
2170
2167
  De as defaultArrowOptions,
2171
2168
  zt as defaultArrowStyle,
2172
2169
  $e as defaultControllerOptions,
2173
- he as defaultTextOptions,
2170
+ le as defaultTextOptions,
2174
2171
  St as defaultTextStyle,
2175
2172
  si as getAnnotationsBounds,
2176
2173
  Wt as getArrowEnd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkurious/ogma-annotations",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "Headless annotation plugin for Ogma",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",