@linkurious/ogma-annotations 1.1.27 → 2.0.0
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/Readme.md +3 -132
- package/dist/index.js +65 -24
- package/dist/index.mjs +6559 -1898
- package/dist/ogma-annotations.css +1 -1
- package/dist/types/index.d.ts +1352 -307
- package/package.json +45 -15
package/dist/index.js
CHANGED
|
@@ -1,24 +1,65 @@
|
|
|
1
|
-
(function(E,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(E=typeof globalThis<"u"?globalThis:E||self,X(E["@linkurious/ogma-annotations"]={}))})(this,function(E){"use strict";var mi=Object.defineProperty;var vi=(E,X,lt)=>X in E?mi(E,X,{enumerable:!0,configurable:!0,writable:!0,value:lt}):E[X]=lt;var m=(E,X,lt)=>vi(E,typeof X!="symbol"?X+"":X,lt);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 lt={strokeType:"plain",strokeColor:"#202020",strokeWidth:1,head:"none",tail:"none"},le={id:0,type:"Feature",properties:{type:"arrow",style:{...lt}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},_e=(a=0,h=0,t=0,i=0,o={...lt})=>({id:X(),type:"Feature",properties:{type:"arrow",style:{...lt,...o}},geometry:{type:"LineString",coordinates:[[a,h],[t,i]]}}),bn="http://www.w3.org/2000/svg";function yt(a){return document.createElementNS(bn,a)}function he(a){return a.geometry.bbox||Ie(a),a.geometry.bbox}function ht(a){const h=he(a);return{width:h[2]-h[0],height:h[3]-h[1]}}function ct(a){const h=he(a);return{x:h[0],y:h[1]}}function Ie(a){const[h,t]=a.geometry.coordinates[0][0],[i,o]=a.geometry.coordinates[0][2];a.geometry.bbox=[h,t,i,o]}function De(a,h,t,i,o){a.geometry.bbox=[h,t,h+i,t+o],a.geometry.coordinates=[[[h,t],[h+i,t],[h+i,t+o],[h,t+o],[h,t]]]}function _t(a){const[h,t]=a.geometry.coordinates[0];return{x:h,y:t}}function Lt(a,h){const[t,i]=a.geometry.coordinates[h==="start"?0:1];return{x:t,y:i}}function $t(a){const[h,t]=a.geometry.coordinates[1];return{x:h,y:t}}function ce(a,h,t){a.geometry.coordinates[0]=[h,t]}function ue(a,h,t){a.geometry.coordinates[1]=[h,t]}function Pt(a){return{start:_t(a),end:$t(a)}}function bt(a,h,t,i){h==="start"?ce(a,t,i):ue(a,t,i)}const de=a=>parseInt(a.getAttribute("data-handle-id")||"-1");function xn(a){return Nt(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 An(a){return Array.isArray(a)&&a.length===2&&a.every(isFinite)}function Oe(a,h,t,i){for(let o=0;o<a.coordinates.length;o++){const l=a.coordinates[o];if(An(l))l[0]=t+(l[0]-t)*h,l[1]=i+(l[1]-i)*h;else for(let u=0;u<l.length;u++){const d=l[u];d[0]=t+(d[0]-t)*h,d[1]=i+(d[1]-i)*h}}return a}function Nt(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,i){return t.concat(i)},[]):a.type=="MultiPolygon"?h=a.coordinates.reduce((t,i)=>t.concat(i.reduce((o,l)=>o.concat(l),[])),[]):a.type=="Feature"?h=Nt(a.geometry):a.type=="GeometryCollection"?h=a.geometries.reduce((t,i)=>t.concat(Nt(i)),[]):a.type=="FeatureCollection"&&(h=a.features.reduce((t,i)=>t.concat(Nt(i)),[])),h}function zt(a,h,t){const i=Math.atan2(a.y-h.y,a.x-h.x);return{x:h.x+t*Math.cos(i),y:h.y+t*Math.sin(i)}}function Ht(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}}function En(a,h){return a.startsWith("#")?Ce(a,h):a.startsWith("rgb")?Le(a,h):a}function Me(a){return a.length===4?a.split("").map(h=>h+h).join(""):a}function Ce(a,h){const[t,i,o]=Me(a).match(/\w\w/g).map(l=>parseInt(l,16));return`rgba(${t}, ${i}, ${o}, ${h})`}function Le(a,h){const[t,i,o]=a.match(/\d+/g).map(l=>parseInt(l,10));return`rgba(${t}, ${i}, ${o}, ${h})`}const xt=(a,h)=>({x:a.x-h.x,y:a.y-h.y}),It=a=>Math.sqrt(a.x*a.x+a.y*a.y),$e=a=>({x:-a.x,y:-a.y}),Pe=a=>{const h=It(a);return h===0?{x:0,y:0}:{x:a.x/h,y:a.y/h}},Dt=(a,h)=>({x:a.x+h.x,y:a.y+h.y}),Ne=(a,h)=>({x:a.x*h,y:a.y*h}),Yt=(a,h)=>({x:a.x*h.x,y:a.y*h.y}),it=(a,h)=>{const t=Math.sin(h),i=Math.cos(h);return{x:a.x*i-a.y*t,y:a.x*t+a.y*i}},Tn=(a,h)=>({x:a.x/h,y:a.y/h}),ze=(a,h)=>a.x*h.x+a.y*h.y,Sn=.5;function He(a,h=5,t=30){var d;const{start:i,end:o}=Pt(a),l=xt(o,i),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,It(l)*.01,h))}function Re(a,h,t,i){const o=Ne($e(Pe(h)),i);if(!t||t!=="arrow"&&t!=="arrow-plain")return"";const l=Dt(a,it(o,Math.PI/10)),u=Dt(a,it(o,-Math.PI/10)),d=`${a.x} ${a.y}`;return`M ${l.x} ${l.y} L ${d} ${u.x} ${u.y} ${t==="arrow"?"":`${l.x} ${l.y}`}`}function kn(a,h,t,i,o){const{start:l,end:u}=Pt(a),{tail:d,head:y,strokeColor:f,strokeWidth:p=0}=a.properties.style||t,v=xt(u,l),S=He(a,i,o),x=yt("g"),b=yt("path");x.setAttribute("data-annotation",`${a.id}`),x.setAttribute("data-annotation-type","arrow");const P=y==="arrow-plain"||d==="arrow",T=f||"none";b.setAttribute("stroke",T),b.setAttribute("stroke-width",`${p}`),b.setAttribute("fill",P?f||"":"none"),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");const $=Re(l,$e(v),d,S),H=Re(u,v,y,S),O=$+`M ${l.x} ${l.y} ${u.x} ${u.y}`+H;b.setAttribute("d",O),x.appendChild(b),Ve(x,l,T,d,p),Ve(x,u,T,y,p),h.appendChild(x)}function Ve(a,h,t,i,o){i==="halo-dot"&&Fe(a,h,_n(t),Sn,o*4),(i==="dot"||i==="halo-dot")&&Fe(a,h,t,1,o*2)}function _n(a){return a==="none"?"none":a}function Fe(a,h,t,i,o){const l=yt("circle");l.setAttribute("cx",`${h.x}`),l.setAttribute("cy",`${h.y}`),l.setAttribute("r",`${o}`),l.setAttribute("fill-opacity",`${i}`),l.setAttribute("fill",t),a.appendChild(l)}const B=-1,Rt="dragging",Vt="dragstart",At="dragend",Xt="select",Zt="unselect",Be="hover",qe="unhover",Kt="remove",Jt="add",je="cancelDrawing",Qt="update",Ue="link";function Ge(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var fe={exports:{}},We;function In(){return We||(We=1,function(a){var h=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function o(y,f,p){this.fn=y,this.context=f,this.once=p||!1}function l(y,f,p,v,S){if(typeof p!="function")throw new TypeError("The listener must be a function");var x=new o(p,v||y,S),b=t?t+f:f;return y._events[b]?y._events[b].fn?y._events[b]=[y._events[b],x]:y._events[b].push(x):(y._events[b]=x,y._eventsCount++),y}function u(y,f){--y._eventsCount===0?y._events=new i:delete y._events[f]}function d(){this._events=new i,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,v;if(this._eventsCount===0)return f;for(v in p=this._events)h.call(p,v)&&f.push(t?v.slice(1):v);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=t?t+f:f,v=this._events[p];if(!v)return[];if(v.fn)return[v.fn];for(var S=0,x=v.length,b=new Array(x);S<x;S++)b[S]=v[S].fn;return b},d.prototype.listenerCount=function(f){var p=t?t+f:f,v=this._events[p];return v?v.fn?1:v.length:0},d.prototype.emit=function(f,p,v,S,x,b){var P=t?t+f:f;if(!this._events[P])return!1;var T=this._events[P],$=arguments.length,H,O;if(T.fn){switch(T.once&&this.removeListener(f,T.fn,void 0,!0),$){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,p),!0;case 3:return T.fn.call(T.context,p,v),!0;case 4:return T.fn.call(T.context,p,v,S),!0;case 5:return T.fn.call(T.context,p,v,S,x),!0;case 6:return T.fn.call(T.context,p,v,S,x,b),!0}for(O=1,H=new Array($-1);O<$;O++)H[O-1]=arguments[O];T.fn.apply(T.context,H)}else{var z=T.length,F;for(O=0;O<z;O++)switch(T[O].once&&this.removeListener(f,T[O].fn,void 0,!0),$){case 1:T[O].fn.call(T[O].context);break;case 2:T[O].fn.call(T[O].context,p);break;case 3:T[O].fn.call(T[O].context,p,v);break;case 4:T[O].fn.call(T[O].context,p,v,S);break;default:if(!H)for(F=1,H=new Array($-1);F<$;F++)H[F-1]=arguments[F];T[O].fn.apply(T[O].context,H)}}return!0},d.prototype.on=function(f,p,v){return l(this,f,p,v,!1)},d.prototype.once=function(f,p,v){return l(this,f,p,v,!0)},d.prototype.removeListener=function(f,p,v,S){var x=t?t+f:f;if(!this._events[x])return this;if(!p)return u(this,x),this;var b=this._events[x];if(b.fn)b.fn===p&&(!S||b.once)&&(!v||b.context===v)&&u(this,x);else{for(var P=0,T=[],$=b.length;P<$;P++)(b[P].fn!==p||S&&!b[P].once||v&&b[P].context!==v)&&T.push(b[P]);T.length?this._events[x]=T.length===1?T[0]:T:u(this,x)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=t?t+f:f,this._events[p]&&u(this,p)):(this._events=new i,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)),fe.exports}var Dn=In();const Ye=Ge(Dn);class Xe extends Ye{constructor(t,i){super();m(this,"ogma");m(this,"elements");m(this,"layer");m(this,"editor");m(this,"selectedId",B);m(this,"hoveredId",B);m(this,"ogmaOptions");m(this,"shouldDetect");m(this,"isDragging");m(this,"showeditorOnHover");m(this,"_onKeyUp",t=>{t.code===27&&this.selectedId!==B?this.unselect():(t.code===46||t.code===8)&&this.selectedId!==B&&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 i=this.ogma.view.screenToGraphCoordinates(t),o=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(i,0):void 0;t.domEvent.type==="mousemove"?o?this.hover(o.id):this.hoveredId!==B&&this.unhover():o?this.select(o.id):this.selectedId!==B&&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(i),this.editor.hide()}_canRemove(){return!0}add(t){const i=this.getDefaultOptions(),o=Object.assign(t,{id:t.id===void 0?X():t.id,type:t.type,properties:{...i.properties,...t.properties||{},style:{...i.properties.style,...t.properties.style||{}}},geometry:{...i.geometry,...t.geometry}});return this.elements.push(o),this.layer.refresh(),this.emit(Jt,o),o}updateStyle(t,i){this.updateAnnotation(t,{properties:{style:i}})}updateGeometry(t,i){this.updateAnnotation(t,{geometry:i})}scale(t,i,o,l){this.updateGeometry(t,Oe(t.geometry,i,o,l))}update(t,i){const o=this.getById(t);this.updateAnnotation(o,i)}updateAnnotation(t,i){if(!t)return;const o=t.id;Object.keys(i).forEach(l=>{if(l!=="id")if(l==="properties"){const u=i.properties||{style:{}};t.properties={...t.properties||{},...u||{},style:{...t.properties.style||{},...u.style||{}}}}else l==="geometry"?t.geometry={...t.geometry,...i.geometry}:t[l]=i[l]}),o===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){const i=Number(t);for(let o=0;o<this.elements.length;o++){const l=this.elements[o];if(!(l.id!==t&&l.id!==i))return l}}select(t){const i=this.getById(t);i&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Xt,i))}hover(t){const i=this.getById(t);i&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(Be,i))}getSelectedFeature(){return this.selectedId===B?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(Zt,t),this.selectedId=B,this.hoveredId===B&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit(qe,t),this.hoveredId=B,this.selectedId===B&&this.editor.hide(),this.layer.refresh(),this}remove(t){const i=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(o=>o.id!==t),i&&this.emit(Kt,i),this.layer.refresh()}disableDragging(){this.ogma.setOptions({interactions:{drag:{enabled:!1},pan:{enabled:!1}},detect:{nodes:!1,edges:!1,nodeTexts:!1,edgeTexts:!1}})}restoreDragging(){this.ogma.setOptions(this.ogmaOptions)}enableDetection(){this.shouldDetect=!0}disableDetection(){this.shouldDetect=!1}refreshLayer(){this.layer.refresh()}refreshDrawing(){}getElements(){return[...this.elements]}destroy(){this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp),this.layer.destroy()}}const Ze="handle-line",Ke="handle-start",Je="handle-end";class Qe extends Xe{constructor(t,i={}){super(t,`
|
|
2
|
-
|
|
3
|
-
<div id="${Ze}" data-handle-id="0" class="handle line"></div>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`);m(this,"draggedHandle",B);m(this,"start",{x:0,y:0});m(this,"end",{x:0,y:0});m(this,"arrow",{...le});m(this,"startX",0);m(this,"startY",0);m(this,"minArrowHeight",0);m(this,"maxArrowHeight",0);m(this,"handles",[]);m(this,"onHandleMouseDown",t=>{const i=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!i)return;const{x:o,y:l}=Ht(t,this.ogma.getContainer());this.startDragging(i,o,l),this.draggedHandle=de(t.target)});m(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=B,this.emit(At,this.arrow))});m(this,"onMouseMove",t=>{if(!this.isDragging||this.draggedHandle===B)return;const{x:i,y:o}=Ht(t,this.ogma.getContainer()),l=this.handles[this.draggedHandle],u=this.ogma.view.getAngle(),{x:d,y}=it(Tn({x:i-this.startX,y:o-this.startY},this.ogma.view.getZoom()),u),f=l.id===Ze,p=l.id===Ke,v=l.id===Je;(f||p)&&ce(this.arrow,this.start.x+d,this.start.y+y),(f||v)&&ue(this.arrow,this.end.x+d,this.end.y+y),this.emit(Rt,this.arrow,f?"line":p?"start":"end"),this.refreshEditor(),this.layer.refresh()});this.minArrowHeight=i.minArrowHeight||0,this.maxArrowHeight=i.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(o=>o.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,i,o=_e(t,i,t,i,lt)){var d;this.disableDragging(),this.add(o),this.hoveredId=o.id;const l=this.ogma.view.graphToScreenCoordinates({x:t,y:i}),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(At,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=B)}startDragging(t,i,o){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=i,this.startY=o,this.start=_t(this.arrow),this.end=$t(this.arrow),this.disableDragging(),this.emit(Vt,this.arrow),this.isDragging=!0}detect(t,i=0){return this.elements.find(o=>{const{start:l,end:u}=Pt(o),d=xt(t,{x:(l.x+u.x)/2,y:(l.y+u.y)/2}),y=xt(u,l),f=It(y),p=Pe(y),v=He(o);return Math.abs(ze(p,d))<f/2+i&&Math.abs(ze(it(p,Math.PI/2),d))<v/2+i})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==B?this.getById(this.selectedId):this.getById(this.hoveredId),i=Pt(t),o=this.ogma.view.graphToScreenCoordinates(i.start),l=this.ogma.view.graphToScreenCoordinates(i.end),[u,d,y]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));d.style.transform=`translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`,y.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},p=xt(l,o),v=Ne(p,1/It(p)),S=Math.atan2(v.y,v.x);u.style.width=`${It(p)}px`,u.style.left=`${f.x}px`,u.style.top=`${f.y}px`,u.style.transform=`translate(-50%, -50%) rotate(${S}rad)`}getDefaultOptions(){return le}draw(t){t.innerHTML="";const i=yt("g"),o=this.ogma.view.getAngle();o!==0&&i.setAttribute("transform",`rotate(${-o*(180/Math.PI)})`),this.elements.forEach(l=>kn(l,i,lt,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(i)}refreshDrawing(){const t=this.ogma.view.getAngle();this.layer.element!==null&&t!==0&&this.layer.element.children[0].setAttribute("transform",`rotate(${-t*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const Et={font:"sans-serif",fontSize:18,color:"#505050",background:"#f5f5f5",strokeWidth:0,borderRadius:8,padding:16,strokeType:"plain"},te={id:0,type:"Feature",properties:{type:"text",content:"",style:{...Et}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},ge={handleSize:3.5,placeholder:"Your text..."},tn=(a=0,h=0,t=100,i=50,o="",l={...Et})=>({id:X(),type:"Feature",properties:{type:"text",content:o,style:{...Et,...l}},geometry:{type:"Polygon",coordinates:[[[a,h],[a+t,h],[a+t,h+i],[a,h+i],[a,h]]]}});var ee={exports:{}},On=ee.exports,en;function Mn(){return en||(en=1,function(a,h){(function(t,i){a.exports=i()})(On,()=>(()=>{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)},i={};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(i,{default:()=>pi});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/,y=/\bbold(?:er)?\b/,f=13.3333333,p={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32};function 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 S={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:v,valueOf:v};function x(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=l.exec(e);n.family=(s[6]||"").trim();var r=p[s[2]]||parseFloat(s[2]);s[3]==="%"?r*=.16:s[3]==="em"?r*=16:s[3]==="pt"&&(r*=f),n.size=r;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*r:n.height=c:n.height=c*r:n.height=Math.round(r*(7/6)),u.test(s[1])&&(n.variant="small-caps"),d.test(s[1])&&(n.style="italic"),y.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,r=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,A=12,w=null,k=null,_="";if(r&&r.nodeType){var M=r&&(r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView),C=M.getComputedStyle(r,null);e=C.getPropertyValue("font-family")||"",A=parseFloat(C.getPropertyValue("font-size")),g=C.getPropertyValue("line-height"),w=C.getPropertyValue("font-weight"),k=C.getPropertyValue("font-style"),_=C.getPropertyValue("font-variant")||""}else if(typeof r=="string"){var I=x(r);e=I.family,A=I.size,g=I.height,_=I.variant,k=I.style,w=I.weight}else o(r)==="object"&&(e=r.family,A=r.size,g=r.height,_=r.variant,w=r.weight,k=r.style,n=r.baseline,s=r.color);c.size&&c.size<3&&(A*=c.size),g=g!=="normal"&&g?parseFloat(g):A*(7/6),c.height&&c.height<3&&(g*=c.height);var L=Object.create(S);return L.family=c.family||e||"sans-serif",L.height=g??14,L.size=A??12,L.variant=c.variant||_||"",L.style=c.style||k||"",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 T,$=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(r,c){return s.font=String(c),s.measureText(r).width}}}(typeof document<"u"?document:null)||(T={},function(e,n){if(!T[n]){var s=b(n);T[n]=s,/\bmonospace\b/.test(s.family)?s.size*=.6:(s.size*=.45,s.weight&&(s.size*=1.18))}return e.length*T[n].size}),H={},O={trim:!0,collapse:!0};function z(e,n,s){var r=Object.assign({},O,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 r.trim&&r.collapse?r.trim?c=c.trim():r.collapse&&(c=c.replace(/\s+/g," ")):c=c.replace(/\n/g," "),$(c,n)+n.size*(e.tracking||0)}function F(e){return F=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},F(e)}function mt(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,r){return s.__proto__=r,s},Ft(e,n)}function Bt(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,r=ne(e);if(n){var c=ne(this).constructor;s=Reflect.construct(r,arguments,c)}else s=r.apply(this,arguments);return zn(this,s)}}function zn(e,n){if(n&&(F(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 ne(e){return ne=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ne(e)}function ie(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Hn(e,n){for(var s=0;s<n.length;s++){var r=n[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(c=function(g,A){if(F(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var k=w.call(g,A);if(F(k)!=="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(r.key,"string"),F(c)==="symbol"?c:String(c)),r)}var c}function re(e,n,s){return n&&Hn(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var q=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";ie(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return re(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}(),qt=function(e){mt(s,e);var n=Bt(s);function s(){return ie(this,s),n.apply(this,arguments)}return re(s)}(q),rt=function(e){mt(s,e);var n=Bt(s);function s(){return ie(this,s),n.apply(this,arguments)}return re(s)}(q),Tt=function(e){mt(s,e);var n=Bt(s);function s(){return ie(this,s),n.apply(this,arguments)}return re(s)}(q),ve=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,Rn=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,ln=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Vn=/^(?:[;\xAD%?…]|,(?!\d))/,Fn=/^[´±°¢£¤$¥\u2212]/;function se(e,n){n!==!1&&(e=e.trim());for(var s,r,c=[],g=e.charAt(0),A=0,w=1,k=e.length;w<k;w++){s=e.charAt(w),r=e.charAt(w+1);var _=ve.test(g),M=ve.test(s),C=M||_,I=void 0;if((Fn.test(s)&&!ln.test(g)||Vn.test(g+r)&&!ln.test(s))&&(C=!0),g!=="-"&&g!=="‐"&&g!=="–"&&g!=="—"||((I=ve.test(e.charAt(w-2)))&&!M&&(C=!1),!I&&Rn.test(s+r)&&(C=!0)),C){var L=e.slice(A,w);/\u00AD$/.test(L)?(c.push(new q(L.slice(0,-1))),c.push(new Tt)):(c.push(new q(L)),c.push(new qt)),A=w}g=s}return c.push(new q(e.slice(A))),c}const hn={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 Bn=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,qn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,jn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Un=/^<!--(.+?)-->/,Gn=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,cn={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}},Wn={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 un(e){return e.replace(Gn,function(n,s,r,c){if(s||r){var g=s?10:16;return String.fromCharCode(parseInt(s||r,g))}return c in hn?hn[c]:n})}function Yn(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var Xn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Zn(e){var n,s={};if(e){do if(n=Xn.exec(e)){var r=un(Yn(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(s[n[1]]=r,(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 dn={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 Kn=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Jn=/^%[^\n]+(?:\n|$)/,Qn=/^[^#$%&~_^\\{}]+/,ti=/^\\([&{}$%#_])/,ei=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,ni={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},Y={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 rt,new rt)},newline:function(e){this.tokens.push(new rt)},url:function(e,n){this.open_context().href=n,this.add_token(new q(n)),this.close_context()}};Y.textsuperscript=Y["^"],Y.textsubscript=Y._,Y.textsl=Y.sl,Y.mathbf=Y.bf,Y.mathit=Y.it,Y.textbf=Y.bf,Y.textit=Y.it,Y.textcolor=Y.color;var ii=/[\r\n\xA0]+/g;function ri(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 fn(e,n,s){for(var r,c,g=e.width;g+s.width>n&&e.length;)c=(r=e[e.length-1]).width,r.width>s.width?(r.value=r.value.slice(0,-1),r.width=z(r,r.font),g+=r.width):e.pop(),g-=c;e[e.length-1]instanceof Tt&&e.pop(),r=e[e.length-1]||r||{},s.font=b(s.font,r.bold,r.italic,""),s.href=e.length?r.href:null,s.rel=e.length?r.rel:null,s.target=e.length?r.target:null,e.push(s)}function Ot(e){return Math.round(1e6*e)/1e6}function gn(e){return function(n){if(Array.isArray(n))return we(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 we(n,s);var r=Object.prototype.toString.call(n).slice(8,-1);return r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set"?Array.from(n):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?we(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 we(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,r=new Array(n);s<n;s++)r[s]=e[s];return r}var si={center:"middle",right:"end"},oi={middle:.5,center:.5,bottom:1,end:1},be=function(e,n){return!e&&!n||e===n};function ai(e,n){var s=[],r=n.font(),c=r.size,g=r.family,A=n.align(),w=n.createElement();if(e.length){var k=r.height,_=n.valign(),M=n.height()(),C=n.width()(0),I=!isFinite(C)&&e.length===1,L=I?null:n.x(),j=Ot(k/c),tt=I?null:Ot(k/(1.15*c+(k-c)/2));if(oi[_]&&isFinite(M)){var R=_==="bottom"?1:.5;tt+=(M*R-k*e.length*R)/c}var N=A==="justify",U=0;A==="right"?U=C:A==="center"&&(U=C/2);for(var V=[],et="tspan",Z=null,G="",D=function(){if(G){var St=w(et,Z,G);V.push(St)}et="tspan",Z=null,G=""},st=0,nt=e.length;st<nt;st++){var ft="",vt="",ut=0,gt=e[st];if(gt.length){V=[];for(var Mt=0,Gt=0,pt=void 0,K=0,oe=gt.length;K<oe;K++){var W=gt[K],J=W.font;W.whitespace&&Mt++,Gt+=W.width,K&&!W.tracking&&!ut&&be(J.id,ft)&&be(W.class,vt)&&be(pt,W.href)?G+=W.value:(D(),G=W.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:W.class||null},ut&&(Z.dx=Ot(ut),ut=0),W.tracking&&(ut=J.size*W.tracking),W.href&&!pt?(pt=W.href,et="a",Z.href=pt,Z.rel=W.rel,Z.target=W.target):pt=null,ft=J.id,vt=W.class)}if(D(),I)s.push.apply(s,gn(V));else{var ae=null,Wt=st===nt-1||gt[gt.length-1]instanceof rt;N&>.length>1&&!Wt&&(ae=Ot((C-Gt)/Mt)),s.push(w.apply(void 0,["tspan",{wordSpacing:ae,x:L(st)+U,dy:Ot(st?j:tt)+"em"}].concat(gn(V))))}}else s.push(w("tspan",{x:L(st),dy:Ot(st?j:tt)+"em"}," "))}}return w.apply(void 0,["text",{fontFamily:g,fontSize:c,textAnchor:si[A]||"start"}].concat(s))}var li={middle:.5,center:.5,bottom:1,end:1};function hi(e,n,s){if(e.length){s.textBaseline="middle";var r=n.font(),c=r.height,g=r.size,A=n.valign(),w=n.height()(),k=n.width()(0),_=n.align(),M=_==="justify",C=.5*c,I=li[A];if(I&&isFinite(w)){var L=e.length*c;C+=w*I-L*I}e.forEach(function(j,tt){var R=n.x()(tt),N=tt*c+C,U=0,V=0;j.forEach(function(G){G.whitespace&&U++,V+=G.width});var et=0,Z=tt===e.length-1||j[j.length-1]instanceof rt;M&&j.length>1&&!Z&&(et=(k-V)/U),j.forEach(function(G){s.font=G.font;var D=G.font,st=D.baseline?g*-D.baseline+.15*g:0;s.fillStyle=function(vt,ut){return vt.color?vt.color:ut.href?"#00C":"#000"}(D,G);var nt=0;if(_==="right"?nt+=k-V:_==="center"?nt+=k/2-V/2:_==="justify"&&(G.whitespace||G instanceof rt)&&(R+=et),s.fillText(G.value,R+nt,N+st),G.href){s.beginPath(),s.strokeStyle=s.fillStyle;var ft=Math.floor(N+.45*g)+.5;s.moveTo(R+nt,ft),s.lineTo(R+nt+G.width,ft),s.stroke()}R+=G.width})})}}function xe(e){return xe=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},xe(e)}function pn(e){for(var n={},s=0;s<e.length;s++){var r=e[s];typeof r!="number"&&r!=null&&(typeof r=="string"?n.text=r:typeof r=="function"?n.fn=r:xe(r)==="object"&&r._groups?n.d3=r:r&&r.nodeType&&r.getContext?n.ctx=r.getContext("2d"):r&&r.fillText&&r.beginPath?n.ctx=r:r&&(n.text=r))}return n}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 ci(e,n){for(var s=0;s<n.length;s++){var r=n[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(c=function(g,A){if(jt(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var k=w.call(g,A);if(jt(k)!=="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(r.key,"string"),jt(c)==="symbol"?c:String(c)),r)}var c}var ui=b(),Ae=function(e){return typeof e=="function"?e:function(){return e}},at=function(){function e(r){if(function(g,A){if(!(g instanceof A))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},r)for(var c in r)typeof this[c]=="function"&&this[c](r[c])}var n,s;return n=e,s=[{key:"linebreak",value:function(r){var c=this,g=this.props.parser(String(r)),A=this.font(),w=function(k,_,M){if(!k.length)return[];var C=_.height(),I=_.width(),L=_.overflowLine(),j=_.overflowWrap(),tt=b(M,!0,!1),R=isFinite(C())?Math.floor(C()/M.height):1/0;if(!C()&&!I(0)||!R)return[];for(var N=0,U=0,V=0,et=[],Z=[],G=!1;N<k.length&&U<R;){var D=k[N],st=ri(D,M);if(D.width=z(D,st),D.font=st,D.line=U,D.whitespace=D.value in P,D.value&&(D.value=D.value.replace(ii," ")),!(!V&&D.whitespace||G&&D.whitespace))if(D instanceof rt)V=0,Z=[],et.push(N+1),U++;else if(D instanceof qt||D instanceof Tt)Z.push({index:N,width:V});else if(D.whitespace||V+D.width<I(U))V+=D.width;else if(Z.length){var nt=void 0,ft=void 0;do{ft=!0,nt=Z.pop();var vt=k[nt.index],ut=void 0;vt instanceof Tt&&(ut=z("-",vt.font),nt.width+ut>I(U)&&(ft=!Z.length))}while(!ft);et.push(nt.index+1),V=0,U++,N=nt.index,Z=[]}else if(j==="break-word"){var gt=I(U);if(V+D.width>gt){var Mt=D.clone();do D.value=D.value.slice(0,-1),D.width=z(D,D.font),V+=D.width;while(D.value&&D.width>gt);Mt.value=Mt.value.slice(D.value.length),k.splice(N+1,0,new qt,Mt)}et.push(N+1),V=0,U++}else V+=D.width;N++,G=D.whitespace}N!==et[et.length-1]&&et.push(N);var Gt=0,pt=0,K=et.map(function(St){for(var Q,kt=Gt;(Q=k[kt])&&(Q.whitespace||!Q.value);)kt++;for(var wt=St,Se=null;wt>kt&&(Q=k[wt-1])&&(Q.whitespace||!(Q.value||Q instanceof Tt));)Q instanceof rt&&(Se=Q),wt--;Q instanceof Tt&&(Q.value="-",Q.width=z("-",Q.font)),Gt=St;var Ct=k.slice(kt,wt).filter(function(ke){return ke.value});return Se&&Ct.push(Se),Ct.width=Ct.reduce(function(ke,yi){return ke+yi.width},0),Ct.width>pt&&(pt=Ct.width),Ct});if(K.hasLineOverflow=!1,L){var oe=L==="ellipsis"?"…":L;K.forEach(function(St,Q){var kt=I(Q);if(St.width>kt){var wt=new q(oe);wt.font=M,wt.width=z(oe,tt),fn(St,kt,wt),K.hasLineOverflow=!0}})}var W=_.overflow()==="ellipsis"?"…":_.overflow();if(W&&N!==k.length){var J=I(K.length-1),ae=K[K.length-1],Wt=new q(W);Wt.font=M,Wt.width=z(W,tt),fn(ae,J,Wt),K.hasOverflow=!0}else K.hasOverflow=!1;return K.font=M,K.width=pt,K}(g,this,A);return w.height=w.length*A.height,w.render=function(k){return c.render(w,k)},w.svg=w.render,w.draw=w.render,w}},{key:"font",value:function(r){return arguments.length?(this.props.font=b(r),this):this.props.font||b(ui)}},{key:"overflow",value:function(r){return arguments.length?(this.props.overflow=String(r),this):this.props.overflow}},{key:"overflowLine",value:function(r){return arguments.length?(this.props.lineclamp=String(r),this):this.props.lineclamp}},{key:"valign",value:function(r){return arguments.length?(this.props.valign=r,this):this.props.valign}},{key:"align",value:function(r){if(!arguments.length)return this.props.align;var c=String(r).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=r,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(r){if(!arguments.length)return this.props.overflowWrap||"normal";var c=String(r).toLowerCase();return c==="break-word"?this.props.overflowWrap="break-word":c!=="normal"&&r!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(r){return arguments.length?(this.props.width=Ae(r),this):this.props.width}},{key:"height",value:function(r){return arguments.length?(this.props.height=Ae(r),this):this.props.height}},{key:"x",value:function(r){return arguments.length?(this.props.x=Ae(r),this):this.props.x}},{key:"parser",value:function(r){if(!arguments.length)return this.props.parser;if(typeof r=="string"){var c=e[r]||e[r+"parser"];typeof c=="function"&&(r=c)}if(typeof r!="function")throw new Error("Unknown parser: "+r);return this.props.parser=r,this}},{key:"createElement",value:function(r){return arguments.length?(this.props.createElement=r,this):this.props.createElement||e.createElement}},{key:"render",value:function(){var r=pn(arguments);return typeof r.text=="string"&&(r.text=this.linebreak(r.text)),r.ctx?hi(r.text,this,r.ctx):ai(r.text,this)}}],s&&ci(n.prototype,s),Object.defineProperty(n,"prototype",{writable:!1}),e}();function Ut(e){return Ut=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},Ut(e)}function Ee(e,n){(n==null||n>e.length)&&(n=e.length);for(var s=0,r=new Array(n);s<n;s++)r[s]=e[s];return r}function di(e,n){for(var s=0;s<n.length;s++){var r=n[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(c=function(g,A){if(Ut(g)!=="object"||g===null)return g;var w=g[Symbol.toPrimitive];if(w!==void 0){var k=w.call(g,A);if(Ut(k)!=="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(r.key,"string"),Ut(c)==="symbol"?c:String(c)),r)}var c}var yn=function(e){return typeof e=="function"?e:function(){return e}},mn=function(){function e(r){if(function(g,A){if(!(g instanceof A))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},r)for(var c in r)typeof this[c]=="function"&&this[c](r[c]);this.render=this.render.bind(this)}var n,s;return n=e,s=[{key:"anchor",value:function(r){var c=this.props,g=c.hAnchor,A=c.vAnchor,w=c.width,k=c.height;if(!arguments.length)return[g*w(0),A*k(0)];if(typeof r=="string"){var _=this.props;r.toLowerCase().trim().split(/\s+/).forEach(function(M){M==="top"&&(_.vAnchor=-0),M==="middle"&&(_.vAnchor=-.5),M==="bottom"&&(_.vAnchor=-1),M==="left"&&(_.hAnchor=-0),M==="center"&&(_.hAnchor=-.5),M==="right"&&(_.hAnchor=-1)})}return this}},{key:"width",value:function(r){return arguments.length?(this.props.width=yn(r),this):this.props.width}},{key:"height",value:function(r){return arguments.length?(this.props.height=yn(r),this):this.props.height}},{key:"rotate",value:function(r){return arguments.length?(this.props.rotation=r,this):this.props.rotation}},{key:"createElement",value:function(r){return arguments.length?(this.props.createElement=r,this):this.props.createElement||e.createElement}},{key:"canvas",value:function(r,c){var g,A=r.getContext?r.getContext("2d"):r;return A.save(),A.rotate(this.rotate()*Math.PI/180),A.translate.apply(A,function(w){if(Array.isArray(w))return Ee(w)}(g=this.anchor())||function(w){if(typeof Symbol<"u"&&w[Symbol.iterator]!=null||w["@@iterator"]!=null)return Array.from(w)}(g)||function(w,k){if(w){if(typeof w=="string")return Ee(w,k);var _=Object.prototype.toString.call(w).slice(8,-1);return _==="Object"&&w.constructor&&(_=w.constructor.name),_==="Map"||_==="Set"?Array.from(w):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Ee(w,k):void 0}}(g)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`);m(this,"textArea");m(this,"handleSize");m(this,"rect",{x:0,y:0,width:0,height:0});m(this,"annotation",{...te});m(this,"startX",0);m(this,"startY",0);m(this,"handles",[]);m(this,"draggedHandle",B);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,i,o=tn(t,i,0,0,"",Et))=>{this.add(o);const l=this.ogma.view.graphToScreenCoordinates({x:t,y:i});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={...te},this.draggedHandle=B,this.isDragging=!1,this.emit(At,this.annotation))});m(this,"startDragging",(t,i,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=i,this.startY=o,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Vt,this.annotation),this.isDragging=!0});m(this,"onHandleMouseDown",t=>{const i=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!i)return;this.selectedId!==i.id&&this.select(this.hoveredId);const{x:o,y:l}=Ht(t,this.ogma.getContainer());this.startDragging(i,o,l),this.draggedHandle=de(t.target)});m(this,"onMouseMove",t=>{requestAnimationFrame(()=>this._onMouseMove(t))});m(this,"_onMouseMove",t=>{if(!this.isDragging)return;t.stopPropagation(),t.preventDefault();const i=this.handles[this.draggedHandle];let o=i.classList.contains("top");const l=i.classList.contains("left"),u=i.classList.contains("right"),d=i.classList.contains("bottom");let y=i.classList.contains("line-handle");!y&&!o&&!d&&!l&&!u&&(o=!0,y=!0);const{x:f,y:p}=Ht(t,this.ogma.getContainer());let v=this.rect.x,S=this.rect.y,x=Math.max(this.rect.width,rn),b=Math.max(this.rect.height,rn);const P=this.ogma.view.getZoom(),T=(f-this.startX)/P,$=(p-this.startY)/P,H=this.ogma.view.getAngle(),O=it({x:T,y:$},H),z=it({x:T,y:$},-H);y?(v=this.rect.x+O.x,S=this.rect.y+O.y):l&&o?(v+=O.x,S+=O.y,x-=T,b-=$):u&&d?(x+=T,b+=$):l&&d?(v+=z.x,x-=z.x,b+=z.y):u&&o&&(S+=z.y,x+=z.x,b-=z.y),De(this.annotation,v,S,x,b),this.emit(Rt,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()});m(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===B||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(At,this.annotation),this.isDragging=!1,this.draggedHandle=B)});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}`),this.ogma.view.getAngle()===0?this.editor.element.classList.remove("rotated"):this.editor.element.classList.add("rotated")});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(Qt,t),this.layer.refresh())});this.showeditorOnHover=!1,this.handleSize=ge.handleSize||i.textHandleSize,this.placeholder=ge.placeholder||i.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.push(this.editor.element),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:i},o=0){const l={x:t,y:i},u=this.ogma.view.getAngle();return this.elements.find(d=>{const{x:y,y:f}=ct(d),{width:p,height:v}=ht(d),S={x:y,y:f},{x,y:b}=it(xt(l,S),-u);return x>-o&&x<p+o&&b>-o&&b<v+o})}draw(t){t.innerHTML="";const i="",o=this.ogma.view.getAngle();for(let u=0;u<this.elements.length;u++){const d=this.elements[u],y=`class${u}`,f=ht(d),p=ct(d);if(d.id===this.selectedId)continue;const{color:S,fontSize:x,font:b,strokeColor:P,strokeWidth:T,strokeType:$,background:H,borderRadius:O}=d.properties.style||Et,z=yt("g");z.classList.add("annotation-text"),z.setAttribute("fill",`${S}`),z.setAttribute("font-size",`${x}px`),z.setAttribute("font-family",`${b}`);const F=yt("rect");O&&(F.setAttribute("rx",`${O}`),F.setAttribute("ry",`${O}`));let mt=!1;$&&$!=="none"&&(mt=!0,F.setAttribute("stroke",P||"black"),F.setAttribute("stroke-width",`${T}`),$==="dashed"&&F.setAttribute("stroke-dasharray","5,5")),(H&&H.length||mt)&&(mt=!0,F.setAttribute("fill",H||"transparent")),mt&&(F.setAttribute("width",`${f.width}`),F.setAttribute("height",`${f.height}`)),z.appendChild(F),Ln(d,z);const{x:Ft,y:Bt}=it(p,-o);z.setAttribute("transform",`translate(${Ft},${Bt})`),z.classList.add(y),z.setAttribute("data-annotation",`${d.id}`),z.setAttribute("data-annotation-type","text"),t.appendChild(z)}const l=yt("style");l.innerHTML=i,t.firstChild&&t.insertBefore(l,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle(),i=this.layer.element.children;for(let o=0;o<i.length;o++){const l=i[o];if(!l.hasAttribute("data-annotation"))continue;const u=l.getAttribute("data-annotation"),d=ct(this.getById(u)),{x:y,y:f}=it(d,-t);l.setAttribute("transform",`translate(${y},${f})`)}}getDefaultOptions(){return te}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),i=ht(t),o=this.ogma.view.graphToScreenCoordinates(ct(t)),l=this.ogma.view.getZoom(),{font:u,fontSize:d,color:y,background:f,padding:p=0}=t.properties.style||Et,v=(d||1)*l;this.textArea.value=t.properties.content;const S=this.editor.element.style;S.transform=`translate(${o.x}px, ${o.y}px)translate(-50%, -50%)translate(${i.width/2*l}px, ${i.height/2*l}px)`,S.width=`${i.width*l}px`,S.height=`${i.height*l}px`;const x=this.textArea.style;x.font=`${v} ${u}`,x.fontFamily=u||"sans-serif",x.fontSize=`${v}px`,x.padding=`${l*p}px`,x.lineHeight=`${v}px`,x.boxSizing="border-box",x.color=y||"black",x.background=f||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.classList.add("noevents")}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class $n{constructor(){m(this,"links",{});m(this,"linksByTargetId",{});m(this,"linksByArrowId",{})}add(h,t,i,o,l){const u=X(),d=h.id,y={id:u,arrow:d,target:i,targetType:o,connectionPoint:l,side:t};return this.links[u]=y,this.linksByTargetId[i]||(this.linksByTargetId[i]=[]),this.linksByTargetId[i].push(u),this.linksByArrowId[d]||(this.linksByArrowId[d]={}),this.linksByArrowId[d][t]=u,h.properties.link=h.properties.link||{},h.properties.link[t]={id:i,side:t,type:o,magnet:l},this}arrowIsLinked(h,t){var i;return!!((i=this.linksByArrowId[h])!=null&&i[t])}remove(h,t){var d,y;const i=h.id,o=(d=this.linksByArrowId[i])==null?void 0:d[t];if((y=h.properties.link)==null||delete y[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[i][t],this}getArrowLink(h,t){var o;const i=(o=this.linksByArrowId[h])==null?void 0:o[t];return i?this.links[i]:null}getTargetLinks(h,t){var i;return((i=this.linksByTargetId[h])==null?void 0:i.map(o=>this.links[o]).filter(o=>o.targetType===t))??[]}forEach(h){Object.values(this.links).forEach(h)}}const ot=a=>a.properties.type==="arrow",dt=a=>a.properties.type==="text",me=a=>a.type==="FeatureCollection",Pn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},on=["start","end"],an=[{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 Nn extends Ye{constructor(t,i={}){super();m(this,"arrows");m(this,"texts");m(this,"links",new $n);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 i=this.ogma.view.getZoom();an.forEach(o=>{if(!this.textToMagnet)return;const l=ht(this.textToMagnet),u=ct(this.textToMagnet),d=Yt(o,{x:l.width,y:l.height}),y=it(d,this.ogma.view.getAngle()),{x:f,y:p}=Dt(y,u);t.moveTo(f,p),t.arc(f,p,this.options.magnetHandleRadius/i,0,Math.PI*2)}),t.fill(),t.closePath()});m(this,"_onFeatureDrag",(t,i)=>{const o=i;if(ot(t)&&o==="line")["start","end"].find(l=>{const u=l==="start"?_t(t):$t(t);return this._snapToText(t,o,u)||this._findAndSnapToNode(t,l,u)});else if(ot(t)&&o!=="line"){const l=o==="start"?_t(t):$t(t);this._snapToText(t,o,l)||this._findAndSnapToNode(t,o,l)}else dt(t)&&(this.activeLinks.forEach(({arrow:l,side:u,connectionPoint:d})=>{const y=this.getAnnotation(l),f=ht(t),p=ct(t),v=Yt(d,{x:f.width,y:f.height}),S=it(v,this.ogma.view.getAngle()),x=Dt(S,p);y.geometry.coordinates[u==="start"?0:1]=[x.x,x.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(Rt,t,i)});m(this,"_onFeatureDragEnd",t=>{this.dragged!==null&&ot(t)&&_t(this.dragged)&&on.forEach(i=>{this.links.getArrowLink(t.id,i)&&this.emit(Ue,{arrow:t,link:this.links.getArrowLink(t.id,i)})}),(dt(t)||ot(t))&&this.onUpdate(t),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(i=>i.enableDetection()),this.layer.refresh(),this.emit(At,t)});m(this,"_onFeatureDragStart",t=>{this.textToMagnet=void 0,ot(t)?this.dragged=t:dt(t)&&this.activeLinks.push(...this.links.getTargetLinks(t.id,"text")),this.annotations.forEach(i=>{const o=i.getSelectedFeature();o&&o!==t&&i.unhover().unselect(),i.disableDetection()}),this.emit(Vt,t)});m(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()});m(this,"_onNodesDrag",t=>{const{dx:i,dy:o}=t;this._moveNodes(t.nodes,i,o)});m(this,"_onLayoutEnd",t=>{t.ids.forEach((i,o)=>{this.links.getTargetLinks(i,"node").forEach(u=>{const d=this.getAnnotation(u.arrow),y=u.side,f=Lt(d,y==="start"?"end":"start"),p=t.positions.current[o],v=this.ogma.getNode(i).getAttribute("radius"),S=zt(f,p,+v);bt(d,y,S.x,S.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()});m(this,"_onAdded",t=>{this.emit(Jt,t)});m(this,"_onRemoved",t=>{this.emit(Kt,t)});m(this,"_onUnselect",t=>{this.selected=null,this.emit(Zt,t)});m(this,"_onSelect",t=>{this.selected!==t&&(this.selected=t,this.emit(Xt,this.selected))});m(this,"onUpdate",t=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(t))});m(this,"_onUpdate",t=>{this.emit(Qt,t)});this.options=this.setOptions({...Pn,...i}),this.ogma=t,this.arrows=new Qe(t,this.options),this.texts=new sn(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(o=>{o.on(Vt,this._onFeatureDragStart).on(Rt,this._onFeatureDrag).on(At,this._onFeatureDragEnd).on(Qt,this.onUpdate).on(Zt,this._onUnselect).on(Xt,this._onSelect).on(Jt,this._onAdded).on(Kt,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=t.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(t,i,o){t.forEach(l=>{const u=this.links.getTargetLinks(l.getId(),"node"),d=l.getPosition();u.forEach(y=>{const f=this.getAnnotation(y.arrow),p=y.side,v=Lt(f,p==="start"?"end":"start");let S=d;const x=+l.getAttribute("radius"),b=1e-6;(y.connectionPoint.x-(d.x-i)>b||y.connectionPoint.y-(d.y-o)>b)&&(S=zt(v,d,x)),bt(f,p,S.x,S.y)})}),this.arrows.refreshLayer()}_snapToText(t,i,o){const l=this.texts.detect(o,this.options.detectMargin);if(this.links.remove(t,i),!l)return!1;this.textToMagnet=l;const u=this.findMagnetPoint(an,l,o);return u?(bt(t,i,u.point.x,u.point.y),this.links.add(t,i,l.id,"text",u.magnet),!0):!1}_findAndSnapToNode(t,i,o){var d,y;const l=this.ogma.view.graphToScreenCoordinates(o),u=this.ogma.view.getElementAt(l);this.links.remove(t,i),u&&u.isNode?((d=this.hoveredNode)==null||d.setSelected(!1),this.hoveredNode=u,u.setSelected(!0),this._snapToNode(t,i,u,l)):((y=this.hoveredNode)==null||y.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,i,o,l){const u=o.getPositionOnScreen(),d=+o.getAttribute("radius"),y=d*this.ogma.view.getZoom(),f=l.x-u.x,p=l.y-u.y,v=Math.sqrt(f*f+p*p),S=o.getPosition();if(v<y+this.options.detectMargin){let x=S;if(v>y/2){const b=Lt(t,i==="end"?"start":"end");x=zt(b,x,d)}bt(t,i,x.x,x.y),this.links.add(t,i,o.getId(),"node",x)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:i,targetType:o,target:l,arrow:u,side:d})=>{if(o!=="text")return;t=!0;const y=this.getAnnotation(l),f=this.getAnnotation(u),p=ht(y),v=ct(y),S=Yt(i,{x:p.width,y:p.height}),x=it(S,this.ogma.view.getAngle()),b=Dt(x,v);bt(f,d,b.x,b.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,i,o){let l;for(const u of t){const d=ht(i),y=ct(i),f=Yt(u,{x:d.width,y:d.height}),p=it(f,this.ogma.view.getAngle()),v=Dt(p,y),S=It(xt(v,o)),x=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),d.width/2,d.height/2);if(S<Math.max(x,this.options.magnetHandleRadius)){l={point:v,magnet:u};break}}return l}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const i=this.getAnnotations().features.find(o=>o.id===t);return i?(ot(i)?this.arrows.select(i.id):dt(i)&&this.texts.select(i.id),this):this}unselect(){return this.selected?(ot(this.selected)?this.arrows.unselect():dt(this.selected)&&this.texts.unselect(),this):this}add(t){if(me(t)){const[i,o]=t.features.reduce((l,u)=>(ot(u)?l[1].push(u):dt(u)&&l[0].push(u),l),[[],[]]);return i.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 me(t)?(t.features.forEach(i=>this.remove(i)),this):(ot(t)?(this.links.remove(t,"start"),this.links.remove(t,"end"),this.arrows.remove(t.id)):this.texts.remove(t.id),this)}loadLink(t){if(t.properties.link)for(const i of on){const o=t.properties.link[i];if(!o)continue;const l=this.getAnnotation(o.id);if(o.type==="text"&&l)this.links.add(t,i,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,i,o.id,o.type,o.magnet);const d=u.getPosition(),y=u.getAttribute("radius")||0,f=Lt(t,i==="start"?"end":"start"),p=zt(f,d,+y);bt(t,i,p.x,p.y)}}}startArrow(t,i,o){this.cancelDrawing(),this.arrows.startDrawing(t,i,o)}startText(t,i,o){this.cancelDrawing(),this.texts.startDrawing(t,i,o)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(je)}updateStyle(t,i){const o=this.getAnnotations().features.find(l=>l.id===t);return o?(ot(o)?this.arrows.updateStyle(o,i):dt(o)&&this.texts.updateStyle(o,i),this.onUpdate(o),this):this}setScale(t,i,o,l){const u=this.getAnnotations().features.find(d=>d.id===t);return u?(ot(u)?this.arrows.scale(u,i,o,l):dt(u)&&this.texts.scale(u,i,o,l),this.onUpdate(u),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(i=>{t.features=[...t.features,...i.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(i=>i.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}E.Arrows=Qe,E.Control=Nn,E.EVT_ADD=Jt,E.EVT_CANCEL_DRAWING=je,E.EVT_DRAG=Rt,E.EVT_DRAG_END=At,E.EVT_DRAG_START=Vt,E.EVT_HOVER=Be,E.EVT_LINK=Ue,E.EVT_REMOVE=Kt,E.EVT_SELECT=Xt,E.EVT_UNHOVER=qe,E.EVT_UNSELECT=Zt,E.EVT_UPDATE=Qt,E.NONE=B,E.Texts=sn,E.clientToContainerPosition=Ht,E.colorToRgba=En,E.createArrow=_e,E.createSVGElement=yt,E.createText=tn,E.defaultArrowOptions=le,E.defaultArrowStyle=lt,E.defaultControllerOptions=ge,E.defaultTextOptions=te,E.defaultTextStyle=Et,E.getAnnotationsBounds=xn,E.getArrowEnd=$t,E.getArrowEndPoints=Pt,E.getArrowSide=Lt,E.getArrowStart=_t,E.getAttachmentPointOnNode=zt,E.getCoordinates=Nt,E.getHandleId=de,E.getTextBbox=he,E.getTextPosition=ct,E.getTextSize=ht,E.hexShortToLong=Me,E.hexToRgba=Ce,E.isAnnotationCollection=me,E.isArrow=ot,E.isText=dt,E.rgbToRgba=Le,E.scaleGeometry=Oe,E.setArrowEnd=ue,E.setArrowEndPoint=bt,E.setArrowStart=ce,E.setTextBbox=De,E.updateTextBbox=Ie,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(w,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("@linkurious/ogma")):typeof define=="function"&&define.amd?define(["exports","@linkurious/ogma"],O):(w=typeof globalThis<"u"?globalThis:w||self,O(w["@linkurious/ogma-annotations"]={},w.Ogma))})(this,(function(w,O){"use strict";var Yr=Object.defineProperty;var Xr=(w,O,pt)=>O in w?Yr(w,O,{enumerable:!0,configurable:!0,writable:!0,value:pt}):w[O]=pt;var y=(w,O,pt)=>Xr(w,typeof O!="symbol"?O+"":O,pt);function pt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Jt={exports:{}},Oe;function Vn(){return Oe||(Oe=1,(function(i){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function r(l,h,c,d,u){if(typeof c!="function")throw new TypeError("The listener must be a function");var g=new s(c,d||l,u),f=t?t+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],g]:l._events[f].push(g):(l._events[f]=g,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new n:delete l._events[h]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,d;if(this._eventsCount===0)return h;for(d in c=this._events)e.call(c,d)&&h.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=t?t+h:h,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,g=d.length,f=new Array(g);u<g;u++)f[u]=d[u].fn;return f},a.prototype.listenerCount=function(h){var c=t?t+h:h,d=this._events[c];return d?d.fn?1:d.length:0},a.prototype.emit=function(h,c,d,u,g,f){var m=t?t+h:h;if(!this._events[m])return!1;var p=this._events[m],b=arguments.length,S,v;if(p.fn){switch(p.once&&this.removeListener(h,p.fn,void 0,!0),b){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,d),!0;case 4:return p.fn.call(p.context,c,d,u),!0;case 5:return p.fn.call(p.context,c,d,u,g),!0;case 6:return p.fn.call(p.context,c,d,u,g,f),!0}for(v=1,S=new Array(b-1);v<b;v++)S[v-1]=arguments[v];p.fn.apply(p.context,S)}else{var A=p.length,x;for(v=0;v<A;v++)switch(p[v].once&&this.removeListener(h,p[v].fn,void 0,!0),b){case 1:p[v].fn.call(p[v].context);break;case 2:p[v].fn.call(p[v].context,c);break;case 3:p[v].fn.call(p[v].context,c,d);break;case 4:p[v].fn.call(p[v].context,c,d,u);break;default:if(!S)for(x=1,S=new Array(b-1);x<b;x++)S[x-1]=arguments[x];p[v].fn.apply(p[v].context,S)}}return!0},a.prototype.on=function(h,c,d){return r(this,h,c,d,!1)},a.prototype.once=function(h,c,d){return r(this,h,c,d,!0)},a.prototype.removeListener=function(h,c,d,u){var g=t?t+h:h;if(!this._events[g])return this;if(!c)return o(this,g),this;var f=this._events[g];if(f.fn)f.fn===c&&(!u||f.once)&&(!d||f.context===d)&&o(this,g);else{for(var m=0,p=[],b=f.length;m<b;m++)(f[m].fn!==c||u&&!f[m].once||d&&f[m].context!==d)&&p.push(f[m]);p.length?this._events[g]=p.length===1?p[0]:p:o(this,g)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=t?t+h:h,this._events[c]&&o(this,c)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,i.exports=a})(Jt)),Jt.exports}var Zn=Vn();const Kn=pt(Zn),Jn=-1,Et="dragging",yt="dragstart",Rt="dragend",zt="click",$e="select",Ye="unselect",Qn="hover",ts="unhover",Xe="remove",Nt="add",Ue="cancelDrawing",Qt="completeDrawing",qe="update",We="link",Ge="history",es="data-annotation",te=5,je=3,Ot={SHAPES:1,EDITOR:2,HANDLES:3},q="start",it="end",F={default:"default",move:"move",pointer:"pointer",crosshair:"crosshair",grab:"grab",grabbing:"grabbing",ewResize:"ew-resize",nsResize:"ns-resize",neswResize:"nesw-resize",nwseResize:"nwse-resize",nwResize:"nw-resize",neResize:"ne-resize",swResize:"sw-resize",seResize:"se-resize",nResize:"n-resize",eResize:"e-resize",sResize:"s-resize",wResize:"w-resize"},et="collapsed",$t="expanded",Yt=1.2,ee=.2,P={TEXT:"text",NODE:"node",BOX:"box",COMMENT:"comment",POLYGON:"polygon",ANNOTATION:"annotation",EDGE:"edge"},ne=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
</svg>`;let at=(i=21)=>crypto.getRandomValues(new Uint8Array(i)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");function ns(i,e){const t=i[0]-e[0],n=i[1]-e[1];return t*t+n*n}function ss(i,e,t){let n=e[0],s=e[1],r=t[0]-n,o=t[1]-s;if(r!==0||o!==0){const a=((i[0]-n)*r+(i[1]-s)*o)/(r*r+o*o);a>1?(n=t[0],s=t[1]):a>0&&(n+=r*a,s+=o*a)}return r=i[0]-n,o=i[1]-s,r*r+o*o}function is(i,e){let t=i[0];const n=[t];let s;for(let r=1,o=i.length;r<o;r++)s=i[r],ns(s,t)>e&&(n.push(s),t=s);return t!==s&&n.push(s),n}function se(i,e,t,n,s){let r=n,o=0;for(let a=e+1;a<t;a++){const l=ss(i[a],i[e],i[t]);l>r&&(o=a,r=l)}r>n&&(o-e>1&&se(i,e,o,n,s),s.push(i[o]),t-o>1&&se(i,o,t,n,s))}function rs(i,e){const t=i.length-1,n=[i[0]];return se(i,0,t,e,n),n.push(i[t]),n}function ie(i,e,t){if(i.length<=2)return i;const n=e!==void 0?e*e:1;return i=t?i:is(i,n),i=rs(i,n),i}function re(i){if(i.geometry.bbox)return i.geometry.bbox;const e=i.geometry.coordinates[0];let t=1/0,n=1/0,s=-1/0,r=-1/0;for(const[o,a]of e)o<t&&(t=o),o>s&&(s=o),a<n&&(n=a),a>r&&(r=a);return[t,n,s,r]}function oe(i){const e=i.geometry.coordinates[0];let t=0,n=0;const s=e.length-1;for(let r=0;r<s;r++)t+=e[r][0],n+=e[r][1];return{x:t/s,y:n/s}}function Ve(i,e,t){const n=i.geometry.coordinates.map(o=>o.map(([a,l])=>[a+e,l+t])),s=i.geometry.bbox,r=s?[s[0]+e,s[1]+t,s[2]+e,s[3]+t]:void 0;return{...i,geometry:{...i.geometry,coordinates:n,bbox:r}}}function ae(i){const e=i.geometry.coordinates[0];let t=1/0,n=1/0,s=-1/0,r=-1/0;for(const[o,a]of e)o<t&&(t=o),o>s&&(s=o),a<n&&(n=a),a>r&&(r=a);i.geometry.bbox=[t,n,s,r]}function os(i,e,t,n){const s=i.geometry.coordinates.map(o=>o.map(([a,l])=>{const h=a-t,c=l-n;return[t+h*e,n+c*e]})),r={...i,geometry:{...i.geometry,coordinates:s}};return ae(r),r}const as="http://www.w3.org/2000/svg";function k(i){return document.createElementNS(as,i)}function tt(i){return i.geometry.bbox||ct(i),i.geometry.bbox}function z(i){if("width"in i.properties&&"height"in i.properties)return{width:i.properties.width,height:i.properties.height};const e=tt(i);return{width:e[2]-e[0],height:e[3]-e[1]}}function lt(i,e=!1,t=1){if(i.geometry.type==="Point"&&"width"in i.properties&&"height"in i.properties){const[s,r]=i.geometry.coordinates;let o=i.properties.width,a=i.properties.height;return e&&(o/=t,a/=t),{x:s-o/2,y:r-a/2}}const n=tt(i);return{x:n[0],y:n[1]}}function W(i){if(i.geometry.type==="Point")return{x:i.geometry.coordinates[0],y:i.geometry.coordinates[1]};const e=tt(i);return{x:(e[0]+e[2])/2,y:(e[1]+e[3])/2}}function ct(i){if(J(i)){const[e,t]=i.geometry.coordinates[0],[n,s]=i.geometry.coordinates[1];i.geometry.bbox=[Math.min(e,n),Math.min(t,s),Math.max(e,n),Math.max(t,s)]}else if(i.geometry.type==="Point"&&"width"in i.properties&&"height"in i.properties){const[e,t]=i.geometry.coordinates,n=i.properties.width/2,s=i.properties.height/2;i.geometry.bbox=[e-n,t-s,e+n,t+s]}else if(i.geometry.type==="Polygon"){const e=i.geometry.coordinates[0];let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const o of e){const a=o[0],l=o[1];a<t&&(t=a),l<n&&(n=l),a>s&&(s=a),l>r&&(r=l)}i.geometry.bbox=[t,n,s,r]}}function Ze(i,e,t,n,s){i.geometry.coordinates=[e+n/2,t+s/2],i.geometry.bbox=[e,t,e+n,t+s],i.properties.width=n,i.properties.height=s}function le(i){const[e,t]=i.geometry.coordinates[0];return{x:e,y:t}}function Ct(i,e){const[t,n]=i.geometry.coordinates[e===q?0:1];return{x:t,y:n}}function ce(i){const[e,t]=i.geometry.coordinates[1];return{x:e,y:t}}function Ke(i,e,t){i.geometry.coordinates[0]=[e,t]}function Je(i,e,t){i.geometry.coordinates[1]=[e,t]}function Xt(i){return{start:le(i),end:ce(i)}}function Qe(i,e,t,n){e===q?Ke(i,t,n):Je(i,t,n)}const ls=i=>parseInt(i.getAttribute("data-handle-id")||"-1");function cs(i){return Tt(i).reduce((e,t)=>(e[0]=Math.min(t[0],e[0]),e[1]=Math.min(t[1],e[1]),e[2]=Math.max(t[0],e[2]),e[3]=Math.max(t[1],e[3]),e),[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY])}function hs(i){return Array.isArray(i)&&i.length===2&&i.every(isFinite)}function ds(i,e,t,n){for(let s=0;s<i.coordinates.length;s++){const r=i.coordinates[s];if(hs(r))r[0]=t+(r[0]-t)*e,r[1]=n+(r[1]-n)*e;else for(let o=0;o<r.length;o++){const a=r[o];a[0]=t+(a[0]-t)*e,a[1]=n+(a[1]-n)*e}}return i}function Tt(i){let e=[];if(i.type=="Point")i.bbox?e=[[i.bbox[0],i.bbox[1]],[i.bbox[2],i.bbox[3]]]:e=[i.coordinates];else if(i.type=="LineString"||i.type=="MultiPoint")e=i.coordinates;else if(i.type=="Polygon"||i.type=="MultiLineString")e=i.coordinates.reduce(function(t,n){return t.concat(n)},[]);else if(i.type=="MultiPolygon")e=i.coordinates.reduce((t,n)=>t.concat(n.reduce((s,r)=>s.concat(r),[])),[]);else if(i.type=="Feature")if(L(i)||G(i)){const t=tt(i);e=[[t[0],t[1]],[t[2],t[3]]]}else e=Tt(i.geometry);else i.type=="GeometryCollection"?e=i.geometries.reduce((t,n)=>t.concat(Tt(n)),[]):i.type=="FeatureCollection"&&(e=i.features.reduce((t,n)=>t.concat(Tt(n)),[]));return e}function us(i,e,t){const n=Math.atan2(i.y-e.y,i.x-e.x);return{x:e.x+t*Math.cos(n),y:e.y+t*Math.sin(n)}}function kt(i,e){if(!e)return{x:i.clientX,y:i.clientY};const t=e.getBoundingClientRect();return{x:i.clientX-t.left-e.clientLeft,y:i.clientY-t.top-e.clientTop}}function gs(i,e){return i.startsWith("#")?tn(i,e):i.startsWith("rgb")?en(i,e):i}function fs(i){if(i.startsWith("#")){const e=Ut(i),t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),s=parseInt(e.slice(5,7),16);return{r:t,g:n,b:s,a:1}}else{const e=i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/);if(!e)throw new Error(`Invalid RGB color: ${i}`);return{r:parseInt(e[1]),g:parseInt(e[2]),b:parseInt(e[3]),a:e[4]!==void 0?parseFloat(e[4]):1}}}function Ut(i){return i.length===4?i.split("").map(e=>e+e).join(""):i}function tn(i,e){const[t,n,s]=Ut(i).match(/\w\w/g).map(r=>parseInt(r,16));return`rgba(${t}, ${n}, ${s}, ${e})`}function en(i,e){const[t,n,s]=i.match(/\d+/g).map(r=>parseInt(r,10));return`rgba(${t}, ${n}, ${s}, ${e})`}function he(){return typeof window<"u"?window:void 0}const de=(i,e=16)=>{let t=!1;const n=Math.max(1,Math.round(e*60/1e3)),s=r=>{requestAnimationFrame(()=>{r>1?s(r-1):t=!1})};return(...r)=>{t||(i(...r),t=!0,s(n))}},ms=(i,e)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>i(...s),e)}};function ps(i,e){let t;return function(...n){clearTimeout(t),t=setTimeout(()=>{i.apply(this,n)},e)}}function nn(i){if((G(i)||L(i))&&i.geometry.type==="Polygon"){const e=i.geometry.coordinates[0],t=e[0][0],n=e[0][1],s=e[2][0],r=e[2][1],o=s-t,a=r-n,l=t+o/2,h=n+a/2;return{...i,geometry:{type:"Point",coordinates:[l,h],bbox:[t,n,s,r]},properties:{...i.properties,width:o,height:a}}}return i}function ue(i,e){let t,n,s,r=1;const o=i.trim();if(o.startsWith("#")){const d=(o.length===4?Ut(o):o).match(/#?(\w{2})(\w{2})(\w{2})/);if(!d)return i;t=parseInt(d[1],16),n=parseInt(d[2],16),s=parseInt(d[3],16)}else{const c=o.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/);if(!c)return i;t=parseInt(c[1]),n=parseInt(c[2]),s=parseInt(c[3]),r=c[4]!==void 0?parseFloat(c[4]):1}const a=e*100,h=.299*t+.587*n+.114*s>186?-a/2:a;return t=Math.max(0,Math.min(255,t+Math.round(2.55*h))),n=Math.max(0,Math.min(255,n+Math.round(2.55*h))),s=Math.max(0,Math.min(255,s+Math.round(2.55*h))),`rgba(${t},${n},${s},${r})`}const wt=i=>ue(i,ee),ys=i=>ue(i,-ee),I=(i,e)=>({x:i.x-e.x,y:i.y-e.y}),V=i=>Math.sqrt(i.x*i.x+i.y*i.y),ws=i=>({x:-i.x,y:-i.y}),qt=i=>{const e=V(i);return e===0?{x:0,y:0}:{x:i.x/e,y:i.y/e}},ht=(i,e)=>({x:i.x+e.x,y:i.y+e.y}),nt=(i,e)=>({x:i.x*e,y:i.y*e}),sn=(i,e)=>{const t=Math.sin(e),n=Math.cos(e);return{x:i.x*n-i.y*t,y:i.x*t+i.y*n}},xt=(i,e)=>i.x*e.x+i.y*e.y,xs=(i,e)=>i.x*e.y-i.y*e.x,J=i=>i.properties.type==="arrow";function ge(i,e,t){const{start:n,end:s}=Xt(i),r=I(e,n),o=i.properties.style.strokeWidth,a=I(s,n),l=V(a),h=xt(r,qt(a));return h>0&&h<l&&Math.abs(xs(r,qt(a)))<o/2+t}const dt={strokeType:"plain",strokeColor:"#202020",strokeWidth:1,head:"none",tail:"none"},bs={id:void 0,type:"Feature",properties:{type:"arrow",style:{...dt}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},Mt=(i=0,e=0,t=0,n=0,s={...dt})=>({id:at(),type:"Feature",properties:{type:"arrow",style:{...dt,...s}},geometry:{type:"LineString",coordinates:[[i,e],[t,n]]}}),G=i=>i.properties.type==="box";function rn(i,e,t=0,n=1,s=0){const r=lt(i),{width:o,height:a}=z(i),l=e.x-r.x,h=e.y-r.y,c=l*n-h*t,d=l*t+h*n;return c>-s&&c<o+s&&d>-s&&d<a+s}const bt={background:"#f5f5f5",strokeWidth:0,borderRadius:8,padding:16,strokeType:"plain"},Ss={id:void 0,type:"Feature",properties:{type:"box",width:100,height:50,style:{...bt}},geometry:{type:"Point",coordinates:[50,25],bbox:[0,0,100,50]}},fe=(i=0,e=0,t=100,n=50,s={...bt})=>({id:at(),type:"Feature",properties:{type:"box",width:t,height:n,style:{...bt,...s}},geometry:{type:"Point",coordinates:[i+t/2,e+n/2]}}),L=i=>i.properties.type==="text",$={font:"sans-serif",fontSize:18,color:"#505050",background:"#f5f5f5",strokeWidth:0,borderRadius:8,padding:16,strokeType:"plain",fixedSize:!1},vs={id:at(),type:"Feature",properties:{type:"text",content:"",width:100,height:50,style:{...$}},geometry:{type:"Point",coordinates:[50,25],bbox:[0,0,100,50]}},me=(i=0,e=0,t=100,n=50,s="",r={...$})=>({id:at(),type:"Feature",properties:{type:"text",content:s,width:t,height:n,style:{...$,...r}},geometry:{type:"Point",coordinates:[i+t/2,e+n/2],bbox:[i,e,i+t,e+n]}});function pe(i,e,t=0,n=0,s=1,r=1){var p;const[o,a]=i.geometry.coordinates;let{width:l,height:h}=z(i);(p=i.properties.style)!=null&&p.fixedSize&&(l/=r,h/=r);const c=l/2,d=h/2,u=e.x-o,g=e.y-a,f=u*s-g*n,m=u*n+g*s;return f>-c-t&&f<c+t&&m>-d-t&&m<d+t}const H=i=>i.properties.type==="comment",Q={background:"#FFFACD",padding:8,borderRadius:4,strokeColor:"#DDD",strokeWidth:1,strokeType:"plain",iconColor:"#FFCB2F",iconSymbol:"💬",iconBorderColor:"#aaa",iconBorderWidth:2,minHeight:60,maxHeight:480,iconSize:32,color:"#333",font:"Arial, sans-serif",fontSize:12,showSendButton:!0,autoGrow:!0,fixedSize:!0},Wt={mode:"expanded",width:200,height:60,style:Q};function ye(i,e,t,n){const s={type:"comment",content:t,mode:(n==null?void 0:n.mode)??Wt.mode,width:(n==null?void 0:n.width)??Wt.width,height:(n==null?void 0:n.height)??Wt.height,author:n==null?void 0:n.author,timestamp:n==null?void 0:n.timestamp,style:{...Q,...n==null?void 0:n.style}};return{id:at(),type:"Feature",properties:s,geometry:{type:"Point",coordinates:[i,e]}}}function As(i){return{...i,properties:{...i.properties,mode:i.properties.mode===et?$t:et}}}function on(i,e,t=0,n,s,r=1){if(i.properties.mode!==et)return pe(i,e,t,n,s,r);const o=i.properties,a={...Q,...o.style};let l=a.iconSize,h=a.iconSize;a.fixedSize&&(l/=r,h/=r);const c=l/2,d=h/2,u=e.x-i.geometry.coordinates[0],g=e.y-i.geometry.coordinates[1];return u>=-c-t&&u<=c+t&&g>=-d-t&&g<=d+t}function Es(i){const[e,t]=i.geometry.coordinates;return{x:e,y:t}}function Cs(i){const e=i.properties,t={...Q,...e.style};return e.mode===et?{width:t.iconSize,height:t.iconSize}:{width:e.width,height:e.height}}function an(i,e=80){const t=e/i.properties.width;return Math.max(.1,Math.min(1,t))}function Ts(i){const e={...Q,...i.properties.style};return e.collapseZoomThreshold!==void 0?e.collapseZoomThreshold:an(i)}function ks(i,e,t,n,s="",r){const o=ye(t,n,s,r==null?void 0:r.commentStyle),a={...dt,head:"arrow",...r==null?void 0:r.arrowStyle},l=Mt(t,n,i,e,a);return l.properties.link={[q]:{id:o.id,side:q,type:"comment",magnet:{x:0,y:0}}},{comment:o,arrow:l}}function Ms(i,e,t,n,s,r,o,a,l){const h=i-o,c=e-a,d=o+h*r-c*s,u=a+h*s+c*r,g=o+(h+t)*r-c*s,f=a+(h+t)*s+c*r,m=o+(h+t)*r-(c+n)*s,p=a+(h+t)*s+(c+n)*r,b=o+h*r-(c+n)*s,S=a+h*s+(c+n)*r;return l[0]=Math.min(d,g,m,b),l[1]=Math.min(u,f,p,S),l[2]=Math.max(d,g,m,b),l[3]=Math.max(u,f,p,S),l}function Ps(i,e,t){const n=t.x-e.x,s=t.y-e.y,r=n*n+s*s;if(r===0){const d=i.x-e.x,u=i.y-e.y;return Math.sqrt(d*d+u*u)}let o=((i.x-e.x)*n+(i.y-e.y)*s)/r;o=Math.max(0,Math.min(1,o));const a=e.x+o*n,l=e.y+o*s,h=i.x-a,c=i.y-l;return Math.sqrt(h*h+c*c)}const st=i=>i.properties.type==="polygon";function we(i,e,t=0){const n=i.geometry.coordinates[0],s=i.geometry.bbox;if(s){const[o,a,l,h]=s;if(e.x<o-t||e.x>l+t||e.y<a-t||e.y>h+t)return!1}let r=!1;for(let o=0,a=n.length-1;o<n.length;a=o++){const l=n[o][0],h=n[o][1],c=n[a][0],d=n[a][1];h>e.y!=d>e.y&&e.x<(c-l)*(e.y-h)/(d-h)+l&&(r=!r)}if(r)return!0;if(t>0)for(let o=0;o<n.length-1;o++){const[a,l]=n[o],[h,c]=n[o+1];if(Ps(e,{x:a,y:l},{x:h,y:c})<=t)return!0}return!1}function ln(i,e){const t=i[0];t.length>0&&(t[0][0]!==t[t.length-1][0]||t[0][1]!==t[t.length-1][1])&&t.push([t[0][0],t[0][1]]);let n=1/0,s=1/0,r=-1/0,o=-1/0;for(const[d,u]of t)d<n&&(n=d),d>r&&(r=d),u<s&&(s=u),u>o&&(o=u);const a=[n,s,r,o],{id:l,style:h,...c}=e||{};return{type:"Feature",id:l||at(),geometry:{type:"Polygon",coordinates:i,bbox:a},properties:{type:"polygon",style:{...rt,...h},...c}}}const rt={...bt,strokeColor:"#000000",strokeWidth:2,background:"transparent"},Ds={type:"polygon",style:{...rt}},xe=i=>i.type==="FeatureCollection";function be(i){return/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(i.trim())}function Se(i){return/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.test(i.trim())}function ve(i){return/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[0-9.]+\s*\)$/.test(i.trim())}function cn(i){return be(i)||Se(i)||ve(i)}function Fs(i){if(cn(i))return i;throw new Error(`Invalid color format: ${i}`)}function _s(i){if(be(i))return i;throw new Error(`Invalid hex color format: ${i}`)}function Ls(i){if(Se(i))return i;throw new Error(`Invalid RGB color format: ${i}`)}function Hs(i){if(ve(i))return i;throw new Error(`Invalid RGBA color format: ${i}`)}class Is{constructor(e){y(this,"previousZoom",-1);this.store=e}toggleComment(e){const t=this.store.getState().getFeature(e);if(!t||!H(t))return;const n=t;this.store.getState().applyLiveUpdate(e,{properties:{...n.properties,mode:n.properties.mode==="collapsed"?"expanded":"collapsed"}})}updateCommentModesForZoom(e){if(Math.abs(this.previousZoom-e)<5e-4)return;this.previousZoom=e;const t=this.store.getState(),n=t.features,s={};Object.values(n).forEach(r=>{if(H(r)){const o=r,a=this.getCommentZoomThreshold(o),l=e<a?et:$t;if(o.properties.mode===l)return;s[o.id]={properties:{...o.properties,mode:l}}}}),t.applyLiveUpdates(s)}getCommentZoomThreshold(e){const t={...e.properties.style};if(t.collapseZoomThreshold!==void 0)return t.collapseZoomThreshold;const s=80/e.properties.width;return Math.max(.1,Math.min(1,s))}}class Gt extends EventTarget{constructor(t,n){super();y(this,"annotation",null);y(this,"ogma");y(this,"dragging",!1);y(this,"dragStartPoint");y(this,"hoveredHandle");y(this,"ogmaPanningOption",!1);y(this,"store");y(this,"draggingWasEnabled",!0);y(this,"handleMouseMove",t=>{if(t.target instanceof HTMLTextAreaElement||!this.isActive())return;const n=this.store.getState();if(!this.dragging&&n.mousePressed&&n.mousePressPoint&&(this.detectHandle(t,this.ogma.view.getZoom()),this.hoveredHandle)){this.dragStartPoint=n.mousePressPoint,this.onDragStart(t),this.dispatchEvent(new Event(yt)),this.disablePanning();return}this.dragging?this.dragStartPoint&&this.onDrag(t):this.detectHandle(t,this.ogma.view.getZoom())});y(this,"handleMouseDown",t=>{t.target instanceof HTMLTextAreaElement||!this.isActive()||this.dragging||(this.hoveredHandle||this.detectHandle(t,this.ogma.view.getZoom()),this.hoveredHandle&&(t.preventDefault(),t.stopPropagation(),this.dragStartPoint=this.clientToCanvas(t),this.onDragStart(t),this.dispatchEvent(new Event(yt)),this.disablePanning()))});y(this,"disablePanning",()=>{var t,n;this.ogmaPanningOption=!!((n=(t=this.ogma.getOptions().interactions)==null?void 0:t.pan)!=null&&n.enabled),this.ogma.setOptions({interactions:{pan:{enabled:!1},drag:{enabled:!1}}})});y(this,"restorePanning",()=>{this.ogma.setOptions({interactions:{pan:{enabled:!0},drag:{enabled:!0}}})});y(this,"handleMouseUp",t=>{!this.isActive()||!this.dragging||(this.restorePanning(),this.onDragEnd(t),this.dispatchEvent(new Event(Rt)))});this.store=n,this.ogma=t,this.store.subscribe(s=>s.features,s=>{this.isActive()&&!s[this.annotation]&&this.stopEditing()})}cancelEdit(){!this.isActive()||this.annotation===null||this.clearDragState()}clearDragState(){this.dragging=!1,this.dragStartPoint=void 0,this.hoveredHandle=void 0,this.restorePanning(),this.setCursor(F.default)}commitChange(){this.getAnnotation()&&this.store.getState().commitLiveUpdates()}onDrag(t){this.dispatchEvent(new Event(Et))}onDragStart(t){return this.isActive()?(this.dragging=!0,this.dragStartPoint=this.clientToCanvas(t),this.disablePanning(),!0):!1}onDragEnd(t){return this.isActive()?(this.restorePanning(),this.dragging=!1,!0):!1}clientToCanvas(t){const n=this.ogma,s=kt(t,n.getContainer());return n.view.screenToGraphCoordinates(s)}setAnnotation(t){if(this.annotation=t?t.id:null,this.annotation!==null){const n=this.ogma.getContainer();if(n){const s=he()||n;s.addEventListener("mousemove",this.handleMouseMove),s.addEventListener("mouseup",this.handleMouseUp,!1),n.addEventListener("mousedown",this.handleMouseDown,!0)}}else{const n=this.ogma.getContainer();if(n){const s=he()||n;s.removeEventListener("mousemove",this.handleMouseMove),s.removeEventListener("mouseup",this.handleMouseUp),n.removeEventListener("mousedown",this.handleMouseDown)}this.clearDragState(),this.setCursor(F.default)}}getAnnotation(){return this.store.getState().getFeature(this.annotation)}setCursor(t){var s;const n=(s=this.ogma.getContainer())==null?void 0:s.firstChild;n&&(n.style.cursor=t)}stopEditing(){this.isActive()&&this.setAnnotation(null)}cancelDrawing(){if(!this.isActive())return;const t=this.store.getState();t.drawingFeature===this.annotation&&t.removeFeature(this.annotation),this.stopEditing()}isActive(){return this.annotation!==null}}class Bs extends Gt{constructor(t,n,s,r,o,a,l){super(t,n);y(this,"links");y(this,"snapping");y(this,"arrowHandler");y(this,"arrowStyle");y(this,"offsetX");y(this,"offsetY");y(this,"comment");y(this,"startX",0);y(this,"startY",0);y(this,"onArrowComplete",()=>{var b;this.arrowHandler.removeEventListener("dragend",this.onArrowComplete);const t=this.store.getState(),n=Array.from(t.selectedFeatures);if(n.length===0)return;const s=t.getFeature(n[0]);if(!s||!J(s))return;const r=s.geometry.coordinates[0],o=s.geometry.coordinates[1],a=o[0]-this.startX,l=o[1]-this.startY,h=Math.sqrt(a*a+l*l);let c,d;h<5?(c=this.startX+this.offsetX,d=this.startY+this.offsetY):(c=o[0],d=o[1]);const u=this.comment;u.geometry.coordinates=[c,d],t.addFeature(u),this.store.setState({drawingFeature:u.id});const g=u.properties.height,f=c,m=d+g*.5;this.snapArrowStart(s,r[0],r[1]);const p=(b=s.properties.link)==null?void 0:b.start;t.updateFeature(s.id,{...s,geometry:{...s.geometry,coordinates:[[f,m],r]},properties:{...s.properties,link:{start:{side:q,id:u.id,type:P.COMMENT,magnet:{x:0,y:.5}},end:p?{side:it,id:p.id,type:p.type,magnet:p.magnet}:void 0}}}),this.links.add(s,q,u.id,P.COMMENT,{x:0,y:.5}),p&&p.magnet&&this.links.add(s,it,p.id,p.type,p.magnet),t.setSelectedFeatures([u.id]),this.store.setState({drawingFeature:null})});this.links=s,this.arrowHandler=o,this.snapping=r,this.offsetX=(l==null?void 0:l.offsetX)??100,this.offsetY=(l==null?void 0:l.offsetY)??-50,this.arrowStyle=l==null?void 0:l.arrowStyle,this.comment=a}detectHandle(t,n){}startDrawing(t,n,s){var o;this.startX=n,this.startY=s;const r=Mt(n,s,n,s,{...dt,head:"arrow",...(o=this.arrowStyle)==null?void 0:o.style});this.store.getState().addFeature(r),this.store.setState({drawingFeature:r.id}),this.arrowHandler.addEventListener("dragend",this.onArrowComplete),this.store.getState().setSelectedFeatures([r.id]),this.arrowHandler.startDrawing(r.id,n,s)}snapArrowStart(t,n,s){const r=this.snapping.snap({x:n,y:s});r&&(t.geometry.coordinates[0]=[r.point.x,r.point.y],t.properties.link={start:{side:q,id:r.id,type:r.type,magnet:r.magnet}},this.links.add(t,q,r.id,r.type,r.magnet))}}function Rs(i,e,t,n,s){const{width:r,height:o}=n.view.getSize(),a=8,l=16,h=a*l,c={width:150,height:50},d=c.width,u=c.height,g=Math.max(r,o),f=200,m={minX:0,minY:0,maxX:0,maxY:0},p=n.view.graphToScreenCoordinates({x:i,y:e});for(let b=0;b<h;b++){const S=b%a,v=Math.floor(b/a),A=2*Math.PI*(S/a),x=f+v/l*(g-f),C=Math.cos(A)*x,E=Math.sin(A)*x,T=p.x+C,M=p.y+E;if(m.minX=T,m.minY=M-u/2,m.maxX=T+d,m.maxY=M+u/2,C<0&&(m.minX-=d,m.maxX-=d),m.minX<0||m.maxX>r||m.minY<0||m.maxY>o)continue;const D=n.view.screenToGraphCoordinates({x:m.minX,y:m.minY}),j=n.view.screenToGraphCoordinates({x:m.maxX,y:m.maxY});if(m.minX=D.x,m.minY=D.y,m.maxX=j.x,m.maxY=j.y,!t.query(m).filter(X=>X.properties.type!=="arrow").length)return n.view.screenToGraphCoordinates({x:T,y:M})}return n.view.screenToGraphCoordinates({x:r/2,y:o/2})}class zs{constructor(e,t,n,s,r,o,a){y(this,"ogma");y(this,"store");y(this,"editor");y(this,"interactions");y(this,"links");y(this,"control");y(this,"index");y(this,"pendingDrawingListener",null);this.ogma=e,this.store=t,this.editor=n,this.interactions=s,this.links=r,this.control=o,this.index=a}cancelPendingDrawing(){this.pendingDrawingListener&&(this.ogma.events.off(this.pendingDrawingListener),this.pendingDrawingListener=null)}isDrawing(){return this.store.getState().drawingFeature!==null}enableDrawingMode(e){this.control.unselect().cancelDrawing();const t=n=>{this.ogma.events.off(t),this.pendingDrawingListener=null;const{x:s,y:r}=this.ogma.view.screenToGraphCoordinates(n);e(s,r)};return this.pendingDrawingListener=t,this.ogma.events.once("mousedown",t),this.control}enableArrowDrawing(e){return this.enableDrawingMode((t,n)=>{const s=Mt(t,n,t,n,e);this.startArrow(t,n,s)})}enableTextDrawing(e){return this.enableDrawingMode((t,n)=>{const s=me(t,n,0,0,void 0,e);this.startText(t,n,s)})}enableBoxDrawing(e){return this.enableDrawingMode((t,n)=>{const s=fe(t,n,0,0,e);this.startBox(t,n,s)})}enablePolygonDrawing(e){return this.enableDrawingMode((t,n)=>{const s=ln([[[t,n]]],{style:e});this.startPolygon(t,n,s)})}enableCommentDrawing(e={}){return this.enableDrawingMode((t,n)=>{let s=e.offsetX,r=e.offsetY;if(s===void 0&&r===void 0){const a=Rs(t,n,this.index,this.ogma);s=a.x,r=a.y}const o=ye(t,n,"",e==null?void 0:e.commentStyle);this.startComment(t,n,o,{...e,offsetX:s,offsetY:r})})}startComment(e,t,n,s){this.editor.getActiveHandler()&&this.editor.getActiveHandler().stopEditing(),this.control.cancelDrawing(),this.store.setState({drawingFeature:n.id}),this.interactions.suppressClicksTemporarily(200);const r=new Bs(this.ogma,this.store,this.links,this.editor.getSnapping(),this.editor.getArrowHandler(),n,s),o=a=>{var l;a.id===n.id&&(this.control.select(a.id),this.control.off(Nt,o),(l=this.editor.getActiveHandler())==null||l.startEditingText())};return this.control.on(Nt,o),r.startDrawing(n.id,e,t),this.control}startBox(e,t,n){return n||(n=fe(e,t)),this.store.setState({drawingFeature:n.id}),this.control.add(n),this.interactions.suppressClicksTemporarily(200),this.control.select(n.id),this.editor.getActiveHandler().startDrawing(n.id,e,t),this.control}startArrow(e,t,n){return n||(n=Mt(e,t)),this.editor.getActiveHandler()&&this.editor.getActiveHandler().stopEditing(),this.control.cancelDrawing(),this.store.setState({drawingFeature:n.id}),this.control.add(n),this.interactions.suppressClicksTemporarily(200),this.control.select(n.id),this.editor.getActiveHandler().startDrawing(n.id,e,t),this.control}startText(e,t,n){return n||(n=me(e,t)),this.store.setState({drawingFeature:n.id}),this.control.add(n),this.interactions.suppressClicksTemporarily(200),this.control.select(n.id),this.editor.getActiveHandler().startDrawing(n.id,e,t),this.control}startPolygon(e,t,n){return this.store.setState({drawingFeature:n.id}),this.control.add(n),this.interactions.suppressClicksTemporarily(200),this.control.select(n.id),this.editor.getActiveHandler().startDrawing(n.id,e,t),this.control}}class Ns{constructor(e,t){this.store=e,this.links=t}undo(){return this.canUndo()?(this.store.temporal.getState().undo(),this.links.refresh(),!0):!1}redo(){return this.canRedo()?(this.store.temporal.getState().redo(),this.links.refresh(),!0):!1}canUndo(){return this.store.temporal.getState().pastStates.length>0}canRedo(){return this.store.temporal.getState().futureStates.length>0}clearHistory(){this.store.temporal.getState().clear()}}class Os{constructor(e){this.store=e}select(e){const t=Array.isArray(e)?e:[e];this.store.getState().setSelectedFeatures(t)}unselect(e){const t=Array.isArray(e)?e:[e];if(e===void 0)this.store.getState().setSelectedFeatures([]);else{const n=new Set(t),s=Array.from(this.store.getState().selectedFeatures).filter(r=>!n.has(r));this.store.getState().setSelectedFeatures(s)}}getSelectedAnnotations(){const e=this.store.getState();return{type:"FeatureCollection",features:Array.from(e.selectedFeatures).map(t=>e.features[t])}}getSelected(){const e=this.store.getState(),t=Array.from(e.selectedFeatures)[0];return t?e.features[t]:null}}class $s{constructor(e){this.store=e}add(e){if(xe(e))for(const t of e.features)this.add(t);else{const t=nn(e);this.store.getState().addFeature(t)}}remove(e){if(xe(e))for(const t of e.features)this.remove(t);else this.store.getState().removeFeature(e.id)}getAnnotations(){const e=this.store.getState().features;return{type:"FeatureCollection",features:Object.values(e)}}getAnnotation(e){return this.store.getState().getFeature(e)}updateStyle(e,t){const n=this.store.getState().getFeature(e);n&&this.store.getState().updateFeature(e,{id:e,properties:{...n.properties,style:{...n.properties.style,...t}}})}update(e){var s;const t=this.store.getState(),n=t.getFeature(e.id);n&&t.updateFeature(e.id,{...n,...e,properties:{...n.properties,...e.properties,style:{...n.properties.style,...(s=e.properties)==null?void 0:s.style}},geometry:{...n.geometry,...e.geometry}})}setScale(e,t,n,s){const r=this.store.getState().getFeature(e);if(!r)return;const o=this.store.getState();if(J(r)){const a=r.geometry.coordinates.map(([l,h])=>{const c=l-n,d=h-s;return[n+c*t,s+d*t]});o.updateFeature(e,{geometry:{...r.geometry,coordinates:a}})}else if(L(r)||G(r)){const[a,l]=r.geometry.coordinates,h=a-n,c=l-s,d=n+h*t,u=s+c*t,g=r.properties.width*t,f=r.properties.height*t;o.updateFeature(e,{properties:{...r.properties,width:g,height:f},geometry:{...r.geometry,coordinates:[d,u]}})}}}function Ae(i){var t,n;const e=i.properties.link;return e?((t=e.start)==null?void 0:t.type)===P.COMMENT||((n=e.end)==null?void 0:n.type)===P.COMMENT:!1}function hn(i){var e,t;return((t=(e=i.properties.link)==null?void 0:e.start)==null?void 0:t.type)!==P.COMMENT}function Ys(i){return!0}class Xs extends Gt{constructor(t,n,s,r){super(t,n);y(this,"snapping");y(this,"links");y(this,"snap",null);this.snapping=s,this.links=r}detectHandle(t){const n=this.getAnnotation(),s=this.clientToCanvas(t),r=te,o=n.geometry.coordinates[0],a=n.geometry.coordinates[1],l=Math.sqrt(Math.pow(s.x-o[0],2)+Math.pow(s.y-o[1],2)),h=Math.sqrt(Math.pow(s.x-a[0],2)+Math.pow(s.y-a[1],2));l<r?this.grabHandle("start",o[0],o[1]):h<r?this.grabHandle("end",a[0],a[1]):ge(n,s,r)?(this.setCursor(F.grab),this.hoveredHandle={type:"body",point:s},this.store.setState({hoveredHandle:2})):(this.store.setState({hoveredHandle:-1}),this.hoveredHandle=void 0)}grabHandle(t,n,s){this.hoveredHandle={type:t,point:{x:n,y:s}},this.store.setState({hoveredHandle:t==="start"?0:1}),this.setCursor(F.move)}onDrag(t){var h;if(!(this.dragStartPoint||!this.hoveredHandle)||!this.isActive())return;t.stopPropagation(),t.stopImmediatePropagation();const n=this.clientToCanvas(t),s=this.hoveredHandle,r=this.getAnnotation();this.snap=this.snapping.snap(n);const o=((h=this.snap)==null?void 0:h.point)||n,a=r.properties.link||{},l=[...r.geometry.coordinates];if(s.type==="start")l[0]=[o.x,o.y],this.snap&&(a.start={side:s.type,id:this.snap.id,type:this.snap.type,magnet:this.snap.magnet});else if(s.type==="end")l[1]=[o.x,o.y],this.snap&&(a.end={side:s.type,id:this.snap.id,type:this.snap.type,magnet:this.snap.magnet});else if(s.type==="body"){const c=o.x-s.point.x,d=o.y-s.point.y,u=r.geometry.coordinates[0],g=r.geometry.coordinates[1];l[0]=[u[0]+c,u[1]+d],l[1]=[g[0]+c,g[1]+d]}this.store.getState().applyLiveUpdate(r.id,{id:r.id,properties:{...r.properties,link:a},geometry:{type:r.geometry.type,coordinates:l}}),this.dispatchEvent(new CustomEvent(Et,{detail:{point:o,annotation:this.annotation,handle:s}}))}onDragStart(t){if(!super.onDragStart(t))return!1;const n=this.getAnnotation(),s=this.hoveredHandle;return s.type==="body"&&Ae(n)||s.type==="end"&&!1||s.type==="start"&&!hn(n)?(this.clearDragState(),!1):(this.store.getState().startLiveUpdate([this.annotation]),!0)}onDragEnd(t){if(!super.onDragEnd(t))return!1;if(this.snap&&this.hoveredHandle){const s=this.hoveredHandle;s.type!=="body"&&this.links.add(this.getAnnotation(),s.type,this.snap.id,this.snap.type,this.snap.magnet)}else if(this.snap===null&&this.hoveredHandle){const s=this.getAnnotation(),r=this.hoveredHandle.type;if(s.properties.link&&s.properties.link[r]){this.links.remove(s,r);const o={...s.properties.link};delete o[r],this.store.getState().applyLiveUpdate(s.id,{properties:{...s.properties,link:o}})}}return this.store.getState().drawingFeature===this.annotation&&this.store.setState({drawingFeature:null}),this.commitChange(),this.clearDragState(),this.snap=null,!0}snapDrawingStart(t,n,s){const r=this.snapping.snap({x:n,y:s});if(r){const o={geometry:{...t.geometry,coordinates:[[r.point.x,r.point.y],t.geometry.coordinates[1]]},properties:{...t.properties,link:{start:{side:q,id:r.id,type:r.type,magnet:r.magnet}}}},a=this.store.getState();a.applyLiveUpdate(t.id,o),a.updateFeature(t.id,o),this.links.add(t,"start",r.id,r.type,r.magnet)}}startDrawing(t,n,s){this.annotation=t;const r=this.getAnnotation();this.snapDrawingStart(r,n,s),this.grabHandle("end",n,s),this.dragging=!0,this.dragStartPoint={x:n,y:s};const o=this.ogma.view.graphToScreenCoordinates({x:n,y:s});this.onDragStart({clientX:o.x,clientY:o.y})}link(t,n,s){let r=Ct(t,s);const o=t.properties.link||{};let a=null;if(n instanceof O.Node)r=n.getPosition(),a=this.snapping.snapToNodes(r,n.toList());else{const l=this.store.getState().getFeature(n);if(!l)throw new Error(`Annotation with id ${n} not found`);if(L(l)||G(l))r=W(l),a=this.snapping.snapToText(r,[l]);else if(st(l))r=oe(l),a=this.snapping.snapToPolygon(r,[l]);else throw new Error(`Cannot link arrow to annotation of type ${l.properties.type}`)}a&&(o[s]={side:s,id:a.id,type:a.type,magnet:a.magnet},this.links.add(t,s,a.id,a.type,a.magnet),Qe(t,s,r.x,r.y),this.store.getState().updateFeature(t.id,{properties:{...t.properties,link:o},geometry:{type:t.geometry.type,coordinates:t.geometry.coordinates}}))}}class Us extends Gt{constructor(t,n,s){super(t,n);y(this,"links");y(this,"isDrawingMode",!1);y(this,"simplificationTolerance",5);y(this,"handleMouseDown",t=>{!this.isActive()||this.dragging||!this.hoveredHandle||(t.preventDefault(),t.stopPropagation(),this.dragStartPoint=this.clientToCanvas(t),this.onDragStart(t),this.dispatchEvent(new Event(yt)),this.disablePanning())});this.links=s}startDrawing(t,n,s){this.annotation=t,this.isDrawingMode=!0;const r=this.store.getState();r.startLiveUpdate([t]),r.setDrawingPoints([]);const o=this.ogma.view.graphToScreenCoordinates({x:n,y:s});return this.dragStartPoint=o,this.disablePanning(),this.onDragStart({clientX:o.x,clientY:o.y}),this}cancelDrawing(){this.isDrawingMode&&(this.isDrawingMode=!1,this.annotation&&(this.store.getState().removeFeature(this.annotation),this.annotation=null)),this.restorePanning()}detectHandle(t,n=1){const s=this.getAnnotation();if(!s)return;const r=this.clientToCanvas(t),o=te/n,a=s.geometry.coordinates[0];for(let l=0;l<a.length-1;l++){const[h,c]=a[l];if(Math.sqrt(Math.pow(r.x-h,2)+Math.pow(r.y-c,2))<o*2){this.grabHandle("vertex",h,c,l);return}}we(s,r,o)?(this.setCursor(F.grab),this.hoveredHandle={type:"body",point:r},this.store.setState({hoveredHandle:-1})):(this.store.setState({hoveredHandle:-1}),this.hoveredHandle=void 0)}grabHandle(t,n,s,r){this.setCursor(t==="vertex"?F.pointer:F.grab),this.hoveredHandle={type:t,point:{x:n,y:s},vertexIndex:r},this.store.setState({hoveredHandle:r??0})}onDragStart(t){if(this.isDrawingMode){const n=this.clientToCanvas(t);this.dragging=!0;const s=this.getAnnotation();if(s){const r=[[n.x,n.y],[n.x,n.y]],o=this.store.getState();o.setDrawingPoints(r),o.applyLiveUpdate(s.id,{...s,geometry:{type:"Polygon",coordinates:[r],bbox:[n.x,n.y,n.x,n.y]}})}return this.dragStartPoint=n,!0}return this.hoveredHandle?(this.dragging=!0,this.setCursor(F.grabbing),this.store.getState().startLiveUpdate([this.annotation]),!0):!1}onDrag(t){if(this.isDrawingMode&&this.dragging){const a=this.clientToCanvas(t),l=this.store.getState(),h=this.getAnnotation();if(!h)return;const c=l.liveUpdates[this.annotation],d=c?{...h,...c}:h,g=l.drawingPoints.slice(0,-1),f=[...g,[a.x,a.y],g[0]];l.setDrawingPoints(f);const m=ie(f,this.simplificationTolerance,!1),p=[...m,m[0]];l.applyLiveUpdate(this.annotation,{...d,geometry:{type:"Polygon",coordinates:[p]}});return}if(!this.dragging||!this.dragStartPoint||!this.hoveredHandle)return;const n=this.clientToCanvas(t),s=n.x-this.dragStartPoint.x,r=n.y-this.dragStartPoint.y,o=this.getAnnotation();if(o){if(this.hoveredHandle.type==="body"){const a=Ve(o,s,r);this.store.getState().applyLiveUpdate(o.id,a),this.links.updateLinkedArrowsDuringDrag(o.id,{x:s,y:r})}else if(this.hoveredHandle.type==="vertex"&&this.hoveredHandle.vertexIndex!==void 0){const a=o.geometry.coordinates[0].map((h,c)=>c===this.hoveredHandle.vertexIndex?[this.hoveredHandle.point.x+s,this.hoveredHandle.point.y+r]:c===o.geometry.coordinates[0].length-1&&this.hoveredHandle.vertexIndex===0?[this.hoveredHandle.point.x+s,this.hoveredHandle.point.y+r]:h),l={...o,geometry:{...o.geometry,coordinates:[a]}};ae(l),this.store.getState().applyLiveUpdate(o.id,l)}this.dispatchEvent(new Event(Et))}}onDragEnd(){if(this.isDrawingMode&&this.dragging){const n=this.store.getState(),s=this.getAnnotation();if(s){const r=n.drawingPoints;if(r.length<3)this.cancelDrawing();else{const o=ie(r.slice(1,-1),this.simplificationTolerance,!0),a={...s,geometry:{type:"Polygon",coordinates:[o]}};ct(a),this.store.getState().applyLiveUpdate(s.id,a),this.store.setState({drawingFeature:null}),this.commitChange(),this.isDrawingMode=!1,this.dragging=!1,this.restorePanning(),this.dispatchEvent(new CustomEvent(Qt,{detail:a}))}}return!0}return!this.dragging||(this.dragging=!1,this.dragStartPoint=void 0,!this.getAnnotation())?!1:(this.commitChange(),this.setCursor(F.grab),!0)}getAnnotation(){if(this.annotation)return this.store.getState().getFeature(this.annotation)}}function qs(i,e,t,n,s=20){let r=0,o=1/0,a=null;for(let l=0;l<=s;l++){const h=l/s,c=O.geometry.getPointOnQuadraticCurve(h,e.x,e.y,t.x,t.y,n.x,n.y),d=V(I(c,i));d<o&&(o=d,a=c,r=h)}return a?{t:r,point:a,distance:o}:null}function Ws(i,e,t){const n=t.x-e.x,s=t.y-e.y,r=n*n+s*s;if(r===0)return{t:0,point:{x:e.x,y:e.y},distance:V(I(e,i))};const o=Math.max(0,Math.min(1,((i.x-e.x)*n+(i.y-e.y)*s)/r)),a={x:e.x+o*n,y:e.y+o*s};return{t:o,point:a,distance:V(I(a,i))}}function Gs(i,e,t){let n=null,s=t;const r=e.getAttribute("curvature"),a=e.getExtremities().getPosition();for(let l=0;l<e.size;l++){const h=e.get(l),c=r[l],d=a[2*l],u=a[2*l+1];let g;if(c===0||c===void 0)g=Ws(i,d,u);else{const f=O.geometry.getQuadraticCurveControlPoint(d.x,d.y,u.x,u.y,c);g=qs(i,d,u,f)}g&&g.distance<s&&(s=g.distance,n={point:g.point,id:h.getId(),magnet:{x:g.t,y:0},type:P.EDGE})}return n}function js(i,e,t){const n=e.getAttributes(["x","y","radius"]);for(let s=0;s<n.length;s++){const r=n[s],o=I({x:r.x,y:r.y},i),a=V(o);if(a>=Number(r.radius)+Number(t))continue;const l=nt(o,1/a),h=a<Number(r.radius)/2,c=h?{x:r.x,y:r.y}:ht({x:r.x,y:r.y},nt(l,-Number(r.radius))),d=h?{x:0,y:0}:l;return{point:c,id:e.get(s).getId(),magnet:d,type:P.NODE}}return null}function Vs(i,e){let t=!1;for(let n=0,s=e.length-1;n<e.length;s=n++){const r=e[n][0],o=e[n][1],a=e[s][0],l=e[s][1];o>i.y!=l>i.y&&i.x<(a-r)*(i.y-o)/(l-o)+r&&(t=!t)}return t}function Zs(i,e,t,n,s){const r=i*i,o=r*i,a=1-i,l=a*a,h=l*a;return{x:h*e.x+3*l*i*t.x+3*a*r*n.x+o*s.x,y:h*e.y+3*l*i*t.y+3*a*r*n.y+o*s.y}}function Ks(i,e,t,n,s){let r=1/0,o=null;const a=20;for(let l=0;l<=a;l++){const h=l/a,c=Zs(h,e,t,n,s),d=V(I(c,i));d<r&&(r=d,o=c)}return o?{point:o,distance:r}:null}function Js(i,e,t){const n=e.geometry.coordinates[0];for(let s=0;s<n.length-1;s++){const[r,o]=n[s];if(V(I({x:r,y:o},i))<t)return{point:{x:r,y:o},magnet:{x:r,y:o},type:P.POLYGON,id:e.id}}for(let s=0;s<n.length-1;s++){const[r,o]=n[s],[a,l]=n[s+1],h={x:r,y:o},d=I({x:a,y:l},h),u=V(d),g={x:d.x/u,y:d.y/u},f={x:-g.y,y:g.x},m=I(i,h),p=Math.abs(xt(f,m)),b=xt(g,m);if(b>=0&&b<=u&&p<t){const S={x:h.x+g.x*b,y:h.y+g.y*b};return{point:S,magnet:S,type:P.POLYGON,id:e.id}}}return null}function Qs(i,e,t){for(const s of e){const o=s.geometry.coordinates[0].slice(0,-1);if(o.length<3)return Js(i,s,t);for(let c=0;c<o.length;c++){const[d,u]=o[c];if(V(I({x:d,y:u},i))<t)return{point:{x:d,y:u},magnet:{x:d,y:u},type:P.POLYGON,id:s.id}}const a=Vs(i,o);let l=null,h=a?1/0:t;for(let c=0;c<o.length;c++){const d=o[(c-1+o.length)%o.length],u=o[c],g=o[(c+1)%o.length],f=o[(c+2)%o.length],m=u[0]+(g[0]-d[0])/6*.5,p=u[1]+(g[1]-d[1])/6*.5,b=g[0]-(f[0]-u[0])/6*.5,S=g[1]-(f[1]-u[1])/6*.5,v=Ks(i,{x:u[0],y:u[1]},{x:m,y:p},{x:b,y:S},{x:g[0],y:g[1]});if(v){const A=v.distance;if(a)A<h&&(h=A,l=v.point);else if(A<t)return{point:v.point,magnet:v.point,type:P.POLYGON,id:s.id}}}if(a&&l)return{point:l,magnet:l,type:P.POLYGON,id:s.id}}return null}const dn=[{x:-.5,y:-.5},{x:0,y:-.5},{x:.5,y:-.5},{x:-.5,y:0},{x:.5,y:0},{x:-.5,y:.5},{x:0,y:.5},{x:.5,y:.5},{x:0,y:0}],ti=[[-.5,-.5,.5,-.5],[.5,-.5,.5,.5],[.5,.5,-.5,.5],[-.5,.5,-.5,-.5]];function un(i,e,t,n,s,r,o,a,l){const h=i*s,c=e*r;return l?{x:t+(h*o-c*a),y:n+(h*a+c*o)}:{x:t+h,y:n+c}}function ei(i,e,t,n,s){var c;const r=W(e);let{width:o,height:a}=z(e);const{sin:l,cos:h}=s.getState();(c=e.properties.style)!=null&&c.fixedSize&&(o/=t,a/=t);for(const d of dn){let u=d.x*o,g=d.y*a;if(!G(e)){const p=u*h-g*l,b=u*l+g*h;u=p,g=b}const f={x:r.x+u,y:r.y+g};if(!(V(I(f,i))>=n))return{point:{x:f.x,y:f.y},type:P.TEXT,magnet:d,id:e.id}}return null}function ni(i,e,t,n,s){var f;const{x:r,y:o}=W(e);let{width:a,height:l}=z(e);(f=e.properties.style)!=null&&f.fixedSize&&(a/=t,l/=t);const{sin:h,cos:c}=s.getState(),d=!G(e);let u=null,g=1/0;for(let m=0;m<4;m++){const[p,b,S,v]=ti[m],A=un(p,b,r,o,a,l,c,h,d),x=un(S,v,r,o,a,l,c,h,d),C=I(x,A),E=V(C),T={x:C.x/E,y:C.y/E},M={x:-T.y,y:T.x},D=I(i,A),j=xt(M,D),Y=xt(T,D);if(Y>=0&&Y<=E){const X=Math.abs(j);if(X<n||X<g){const gt=Y/E,ft={point:{x:A.x+T.x*Y,y:A.y+T.y*Y},magnet:{x:p+(S-p)*gt,y:b+(v-b)*gt},type:P.TEXT,id:e.id};if(X<n)return ft;X<g&&(g=X,u=ft)}}}return u&&g<Math.max(a,l)?u:null}function si(i,e,t,n,s){for(const r of e){const o=ei(i,r,t,n,s)||ni(i,r,t,n,s);if(o)return o}return null}class ii extends EventTarget{constructor(t,n,s,r){super();y(this,"ogma");y(this,"options");y(this,"spatialIndex");y(this,"hoveredNode",null);y(this,"store");this.ogma=t,this.options=n,this.spatialIndex=s,this.store=r}snap(t){const n=this.findMagnet(t);return n||null}findMagnet(t){const n=this.options.detectMargin,s={minX:t.x-n,minY:t.y-n,maxX:t.x+n,maxY:t.y+n},r=this.spatialIndex.search(s),o=r.filter(f=>L(f)||G(f)),a=r.filter(f=>st(f)),{nodes:l,edges:h}=this.ogma.view.getElementsInside(s.minX,s.minY,s.maxX,s.maxY),c=this.snapToNodes(t,l);if(c)return c;const d=this.snapToEdges(t,h);if(d)return d;const u=this.snapToText(t,o);if(u)return u;const g=this.snapToPolygon(t,a);return g||null}snapToText(t,n){const{zoom:s}=this.store.getState();return si(t,n,s,this.options.magnetRadius,this.store)}snapToPolygon(t,n){return Qs(t,n,this.options.magnetRadius)}snapToNodes(t,n){return js(t,n,this.options.detectMargin)}snapToEdges(t,n){return Gs(t,n,this.options.magnetRadius)}getHoveredNode(){return this.hoveredNode}clearHoveredNode(){var t;(t=this.hoveredNode)==null||t.setSelected(!1),this.hoveredNode=null}getMagnets(){return dn}}class ri{constructor(e,t,n,s=()=>{}){y(this,"layer");y(this,"textarea");y(this,"sendButton",null);y(this,"isFocused");y(this,"unsubscribe");y(this,"onFocus",()=>{this.isFocused=!0});y(this,"onBlur",()=>{this.getAnnotation()&&this.updateContent(),this.isFocused=!1});y(this,"onKeyup",e=>{e.key==="Escape"&&this.textarea.blur(),e.stopPropagation()});y(this,"onKeydown",e=>{e.stopPropagation()});y(this,"onWheel",e=>{e.stopPropagation()});y(this,"onInput",()=>{this.updateContent(),this.updateStyle(),this.updatePosition(),this.layer.setSize(this.getSize()),this.updateSendButtonState()});y(this,"onSendClick",e=>{e.preventDefault(),e.stopPropagation(),!(!this.sendButton||this.sendButton.disabled)&&(this.updateContent(),this.textarea.blur(),this.onSendHandler())});y(this,"update",()=>{this.getAnnotation()&&(this.updateStyle(),this.updatePosition(),this.layer.setSize(this.getSize()))});var u,g,f;this.ogma=e,this.store=t,this.annotation=n,this.onSendHandler=s;const r=this.getPosition(),o=this.getSize(),a=this.getAnnotation(),l=this.store.getState(),h=((u=l.options)==null?void 0:u.showSendButton)??!0,c=((g=l.options)==null?void 0:g.sendButtonIcon)||"",d=((f=l.options)==null?void 0:f.textPlaceholder)||"Enter text";this.layer=this.ogma.layers.addOverlay({element:`<div class="ogma-annotation-text-editor">
|
|
4
|
+
<textarea wrap="on" name="annotation-text--input" spellcheck="false" placeholder="${d}"></textarea>
|
|
5
|
+
${h?`<button class="ogma-send-button" type="button" title="Send">
|
|
6
|
+
<span class="ogma-send-button-icon">${c}</span>
|
|
7
|
+
</button>`:""}
|
|
8
|
+
</div>`,position:r,size:o},Ot.EDITOR),this.textarea=this.layer.element.querySelector("textarea"),this.textarea.setAttribute("wrap","on"),this.textarea.setAttribute("spellcheck","false"),this.textarea.value=a.properties.content||"",h&&(this.sendButton=this.layer.element.querySelector(".ogma-send-button"),this.sendButton.addEventListener("click",this.onSendClick),this.updateSendButtonState()),this.isFocused=!1,this.textarea.addEventListener("focus",this.onFocus),this.textarea.addEventListener("blur",this.onBlur),this.textarea.addEventListener("input",this.onInput),this.textarea.addEventListener("keyup",this.onKeyup),this.textarea.addEventListener("keydown",this.onKeydown),this.textarea.addEventListener("wheel",this.onWheel),this.updateStyle(),this.updatePosition(),this.textarea.focus(),this.unsubscribe=this.store.subscribe(m=>({rotation:m.rotation,zoom:m.zoom,annotation:m.features[this.annotation]}),this.update,{equalityFn:(m,p)=>m.rotation===p.rotation&&m.zoom===p.zoom&&m.annotation===p.annotation})}getAnnotation(){const e=this.store.getState();return e.liveUpdates[this.annotation]?e.liveUpdates[this.annotation]:(e.startLiveUpdate([this.annotation]),this.store.getState().getFeature(this.annotation))}getPosition(){const e=this.getAnnotation();if(!e)return{x:0,y:0};const t=e.properties.style,n=(t==null?void 0:t.fixedSize)||!1,s=t==null?void 0:t.maxHeight,r=this.store.getState().zoom,o=Ee(e),[a,l]=e.geometry.coordinates,h=e.properties.width;let c=e.properties.height;s&&(c=Math.min(c,s));const d=n?1/r:1;return{x:a-h*d/2+o*d,y:l-c*d/2+o*d}}getSize(){const e=this.getAnnotation(),t=z(e),n=Ee(e),s=e.properties.style,r=(s==null?void 0:s.fixedSize)||!1,o=s==null?void 0:s.maxHeight,a=this.store.getState().zoom,l=r?1/a:1;let h=(t.height-n*2)*l;if(o){const c=(o-n*2)*l;h=Math.min(h,c)}return{width:(t.width-n*2)*l,height:h}}updateStyle(){var m;const e=this.getAnnotation();if(!e)return;const{font:t,fontSize:n=$.fontSize,borderRadius:s,color:r,background:o,padding:a=0,fixedSize:l=$.fixedSize}=e.properties.style||$,h=this.textarea,c=this.store.getState().zoom,d=l?1/c:1,u=parseFloat(n.toString())*d,g=a*d,f=h.style;if(f.font=`${u} ${t}`,f.fontFamily=t||"sans-serif",f.fontSize=`${u}px`,f.padding=`${g}px`,f.lineHeight=`${u*Yt}px`,f.boxSizing="border-box",f.color=r||"black",f.background=o||"transparent",f.borderRadius=`${s}px`,l){const p=(m=e.properties.style)==null?void 0:m.maxHeight;f.overflowY=p?"auto":"hidden",f.overflowX="hidden",f.resize="none"}if(f.transformOrigin="center",f.transform=`rotate(${this.store.getState().rotation}rad)`,this.sendButton){const p=l?1/c:1;this.sendButton.style.transform=`scale(${p})`,this.sendButton.style.transformOrigin="bottom right"}}updatePosition(){this.layer.setPosition(this.getPosition())}updateContent(){var o,a,l;const e=this.getAnnotation();let t=e.properties.height,n=e.geometry.coordinates;const s=(o=e.properties.style)==null?void 0:o.fixedSize;if(s){const h=this.textarea.scrollHeight,c=Ee(e),d=this.store.getState().zoom,u=(h+c*2/d)*d,g=((a=e.properties.style)==null?void 0:a.minHeight)||50;t=Math.max(g,u);const f=(l=e.properties.style)==null?void 0:l.maxHeight,m=e.properties.height,p=t-m;if(Math.abs(p)>1){const[b,S]=e.geometry.coordinates;if(f&&m>=f)n=[b,S];else if(f&&t>f){const v=f-m;n=[b,S+v/2]}else n=[b,S+p/2]}}const r={...e,properties:{...e.properties,content:this.textarea.value,height:t},geometry:{...e.geometry,coordinates:n}};s&&Math.abs(e.properties.height-t)>1&&(this.layer.setSize(this.getSize()),this.layer.setPosition(this.getPosition())),this.store.getState().applyLiveUpdate(this.annotation,r)}updateSendButtonState(){if(!this.sendButton)return;const e=this.textarea.value.trim().length===0;this.sendButton.disabled=e}destroy(){this.store.getState().commitLiveUpdates(new Set([this.annotation])),this.unsubscribe(),this.sendButton&&this.sendButton.removeEventListener("click",this.onSendClick),this.layer.destroy()}}function Ee(i){var e;return((e=i.properties.style)==null?void 0:e.strokeWidth)||0}const gn={x:1,y:0},fn={x:0,y:1},oi=[["top",fn,-.5,-.5,.5,-.5],["right",gn,.5,-.5,.5,.5],["bottom",fn,-.5,.5,.5,.5],["left",gn,-.5,-.5,-.5,.5]],ai={top:[0,1],right:[1,2],bottom:[2,3],left:[3,0]},mn=[[-.5,-.5],[.5,-.5],[.5,.5],[-.5,.5]],li=[F.nwResize,F.neResize,F.seResize,F.swResize];class Ce extends Gt{constructor(t,n,s){super(t,n);y(this,"links");y(this,"textEditor",null);y(this,"stopEditingText",()=>{this.textEditor&&(this.store.getState().drawingFeature===this.annotation&&this.store.setState({drawingFeature:null}),this.textEditor.destroy()),this.textEditor=null});this.links=s}detectHandle(t,n){var A;const s=this.getAnnotation(),{x:r,y:o}=this.clientToCanvas(t);let{width:a,height:l}=z(s);const h=5/n,c=W(s),d=this.store.getState();let{revSin:u,revCos:g}=d;(G(s)||H(s))&&(u=0,g=1),this.hoveredHandle=void 0;const f=je*(1/n),m=r-c.x,p=o-c.y,b=m*g-p*u,S=m*u+p*g,v=((A=s.properties.style)==null?void 0:A.fixedSize)===!0||H(s);if(v&&(a/=n,l/=n),!v){for(let x=0;x<mn.length;x++){const[C,E]=mn[x],T=a*C,M=l*E;if(b>=T-f-h&&b<=T+f+h&&S>=M-f-h&&S<=M+f+h){this.hoveredHandle={type:"corner",corner:x},this.store.setState({hoveredHandle:x}),this.setCursor(this.getCornerCursor(x));return}}for(const[x,C,E,T,M,D]of oi){const j=a*E,Y=l*T,X=a*M,gt=l*D,ft=xt(C,{x:b-j,y:S-Y});if(Math.abs(ft)<h&&b>=j-h&&b<=X+h&&S>=Y-h&&S<=gt+h){this.hoveredHandle={type:"edge",edge:x,corner:-1},this.store.setState({hoveredHandle:ai[x][0]+4}),this.setCursor(this.getEdgeCursor(x));return}}}if(b>=-a/2-h&&b<=a/2+h&&S>=-l/2-h&&S<=l/2+h){this.store.setState({hoveredHandle:8}),this.hoveredHandle={type:"body",corner:-1},this.setCursor(F.grab);return}this.store.setState({hoveredHandle:-1}),this.setCursor(F.default)}onDrag(t){if(!this.dragStartPoint||!this.hoveredHandle||!this.isActive())return;t.stopPropagation(),t.stopImmediatePropagation();const n=this.getAnnotation(),s=this.clientToCanvas(t),r={x:s.x-this.dragStartPoint.x,y:s.y-this.dragStartPoint.y},o=this.hoveredHandle,a=this.getAnnotation();let l=null;if(o.type==="corner"?l=this.dragCorner(a,r,o.corner):o.type==="edge"&&o.edge?l=this.dragEdge(a,r,o):o.type==="body"&&(l=this.dragBody(a,r)),l){const h=l;this.store.getState().applyLiveUpdate(n.id,h);const c=I(W(h),W(a));this.links.updateLinkedArrowsDuringDrag(n.id,c),this.textEditor&&this.textEditor.update()}this.dispatchEvent(new CustomEvent(Et,{detail:{point:s,annotation:this.annotation,handle:o}}))}dragBody(t,n){const s=W(t);return{...t,geometry:{type:t.geometry.type,coordinates:[s.x+n.x,s.y+n.y]}}}dragCorner(t,n,s){const r=s===0||s===1,o=s===0||s===3,a=s===1||s===2,l=s===2||s===3,{width:h,height:c}=z(t),d=this.store.getState();let{revSin:u,revCos:g}=d;(G(t)||H(t))&&(u=0,g=1);const f=n.x*g-n.y*u,m=n.x*u+n.y*g;let p=0,b=0;o?p=-f:a&&(p=f),r?b=-m:l&&(b=m);const S=Math.max(0,h+p),v=Math.max(0,c+b),A=W(t),x=A.x+n.x/2,C=A.y+n.y/2;return{...t,properties:{...t.properties,width:S,height:v},geometry:{type:t.geometry.type,coordinates:[x,C]}}}dragEdge(t,n,s){const{width:r,height:o}=z(t),a=W(t),l=this.store.getState();let{revSin:h,revCos:c}=l;(G(t)||H(t))&&(h=0,c=1);const d=n.x*c-n.y*h,u=n.x*h+n.y*c;let g=r,f=o,m=0,p=0;switch(s.edge){case"top":f=Math.max(0,o-u),p=u/2;break;case"bottom":f=Math.max(0,o+u),p=u/2;break;case"left":g=Math.max(0,r-d),m=d/2;break;case"right":g=Math.max(0,r+d),m=d/2;break}const b=m*c+p*h,S=-m*h+p*c;return{...t,properties:{...t.properties,width:g,height:f},geometry:{type:t.geometry.type,coordinates:[a.x+b,a.y+S]}}}onDragStart(t){return super.onDragStart(t)?(this.stopEditingText(),this.store.getState().startLiveUpdate([this.annotation]),!0):!1}onClick(t){const n=this.getAnnotation();n&&(L(n)||H(n))&&this.startEditingText()}startEditingText(){this.textEditor===null&&(this.textEditor=new ri(this.ogma,this.store,this.annotation,this.stopEditingText))}onDragEnd(t){var a,l;if(!super.onDragEnd(t))return!1;this.store.getState().drawingFeature===this.annotation&&this.store.setState({drawingFeature:null});const s=this.clientToCanvas(t),r=s.x-(((a=this.dragStartPoint)==null?void 0:a.x)||0),o=s.y-(((l=this.dragStartPoint)==null?void 0:l.y)||0);return Math.abs(r)<1&&Math.abs(o)<1?(this.clearDragState(),this.onClick({clientX:t.clientX,clientY:t.clientY})):this.commitChange(),this.hoveredHandle=void 0,this.dragStartPoint=void 0,this.dragging=!1,!0}getCornerCursor(t){return li[t]}getEdgeCursor(t){switch(t){case"top":case"bottom":return F.nsResize;case"left":case"right":return F.ewResize;default:return F.default}}stopEditing(){super.stopEditing(),this.commitChange(),this.stopEditingText()}startDrawing(t,n,s){this.annotation=t,this.hoveredHandle={type:"corner",corner:2},this.store.setState({hoveredHandle:2}),this.dragging=!0;const r=this.ogma.view.graphToScreenCoordinates({x:n,y:s});this.dragStartPoint=r,this.disablePanning(),this.onDragStart({clientX:r.x,clientY:r.y})}setAnnotation(t){super.setAnnotation(t),t&&H(t)&&t.properties.mode===et&&this.store.getState().updateFeature(t.id,{properties:{...t.properties,mode:$t}})}}class ci extends EventTarget{constructor(t,n,s,r,o){super();y(this,"handlers",new Map);y(this,"activeHandler");y(this,"interaction");y(this,"ogma");y(this,"snapping");y(this,"store");this.ogma=t,this.store=n,this.interaction=o,this.snapping=new ii(t,{detectMargin:10,magnetRadius:10},s,n),this.handlers.set("box",new Ce(this.ogma,this.store,r)),this.handlers.set("text",new Ce(this.ogma,this.store,r)),this.handlers.set("comment",new Ce(this.ogma,this.store,r)),this.handlers.set("arrow",new Xs(this.ogma,this.store,this.snapping,r)),this.handlers.set("polygon",new Us(this.ogma,this.store,r)),this.handlers.forEach(a=>{a.addEventListener("dragstart",()=>{this.dispatchEvent(new Event("dragstart")),this.store.setState({isDragging:!0}),this.interaction.setMode("edit")}),a.addEventListener("dragend",()=>{this.dispatchEvent(new Event("dragend")),this.store.setState({isDragging:!1}),this.interaction.suppressClicksTemporarily()})}),this.store.subscribe(a=>a.selectedFeatures,(a,l)=>{const h=Array.from(a.keys()).filter(d=>!l.has(d)),c=Array.from(l.keys()).filter(d=>!a.has(d));!h.length&&!c.length||(c.forEach(d=>this.stopEditingFeature(d)),h.forEach(d=>this.editFeature(d)))})}stopEditingFeature(t){const n=this.store.getState().features[t];if(!n)return;const s=n.properties.type,r=this.handlers.get(s);r&&r.stopEditing()}editFeature(t){var s;const n=this.store.getState().features[t];n&&(this.setActiveHandler(n.properties.type),(s=this.activeHandler)==null||s.setAnnotation(n))}getSnapping(){return this.snapping}getArrowHandler(){return this.handlers.get("arrow")}getActiveHandler(){return this.activeHandler}setActiveHandler(t){const n=this.handlers.get(t);if(!n)throw new Error(`Handler for type ${t} not found`);return this.activeHandler=n,this}destroy(){}}const hi=["x","y","radius"],di=1;class ui{constructor(e,t,n){y(this,"links",new Map);y(this,"nodeToLink",new Map);y(this,"edgeToLink",new Map);y(this,"annotationToLink",new Map);y(this,"linksByArrowId",new Map);y(this,"store");y(this,"ogma");y(this,"updatedItems",new Set);y(this,"onLinkCreated");y(this,"commitTimeout");y(this,"onSetMultipleAttributes",({elements:e,updatedAttributes:t})=>{const n=new Set(t);!e.isNode||!n.has("x")&&!n.has("y")&&!n.has("radius")||this.requestUpdateFromNodePositions(e.toList())});y(this,"refresh",()=>{const e=this.store.getState(),t=new Map;this.annotationToLink.forEach((n,s)=>{var a;const r=e.getFeature(s);if(!r)return;(L(r)&&((a=r.properties.style)==null?void 0:a.fixedSize)||H(r))&&n.forEach(l=>{const h=this.links.get(l);if(!h)return;const c=h.arrow;t.set(c,this.linksByArrowId.get(c))})}),t.size>0&&this.update(t)});y(this,"throttledRefresh",de(()=>this.refresh(),20));y(this,"onAddRemoveEdges",e=>{const t=e.edges;if(!t.size||!this.edgeToLink.size)return;const n=new Map,s=new Map;t.getParallelEdges().getId().forEach(r=>{const o=this.edgeToLink.get(r);o&&o.forEach(a=>{const l=this.links.get(a);if(!l)return;const h=l.arrow;n.set(h,this.linksByArrowId.get(h)),s.set(h,this.linksByArrowId.get(h))})}),s.size!==0&&this.update(s)});y(this,"commit",()=>{this.store.getState().batchUpdate(this.commitLiveUpdates),this.updatedItems.clear()});y(this,"commitLiveUpdates",()=>{this.store.getState().commitLiveUpdates(this.updatedItems)});y(this,"onAddArrow",(e,t)=>{const n=this.store.getState(),s=new Set(Object.keys(t)),r=Object.keys(e).filter(a=>!s.has(a)),o=Object.keys(t).filter(a=>!e[a]);r.forEach(a=>{var c,d;const l=n.getFeature(a);if(!l||!J(l))return;const h=l;if((c=h.properties.link)!=null&&c.start){const u=h.properties.link.start;this.add(h,q,u.id,u.type,u.magnet)}if((d=h.properties.link)!=null&&d.end){const u=h.properties.link.end;this.add(h,it,u.id,u.type,u.magnet)}}),o.forEach(a=>{const l=t[a];if(J(l)){const h=l;this.remove(h,q),this.remove(h,it)}else{const h=this.annotationToLink.get(a);if(h)for(const c of h){const d=this.links.get(c);if(!d)continue;const u=n.getFeature(d.arrow);u&&this.remove(u,d.side),this.linksByArrowId.delete(d.arrow),this.links.delete(c)}}})});this.ogma=e,this.store=t,this.onLinkCreated=n,this.store.subscribe(s=>s.features,this.onAddArrow),this.store.subscribe(s=>({zoom:s.zoom,rotation:s.rotation}),this.throttledRefresh,{equalityFn:(s,r)=>s.zoom===r.zoom&&s.rotation===r.rotation}),this.ogma.events.on("setMultipleAttributes",this.onSetMultipleAttributes).on(["addEdges","removeEdges"],this.onAddRemoveEdges).on("viewChanged",this.refresh)}updateLinkedArrowsDuringDrag(e,t){const n=this.store.getState();if(!n.getFeature(e))return;const r=this.annotationToLink.get(e);if(r)for(const o of r){const a=this.links.get(o);if(!a)continue;const l=n.getFeature(a.arrow),h=Ct(l,a.side),c=ht(h,t),d={...l.geometry,coordinates:l.geometry.coordinates.map((u,g)=>a.side===q&&g===0||a.side===it&&g===1?[c.x,c.y]:[...u])};n.applyLiveUpdate(l.id,{geometry:d}),this.updatedItems.add(l.id)}}add(e,t,n,s,r){const o=at(),a=e.id;let l=r;if(s===P.POLYGON){const u=this.store.getState().getFeature(n);if(u&&st(u)){const g=re(u),f=g[2]-g[0],m=g[3]-g[1],p=r.x-g[0],b=r.y-g[1],S=f>0?p/f:.5,v=m>0?b/m:.5;l={x:S,y:v}}}const h={id:o,arrow:a,target:n,targetType:s,magnet:l,side:t};if(s===P.NODE&&!this.ogma.getNode(n)||s===P.EDGE&&!this.ogma.getEdge(n))return;this.remove(e,t),this.links.set(o,h);const c=s===P.NODE?this.nodeToLink:s===P.EDGE?this.edgeToLink:this.annotationToLink;return c.has(n)||c.set(n,new Set),c.get(n).add(o),this.linksByArrowId.has(a)||this.linksByArrowId.set(a,{}),this.linksByArrowId.get(a)[t]=o,e.properties.link=e.properties.link||{},e.properties.link[t]={id:n,side:t,type:s,magnet:l},this.onLinkCreated&&this.onLinkCreated(e,h),this}remove(e,t){var o,a,l,h,c;const n=e.id,s=(o=this.linksByArrowId.get(n))==null?void 0:o[t];if((a=e.properties.link)==null||delete a[t],!s)return this;const r=this.links.get(s);return r?(this.links.delete(s),(l=this.nodeToLink.get(r.target))==null||l.delete(s),(h=this.edgeToLink.get(r.target))==null||h.delete(s),(c=this.annotationToLink.get(r.target))==null||c.delete(s),this.linksByArrowId.has(n)&&(this.linksByArrowId.get(n)[t]=void 0),this):this}requestUpdateFromNodePositions(e){setTimeout(()=>this.updateFromNodePositions(e),1)}updateFromNodePositions(e){const t=e.getId(),n=new Map;t.forEach(h=>{const c=this.nodeToLink.get(h);c&&c.forEach(d=>{const u=this.links.get(d);if(!u)return;const g=u.arrow;n.set(g,this.linksByArrowId.get(g))})});const s=new Map;e.getAdjacentEdges().getId().forEach(h=>{const c=this.edgeToLink.get(h);c&&c.forEach(d=>{const u=this.links.get(d);if(!u)return;const g=u.arrow;n.set(g,this.linksByArrowId.get(g)),s.set(g,this.linksByArrowId.get(g))})});const o=e.getAttributes(hi),a=this.store.getState(),l={};for(let h=0;h<t.length;h++){const c=t[h],d=this.nodeToLink.get(c);if(d)for(const u of d){const g=this.links.get(u);if(!g)continue;const f=g.arrow,m=this.store.getState().getFeature(f),p=m.geometry.coordinates.slice(),b=Ct(m,it),S=Ct(m,q),v=o[h],A=this._getNodeSnapPoint(v,nt(I(b,S),-1),this._isLinkedToCenter(g));p[g.side===q?0:1]=A,l[f]={...m,geometry:{coordinates:p}},this.updatedItems.add(f),g.magnet={x:A[0]-v.x,y:A[1]-v.y},ct(l[f])}}if(a.applyLiveUpdates(l),s.size>0){this.update(s);return}this.requestCommit()}update(e=this.linksByArrowId){const t=this.store.getState(),n=Array.from(this.nodeToLink.keys()),s=new Map;n.forEach((l,h)=>s.set(l,h));const o=this.ogma.getNodes(n).getAttributes(["x","y","radius"]),a={};e.forEach((l,h)=>{const c=this.links.get(l.start),d=this.links.get(l.end),u=t.getFeature(h);let g=u.geometry.coordinates[0],f=u.geometry.coordinates[1];const m=c?c.targetType===P.NODE?o[s.get(c.target)]:c.targetType===P.EDGE?this._getEdgeSnapPoint(c.target,c.magnet.x,!0):this._getAnnotationCenter(t.getFeature(c.target)):{x:g[0],y:g[1]},p=d?d.targetType===P.NODE?o[s.get(d.target)]:d.targetType===P.EDGE?this._getEdgeSnapPoint(d.target,d.magnet.x,!0):this._getAnnotationCenter(t.getFeature(d.target)):{x:f[0],y:f[1]},b=I(p,m);if(c)if(c.targetType===P.NODE)g=this._getNodeSnapPoint(m,b,this._isLinkedToCenter(c));else if(c.targetType===P.EDGE)g=this._getEdgeSnapPoint(c.target,c.magnet.x);else{const S=t.getFeature(c.target);g=this._getAnnotationSnapPoint(S,p,c,t.zoom)}if(d)if(d.targetType===P.NODE)f=this._getNodeSnapPoint(p,nt(b,-1),this._isLinkedToCenter(d));else if(d.targetType===P.EDGE)f=this._getEdgeSnapPoint(d.target,d.magnet.x);else{const S=t.getFeature(d.target);f=this._getAnnotationSnapPoint(S,m,d,t.zoom)}a[u.id]={properties:u.properties,geometry:{coordinates:[g,f]}},ct(a[u.id]),this.updatedItems.add(u.id)}),t.applyLiveUpdates(a),this.requestCommit()}requestCommit(){clearTimeout(this.commitTimeout),this.commitTimeout=setTimeout(this.commit,di)}_isLinkedToCenter(e){return e.magnet.x===0&&e.magnet.y===0}_getAnnotationCenter(e){return st(e)?oe(e):W(e)}_getAnnotationSnapPoint(e,t,n,s){if(st(e)){const r=re(e),o=r[0]+n.magnet.x*(r[2]-r[0]),a=r[1]+n.magnet.y*(r[3]-r[1]);return[o,a]}return this._getBoxSnapPoint(e,t,n,s)}_getBoxSnapPoint(e,t,n,s){var d;const r=W(e);let{width:o,height:a}=z(e);(L(e)&&((d=e.properties.style)==null?void 0:d.fixedSize)||H(e))&&(o/=s,a/=s);let h=n.magnet.x*o,c=n.magnet.y*a;if(L(e)&&!G(e)){const{sin:u,cos:g}=this.store.getState(),f=h*g-c*u,m=h*u+c*g;h=f,c=m}else if(H(e)){const g={...e.properties.style}.iconSize||32,f=g/16*.5;h=n.magnet.x*g*f,c=n.magnet.y*g*f}return[r.x+h,r.y+c]}_getNodeSnapPoint(e,t,n){if(n)return[e.x,e.y];const s=Math.sqrt(t.x*t.x+t.y*t.y),r=nt(t,1/s),o=s<Number(e.radius)/2?{x:e.x,y:e.y}:ht({x:e.x,y:e.y},nt(r,-Number(e.radius)));return[o.x,o.y]}_getEdgeSnapPoint(e,t,n=!1){const s=this.ogma.getEdge(e);if(!s)return[0,0];const r=s.getAttribute("curvature"),a=s.getExtremities().getPosition(),l=a[0],h=a[1];if(r===0||r===void 0){const u=[l.x+t*(h.x-l.x),l.y+t*(h.y-l.y)];return n?{x:u[0],y:u[1]}:u}const c=O.geometry.getQuadraticCurveControlPoint(l.x,l.y,h.x,h.y,r),d=O.geometry.getPointOnQuadraticCurve(t,l.x,l.y,h.x,h.y,c.x,c.y);return n?{x:d.x,y:d.y}:[d.x,d.y]}destroy(){this.ogma.events.off(this.onSetMultipleAttributes)}}function Te(i){return i instanceof HTMLCanvasElement}class gi extends EventTarget{constructor(t,n,s){super();y(this,"query",{minX:1/0,minY:1/0,maxX:1/0,maxY:1/0});y(this,"suppressClickUntil",0);y(this,"mouseDownState",null);y(this,"DRAG_THRESHOLD",3);y(this,"onMouseMove",t=>{if(!Te(t.target))return;const n=kt(t,this.ogma.getContainer()),s=this.store.getState();if(this.mouseDownState&&!s.isDragging){const c=t.clientX-this.mouseDownState.screenX,d=t.clientY-this.mouseDownState.screenY;Math.sqrt(c*c+d*d)>this.DRAG_THRESHOLD&&(this.mouseDownState.hasMoved=!0)}if(s.isDragging)return;const{x:r,y:o}=this.ogma.view.screenToGraphCoordinates(n),a=this.detect(r,o),l=(a==null?void 0:a.id)??null,h=s.hoveredFeature;l!==h&&s.setHoveredFeature(l),this.setCursor(l===null?F.default:F.pointer)});y(this,"onMouseClick",()=>{Date.now()<this.suppressClickUntil});y(this,"onMouseDown",t=>{if(!Te(t.target)||Date.now()<this.suppressClickUntil)return;const n=kt(t,this.ogma.getContainer()),{x:s,y:r}=this.ogma.view.screenToGraphCoordinates(n),o=this.detect(s,r);this.mouseDownState={annotation:o,screenX:t.clientX,screenY:t.clientY,hasMoved:!1};const a=this.store.getState();this.store.setState({mousePressed:!0,mousePressPoint:{x:s,y:r}}),o&&!a.selectedFeatures.has(o.id)&&(t.ctrlKey||t.metaKey?a.toggleSelection(o.id):a.setSelectedFeatures([o.id]))});y(this,"onMouseUp",t=>{if(!Te(t.target))return;const n=this.store.getState();if(this.store.setState({mousePressed:!1,mousePressPoint:null}),this.mouseDownState&&!this.mouseDownState.hasMoved&&!n.isDragging){const s=this.mouseDownState.annotation;s?t.ctrlKey||t.metaKey?n.toggleSelection(s.id):n.selectedFeatures.has(s.id)||n.setSelectedFeatures([s.id]):!t.ctrlKey&&!t.metaKey&&n.clearSelection(),this.dispatchEvent(new Event(zt))}this.mouseDownState=null});y(this,"onWheel",t=>{var d;if(t.target instanceof HTMLTextAreaElement)return;const n=kt(t,this.ogma.getContainer()),{x:s,y:r}=this.ogma.view.screenToGraphCoordinates(n),o=this.detect(s,r);if(!o||!H(o))return;const a=(d=o.properties.style)==null?void 0:d.maxHeight,l=o.properties.height;if(!a||l<=a)return;const h=this.ogma.getContainer(),c=h==null?void 0:h.querySelector(`[data-annotation="${o.id}"] .comment-box foreignObject div`);c&&(t.stopPropagation(),t.preventDefault(),c.scrollTop+=t.deltaY)});this.ogma=t,this.store=n,this.index=s;const r=this.ogma.getContainer();r&&(r.addEventListener("mousemove",this.onMouseMove,{passive:!0,capture:!0}),r.addEventListener("click",this.onMouseClick,{passive:!0,capture:!0}),r.addEventListener("mousedown",this.onMouseDown,{passive:!0,capture:!1}),r.addEventListener("mouseup",this.onMouseUp,{passive:!0,capture:!0}),r.addEventListener("wheel",this.onWheel,{passive:!1,capture:!0}))}detect(t,n,s){let r=null;const o=this.store.getState(),a=s??o.options.detectMargin;this.query.minX=t-a,this.query.minY=n-a,this.query.maxX=t+a,this.query.maxY=n+a;const l=this.index.query(this.query);if(l.length===0)return null;for(const h of l){const c=o.getFeature(h.id);if(J(c)){if(ge(c,{x:t,y:n},a)){r=c;break}}else if(G(c)){if(rn(c,{x:t,y:n},0,1,a)){r=c;break}}else if(st(c)){if(we(c,{x:t,y:n},a)){r=c;break}}else if(H(c)){if(on(c,{x:t,y:n},a,o.sin,o.cos,o.zoom)){r=c;break}}else if(L(c)&&pe(c,{x:t,y:n},a,o.revSin,o.revCos,o.zoom)){r=c;break}}return r}setCursor(t){var s;const n=(s=this.ogma.getContainer())==null?void 0:s.firstChild;n&&(n.style.cursor=t)}setMode(t){var n;t==="default"?this.setCursor(((n=this.ogma.getOptions().cursor)==null?void 0:n.default)||"default"):t==="add"||t==="link"?this.setCursor(F.crosshair):t==="rotate"&&this.setCursor(F.alias)}suppressClicksTemporarily(t=100){this.suppressClickUntil=Date.now()+t}destroy(){const t=this.ogma.getContainer();t&&(t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("click",this.onMouseClick))}}function pn(i,e,t=0,n=i.length-1,s=fi){for(;n>t;){if(n-t>600){const l=n-t+1,h=e-t+1,c=Math.log(l),d=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*d*(l-d)/l)*(h-l/2<0?-1:1),g=Math.max(t,Math.floor(e-h*d/l+u)),f=Math.min(n,Math.floor(e+(l-h)*d/l+u));pn(i,e,g,f,s)}const r=i[e];let o=t,a=n;for(Pt(i,t,e),s(i[n],r)>0&&Pt(i,t,n);o<a;){for(Pt(i,o,a),o++,a--;s(i[o],r)<0;)o++;for(;s(i[a],r)>0;)a--}s(i[t],r)===0?Pt(i,t,a):(a++,Pt(i,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function Pt(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function fi(i,e){return i<e?-1:i>e?1:0}class mi{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!Vt(e,t))return n;const s=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?s(a):a;Vt(e,l)&&(t.leaf?n.push(a):Me(e,l)?this._all(a,n):r.push(a))}t=r.pop()}return n}collides(e){let t=this.data;if(!Vt(e,t))return!1;const n=[];for(;t;){for(let s=0;s<t.children.length;s++){const r=t.children[s],o=t.leaf?this.toBBox(r):r;if(Vt(e,o)){if(t.leaf||Me(e,o))return!0;n.push(r)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let n=0;n<e.length;n++)this.insert(e[n]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const n=this.data;this.data=t,t=n}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=vt([]),this}remove(e,t){if(!e)return this;let n=this.data;const s=this.toBBox(e),r=[],o=[];let a,l,h;for(;n||r.length;){if(n||(n=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),n.leaf){const c=pi(e,n.children,t);if(c!==-1)return n.children.splice(c,1),r.push(n),this._condense(r),this}!h&&!n.leaf&&Me(n,s)?(r.push(n),o.push(a),a=0,l=n,n=n.children[0]):l?(a++,n=l.children[a],h=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,s){const r=n-t+1;let o=this._maxEntries,a;if(r<=o)return a=vt(e.slice(t,n+1)),St(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=vt([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));yn(e,t,n,h,this.compareMinX);for(let c=t;c<=n;c+=h){const d=Math.min(c+h-1,n);yn(e,c,d,l,this.compareMinY);for(let u=c;u<=d;u+=l){const g=Math.min(u+l-1,d);a.children.push(this._build(e,u,g,s-1))}}return St(a,this.toBBox),a}_chooseSubtree(e,t,n,s){for(;s.push(t),!(t.leaf||s.length-1===n);){let r=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],c=ke(h),d=xi(e,h)-c;d<o?(o=d,r=c<r?c:r,a=h):d===o&&c<r&&(r=c,a=h)}t=a||t.children[0]}return t}_insert(e,t,n){const s=n?e:this.toBBox(e),r=[],o=this._chooseSubtree(s,this.data,t,r);for(o.children.push(e),Ft(o,s);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(s,r,t)}_split(e,t){const n=e[t],s=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,s);const o=this._chooseSplitIndex(n,r,s),a=vt(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,St(n,this.toBBox),St(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=vt([e,t]),this.data.height=e.height+1,this.data.leaf=!1,St(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let s,r=1/0,o=1/0;for(let a=t;a<=n-t;a++){const l=Dt(e,0,a,this.toBBox),h=Dt(e,a,n,this.toBBox),c=bi(l,h),d=ke(l)+ke(h);c<r?(r=c,s=a,o=d<o?d:o):c===r&&d<o&&(o=d,s=a)}return s||n-t}_chooseSplitAxis(e,t,n){const s=e.leaf?this.compareMinX:yi,r=e.leaf?this.compareMinY:wi,o=this._allDistMargin(e,t,n,s),a=this._allDistMargin(e,t,n,r);o<a&&e.children.sort(s)}_allDistMargin(e,t,n,s){e.children.sort(s);const r=this.toBBox,o=Dt(e,0,t,r),a=Dt(e,n-t,n,r);let l=jt(o)+jt(a);for(let h=t;h<n-t;h++){const c=e.children[h];Ft(o,e.leaf?r(c):c),l+=jt(o)}for(let h=n-t-1;h>=t;h--){const c=e.children[h];Ft(a,e.leaf?r(c):c),l+=jt(a)}return l}_adjustParentBBoxes(e,t,n){for(let s=n;s>=0;s--)Ft(t[s],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():St(e[t],this.toBBox)}}function pi(i,e,t){if(!t)return e.indexOf(i);for(let n=0;n<e.length;n++)if(t(i,e[n]))return n;return-1}function St(i,e){Dt(i,0,i.children.length,e,i)}function Dt(i,e,t,n,s){s||(s=vt(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=e;r<t;r++){const o=i.children[r];Ft(s,i.leaf?n(o):o)}return s}function Ft(i,e){return i.minX=Math.min(i.minX,e.minX),i.minY=Math.min(i.minY,e.minY),i.maxX=Math.max(i.maxX,e.maxX),i.maxY=Math.max(i.maxY,e.maxY),i}function yi(i,e){return i.minX-e.minX}function wi(i,e){return i.minY-e.minY}function ke(i){return(i.maxX-i.minX)*(i.maxY-i.minY)}function jt(i){return i.maxX-i.minX+(i.maxY-i.minY)}function xi(i,e){return(Math.max(e.maxX,i.maxX)-Math.min(e.minX,i.minX))*(Math.max(e.maxY,i.maxY)-Math.min(e.minY,i.minY))}function bi(i,e){const t=Math.max(i.minX,e.minX),n=Math.max(i.minY,e.minY),s=Math.min(i.maxX,e.maxX),r=Math.min(i.maxY,e.maxY);return Math.max(0,s-t)*Math.max(0,r-n)}function Me(i,e){return i.minX<=e.minX&&i.minY<=e.minY&&e.maxX<=i.maxX&&e.maxY<=i.maxY}function Vt(i,e){return e.minX<=i.maxX&&e.minY<=i.maxY&&e.maxX>=i.minX&&e.maxY>=i.minY}function vt(i){return{children:i,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function yn(i,e,t,n,s){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=n)continue;const o=e+Math.ceil((t-e)/n/2)*n;pn(i,o,e,t,s),r.push(e,o,o,t)}}const _t={minX:0,minY:0,maxX:0,maxY:0},wn=(i,e)=>i.id===e.id;class Si extends mi{constructor(t){super();y(this,"store");y(this,"onRotationChange",()=>{const t=this.store.getState().getAllFeatures().filter(n=>L(n)||H(n));for(const n of t)this.updateRotatedText(n)});y(this,"onZoomChange",()=>{const t=this.store.getState().getAllFeatures().filter(n=>{var s;return(L(n)||H(n))&&((s=n.properties.style)==null?void 0:s.fixedSize)});for(const n of t)this.updateRotatedText(n)});this.store=t,this.store.subscribe(n=>n.features,n=>{this.clear(),Object.values(n).forEach(s=>{L(s)||H(s)?this.updateRotatedText(s):this.insert(s)})}),this.store.subscribe(n=>({features:n.features,isDragging:n.isDragging,lastChangedFeatures:n.lastChangedFeatures,rotation:n.rotation}),(n,s)=>{s&&s.isDragging&&!n.isDragging&&n.lastChangedFeatures.length>0&&n.lastChangedFeatures.forEach(r=>{const o=n.features[r];o&&(ct(o),L(o)||H(o)?this.updateRotatedText(o):(this.remove(o,wn),this.insert(o)))})},{equalityFn:(n,s)=>n.isDragging===s.isDragging}),this.store.subscribe(n=>n.rotation,this.onRotationChange),this.store.subscribe(n=>n.zoom,this.onZoomChange)}updateRotatedText(t){var d;const n=this.store.getState();this.remove(t,wn);const s=W(t);let{width:r,height:o}=z(t);if(((d=t.properties.style)==null?void 0:d.fixedSize)===!0){const u=n.invZoom;r*=u,o*=u}const l=r/2,h=o/2,c=n.getRotatedBBox(s.x-l,s.y-h,s.x+l,s.y+h);this.insert({...t,geometry:{...t.geometry,bbox:c.slice()}})}compareMinX(t,n){return tt(t)[0]-tt(n)[0]}compareMinY(t,n){return tt(t)[1]-tt(n)[1]}toBBox(t){const n=tt(t);return _t.minX=n[0],_t.minY=n[1],_t.maxX=n[2],_t.maxY=n[3],_t}query(t){return super.search(t)}}class xn{constructor(e,t){y(this,"layer");this.ogma=e,this.store=t}destroy(){}}function vi(i,e,t,n,s,r){const o=Math.min(n/2,s/2),a=Math.min(r,o);i.beginPath(),i.moveTo(e+a,t),i.lineTo(e+n-a,t),i.quadraticCurveTo(e+n,t,e+n,t+a),i.lineTo(e+n,t+s-a),i.quadraticCurveTo(e+n,t+s,e+n-a,t+s),i.lineTo(e+a,t+s),i.quadraticCurveTo(e,t+s,e,t+s-a),i.lineTo(e,t+a),i.quadraticCurveTo(e,t,e+a,t),i.closePath()}const bn=[[-.5,-.5],[.5,-.5],[.5,.5],[-.5,.5]];class Ai extends xn{constructor(t,n){super(t,n);y(this,"handleFill","#fff");y(this,"handleStroke","#1A70E5");y(this,"handleStrokeWidth",1.5);y(this,"handleRadius",3);y(this,"handleMagnifier",1.5);y(this,"refresh",()=>{this.layer.refresh()});y(this,"render",t=>{const n=this.store.getState(),s=1/n.zoom,{hoveredHandle:r,rotation:o,liveUpdates:a,features:l}=n,h=this.handleRadius*s;t.fillStyle=this.handleFill,t.lineWidth=this.handleStrokeWidth*s,t.strokeStyle=this.handleStroke,Object.values(l).forEach(c=>{if(!n.isSelected(c.id))return;const d=a[c.id]?{...c,...a[c.id]}:c;if(J(d))this.renderArrowHandles(d,t,h,r);else if(G(d)||L(d)){const u=L(d)?o:0;this.renderOutline(d,t,u,r,n.zoom),this.renderBoxHandles(d,t,h,r,u)}else st(d)&&this.renderPolygonHandles(d,t,h,r,n.drawingFeature===d.id)})});this.layer=t.layers.addCanvasLayer(this.render,void 0,Ot.HANDLES),this.store.subscribe(s=>({selectedFeatures:s.selectedFeatures,liveUpdates:s.liveUpdates}),this.refresh),t.events.on("zoom",this.refresh)}renderOutline(t,n,s,r,o){var p,b;const a=L(t)&&((p=t.properties.style)==null?void 0:p.fixedSize);let{width:l,height:h}=z(t);a&&(l/=o,h/=o);const c=lt(t,a,o),d=l/2,u=h/2,g=c.x+d,f=c.y+u;n.save(),n.translate(g,f),n.rotate(s);const m=(b=t.properties.style)==null?void 0:b.borderRadius;if(m&&m>0?(vi(n,-d,-u,l,h,m),n.stroke()):n.strokeRect(-d,-u,l,h),r>=4&&r<8){let S,v,A,x;const C=m&&m>0?m:this.handleRadius/o;switch(r){case 4:S=-d+C,v=-u,A=d-C,x=-u;break;case 5:S=d,v=-u+C,A=d,x=u-C;break;case 6:S=d-C,v=u,A=-d+C,x=u;break;case 7:S=-d,v=u-C,A=-d,x=-u+C;break}n.lineWidth=this.handleStrokeWidth*this.handleMagnifier/o,n.beginPath(),n.moveTo(S,v),n.lineTo(A,x),n.stroke(),n.lineWidth=this.handleStrokeWidth}n.restore()}renderArrowHandles(t,n,s,r){const o=le(t),a=ce(t),l=+(r===0),h=+(r===1),c=s*(1+(this.handleMagnifier-1)*l),d=s*(1+(this.handleMagnifier-1)*h);n.beginPath(),n.moveTo(o.x,o.y),n.lineTo(a.x,a.y),n.closePath(),n.stroke(),n.beginPath(),n.moveTo(o.x-c,o.y-c),n.rect(o.x-c,o.y-c,c*2,c*2),n.moveTo(a.x-d,a.y-d),n.rect(a.x-d,a.y-d,d*2,d*2),n.closePath(),n.fill(),n.stroke()}renderBoxHandles(t,n,s,r,o){var f;if(L(t)&&((f=t.properties.style)!=null&&f.fixedSize))return;const{width:a,height:l}=z(t),h=lt(t),c=a/2,d=l/2,u=h.x+c,g=h.y+d;n.save(),n.translate(u,g),n.rotate(o),n.beginPath();for(let m=0;m<bn.length;m++){const[p,b]=bn[m],S=a*p,v=l*b,A=r===m?s*this.handleMagnifier:s;n.rect(S-A,v-A,A*2,A*2)}n.closePath(),n.fill(),n.stroke(),n.restore()}renderPolygonHandles(t,n,s,r,o){const a=t.geometry.coordinates[0];if(!o){a.length>2&&(n.save(),n.strokeStyle=this.handleStroke,n.lineWidth=this.handleStrokeWidth/this.store.getState().zoom,this.drawSmoothPolygon(n,a,.5),n.stroke(),n.restore()),n.beginPath();for(let l=0;l<a.length-1;l++){const[h,c]=a[l],d=r===l?s*this.handleMagnifier:s;n.moveTo(h+d,c),n.arc(h,c,d,0,2*Math.PI)}n.closePath(),n.fill(),n.stroke()}}drawSmoothPolygon(t,n,s){const r=n.slice(0,-1);if(r.length<3)return;t.beginPath();const o=r.length;for(let a=0;a<o;a++){const l=r[(a-1+o)%o],h=r[a],c=r[(a+1)%o],d=r[(a+2)%o],u=h[0]+(c[0]-l[0])/6*s,g=h[1]+(c[1]-l[1])/6*s,f=c[0]-(d[0]-h[0])/6*s,m=c[1]-(d[1]-h[1])/6*s;a===0&&t.moveTo(h[0],h[1]),t.bezierCurveTo(u,g,f,m,c[0],c[1])}t.closePath()}renderCenterPoint(t,n){var r;const s=this.store.getState();if(L(t)){const o=lt(t,(r=t.properties.style)==null?void 0:r.fixedSize,s.zoom),a=z(t);n.moveTo(o.x+a.width/2+5,o.y+a.height/2),n.arc(o.x+a.width/2,o.y+a.height/2,5,0,Math.PI*2,!0)}}destroy(){this.layer.destroy(),super.destroy()}}const Ei=.5;function Ci(i,e,t,n){const{start:s,end:r}=Xt(i),o=I(r,s);return Math.min(n,Math.max(2*e,V(o)*.01,t))}function Sn(i,e){return!i||i==="none"?0:i==="dot"?e*2:i==="halo-dot"?e*4:i==="arrow"||i==="arrow-plain"?e:0}function Ti(i,e){if(!i){i=k("g");const t=k("path");i.classList.add("annotation-arrow"),i.setAttribute("data-annotation",`${e}`),i.setAttribute("data-annotation-type","arrow"),i.appendChild(t);const n=k("g");n.classList.add("annotation-arrow-endpoints"),i.appendChild(n)}return i}function ki(i,e,t,n,s,r){const{start:o,end:a}=Xt(e),l=e.properties.style||dt,{tail:h,strokeWidth:c=0,head:d,strokeColor:u,strokeType:g}=l,f=I(a,o),m=Ae(e)?1/r.zoom:1,p=Ci(e,c,t,n)*m,b=Ti(s,e.id),S=b.firstChild,v=u||"none";S.setAttribute("stroke",v),S.setAttribute("stroke-width",`${m*c}`),S.setAttribute("fill","none"),S.setAttribute("stroke-linecap","round"),S.setAttribute("stroke-linejoin","round");const A=Sn(h,c*m),x=Sn(d,c*m),C=qt(f),E=ht(o,nt(C,A)),T=ht(a,nt(C,-x)),M=`M ${E.x} ${E.y} L ${T.x} ${T.y}`;S.setAttribute("d",M);const D=b.children[1];return D.innerHTML="",g==="dashed"?S.setAttribute("stroke-dasharray","5,10"):S.removeAttribute("stroke-dasharray"),vn(D,o,f,v,h,c,m,p),vn(D,a,ws(f),v,d,c,m,p),b.setAttribute("transform",`rotate(${-r.rotation*(180/Math.PI)})`),i.appendChild(b),b}function vn(i,e,t,n,s,r,o,a){s==="halo-dot"&&An(i,e,Mi(n),Ei,r*o*4),(s==="dot"||s==="halo-dot")&&An(i,e,n,1,r*o*2),(s==="arrow"||s==="arrow-plain")&&Pi(i,e,t,n,s==="arrow-plain",r*o,a)}function Mi(i){return i==="none"?"none":i}function An(i,e,t,n,s){const r=k("circle");r.setAttribute("cx",`${e.x}`),r.setAttribute("cy",`${e.y}`),r.setAttribute("r",`${s}`),r.setAttribute("fill-opacity",`${n}`),r.setAttribute("fill",t),i.appendChild(r)}function Pi(i,e,t,n,s,r,o){const a=nt(qt(t),o),l=ht(e,sn(a,Math.PI/6)),h=ht(e,sn(a,-Math.PI/6)),c=k("path"),d=`${e.x} ${e.y}`,u=`M ${l.x} ${l.y} L ${d} L ${h.x} ${h.y}${s?" Z":""}`;c.setAttribute("d",u),c.setAttribute("stroke",n),c.setAttribute("stroke-width",`${r}`),c.setAttribute("fill",s?n:"none"),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),i.appendChild(c)}function Di(i,e,t="box"){if(!i){i=k("g"),i.setAttribute("data-annotation",`${e}`),i.setAttribute("data-annotation-type",t),i.classList.add(`annotation-${t}`);const n=k("rect");i.appendChild(n)}return i}function En(i,e,t,n){const s=e.id,r=`class${s}`,o=z(e),a=Di(t,s,e.properties.type),{strokeColor:l,strokeWidth:h,strokeType:c,background:d,borderRadius:u}=e.properties.style||bt;a.classList.add("annotation-box"),a.setAttribute("fill",`${d||"transparent"}`);const g=a.firstChild;u&&(g.setAttribute("rx",`${u}`),g.setAttribute("ry",`${u}`)),c&&c!=="none"&&(g.setAttribute("stroke",l||"black"),g.setAttribute("stroke-width",`${h}`),c==="dashed"&&g.setAttribute("stroke-dasharray","5,5")),d&&d.length&&(n.hoveredFeature===e.id?g.setAttribute("fill",wt(d)):g.setAttribute("fill",d));const f=lt(e);return g.setAttribute("width",`${o.width}`),g.setAttribute("height",`${o.height}`),g.setAttribute("x",`${f.x}`),g.setAttribute("y",`${f.y}`),a.appendChild(g),a.setAttribute("transform",n.getRotationTransform(0,0)),a.classList.add(r),a.setAttribute("data-annotation",`${e.id}`),a.setAttribute("data-annotation-type",e.properties.type),i.appendChild(a),a}let Pe=null;function Fi(){return Pe||(Pe=document.createElement("canvas").getContext("2d")),Pe}function _i(i,e,t,n,s){if(!i||i.length===0)return 60;const r=Fi();r.font=`${t}px ${e}`;const o=i.split(`
|
|
9
|
+
`);let a=0;for(const h of o){if(h.length===0)continue;const c=h.split(/\s+/);let d=0;const u=r.measureText(" ").width,g=n-s*2;for(let f=0;f<c.length;f++){const m=c[f],p=r.measureText(m).width;d===0?d=p:d+u+p<=g?d+=u+p:(a=Math.max(a,d),d=p)}a=Math.max(a,d)}const l=a+s*2+4;return Math.min(l,n)}function Li(){const i=k("style");return i.textContent=`
|
|
10
|
+
/* Comment Animation Styles */
|
|
11
|
+
.comment-icon,
|
|
12
|
+
.comment-box {
|
|
13
|
+
transition:
|
|
14
|
+
opacity 0.25s ease-in-out,
|
|
15
|
+
scale 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
16
|
+
will-change: scale, opacity;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Disable transitions when comment was not visible */
|
|
20
|
+
.comment-no-transition .comment-icon,
|
|
21
|
+
.comment-no-transition .comment-box {
|
|
22
|
+
transition: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Collapsed state: icon visible, box hidden */
|
|
26
|
+
.comment-collapsed .comment-icon {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
scale: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.comment-collapsed .comment-box {
|
|
32
|
+
opacity: 0;
|
|
33
|
+
scale: 0.5;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Expanded state: box visible, icon hidden */
|
|
37
|
+
.comment-expanded .comment-icon {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
scale: 0.5;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.comment-expanded .comment-box {
|
|
43
|
+
opacity: 1;
|
|
44
|
+
scale: 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Comment scrollbar styling */
|
|
48
|
+
.comment-box foreignObject div::-webkit-scrollbar {
|
|
49
|
+
width: 6px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.comment-box foreignObject div::-webkit-scrollbar-track {
|
|
53
|
+
background: transparent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.comment-box foreignObject div::-webkit-scrollbar-thumb {
|
|
57
|
+
background: rgba(0, 0, 0, 0.2);
|
|
58
|
+
border-radius: 3px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.comment-box foreignObject div::-webkit-scrollbar-thumb:hover {
|
|
62
|
+
background: rgba(0, 0, 0, 0.3);
|
|
63
|
+
}
|
|
64
|
+
`,i}function Hi(i,e,t){const n={...Q,...e.properties.style},s=n.iconSize,{iconColor:r=Q.iconColor,iconSymbol:o=Q.iconSymbol,iconBorderColor:a=Q.iconBorderColor,iconBorderWidth:l=Q.iconBorderWidth}=n;let h=i.querySelector("circle");h||(h=k("circle"),h.setAttribute("cx","0"),h.setAttribute("cy","0"),i.appendChild(h)),h.setAttribute("r",`${s/2}`),t.hoveredFeature===e.id?h.setAttribute("fill",wt(r)):h.setAttribute("fill",r),l&&l>0?(h.setAttribute("stroke",a||"#CCC"),h.setAttribute("stroke-width",`${l}`)):(h.removeAttribute("stroke"),h.removeAttribute("stroke-width"));let c=i.querySelector("text");c||(c=k("text"),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("text-anchor","middle"),c.setAttribute("dominant-baseline","central"),c.setAttribute("pointer-events","none"),i.appendChild(c)),c.setAttribute("font-size",`${s*.5}`),c.textContent=o}function Ii(i,e,t){const n={...Q,...e.properties.style},{font:s="Arial, sans-serif",fontSize:r=12,padding:o=8,background:a="#FFFACD",color:l="#333",borderRadius:h=4,strokeColor:c="#DDD",strokeWidth:d=1,maxHeight:u}=n,g=e.properties.width,f=e.properties.content||"",m=_i(f,s,typeof r=="number"?r:parseFloat(r),g,o),p=e.properties.height,b=u?Math.min(p,u):p,S=u?p>u:!1;i.innerHTML="";const v=-m/2,A=-b/2,x=k("rect");x.setAttribute("x",`${v}`),x.setAttribute("y",`${A}`),x.setAttribute("width",`${m}`),x.setAttribute("height",`${b}`),x.setAttribute("rx",`${h}`),x.setAttribute("ry",`${h}`),x.setAttribute("fill",t.hoveredFeature===e.id?wt(a):a),d&&d>0&&(x.setAttribute("stroke",c||"#DDD"),x.setAttribute("stroke-width",`${d}`)),i.appendChild(x);const C=k("foreignObject");C.setAttribute("x",`${v}`),C.setAttribute("y",`${A}`),C.setAttribute("width",`${m}`),C.setAttribute("height",`${b}`),C.style.pointerEvents="none";const E=document.createElement("div");E.style.width="100%",E.style.height="100%",E.style.padding=`${o}px`,E.style.boxSizing="border-box",E.style.fontFamily=s,E.style.fontSize=`${r}px`,E.style.lineHeight=`${(typeof r=="number"?r:parseFloat(r))*Yt}px`,E.style.color=l,E.style.overflowY=S?"auto":"hidden",E.style.overflowX="hidden",E.style.overflowWrap="break-word",E.style.whiteSpace="pre-wrap",E.style.pointerEvents="none",E.innerHTML=Bi(f),C.appendChild(E),i.appendChild(C),i.setAttribute("filter","url(#softShadow)")}function Bi(i){if(!i)return"";let e=i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return e=e.replace(/(https?:\/\/[^\s<]+)/g,'<a href="$1" target="_blank" style="color: #38e; text-decoration: none;">$1</a>'),e}function Ri(i,e,t,n,s){const r=e.properties.mode;let o=t;o||(o=k("g"),o.setAttribute("data-annotation",`${e.id}`),o.setAttribute("data-annotation-type","comment"));let a=o.querySelector(".comment-icon");a||(a=k("g"),a.classList.add("comment-icon"),o.appendChild(a));let l=o.querySelector(".comment-box");l||(l=k("g"),l.classList.add("comment-box"),o.appendChild(l)),Hi(a,e,n),Ii(l,e,n),s?o.classList.remove("comment-no-transition"):o.classList.add("comment-no-transition"),r===et&&!o.classList.contains("comment-collapsed")?(o.classList.add("comment-collapsed"),o.classList.remove("comment-expanded")):r!==et&&o.classList.contains("comment-collapsed")&&(o.classList.add("comment-expanded"),o.classList.remove("comment-collapsed"));const h=W(e);return o.setAttribute("transform",n.getScreenAlignedTransform(h.x,h.y,!1)),(!o.parentNode||o.parentNode!==i)&&i.appendChild(o),o}function zi(i,e=.5,t=!1){if(i.length<2)return"";if(i.length<3)return i.map((o,a)=>`${a===0?"M":"L"}${o[0]},${o[1]}`).join(" ")+" Z";const n=i,s=n.length-1,r=[];for(let o=0;o<s;o++){const a=n[(o-1+s)%s],l=n[o],h=n[(o+1)%s],c=n[(o+2)%s],d=l[0]+(h[0]-a[0])/6*e,u=l[1]+(h[1]-a[1])/6*e,g=h[0]-(c[0]-l[0])/6*e,f=h[1]-(c[1]-l[1])/6*e;o===0&&r.push(`M${l[0]},${l[1]}`),t&&o===s-1?r.push(`L${h[0]},${h[1]}`):r.push(`C${d},${u} ${g},${f} ${h[0]},${h[1]}`)}return r.push("Z"),r.join(" ")}const Ni=(i,e,t="box")=>(i||(i=k("g"),i.setAttribute("data-annotation",`${e}`),i.classList.add(`annotation-${t}`)),i);function Oi(i,e,t,n){const s=Ni(t,e.id.toString(),e.properties.type);s.setAttribute("data-annotation",String(e.id));let r=s.querySelector("path");r||(r=k("path"),s.appendChild(r));const{strokeColor:o=rt.strokeColor,strokeWidth:a=rt.strokeWidth,background:l=rt.background,strokeType:h=rt.strokeType}=e.properties.style||rt;o&&r.setAttribute("stroke",o),a!==void 0&&r.setAttribute("stroke-width",String(a)),l&&(n.hoveredFeature===e.id?r.setAttribute("fill",wt(l)):r.setAttribute("fill",l)),h==="dashed"?r.setAttribute("stroke-dasharray","5,5"):r.removeAttribute("stroke-dasharray");const c=e.geometry.coordinates[0],d=zi(c,.5,n.drawingFeature===e.id);return r.setAttribute("d",d),s.setAttribute("transform",n.getRotationTransform(0,0)),i.appendChild(s),s}const $i=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,Yi=/\bsmall-caps\b/,Xi=/\b(?:italic|oblique)\b/,Ui=/\bbold(?:er)?\b/,Cn=16,Tn=13.3333333,qi=.01*Cn,Wi={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32},De=new Map;function Gi(i){if(De.has(i))return De.get(i);const e=$i.exec(i);if(!e)return;const t={};t.family=(e[6]||"").trim();let n=Wi[e[2]]||parseFloat(e[2]);if(e[3]==="%"?n*=qi:e[3]==="em"?n*=Cn:e[3]==="pt"&&(n*=Tn),t.size=n,e[4]==="normal"||e[4]==="inherit"||!e[4]?t.height=Math.round(n*(7/6)):!e[5]||e[5]==="em"?t.height=parseFloat(e[4]||"")*n:e[5]==="pt"?t.height=parseFloat(e[4]||"")*Tn:e[5]==="%"?t.height=n*.01:t.height=parseFloat(e[4]||""),t.variant=Yi.test(e[1])?"small-caps":"normal",t.style=Xi.test(e[1])?"italic":"normal",Ui.test(e[1]))t.weight=700;else{const s=/\b(\d+)\b/.exec(e[1]),r=s?parseInt(s[1],10):400;r>=100&&r!==400?t.weight=r:t.weight=400}return De.set(i,t),t}const ji="12px/14px sans-serif";class Z{constructor(e=ji){let t,n=14,s=12,r=400,o="normal",a="normal",l=0,h;if(typeof e=="string"){const c=Gi(e);c&&(t=c.family,s=c.size,n=c.height||14,a=c.variant,o=c.style,r=c.weight)}else e instanceof Z&&(t=e.family,s=e.size,n=e.height,a=e.variant,r=e.weight,o=e.style,l=e.baseline,h=e.color);this.family=t||"sans-serif",this.size=s||s===0?s:12,this.height=n||n===0?n:this.size*(7/6),this.variant=a||"",this.style=o||"",this.weight=r||400,this.baseline=l||0,this.color=h||""}assign(e={}){const t=new Z(this);return e.bold&&(t.weight=700),e.weight&&(t.weight=e.weight),e.italic&&(t.style="italic"),e.family&&(t.family=e.family),e.style&&(t.style=e.style),e.color&&(t.color=e.color),typeof e.baseline=="number"&&(t.baseline=e.baseline),typeof e.size=="number"&&(t.size=e.size),t}toString(e){let t="";return this.style&&this.style!=="normal"&&(t+=this.style),this.variant&&this.variant!=="normal"&&(t+=(t?" ":"")+this.variant),this.weight&&this.weight!==400&&(t+=t?" ":"",this.weight===700?t+="bold":t+=this.weight),this.size&&(t+=(t?" ":"")+this.size+"px",this.height!==this.size&&(t+="/"+this.height+"px")),this.family&&(t+=(t?" ":"")+this.family),e&&(t+="::"+this.baseline),e&&(t+="::"+this.color),t}valueOf(){return this.toString(!0)}}const kn={"\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},Vi=new Z,Mn={trim:!0,collapse:!0},Fe={};function _e(){return(i,e)=>{const t=new Z(e);let n=t.size;return/\bmonospace\b/.test(t.family)?n*=.6:(n*=.45,t.weight>400&&(n*=1.18)),i.length*n}}function Le(i){if(i&&i.getContext){const e=i.getContext("2d");if(e&&typeof e.measureText=="function")return(t,n)=>(e.font=String(n),e.measureText(t).width)}}function Pn(){const i=typeof document<"u"?document:null;return typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||i&&i.createElement&&i.createElement("canvas")||null}let Lt=Le(Pn())||_e();function Zi(i){if(i==null)Lt=Le(Pn())||_e();else if(i)Lt=Le(i)||_e();else throw new Error("setMeasureCanvas argument is not a canvas or null")}function ot(i,e,t=Mn){typeof e=="string"?e=new Z(e):e instanceof Z?e=Vi.assign(e):e=new Z().assign(e);const n=Object.assign({},Mn,t);let s=String(i);if(!s)return 0;if(s in kn){const o=e.valueOf()+"/"+s;return o in Fe||(Fe[o]=Lt(`_${s}_`,e)-Lt("__",e)),Fe[o]}!n.trim||!n.collapse?s=s.replace(/\n/g," "):n.trim?s=s.replace(/\n/g," ").trim():n.collapse&&(s=s.replace(/\s+/g," "));const r=typeof i=="string"?0:i.tracking||0;return Lt(s,e)+e.size*r}class _{constructor(e=""){this.value=e,this.font=null,this.href="",this.sub=!1,this.sup=!1,this.width,this.line,this.tracking,this.whitespace}clone(){const e=new _(this.value);return Object.assign(e,this)}valueOf(){return this.value}toString(){return this.value}}class Ht extends _{}class K extends _{}class ut extends _{}const Ki=/[\r\n\xA0]+/g,Dn=.7;function Ji(i,e){i.sup&&(i.baseline=.45,i.size=Dn),i.sub&&(i.baseline=-.3,i.size=Dn);let t=e;return(i.style||i.weight||i.baseline||i.color||i.size||i.family)&&(t=e.assign(i)),t}function Fn(i,e,t){let n=i.width,s,r;for(;n+t.width>e&&i.length;)s=i[i.length-1],r=s.width,s.width>t.width?(s.value=s.value.slice(0,-1),s.width=ot(s,s.font),n+=s.width):i.pop(),n-=r;i[i.length-1]instanceof ut&&i.pop(),s=i[i.length-1]||s||{},t.font=t.font.assign(s),t.href=i.length?s.href:null,t.rel=i.length?s.rel:null,t.target=i.length?s.target:null,i.push(t)}function _n(i){return Object.assign([],{height:0,font:i,width:0,hasOverflow:!1,hasLineOverflow:!1})}function Qi(i,e,t){if(!i.length)return _n(t);const n=e.height(),s=e.width(),r=e.overflowLine(),o=e.overflowWrap(),a=t.assign({bold:!0}),l=isFinite(n())?Math.floor(n()/t.height):1/0;if(!n()&&!s(0)||!l)return _n(t);let h=0,c=0,d=0;const u=[];let g=[],f=!1;for(;h<i.length&&c<l;){const x=i[h],C=Ji(x,t);if(x.width=ot(x,C),x.font=C,x.line=c,x.whitespace=x.value in kn,x.value&&(x.value=x.value.replace(Ki," ")),!(!d&&x.whitespace||f&&x.whitespace))if(x instanceof K)d=0,g=[],u.push(h+1),c++;else if(x instanceof Ht||x instanceof ut)g.push({index:h,width:d});else if(x.whitespace||d+x.width<s(c))d+=x.width;else if(g.length){let E,T;do{T=!0,E=g.pop();const M=i[E.index];let D;M instanceof ut&&(D=ot("-",M.font||t),E.width+D>s(c)&&(T=!g.length))}while(!T);u.push(E.index+1),d=0,c++,h=E.index,g=[]}else if(o==="break-word"){const E=s(c);if(d+x.width>E){const T=x.clone();do x.value=x.value.slice(0,-1),x.width=ot(x,x.font||t),d+=x.width;while(x.value&&x.width>E);T.value=T.value.slice(x.value.length),i.splice(h+1,0,new Ht,T)}u.push(h+1),d=0,c++}else d+=x.width;h++,f=x.whitespace}h!==u[u.length-1]&&u.push(h);let m=0,p=0;const b=u.map(x=>{let C=m,E;for(;(E=i[C])&&(E.whitespace||!E.value);)C++;let T=x,M=null;for(;T>C&&(E=i[T-1])&&(E.whitespace||!(E.value||E instanceof ut));)E instanceof K&&(M=E),T--;E instanceof ut&&(E.value="-",E.width=ot("-",E.font||t)),m=x;const D=Object.assign(i.slice(C,T).filter(j=>j.value),{width:0});return M&&D.push(M),D.width=D.reduce((j,Y)=>j+Y.width,0),D.width>p&&(p=D.width),D});let S=!1;if(r){const x=r==="ellipsis"?"…":r;b.forEach((C,E)=>{const T=s(E);if(C.width>T){const M=new _(x);M.font=t,M.width=ot(x,a),Fn(C,T,M),S=!0}})}let v=!1;const A=e.overflow()==="ellipsis"?"…":e.overflow();if(A&&h!==i.length){const x=s(b.length-1),C=b[b.length-1],E=new _(A);E.font=t,E.width=ot(A,a),Fn(C,x,E),v=!0}else v=!1;return Object.assign(b,{height:b.length*t.height,font:t,width:p,hasOverflow:v,hasLineOverflow:S})}function At(i){return Math.round(i*1e6)/1e6}const tr={center:"middle",right:"end"},er={middle:.5,center:.5,bottom:1,end:1},He=(i,e)=>!i&&!e||i===e;function nr(i,e){const t=[],n=e.font(),s=n.size,r=n.family,o=e.align(),a=e.createElement();if(i.length){const l=n.height,h=e.valign(),c=e.height()(),d=e.width()(0),u=!isFinite(d)&&i.length===1,g=u?null:e.x(),f=At(l/s);let m=u?null:At(l/(s*1.15+(l-s)/2));if(er[h]&&isFinite(c)){const T=h==="bottom"?1:.5;m=(m||0)+(c*T-l*i.length*T)/s}const b=o==="justify";let S=0;o==="right"?S=d:o==="center"&&(S=d/2);let v=[],A="tspan",x=null,C="";const E=()=>{if(C){const T=a(A,x,C);v.push(T)}A="tspan",x=null,C=""};for(let T=0,M=i.length;T<M;T++){let D="",j="",Y=0;const X=i[T];if(!X.length){t.push(a("tspan",{x:g(T),dy:At(T?f:m)+"em"}," "));continue}v=[];let gt=0,ft=0,Bt;for(let mt=0,Ne=X.length;mt<Ne;mt++){const N=X[mt],U=N.font;N.whitespace&>++,ft+=N.width,mt&&!N.tracking&&!Y&&He(U.id,D)&&He(N.class,j)&&He(Bt,N.href)?C+=N.value:(E(),C=N.value,x={fontFamily:U.family!==r?U.family:null,fontSize:U.size!==s?U.size:null,fontWeight:U.weight!==400&&U.weight||null,fontStyle:U.style!=="normal"&&U.style||null,fontVariant:U.variant!=="normal"&&U.variant||null,fill:U.color||null,baselineShift:U.baseline?U.baseline*100+"%":null,className:N.class||null,dx:0,href:null,rel:null,target:null},Y&&(x.dx=At(Y),Y=0),N.tracking&&(Y=U.size*N.tracking),N.href&&!Bt?(Bt=N.href,A="a",x.href=Bt,x.rel=N.rel,x.target=N.target):Bt=null,D=U.id,j=N.class)}if(E(),u)t.push(...v);else{let mt=null;const Ne=T===M-1||X[X.length-1]instanceof K;if(b&&X.length>1&&!Ne){const N=d-ft;mt=At(N/gt)}t.push(a("tspan",{wordSpacing:mt,x:g(T)+S,dy:At(T?f:m)+"em"},...v))}}}return a("text",{fontFamily:r,fontSize:s,textAnchor:tr[o]||"start"},...t)}const sr={middle:.5,center:.5,bottom:1,end:1};function ir(i,e){return i.color?i.color:e.href?"#00C":"#000"}function rr(i,e,t){if(!i.length)return;t.textBaseline="middle";const n=e.font(),s=n.height,r=n.size,o=e.valign(),a=e.height()(),l=e.width()(0),h=e.align(),c=h==="justify";let d=s*.5;const u=sr[o];if(u&&isFinite(a)){const g=i.length*s;d+=a*u-g*u}i.forEach((g,f)=>{let m=e.x()(f);const p=f*s+d;let b=0,S=0;g.forEach(x=>{x.whitespace&&b++,S+=x.width});let v=0;const A=f===i.length-1||g[g.length-1]instanceof K;c&&g.length>1&&!A&&(v=(l-S)/b),g.forEach(x=>{t.font=x.font;const C=x.font,E=C.baseline?r*-C.baseline+r*.15:0;t.fillStyle=ir(C,x);let T=0;if(h==="right"?T+=l-S:h==="center"?T+=l/2-S/2:h==="justify"&&(x.whitespace||x instanceof K)&&(m+=v),t.fillText(x.value,m+T,p+E),x.href){t.beginPath(),t.strokeStyle=t.fillStyle;const M=Math.floor(p+r*.45)+.5;t.moveTo(m+T,M),t.lineTo(m+T+x.width,M),t.stroke()}m+=x.width})})}function Ln(i){const e={};for(let t=0;t<i.length;t++){const n=i[t];typeof n=="number"||n==null||(typeof n=="string"?e.text=n:typeof n=="function"?e.fn=n:typeof n=="object"&&n._groups?e.d3=n:n&&n.nodeType&&n.getContext?e.ctx=n.getContext("2d"):n&&n.fillText&&n.beginPath?e.ctx=n:n&&(e.text=n))}return e}const or=Object.prototype.hasOwnProperty,Ie={};function ar(i){return Ie[i]||(Ie[i]=i.replace(/([a-z])([A-Z])/g,(e,t,n)=>t+"-"+n.toLowerCase())),Ie[i]}function Hn(i,e){if(Array.isArray(e))return e.forEach(t=>Hn(i,t));typeof e=="string"&&(e=document.createTextNode(e)),i.appendChild(e)}function In(i,e,...t){if(typeof document>"u")throw new Error("No document found, cannot create elements");const n=typeof i=="string"?document.createElementNS("http://www.w3.org/2000/svg",i):i;if(e&&n.setAttribute)for(const s in e)or.call(e,s)&&e[s]!=null&&n.setAttribute(s==="className"?"class":ar(s),String(e[s]));return t!=null&&t.length&&t.forEach(s=>{Hn(n,s)}),n}const Bn=i=>typeof i=="function"?i:()=>i,lr={top:{vAnchor:-0},middle:{vAnchor:-.5},bottom:{vAnchor:-1},left:{hAnchor:-0},center:{hAnchor:-.5},right:{hAnchor:-1}},Kt=class Kt{constructor(e){if(this.props={width:()=>1/0,height:()=>1/0,rotation:0,vAnchor:0,hAnchor:0},e)for(const t in e)typeof this[t]=="function"&&this[t](e[t]);this.render=this.render.bind(this)}anchor(e){const{hAnchor:t,vAnchor:n,width:s,height:r}=this.props;if(!arguments.length)return[t*s(),n*r()];if(typeof e=="string"){const o=this.props;e.toLowerCase().trim().split(/\s+/).forEach(a=>Object.assign(o,lr[a]))}return this}width(e){return arguments.length?(this.props.width=Bn(e),this):this.props.width}height(e){return arguments.length?(this.props.height=Bn(e),this):this.props.height}rotate(e){return arguments.length?(this.props.rotation=e,this):this.props.rotation}createElement(e){return arguments.length?(this.props.createElement=e,this):this.props.createElement||Kt.createElement}canvas(e,t){const n=e.getContext?e.getContext("2d"):e;return n.save(),n.rotate(this.rotate()*Math.PI/180),n.translate(...this.anchor()),t(n),n.restore(),n}render(...e){const t=Ln(e);if(t.d3)return t.d3.attr("transform",`rotate(${this.rotate()}) translate(${this.anchor()})`);if(t.ctx)return this.canvas(t.ctx,t.fn);if(t.text){const n=typeof t.text.render=="function"?t.text.render():t.text;return this.createElement()("g",{transform:`rotate(${this.rotate()}) translate(${this.anchor()})`},n)}}};y(Kt,"createElement",In);let Be=Kt;const Re=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,cr=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,Rn=/^[\xA0\u2011\u202F\u2060\uFEFF]/,hr=/^(?:[;\xAD%?…]|,(?!\d))/,dr=/^[´±°¢£¤$¥\u2212]/,ur="'“‘[「【﹝〔<‹«{『((<《".split(""),gr="',,,!!??”]」】》>’»﹞〕〗〉}))』。".split(""),zn=i=>{const e=i.charCodeAt(0);return e>=19968&&e<=40959};function Zt(i,e){e!==!1&&(i=i.trim());const t=[];let n=i.charAt(0),s,r,o=0;for(let a=1,l=i.length;a<l;a++){s=i.charAt(a),r=i.charAt(a+1);const h=Re.test(n),c=Re.test(s);let d=c||h||zn(n)||zn(s),u;if((dr.test(s)&&!Rn.test(n)||hr.test(n+r)&&!Rn.test(s))&&(d=!0),d&&(gr.includes(s)||ur.includes(n))&&(d=!1),(n==="-"||n==="‐"||n==="–"||n==="—")&&(u=Re.test(i.charAt(a-2)),u&&!c&&(d=!1),!u&&cr.test(s+r)&&(d=!0)),d){const g=i.slice(o,a);/\u00AD$/.test(g)?(t.push(new _(g.slice(0,-1))),t.push(new ut)):(t.push(new _(g)),t.push(new Ht)),o=a}n=s}return t.push(new _(i.slice(o))),t}const Nn={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:"›"},fr=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,mr=/^<\/([a-zA-Z0-9]+)([^>]*)>/,pr=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,yr=/^<!--(.+?)-->/,wr=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,On={b:i=>i.weight=700,strong:i=>i.weight=700,i:i=>i.style="italic",em:i=>i.style="italic",dfn:i=>i.style="italic",cite:i=>i.style="italic",code:i=>i.family="monospace",kbd:i=>i.family="monospace",samp:i=>i.family="monospace",var:i=>i.family="monospace",tt:i=>i.family="monospace",sub:i=>i.sub=!0,sup:i=>i.sup=!0},xr={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 $n(i){return i.replace(wr,function(e,t,n,s){if(t||n){const r=t?10:16;return String.fromCharCode(parseInt(t||n,r))}else if(s in Nn)return Nn[s];return e})}function br(i){return i&&i.length>1&&(i[0]==='"'&&i[i.length-1]==='"'||i[0]==="'"&&i[i.length-1]==="'")?i.slice(1,-1):i}const Sr=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function vr(i){let e;const t={};if(i){do if(e=Sr.exec(i),e){const n=$n(br(e[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(t[e[1]]=n,i=i.slice(e[0].length),i.length&&/^\S/.test(i[0]))throw new Error("Attribute error")}while(e&&i.length);if(/\S/.test(i))throw new Error("Attribute error")}return t}function Ar(i){i=String(i||"").trim();let e={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null};const t=[],n=[];let s,r;const o=function(d){for(const u in e)e[u]&&(d[u]=e[u]);t.push(d)},a=()=>{n.push(e),e=Object.create(e)},l=()=>{n.length&&(e=n.pop())},h=d=>{const u=t.length;let g=xr[d];if(u&&g){let f=u-1;for(;t[f]&&(t[f]instanceof Ht||fr.test(t[f].value));)f--;for(;g&&t[f]&&t[f]instanceof K;)f--,g--;for(;g-- >0;)t.push(new K)}};for(;i.length;){if(s=/^[^<]+/.exec(i)){const d=$n(s[0]);Zt(d,!1).forEach(o)}else if(!(s=yr.exec(i)))if(s=mr.exec(i))l(),h(s[1]);else if(s=pr.exec(i)){const d=s[1];h(d),a(),On[d]&&On[d](e);const u=vr(s[2]);d==="a"&&(u.href&&(e.href=u.href),u.rel&&(e.rel=u.rel),u.target&&(e.target=u.target)),u.class&&(e.class=e.class?e.class+" "+u.class:u.class),u.style&&(r=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(u.style),r&&r[1]&&(e.color=r[1])),d==="br"&&t.push(new K)}else s=[i.slice(0,1)],o(new _(s[0]));i=i.slice(s[0].length)}let c=t[t.length-1];for(;c instanceof K;)t.pop(),c=t[t.length-1];return t}const Yn={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:"Þ"},Er=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Cr=/^%[^\n]+(?:\n|$)/,Tr=/^[^#$%&~_^\\{}]+/,kr=/^\\([&{}$%#_])/,Mr=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,Pr={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},B={bf:i=>i.weight="bold",it:i=>i.style="italic",sl:i=>i.style="italic",color:(i,e)=>i.color=e,href:(i,e)=>i.href=e,"^":i=>i.sup=!0,_:i=>i.sub=!0,par:function(i){this.tokens.push(new K,new K)},newline:function(i){this.tokens.push(new K)},url:function(i,e){i=this.open_context(),i.href=e,this.add_token(new _(e)),this.close_context()}};B.textsuperscript=B["^"],B.textsubscript=B._,B.textsl=B.sl,B.mathbf=B.bf,B.mathit=B.it,B.textbf=B.bf,B.textit=B.it,B.textcolor=B.color;function Dr(i){i=String(i||"").trim();const e=[0];i=i.replace(/\\verb,(.*?),/,(c,d)=>(e.push(d),"\\verb,"+(e.length-1)+",")).replace(/\\\\\n/g,()=>"\\\\").replace(Mr,(c,d,u)=>u.charAt(d-1)==="\\"?c:Pr[c]).replace(/\n\s+/g,c=>/\n/.test(c.slice(1))?"\\par ":c).replace(/\\symbol\{(\d+)\}/,(c,d,u,g)=>g.charAt(u-1)==="\\"?c:String.fromCharCode(1*d)).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,(c,d,u,g)=>d+u+"{"+g+"}").replace(/\\verb,(.*?),/,(c,d)=>`\\verb,${e[+d]},`);let t={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null};const n=[],s=[];let r;const o=function(c){for(const d in t)t[d]&&(c[d]=t[d]);return n.push(c),c},a=function(){s.push(t),t=Object.create(t)},l=function(){if(!s.length)throw new Error("Unexpected }");t=s.pop()},h={tokens:n,open_context:a,close_context:l,add_token:o};for(;i.length;){if(r=Tr.exec(i))Zt(r[0],!1).forEach(o);else if(r=kr.exec(i))o(new _(r[1]));else if(!(r=Cr.exec(i))){if(r=/^\{/.exec(i))a();else if(r=/^\}/.exec(i))l();else if(!(r=/^\$/.exec(i)))if(r=/^\\verb,([^,]+),/.exec(i))o(new _(r[1]));else if(r=Er.exec(i)){const c=r[1].slice(1)||r[1];let d=!!r[2];if(/^(La)?TeX$/i.test(c)){a(),t.family="serif";let u;c==="LaTeX"&&(u=o(new _("L")),u.tracking=-.25,u=o(new _("A")),u.size=.7,u.baseline=.3,u.tracking=-.1),u=o(new _("T")),u.tracking=-.17,u=o(new _("E")),u.baseline=-.22,u.tracking=-.13,u=o(new _("X")),l()}else if(c in Yn)o(new _(Yn[c])),d&&a();else if(c in B){const u=[];let g=B[c].length-1,f;if(g){for(d=!1,i=i.slice(r[0].length-1);g--;)if(f=/^\{([^}]+)\}/.exec(i))u.push(f[1]),i=i.slice(f[0].length);else throw new Error(c+" is missing an argument");r[0]=/^\{/.exec(i)?"{":"",d=!!r[0]}d&&a(),B[c].apply(h,[t,...u])}else o(new _(r[1])),d&&a()}else r=[i.slice(0,1)],o(new _(r[0]))}i=i.slice(r[0].length)}return n}const Fr=new Z,ze=i=>typeof i=="function"?i:()=>i,Xn={left:"left",start:"left",center:"center",middle:"center",right:"right",end:"right",justify:"justify"},R=class R{constructor(e){this.props={overflow:"ellipsis",overflowWrap:null,overflowLine:"",align:"left",wordBreak:null,valign:"top",width:()=>1/0,height:()=>1/0,x:()=>0,font:Fr,parser:R.defaultparser},e&&(e.font&&this.font(e.font),e.overflow&&this.overflow(e.overflow),e.overflowLine&&this.overflowLine(e.overflowLine),e.overflowWrap&&this.overflowWrap(e.overflowWrap),e.valign&&this.valign(e.valign),e.align&&this.align(e.align),e.width&&this.width(e.width),e.height&&this.height(e.height),e.x&&this.x(e.x),e.parser&&this.parser(e.parser),e.createElement&&this.createElement(e.createElement))}linebreak(e){const t=this.props.parser(String(e)),n=Qi(t,this,this.font()),s=r=>this.render(n,r);return Object.assign(n,{render:s,svg:s,draw:s})}font(e){return arguments.length?(this.props.font=new Z(e),this):this.props.font||new Z}overflow(e){return arguments.length?(this.props.overflow=String(e),this):this.props.overflow}overflowLine(e){return arguments.length?(this.props.overflowLine=String(e),this):this.props.overflowLine}valign(e){return arguments.length?(this.props.valign=e,this):this.props.valign}align(e){if(!arguments.length)return this.props.align;const t=String(e).toLowerCase();return t in Xn&&(this.props.align=Xn[t]),this}overflowWrap(e){if(!arguments.length)return this.props.overflowWrap||"normal";const t=String(e).toLowerCase();return t==="break-word"?this.props.overflowWrap="break-word":(t==="normal"||e==null)&&(this.props.overflowWrap=null),this}width(e){return arguments.length?(this.props.width=ze(e),this):this.props.width}height(e){return arguments.length?(this.props.height=ze(e),this):this.props.height}x(e){return arguments.length?(this.props.x=ze(e),this):this.props.x}parser(e){if(!arguments.length)return this.props.parser;if(typeof e=="string"){const t=R[e]||R[e+"parser"];typeof t=="function"&&(e=t)}if(typeof e!="function")throw new Error("Unknown parser: "+e);return this.props.parser=e,this}createElement(e){return arguments.length?(this.props.createElement=e,this):this.props.createElement||R.createElement}render(e,t){const n=Ln([e,t]);if(typeof n.text=="string"&&(n.text=this.linebreak(n.text)),n.ctx)rr(n.text,this,n.ctx);else return nr(n.text,this)}};y(R,"createElement",In),y(R,"textparser",Zt),y(R,"defaultparser",Zt),y(R,"htmlparser",Ar),y(R,"latexparser",Dr),y(R,"Token",_),y(R,"Break",Ht),y(R,"LineBreak",K),y(R,"SoftHyphen",ut),y(R,"Rotator",Be),y(R,"Font",Z),y(R,"setMeasureCanvas",Zi),y(R,"measureText",function(e,t,n){return ot(e,new Z(t),n)});let It=R;function _r(i,e,t,n){const{width:s,height:r}=z(e),{color:o=$.color,strokeColor:a=$.strokeColor,strokeWidth:l=$.strokeWidth,strokeType:h=$.strokeType,background:c=$.background,borderRadius:d=$.borderRadius,fixedSize:u=$.fixedSize}=e.properties.style||$,g=En(i,e,t,n);g.setAttribute("data-annotation-type",e.properties.type),g.classList.add("annotation-text"),g.setAttribute("fill",`${o}`);let f=g.firstChild;for(;f;){const v=f.nextSibling;f.nodeType===1&&f.tagName!=="rect"&&g.removeChild(f),f=v}let m=g.firstChild;m||(m=k("rect"),g.appendChild(m));const p=-s/2,b=-r/2;d&&(m.setAttribute("rx",`${d}`),m.setAttribute("ry",`${d}`)),h&&h!=="none"&&(m.setAttribute("stroke",a||"black"),m.setAttribute("stroke-width",`${l}`),h==="dashed"&&m.setAttribute("stroke-dasharray","5,5")),c&&c.length&&(n.hoveredFeature===e.id?m.setAttribute("fill",wt(c)):m.setAttribute("fill",c)),m.setAttribute("width",`${s}`),m.setAttribute("height",`${r}`);const S=W(e);return m.setAttribute("x",`${p}`),m.setAttribute("y",`${b}`),Lr(e,g,p,b),g.setAttribute("transform",n.getScreenAlignedTransform(S.x,S.y,!u)),i.appendChild(g),g}const Un=i=>i.replace(/…$/,""),qn=i=>i.children[0].innerHTML;function Lr(i,e,t=0,n=0){const{width:s,height:r}=z(i),{fontSize:o=$.fontSize,font:a=$.font,padding:l=0}=i.properties.style||{};if(s===r&&s===0)return;const h=parseFloat(o.toString())*Yt,c=new It({font:`${o}px/${h}px ${a}`.replace(/(px)+/g,"px"),width:s-l*2,height:r-l,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:It.htmlparser,createElement:It.createElement});c.overflowWrap("break-word");const d=i.properties.content||"";if(d.length===0)return;const g=c.linebreak(d.replaceAll(`
|
|
65
|
+
`,"<br>")).svg(),f=[...g.children],m=d.match(/(https?:\/\/.*)/gm);(m?m.map(b=>b.split(" ")[0]):[]).forEach(b=>{let S=b;const v=[];for(;S.length>0;){const A=f.find(C=>!!C.children[0]&&C.children[0].tagName==="tspan"&&S.startsWith(Un(qn(C))));if(!A)break;v.push(A);const x=Un(A.children[0].innerHTML).length;if(!x)break;S=S.slice(x)}v.forEach(A=>{const x=document.createElementNS("http://www.w3.org/2000/svg","a");x.setAttribute("href",b),x.setAttribute("target","_blank"),x.innerHTML=qn(A),A.children[0].innerHTML="",A.children[0].appendChild(x)})}),g.setAttribute("transform",`translate(${t+l}, ${n+l})`),e.appendChild(g)}class Hr extends xn{constructor(t,n){super(t,n);y(this,"features",new Map);y(this,"arrowsRoot",null);y(this,"shapesRoot",null);y(this,"commentsRoot",null);y(this,"annotationsRoot",null);y(this,"visibleFeatures",new Set);y(this,"isExporting",!1);y(this,"render",t=>{const{features:n,hoveredFeature:s,selectedFeatures:r,liveUpdates:o}=this.store.getState();(!this.annotationsRoot||!t.contains(this.annotationsRoot))&&(t.innerHTML="",t.appendChild(this.getDefs()),this.arrowsRoot=k("g"),this.commentsRoot=k("g"),this.annotationsRoot=k("g"),this.shapesRoot=k("g"),this.annotationsRoot.appendChild(this.arrowsRoot),this.annotationsRoot.appendChild(this.shapesRoot),this.annotationsRoot.appendChild(this.commentsRoot),t.appendChild(this.annotationsRoot)),t.removeChild(this.annotationsRoot);const a=this.arrowsRoot,l=this.annotationsRoot,h=this.commentsRoot,c=this.shapesRoot,d=this.store.getState(),u=this.getViewportBounds(),g=new Set(Object.keys(n));this.removeFeatures(g);const f=new Set;for(let m of Object.values(n)){if(o[m.id]&&(m={...m,...o[m.id]}),!this.isExporting&&!this.isFeatureVisible(m,u))continue;f.add(m.id);let p=this.features.get(m.id);G(m)?p=En(c,m,p,d):L(m)?p=_r(c,m,p,d):H(m)?p=Ri(h,m,p,d,this.visibleFeatures.has(m.id)):st(m)?p=Oi(c,m,p,d):J(m)&&(p=ki(a,m,d.options.minArrowHeight,d.options.maxArrowHeight,p,d)),p&&this.features.set(m.id,p)}this.applyStateClasses(l,s,r),t.appendChild(l),this.visibleFeatures.clear(),this.visibleFeatures=f});y(this,"throttleRender",de(()=>this.render(this.layer.element),16));y(this,"refresh",()=>{this.layer.refresh()});y(this,"onExportStart",()=>{this.isExporting=!0});y(this,"onExportEnd",()=>{this.isExporting=!1});t.events.on("viewExportStart",this.onExportStart),t.events.on("afterImageExport",this.onExportEnd),this.layer=this.ogma.layers.addSVGLayer({draw:this.render},Ot.SHAPES),this.store.subscribe(s=>({features:s.features,liveUpdates:s.liveUpdates,hoveredFeature:s.hoveredFeature,selectedFeatures:s.selectedFeatures,rotation:s.rotation,zoom:s.zoom}),this.throttleRender,{equalityFn:(s,r)=>s.features===r.features&&s.liveUpdates===r.liveUpdates&&s.hoveredFeature===r.hoveredFeature&&s.selectedFeatures===r.selectedFeatures&&s.rotation===r.rotation&&s.zoom===r.zoom})}getViewportBounds(){const t=this.ogma,{width:n,height:s}=t.view.getSize(),r=1.5,o=t.view.screenToGraphCoordinates({x:0,y:0}),a=t.view.screenToGraphCoordinates({x:n*r,y:0}),l=t.view.screenToGraphCoordinates({x:0,y:s*r}),h=t.view.screenToGraphCoordinates({x:n*r,y:s*r});return[Math.min(o.x,a.x,l.x,h.x),Math.min(o.y,a.y,l.y,h.y),Math.max(o.x,a.x,l.x,h.x),Math.max(o.y,a.y,l.y,h.y)]}isFeatureVisible(t,n){const s=t.geometry.bbox;if(!s)return!0;const[r,o,a,l]=s;return!(a<n[0]||r>n[2]||l<n[1]||o>n[3])}getDefs(){const t=k("defs");t.appendChild(Li());const n=k("filter");n.setAttribute("id","softShadow"),n.setAttribute("x","-50%"),n.setAttribute("y","-50%"),n.setAttribute("width","200%"),n.setAttribute("height","200%");const s=k("feGaussianBlur");s.setAttribute("in","SourceAlpha"),s.setAttribute("stdDeviation","2"),s.setAttribute("result","blur");const r=k("feOffset");r.setAttribute("in","blur"),r.setAttribute("dx","0"),r.setAttribute("dy","1"),r.setAttribute("result","offsetBlur");const o=k("feComponentTransfer");o.setAttribute("in","offsetBlur"),o.setAttribute("result","shadow");const a=k("feFuncA");a.setAttribute("type","linear"),a.setAttribute("slope","0.25"),o.appendChild(a);const l=k("feMerge"),h=k("feMergeNode");h.setAttribute("in","shadow");const c=k("feMergeNode");return c.setAttribute("in","SourceGraphic"),l.appendChild(h),l.appendChild(c),n.appendChild(s),n.appendChild(r),n.appendChild(o),n.appendChild(l),t.appendChild(n),t}removeFeatures(t){for(const n of this.features.keys())if(!t.has(n)){const s=this.features.get(n);s&&s.parentNode&&s.parentNode.removeChild(s),this.features.delete(n)}}applyStateClasses(t,n,s){if(n!==null){const r=t.querySelector(`[data-annotation="${n}"]`);r&&r.classList.add("annotation-hovered")}s.forEach(r=>{const o=t.querySelector(`[data-annotation="${r}"]`);o&&o.classList.add("annotation-selected")})}destroy(){this.features.clear(),this.layer.destroy(),this.ogma.events.off(this.onExportStart),this.ogma.events.off(this.onExportEnd),super.destroy()}}const Wn=i=>{let e;const t=new Set,n=(h,c)=>{const d=typeof h=="function"?h(e):h;if(!Object.is(d,e)){const u=e;e=c??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(g=>g(e,u))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>l,subscribe:h=>(t.add(h),()=>t.delete(h))},l=e=i(n,s,a);return a},Gn=i=>i?Wn(i):Wn;var jn=(i,e,t)=>(s,r)=>({pastStates:(t==null?void 0:t.pastStates)||[],futureStates:(t==null?void 0:t.futureStates)||[],undo:(o=1)=>{var a,l;if(r().pastStates.length){const h=((a=t==null?void 0:t.partialize)==null?void 0:a.call(t,e()))||e(),c=r().pastStates.splice(-o,o),d=c.shift();i(d),s({pastStates:r().pastStates,futureStates:r().futureStates.concat(((l=t==null?void 0:t.diff)==null?void 0:l.call(t,h,d))||h,c.reverse())})}},redo:(o=1)=>{var a,l;if(r().futureStates.length){const h=((a=t==null?void 0:t.partialize)==null?void 0:a.call(t,e()))||e(),c=r().futureStates.splice(-o,o),d=c.shift();i(d),s({pastStates:r().pastStates.concat(((l=t==null?void 0:t.diff)==null?void 0:l.call(t,h,d))||h,c.reverse()),futureStates:r().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:o=>s({_onSave:o}),_onSave:t==null?void 0:t.onSave,_handleSet:(o,a,l,h)=>{var c,d;t!=null&&t.limit&&r().pastStates.length>=(t==null?void 0:t.limit)&&r().pastStates.shift(),(d=(c=r())._onSave)==null||d.call(c,o,l),s({pastStates:r().pastStates.concat(h||o),futureStates:[]})}}),Ir=(i,e)=>(n,s,r)=>{var h,c;r.temporal=Gn(((h=e==null?void 0:e.wrapTemporal)==null?void 0:h.call(e,jn(n,s,e)))||jn(n,s,e));const o=((c=e==null?void 0:e.handleSet)==null?void 0:c.call(e,r.temporal.getState()._handleSet))||r.temporal.getState()._handleSet,a=d=>{var f,m,p;if(!r.temporal.getState().isTracking)return;const u=((f=e==null?void 0:e.partialize)==null?void 0:f.call(e,s()))||s(),g=(m=e==null?void 0:e.diff)==null?void 0:m.call(e,d,u);g===null||(p=e==null?void 0:e.equality)!=null&&p.call(e,d,u)||o(d,void 0,u,g)},l=r.setState;return r.setState=(...d)=>{var g;const u=((g=e==null?void 0:e.partialize)==null?void 0:g.call(e,s()))||s();l(...d),a(u)},i((...d)=>{var g;const u=((g=e==null?void 0:e.partialize)==null?void 0:g.call(e,s()))||s();n(...d),a(u)},s,r)};const Br=i=>(e,t,n)=>{const s=n.subscribe;return n.subscribe=(o,a,l)=>{let h=o;if(a){const c=(l==null?void 0:l.equalityFn)||Object.is;let d=o(n.getState());h=u=>{const g=o(u);if(!c(d,g)){const f=d;a(d=g,f)}},l!=null&&l.fireImmediately&&a(d,d)}return s(h)},i(e,t,n)},Rr=[0,0,0,0];function zr(i,e){const t=Object.keys(i.features),n=Object.keys(e.features);if(t.length!==n.length)return!1;for(const s of t)if(!(s in e.features))return!1;for(const s of t){const r=i.features[s],o=e.features[s],a=r.geometry,l=o.geometry;if(a.coordinates!==l.coordinates||r.properties!==o.properties||r.properties.style!==o.properties.style||a!==l)return!1}return i.drawingFeature===e.drawingFeature}const Nr=i=>{const e=Gn()(Br(Ir((t,n)=>({features:{},liveUpdates:{},isDragging:!1,hoveringHandle:!1,hoveredHandle:-1,hoveredFeature:null,selectedFeatures:new Set,lastChangedFeatures:[],drawingFeature:null,drawingPoints:null,mousePressed:!1,mousePressPoint:null,rotation:0,sin:0,cos:1,revRotation:0,revSin:0,revCos:1,zoom:1,invZoom:1,options:{showSendButton:(i==null?void 0:i.showSendButton)??!0,sendButtonIcon:(i==null?void 0:i.sendButtonIcon)??ne,minArrowHeight:(i==null?void 0:i.minArrowHeight)??20,maxArrowHeight:(i==null?void 0:i.maxArrowHeight)??30,detectMargin:(i==null?void 0:i.detectMargin)??2,magnetRadius:(i==null?void 0:i.magnetRadius)??10,magnetHandleRadius:(i==null?void 0:i.magnetHandleRadius)??5,textPlaceholder:(i==null?void 0:i.textPlaceholder)??"Type here"},setOptions:s=>t(r=>({options:{...r.options,...s}})),removeFeature:s=>t(r=>{var u,g,f,m;const o=r.features[s];if(!o)return r;const{features:a,liveUpdates:l}=r,h=new Set([s]);if((H(o)||L(o))&&Object.values(a).forEach(p=>{var b,S,v,A;J(p)&&(((S=(b=p.properties.link)==null?void 0:b.end)==null?void 0:S.id)===s||((A=(v=p.properties.link)==null?void 0:v.start)==null?void 0:A.id)===s)&&h.add(p.id)}),J(o)){const p=((g=(u=o.properties.link)==null?void 0:u.end)==null?void 0:g.type)==="comment"?o.properties.link.end.id:((m=(f=o.properties.link)==null?void 0:f.start)==null?void 0:m.type)==="comment"?o.properties.link.start.id:null;if(p){let b=0;if(Object.values(r.features).forEach(S=>{var v,A,x,C;J(S)&&S.id!==s&&(((A=(v=S.properties.link)==null?void 0:v.end)==null?void 0:A.id)===p||((C=(x=S.properties.link)==null?void 0:x.start)==null?void 0:C.id)===p)&&b++}),b===0)return console.error("Cannot delete last arrow attached to comment. Delete the comment instead."),r}}const c={...a},d={...l};return h.forEach(p=>{delete c[p],delete d[p]}),{features:c,liveUpdates:d}}),addFeature:s=>t(r=>({features:{...r.features,[s.id]:s}})),startLiveUpdate:s=>{t(r=>({liveUpdates:s.reduce((o,a)=>({...o,[a]:{...r.features[a]}}),{})}))},applyLiveUpdate:(s,r)=>{t(o=>({liveUpdates:{...o.liveUpdates,[s]:{...o.liveUpdates[s],...r}}}))},applyLiveUpdates:s=>{t(r=>{const o=r.liveUpdates;for(const a in s)o[a]=s[a];return{liveUpdates:o}})},commitLiveUpdates:s=>{const{features:r,liveUpdates:o}=n(),a={...r},l=[],h=Object.keys(o);s||(s=new Set(h)),h.forEach(c=>{const d=o[c];a[c]&&Object.keys(d).length>0&&(a[c]={...a[c],...d},l.push(c))}),t({features:a,liveUpdates:{},isDragging:!1,lastChangedFeatures:l})},cancelLiveUpdates:()=>t({liveUpdates:{},isDragging:!1}),updateFeature:(s,r)=>t(o=>{const a={...o.features[s],...r},l={...o.liveUpdates};return delete l[s],{features:{...o.features,[s]:a},liveUpdates:l}}),updateFeatures:s=>t(r=>{const o={...r.features};return Object.entries(s).forEach(([a,l])=>{o[a]&&(o[a]={...o[a],...l})}),{features:o}}),batchUpdate:s=>{const r=e.temporal.getState();r.pause(),s(),r.resume()},getFeature:s=>n().features[s],getMergedFeature:s=>{const r=n().features[s],o=n().liveUpdates[s];if(r)return o?{...r,...o}:r},getAllFeatures:()=>{const{features:s,liveUpdates:r}=n();return Object.entries(s).map(([o,a])=>{const l=r[o];return l?{...a,...l}:a})},setHoveredFeature:s=>t({hoveredFeature:s}),setSelectedFeatures:s=>t({selectedFeatures:new Set(s)}),addToSelection:s=>{const{selectedFeatures:r}=n(),o=new Set(r);o.add(s),t({selectedFeatures:o})},removeFromSelection:s=>{const{selectedFeatures:r}=n(),o=new Set(r);o.delete(s),t({selectedFeatures:o})},toggleSelection:s=>{const{selectedFeatures:r}=n(),o=new Set(r);o.has(s)?o.delete(s):o.add(s),t({selectedFeatures:o})},clearSelection:()=>t({selectedFeatures:new Set}),isHovered:s=>n().hoveredFeature===s,isSelected:s=>n().selectedFeatures.has(s),setRotation:s=>{t({rotation:s,sin:Math.sin(s),cos:Math.cos(s),revRotation:-s,revSin:Math.sin(-s),revCos:Math.cos(-s)})},setZoom:s=>{t({zoom:s,invZoom:1/s})},getScreenAlignedTransform(s,r,o=!0){const a=this.revSin,l=this.revCos,h=s*l-r*a,c=s*a+r*l,d=o?1:this.invZoom;return`matrix(${d}, 0, 0, ${d}, ${h}, ${c})`},getRotationTransform(s,r){const o=this.revSin,a=this.revCos,l=s*a-r*o,h=s*o+r*a;return`matrix(${a}, ${o}, ${-o}, ${a}, ${-l}, ${-h})`},getRotatedBBox(s,r,o,a){return Ms(s,r,o-s,a-r,this.sin,this.cos,s+(o-s)/2,r+(a-r)/2,Rr)},setDrawingPoints:s=>t({drawingPoints:s})}),{limit:250,partialize:t=>({drawingFeature:t.drawingFeature,isDragging:t.isDragging,features:t.features,lastChangedFeatures:t.lastChangedFeatures}),equality:zr,handleSet:t=>n=>{n.drawingFeature===null&&t(n)}})));return e},Or={detectMargin:2,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",showSendButton:!0,sendButtonIcon:ne,minArrowHeight:20,maxArrowHeight:30};class $r extends Kn{constructor(t,n={}){super();y(this,"ogma");y(this,"store");y(this,"renderers",{});y(this,"interactions");y(this,"editor");y(this,"links");y(this,"index");y(this,"drawing");y(this,"selectionManager");y(this,"historyManager");y(this,"updateManager");y(this,"commentManager");y(this,"onRotate",()=>this.store.getState().setRotation(this.ogma.view.getAngle()));y(this,"onZoom",()=>{const t=this.ogma.view.getZoom();this.store.getState().setZoom(t),this.commentManager.updateCommentModesForZoom(t)});y(this,"onLayout",()=>{this.links.update()});this.ogma=t;const s={...Or,...n};this.store=Nr(s),this.index=new Si(this.store),this.links=new ui(this.ogma,this.store,(r,o)=>{this.emit(We,{arrow:r,link:o})}),this.interactions=new gi(this.ogma,this.store,this.index),this.editor=new ci(this.ogma,this.store,this.index,this.links,this.interactions),this.drawing=new zs(this.ogma,this.store,this.editor,this.interactions,this.links,this,this.index),this.selectionManager=new Os(this.store),this.historyManager=new Ns(this.store,this.links),this.updateManager=new $s(this.store),this.commentManager=new Is(this.store),this.initializeRenderers(),this.setupEvents()}initializeRenderers(){this.renderers.shapes=new Hr(this.ogma,this.store),this.renderers.handles=new Ai(this.ogma,this.store)}setupEvents(){this.ogma.events.on("rotate",this.onRotate).on("zoom",this.onZoom).on("layoutEnd",this.onLayout),this.editor.addEventListener(yt,()=>this.emit(yt)),this.editor.addEventListener(Rt,()=>this.emit(Rt)),this.interactions.addEventListener(zt,()=>this.emit(zt)),this.store.temporal.subscribe(t=>{this.emit(Ge,{canUndo:t.pastStates.length>0,canRedo:t.futureStates.length>0})}),this.store.subscribe(t=>t.selectedFeatures,(t,n)=>{const s=Array.from(t).filter(r=>!(n!=null&&n.has(r)));if(s.length>0&&this.emit($e,{ids:s}),n){const r=Array.from(n).filter(o=>!t.has(o));r.length>0&&this.emit(Ye,{ids:r})}}),this.store.subscribe(t=>t.drawingFeature,(t,n)=>{t===null&&n!==null&&this.emit(Qt,{id:n})}),this.store.subscribe(t=>t.features,(t,n)=>{if(n){for(const s of Object.keys(t))n[s]?n[s]!==t[s]&&this.emit(qe,t[s]):this.emit(Nt,{id:s});for(const s of Object.keys(n))t[s]||this.emit(Xe,{id:s})}})}setOptions(t={}){return this.store.getState().setOptions(t),this.store.getState().options}add(t){return this.updateManager.add(t),this}remove(t){return this.updateManager.remove(t),this}undo(){return this.historyManager.undo()}redo(){return this.historyManager.redo()}canUndo(){return this.historyManager.canUndo()}canRedo(){return this.historyManager.canRedo()}clearHistory(){this.historyManager.clearHistory()}getAnnotations(){return this.updateManager.getAnnotations()}select(t){return this.selectionManager.select(t),this}unselect(t){return this.selectionManager.unselect(t),this}cancelDrawing(){var t;return this.drawing.cancelPendingDrawing(),(t=this.editor.getActiveHandler())==null||t.cancelDrawing(),this.emit(Ue),this}enableArrowDrawing(t){return this.drawing.enableArrowDrawing(t),this}enableTextDrawing(t){return this.drawing.enableTextDrawing(t),this}enableBoxDrawing(t){return this.drawing.enableBoxDrawing(t),this}enablePolygonDrawing(t){return this.drawing.enablePolygonDrawing(t),this}enableCommentDrawing(t={}){return this.drawing.enableCommentDrawing(t),this}startComment(t,n,s,r){return this.drawing.startComment(t,n,s,r),this}startBox(t,n,s){return this.drawing.startBox(t,n,s),this}startArrow(t,n,s){return this.drawing.startArrow(t,n,s),this}startText(t,n,s){return this.drawing.startText(t,n,s),this}startPolygon(t,n,s){return this.drawing.startPolygon(t,n,s),this}getSelectedAnnotations(){return this.selectionManager.getSelectedAnnotations()}getSelected(){return this.selectionManager.getSelected()}getAnnotation(t){return this.updateManager.getAnnotation(t)}setScale(t,n,s,r){return this.updateManager.setScale(t,n,s,r),this}toggleComment(t){return this.commentManager.toggleComment(t),this}destroy(){this.ogma.events.off(this.onRotate).off(this.onZoom),this.links.destroy(),Object.values(this.renderers).forEach(t=>t.destroy()),this.interactions.destroy(),this.editor.destroy()}updateStyle(t,n){return this.updateManager.updateStyle(t,n),this}update(t){return this.updateManager.update(t),this}link(t,n,s=it){const r=this.getAnnotation(t);if(!r)throw new Error(`Arrow with id ${t} not found`);return this.editor.getArrowHandler().link(r,n,s),this}isDrawing(){return this.drawing.isDrawing()}}w.COMMENT_MODE_COLLAPSED=et,w.COMMENT_MODE_EXPANDED=$t,w.Control=$r,w.DATA_ATTR=es,w.DEFAULT_SEND_ICON=ne,w.EVT_ADD=Nt,w.EVT_CANCEL_DRAWING=Ue,w.EVT_CLICK=zt,w.EVT_COMPLETE_DRAWING=Qt,w.EVT_DRAG=Et,w.EVT_DRAG_END=Rt,w.EVT_DRAG_START=yt,w.EVT_HISTORY=Ge,w.EVT_HOVER=Qn,w.EVT_LINK=We,w.EVT_REMOVE=Xe,w.EVT_SELECT=$e,w.EVT_UNHOVER=ts,w.EVT_UNSELECT=Ye,w.EVT_UPDATE=qe,w.HL_BRIGHTEN=ee,w.LAYERS=Ot,w.NONE=Jn,w.SIDE_END=it,w.SIDE_START=q,w.TARGET_TYPES=P,w.TEXT_LINE_HEIGHT=Yt,w.adjustColorBrightness=ue,w.asColor=Fs,w.asHexColor=_s,w.asRgbColor=Ls,w.asRgbaColor=Hs,w.brighten=wt,w.calculateCommentZoomThreshold=an,w.canDetachArrowEnd=Ys,w.canDetachArrowStart=hn,w.clientToContainerPosition=kt,w.colorToRgba=gs,w.createArrow=Mt,w.createBox=fe,w.createComment=ye,w.createCommentWithArrow=ks,w.createPolygon=ln,w.createSVGElement=k,w.createText=me,w.cursors=F,w.darken=ys,w.debounce=ms,w.debounceTail=ps,w.defaultArrowOptions=bs,w.defaultArrowStyle=dt,w.defaultBoxOptions=Ss,w.defaultBoxStyle=bt,w.defaultCommentOptions=Wt,w.defaultCommentStyle=Q,w.defaultPolygonProperties=Ds,w.defaultPolygonStyle=rt,w.defaultTextOptions=vs,w.defaultTextStyle=$,w.detectArrow=ge,w.detectBox=rn,w.detectComment=on,w.detectPolygon=we,w.detectText=pe,w.getAnnotationsBounds=cs,w.getArrowEnd=ce,w.getArrowEndPoints=Xt,w.getArrowSide=Ct,w.getArrowStart=le,w.getAttachmentPointOnNode=us,w.getBbox=tt,w.getBoxCenter=W,w.getBoxPosition=lt,w.getBoxSize=z,w.getBrowserWindow=he,w.getCommentPosition=Es,w.getCommentSize=Cs,w.getCommentZoomThreshold=Ts,w.getCoordinates=Tt,w.getHandleId=ls,w.getPolygonBounds=re,w.getPolygonCenter=oe,w.getTextBbox=tt,w.getTextPosition=lt,w.getTextSize=z,w.handleDetectionThreshold=te,w.handleRadius=je,w.hexShortToLong=Ut,w.hexToRgba=tn,w.isAnnotationCollection=xe,w.isArrow=J,w.isBox=G,w.isColor=cn,w.isComment=H,w.isCommentArrow=Ae,w.isHexColor=be,w.isPolygon=st,w.isRgbColor=Se,w.isRgbaColor=ve,w.isText=L,w.migrateBoxOrTextIfNeeded=nn,w.parseColor=fs,w.rgbToRgba=en,w.scaleGeometry=ds,w.scalePolygon=os,w.setArrowEnd=Je,w.setArrowEndPoint=Qe,w.setArrowStart=Ke,w.setBbox=Ze,w.setTextBbox=Ze,w.simplifyPolygon=ie,w.throttle=de,w.toggleCommentMode=As,w.translatePolygon=Ve,w.updateBbox=ct,w.updatePolygonBbox=ae,w.updateTextBbox=ct,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
|