@linkurious/ogma-annotations-react 1.1.9 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './AnnotationsContext';
2
- export * from './constants';
3
- export * from './utils';
1
+ export * from "./AnnotationsContext";
2
+ export * from "./constants";
3
+ export * from "./utils";
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ (function(B,Z){typeof exports=="object"&&typeof module<"u"?Z(exports,require("react"),require("@linkurious/ogma-react")):typeof define=="function"&&define.amd?define(["exports","react","@linkurious/ogma-react"],Z):(B=typeof globalThis<"u"?globalThis:B||self,Z(B.index={},B.React,B.OgmaReact))})(this,function(B,Z,Nr){"use strict";var Le={exports:{}},Wt={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var dr;function Hr(){if(dr)return Wt;dr=1;var p=Z,e=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,h=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function g(m,f,s){var d,A={},_=null,R=null;s!==void 0&&(_=""+s),f.key!==void 0&&(_=""+f.key),f.ref!==void 0&&(R=f.ref);for(d in f)i.call(f,d)&&!c.hasOwnProperty(d)&&(A[d]=f[d]);if(m&&m.defaultProps)for(d in f=m.defaultProps,f)A[d]===void 0&&(A[d]=f[d]);return{$$typeof:e,type:m,key:_,ref:R,props:A,_owner:h.current}}return Wt.Fragment=a,Wt.jsx=g,Wt.jsxs=g,Wt}var Yt={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var pr;function Br(){return pr||(pr=1,process.env.NODE_ENV!=="production"&&function(){var p=Z,e=Symbol.for("react.element"),a=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),m=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),P=Symbol.iterator,E="@@iterator";function D(t){if(t===null||typeof t!="object")return null;var o=P&&t[P]||t[E];return typeof o=="function"?o:null}var j=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(t){{for(var o=arguments.length,u=new Array(o>1?o-1:0),y=1;y<o;y++)u[y-1]=arguments[y];N("error",t,u)}}function N(t,o,u){{var y=j.ReactDebugCurrentFrame,v=y.getStackAddendum();v!==""&&(o+="%s",u=u.concat([v]));var w=u.map(function(b){return String(b)});w.unshift("Warning: "+o),Function.prototype.apply.call(console[t],console,w)}}var H=!1,at=!1,At=!1,Zt=!1,Gt=!1,we;we=Symbol.for("react.module.reference");function jt(t){return!!(typeof t=="string"||typeof t=="function"||t===i||t===c||Gt||t===h||t===s||t===d||Zt||t===R||H||at||At||typeof t=="object"&&t!==null&&(t.$$typeof===_||t.$$typeof===A||t.$$typeof===g||t.$$typeof===m||t.$$typeof===f||t.$$typeof===we||t.getModuleId!==void 0))}function Mt(t,o,u){var y=t.displayName;if(y)return y;var v=o.displayName||o.name||"";return v!==""?u+"("+v+")":u}function Kt(t){return t.displayName||"Context"}function nt(t){if(t==null)return null;if(typeof t.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case i:return"Fragment";case a:return"Portal";case c:return"Profiler";case h:return"StrictMode";case s:return"Suspense";case d:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case m:var o=t;return Kt(o)+".Consumer";case g:var u=t;return Kt(u._context)+".Provider";case f:return Mt(t,t.render,"ForwardRef");case A:var y=t.displayName||null;return y!==null?y:nt(t.type)||"Memo";case _:{var v=t,w=v._payload,b=v._init;try{return nt(b(w))}catch{return null}}}return null}var L=Object.assign,ut=0,K,ct,Dt,xe,Jt,Se,Ae;function Et(){}Et.__reactDisabledLog=!0;function Ee(){{if(ut===0){K=console.log,ct=console.info,Dt=console.warn,xe=console.error,Jt=console.group,Se=console.groupCollapsed,Ae=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Et,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}ut++}}function Je(){{if(ut--,ut===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},t,{value:K}),info:L({},t,{value:ct}),warn:L({},t,{value:Dt}),error:L({},t,{value:xe}),group:L({},t,{value:Jt}),groupCollapsed:L({},t,{value:Se}),groupEnd:L({},t,{value:Ae})})}ut<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Qt=j.ReactCurrentDispatcher,te;function Ft(t,o,u){{if(te===void 0)try{throw Error()}catch(v){var y=v.stack.trim().match(/\n( *(at )?)/);te=y&&y[1]||""}return`
18
+ `+te+t}}var ee=!1,_t;{var Qe=typeof WeakMap=="function"?WeakMap:Map;_t=new Qe}function re(t,o){if(!t||ee)return"";{var u=_t.get(t);if(u!==void 0)return u}var y;ee=!0;var v=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=Qt.current,Qt.current=null,Ee();try{if(o){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(O){y=O}Reflect.construct(t,[],b)}else{try{b.call()}catch(O){y=O}t.call(b.prototype)}}else{try{throw Error()}catch(O){y=O}t()}}catch(O){if(O&&y&&typeof O.stack=="string"){for(var S=O.stack.split(`
19
+ `),I=y.stack.split(`
20
+ `),k=S.length-1,C=I.length-1;k>=1&&C>=0&&S[k]!==I[C];)C--;for(;k>=1&&C>=0;k--,C--)if(S[k]!==I[C]){if(k!==1||C!==1)do if(k--,C--,C<0||S[k]!==I[C]){var F=`
21
+ `+S[k].replace(" at new "," at ");return t.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",t.displayName)),typeof t=="function"&&_t.set(t,F),F}while(k>=1&&C>=0);break}}}finally{ee=!1,Qt.current=w,Je(),Error.prepareStackTrace=v}var W=t?t.displayName||t.name:"",z=W?Ft(W):"";return typeof t=="function"&&_t.set(t,z),z}function tr(t,o,u){return re(t,!1)}function er(t){var o=t.prototype;return!!(o&&o.isReactComponent)}function Lt(t,o,u){if(t==null)return"";if(typeof t=="function")return re(t,er(t));if(typeof t=="string")return Ft(t);switch(t){case s:return Ft("Suspense");case d:return Ft("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case f:return tr(t.render);case A:return Lt(t.type,o,u);case _:{var y=t,v=y._payload,w=y._init;try{return Lt(w(v),o,u)}catch{}}}return""}var Tt=Object.prototype.hasOwnProperty,_e={},Te=j.ReactDebugCurrentFrame;function zt(t){if(t){var o=t._owner,u=Lt(t.type,t._source,o?o.type:null);Te.setExtraStackFrame(u)}else Te.setExtraStackFrame(null)}function rr(t,o,u,y,v){{var w=Function.call.bind(Tt);for(var b in t)if(w(t,b)){var S=void 0;try{if(typeof t[b]!="function"){var I=Error((y||"React class")+": "+u+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}S=t[b](o,b,y,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(k){S=k}S&&!(S instanceof Error)&&(zt(v),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",u,b,typeof S),zt(null)),S instanceof Error&&!(S.message in _e)&&(_e[S.message]=!0,zt(v),T("Failed %s type: %s",u,S.message),zt(null))}}}var nr=Array.isArray;function ne(t){return nr(t)}function U(t){{var o=typeof Symbol=="function"&&Symbol.toStringTag,u=o&&t[Symbol.toStringTag]||t.constructor.name||"Object";return u}}function ir(t){try{return ke(t),!1}catch{return!0}}function ke(t){return""+t}function ie(t){if(ir(t))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",U(t)),ke(t)}var lt=j.ReactCurrentOwner,Re={key:!0,ref:!0,__self:!0,__source:!0},$t,Ce,se;se={};function oe(t){if(Tt.call(t,"ref")){var o=Object.getOwnPropertyDescriptor(t,"ref").get;if(o&&o.isReactWarning)return!1}return t.ref!==void 0}function sr(t){if(Tt.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function or(t,o){if(typeof t.ref=="string"&&lt.current&&o&&lt.current.stateNode!==o){var u=nt(lt.current.type);se[u]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',nt(lt.current.type),t.ref),se[u]=!0)}}function ar(t,o){{var u=function(){$t||($t=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};u.isReactWarning=!0,Object.defineProperty(t,"key",{get:u,configurable:!0})}}function ae(t,o){{var u=function(){Ce||(Ce=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};u.isReactWarning=!0,Object.defineProperty(t,"ref",{get:u,configurable:!0})}}var Pe=function(t,o,u,y,v,w,b){var S={$$typeof:e,type:t,key:o,ref:u,props:b,_owner:w};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function kt(t,o,u,y,v){{var w,b={},S=null,I=null;u!==void 0&&(ie(u),S=""+u),sr(o)&&(ie(o.key),S=""+o.key),oe(o)&&(I=o.ref,or(o,v));for(w in o)Tt.call(o,w)&&!Re.hasOwnProperty(w)&&(b[w]=o[w]);if(t&&t.defaultProps){var k=t.defaultProps;for(w in k)b[w]===void 0&&(b[w]=k[w])}if(S||I){var C=typeof t=="function"?t.displayName||t.name||"Unknown":t;S&&ar(b,C),I&&ae(b,C)}return Pe(t,S,I,v,y,lt.current,b)}}var le=j.ReactCurrentOwner,Ie=j.ReactDebugCurrentFrame;function ft(t){if(t){var o=t._owner,u=Lt(t.type,t._source,o?o.type:null);Ie.setExtraStackFrame(u)}else Ie.setExtraStackFrame(null)}var J;J=!1;function yt(t){return typeof t=="object"&&t!==null&&t.$$typeof===e}function Nt(){{if(le.current){var t=nt(le.current.type);if(t)return`
22
+
23
+ Check the render method of \``+t+"`."}return""}}function lr(t){{if(t!==void 0){var o=t.fileName.replace(/^.*[\\\/]/,""),u=t.lineNumber;return`
24
+
25
+ Check your code at `+o+":"+u+"."}return""}}var he={};function Oe(t){{var o=Nt();if(!o){var u=typeof t=="string"?t:t.displayName||t.name;u&&(o=`
26
+
27
+ Check the top-level render call using <`+u+">.")}return o}}function je(t,o){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var u=Oe(o);if(he[u])return;he[u]=!0;var y="";t&&t._owner&&t._owner!==le.current&&(y=" It was passed a child from "+nt(t._owner.type)+"."),ft(t),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,y),ft(null)}}function Ht(t,o){{if(typeof t!="object")return;if(ne(t))for(var u=0;u<t.length;u++){var y=t[u];yt(y)&&je(y,o)}else if(yt(t))t._store&&(t._store.validated=!0);else if(t){var v=D(t);if(typeof v=="function"&&v!==t.entries)for(var w=v.call(t),b;!(b=w.next()).done;)yt(b.value)&&je(b.value,o)}}}function hr(t){{var o=t.type;if(o==null||typeof o=="string")return;var u;if(typeof o=="function")u=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===f||o.$$typeof===A))u=o.propTypes;else return;if(u){var y=nt(o);rr(u,t.props,"prop",y,t)}else if(o.PropTypes!==void 0&&!J){J=!0;var v=nt(o);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Me(t){{for(var o=Object.keys(t.props),u=0;u<o.length;u++){var y=o[u];if(y!=="children"&&y!=="key"){ft(t),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",y),ft(null);break}}t.ref!==null&&(ft(t),T("Invalid attribute `ref` supplied to `React.Fragment`."),ft(null))}}function ue(t,o,u,y,v,w){{var b=jt(t);if(!b){var S="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var I=lr(v);I?S+=I:S+=Nt();var k;t===null?k="null":ne(t)?k="array":t!==void 0&&t.$$typeof===e?(k="<"+(nt(t.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):k=typeof t,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",k,S)}var C=kt(t,o,u,v,w);if(C==null)return C;if(b){var F=o.children;if(F!==void 0)if(y)if(ne(F)){for(var W=0;W<F.length;W++)Ht(F[W],t);Object.freeze&&Object.freeze(F)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ht(F,t)}return t===i?Me(C):hr(C),C}}function ur(t,o,u){return ue(t,o,u,!0)}function r(t,o,u){return ue(t,o,u,!1)}var n=r,l=ur;Yt.Fragment=i,Yt.jsx=n,Yt.jsxs=l}()),Yt}process.env.NODE_ENV==="production"?Le.exports=Hr():Le.exports=Br();var Ur=Le.exports,Wr=Object.defineProperty,Yr=(p,e,a)=>e in p?Wr(p,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):p[e]=a,x=(p,e,a)=>(Yr(p,typeof e!="symbol"?e+"":e,a),a),Vr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ze(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}var gr={exports:{}};(function(p){(function(e,a){p.exports=a()})("Vector",function(){var e=function(){var a=Math.PI*2,i=180/Math.PI,h=Math.PI/180;function c(s){return Math.round(s*1e8)/1e8}function g(s,d){var A=d.x-s.x,_=d.y-s.y;return Math.sqrt(A*A+_*_)}function m(s,d,A){var _=d.y-s.y,R=d.x-s.x,P=Math.atan2(_,R);if(A)for(;P<0;)P+=a;return P}function f(s,d){this.x=s!==void 0?s:0,this.y=d!==void 0?d:0}return f.fromRadians=function(s){var d=Math.cos(s),A=Math.sin(s);return new f(d,A)},f.fromDegrees=function(s){var d=s*(Math.PI/180);return f.fromRadians(d)},f.fromString=function(s){var d=s.split(",");return new f(parseFloat(d[0]),parseFloat(d[1]))},f.fromArray=function(s){return new f(s[0],s[1])},f.prototype={version:"2.0.1",clone:function(){return new f(this.x,this.y)},equals:function(s){return this.prototype===s.prototype&&this.x===s.x&&this.y===s.y},copy:function(s){return this.x=s.x,this.y=s.y,this},copyX:function(s){return this.x=s.x,this},copyY:function(s){return this.y=s.y,this},toDict:function(){return{x:this.x,y:this.y}},toArray:function(){return[this.x,this.y]},set:function(s,d){return s!==void 0&&(this.x=s),d!==void 0&&(this.y=d),this},flipXY:function(){return new f(this.y,this.x)},flipXYSelf:function(){return this.y=[this.x,this.x=this.y][0],this},invert:function(){return this.mulScalar(-1)},invertSelf:function(){return this.mulScalarSelf(-1),this},distanceFrom:function(s){return g(this,s)},radiansTo:function(s){return m(this,s,!0)},degreesTo:function(s){return m(this,s,!0)*i},toRadians:function(s){return m(f.zero,this,!0)},toDegrees:function(s){return this.toRadians()*i},rotateDegreesSelf:function(s){return this.rotateRadiansSelf(s*h)},rotateDegrees:function(s){return this.clone().rotateDegreesSelf(s)},rotateRadiansSelf:function(s){var d=Math.cos(s),A=Math.sin(s),_=this.x*d-this.y*A,R=this.x*A+this.y*d;return this.x=c(_),this.y=c(R),this},rotateRadians:function(s){return this.clone().rotateRadiansSelf(s)},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalizeSelf:function(){var s=Math.sqrt(this.x*this.x+this.y*this.y);return s===0?this:(this.x/=s,this.y/=s,this)},normalize:function(){return this.clone().normalizeSelf()},addSelf:function(s){return typeof s=="number"?this.addScalarSelf(s):(this.x+=s.x,this.y+=s.y,this)},subSelf:function(s){return typeof s=="number"?this.subScalarSelf(s):(this.x-=s.x,this.y-=s.y,this)},divSelf:function(s){return typeof s=="number"?this.divScalarSelf(s):(this.x/=s.x,this.y/=s.y,this)},mulSelf:function(s){return typeof s=="number"?this.mulScalarSelf(s):(this.x*=s.x,this.y*=s.y,this)},addScalarSelf:function(s){return this.x+=s,this.y+=s,this},subScalarSelf:function(s){return this.x-=s,this.y-=s,this},divScalarSelf:function(s){return this.x/=s,this.y/=s,this},mulScalarSelf:function(s){return this.x*=s,this.y*=s,this},add:function(s){return this.clone().addSelf(s)},sub:function(s){return this.clone().subSelf(s)},mul:function(s){return this.clone().mulSelf(s)},div:function(s){return this.clone().divSelf(s)},addScalar:function(s){return this.clone().addScalarSelf(s)},subScalar:function(s){return this.clone().subScalarSelf(s)},mulScalar:function(s){return this.clone().mulScalarSelf(s)},divScalar:function(s){return this.clone().divScalarSelf(s)},clampSelf:function(s,d){return this.x<s.x&&(this.x=s.x),this.y<s.y&&(this.y=s.y),this.x>d.x&&(this.x=d.x),this.y>d.y&&(this.y=d.y),this},clamp:function(s,d){return this.clone().clampSelf(s,d)},applySelf:function(s){return this.x=s(this.x),this.y=s(this.y),this},apply:function(s){return this.clone().applySelf(s)},absSelf:function(){return this.applySelf(Math.abs)},abs:function(){return this.clone().absSelf()},roundSelf:function(){return this.applySelf(Math.round)},round:function(){return this.clone().roundSelf()},dot:function(s){return this.x*s.x+this.y*s.y},cross:function(s){return this.x*s.y-this.y*s.x},repairSelf:function(s,d){return(typeof this.x!="number"||isNaN(this.x+1))&&(this.x=s||0),(typeof this.y!="number"||isNaN(this.y+1))&&(this.y=d||0),this},repair:function(s,d){return this.clone().repairSelf(s,d)},toString:function(){return this.x+","+this.y},format:function(s){return s=s||"%x,%y",s=s.replace(new RegExp("%x","g"),this.x),s=s.replace(new RegExp("%y","g"),this.y),s}},f}();return e.zero=new e(0,0),e.one=new e(1,1),e.up=new e(0,-1),e.down=new e(0,1),e.left=new e(-1,0),e.right=new e(1,0),e.upLeft=new e(-1,-1),e.downLeft=new e(-1,1),e.upRight=new e(1,-1),e.downRight=new e(1,1),e.prototype.magnitude=e.prototype.length,Object.freeze&&(Object.freeze(e.zero),Object.freeze(e.one),Object.freeze(e.up),Object.freeze(e.down),Object.freeze(e.left),Object.freeze(e.right),Object.freeze(e.upLeft),Object.freeze(e.downLeft),Object.freeze(e.upRight),Object.freeze(e.downRight)),e})})(gr);var Xr=gr.exports;const G=ze(Xr);let de=(p=21)=>crypto.getRandomValues(new Uint8Array(p)).reduce((e,a)=>(a&=63,a<36?e+=a.toString(36):a<62?e+=(a-26).toString(36).toUpperCase():a>62?e+="-":e+="_",e),"");const Vt={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},yr={id:0,type:"Feature",properties:{type:"arrow",style:{...Vt}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},qr=(p=0,e=0,a=0,i=0,h={...Vt})=>({id:de(),type:"Feature",properties:{type:"arrow",style:{...Vt,...h}},geometry:{type:"LineString",coordinates:[[p,e],[a,i]]}}),Zr="http://www.w3.org/2000/svg";function Xt(p){return document.createElementNS(Zr,p)}function mr(p){return p.geometry.bbox||Gr(p),p.geometry.bbox}function pt(p){const e=mr(p);return{width:e[2]-e[0],height:e[3]-e[1]}}function gt(p){const e=mr(p);return{x:e[0],y:e[1]}}function Gr(p){const[e,a]=p.geometry.coordinates[0][0],[i,h]=p.geometry.coordinates[0][2];p.geometry.bbox=[e,a,i,h]}function Kr(p,e,a,i,h){p.geometry.bbox=[e,a,e+i,a+h],p.geometry.coordinates=[[[e,a],[e+i,a],[e+i,a+h],[e,a+h],[e,a]]]}function qt(p){const[e,a]=p.geometry.coordinates[0];return{x:e,y:a}}function pe(p,e){const[a,i]=p.geometry.coordinates[e==="start"?0:1];return{x:a,y:i}}function ge(p){const[e,a]=p.geometry.coordinates[1];return{x:e,y:a}}function vr(p,e,a){p.geometry.coordinates[0]=[e,a]}function br(p,e,a){p.geometry.coordinates[1]=[e,a]}function ye(p){return{start:qt(p),end:ge(p)}}function Pt(p,e,a,i){e==="start"?vr(p,a,i):br(p,a,i)}const wr=p=>parseInt(p.getAttribute("data-handle-id")||"-1");function me(p,e,a){const i=Math.atan2(p.y-e.y,p.x-e.x);return{x:e.x+a*Math.cos(i),y:e.y+a*Math.sin(i)}}function $e(p,e){if(!e)return{x:p.clientX,y:p.clientY};const a=e.getBoundingClientRect();return{x:p.clientX-a.left-e.clientLeft,y:p.clientY-a.top-e.clientTop}}function xr(p,e=5,a=30){var i;const{start:h,end:c}=ye(p),g=new G(h.x,h.y),m=new G(c.x,c.y).sub(g),f=p.properties.style&&p.properties.style.strokeWidth?(i=p.properties.style)==null?void 0:i.strokeWidth:0;return Math.min(a,Math.max(3*f,m.length()*.1,e))}function Sr(p,e,a,i){const h=e.clone().normalize().invert().mul(i);if(!a||a==="none")return"";const c=p.clone().add(h.rotateRadians(Math.PI/8)),g=p.clone().add(h.rotateRadians(-Math.PI/8)),m=`${p.x} ${p.y}`;return`M ${c.x} ${c.y} L ${m} ${g.x} ${g.y} ${a==="arrow"?"":`${c.x} ${c.y}`}`}function Jr(p,e,a,i,h){const{start:c,end:g}=ye(p),{tail:m,head:f,strokeColor:s,strokeWidth:d}=p.properties.style||a,A=new G(c.x,c.y),_=new G(g.x,g.y),R=_.clone().sub(A),P=xr(p,i,h),E=Xt("path");E.setAttribute("data-annotation",`${p.id}`),E.setAttribute("data-annotation-type","arrow");const D=f==="arrow-plain"||m==="arrow";E.setAttribute("stroke",s||"none"),E.setAttribute("stroke-width",`${d}`),E.setAttribute("fill",D?s||"":"none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round");const j=Sr(A,R.clone().invert(),m,P),T=Sr(_,R,f,P),N=j+`M ${A.x} ${A.y} ${_.x} ${_.y}`+T;E.setAttribute("d",N),e.appendChild(E)}const X=-1,ve="dragging",be="dragstart",It="dragend",Ne="select",He="unselect",Qr="hover",tn="unhover",Be="remove",Ue="add",en="cancelDrawing",We="update",rn="link";var Ar={exports:{}};(function(p){var e=Object.prototype.hasOwnProperty,a="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(a=!1));function h(f,s,d){this.fn=f,this.context=s,this.once=d||!1}function c(f,s,d,A,_){if(typeof d!="function")throw new TypeError("The listener must be a function");var R=new h(d,A||f,_),P=a?a+s:s;return f._events[P]?f._events[P].fn?f._events[P]=[f._events[P],R]:f._events[P].push(R):(f._events[P]=R,f._eventsCount++),f}function g(f,s){--f._eventsCount===0?f._events=new i:delete f._events[s]}function m(){this._events=new i,this._eventsCount=0}m.prototype.eventNames=function(){var f=[],s,d;if(this._eventsCount===0)return f;for(d in s=this._events)e.call(s,d)&&f.push(a?d.slice(1):d);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(s)):f},m.prototype.listeners=function(f){var s=a?a+f:f,d=this._events[s];if(!d)return[];if(d.fn)return[d.fn];for(var A=0,_=d.length,R=new Array(_);A<_;A++)R[A]=d[A].fn;return R},m.prototype.listenerCount=function(f){var s=a?a+f:f,d=this._events[s];return d?d.fn?1:d.length:0},m.prototype.emit=function(f,s,d,A,_,R){var P=a?a+f:f;if(!this._events[P])return!1;var E=this._events[P],D=arguments.length,j,T;if(E.fn){switch(E.once&&this.removeListener(f,E.fn,void 0,!0),D){case 1:return E.fn.call(E.context),!0;case 2:return E.fn.call(E.context,s),!0;case 3:return E.fn.call(E.context,s,d),!0;case 4:return E.fn.call(E.context,s,d,A),!0;case 5:return E.fn.call(E.context,s,d,A,_),!0;case 6:return E.fn.call(E.context,s,d,A,_,R),!0}for(T=1,j=new Array(D-1);T<D;T++)j[T-1]=arguments[T];E.fn.apply(E.context,j)}else{var N=E.length,H;for(T=0;T<N;T++)switch(E[T].once&&this.removeListener(f,E[T].fn,void 0,!0),D){case 1:E[T].fn.call(E[T].context);break;case 2:E[T].fn.call(E[T].context,s);break;case 3:E[T].fn.call(E[T].context,s,d);break;case 4:E[T].fn.call(E[T].context,s,d,A);break;default:if(!j)for(H=1,j=new Array(D-1);H<D;H++)j[H-1]=arguments[H];E[T].fn.apply(E[T].context,j)}}return!0},m.prototype.on=function(f,s,d){return c(this,f,s,d,!1)},m.prototype.once=function(f,s,d){return c(this,f,s,d,!0)},m.prototype.removeListener=function(f,s,d,A){var _=a?a+f:f;if(!this._events[_])return this;if(!s)return g(this,_),this;var R=this._events[_];if(R.fn)R.fn===s&&(!A||R.once)&&(!d||R.context===d)&&g(this,_);else{for(var P=0,E=[],D=R.length;P<D;P++)(R[P].fn!==s||A&&!R[P].once||d&&R[P].context!==d)&&E.push(R[P]);E.length?this._events[_]=E.length===1?E[0]:E:g(this,_)}return this},m.prototype.removeAllListeners=function(f){var s;return f?(s=a?a+f:f,this._events[s]&&g(this,s)):(this._events=new i,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prefixed=a,m.EventEmitter=m,p.exports=m})(Ar);var nn=Ar.exports;const Er=ze(nn);class _r extends Er{constructor(e,a){super(),x(this,"ogma"),x(this,"elements"),x(this,"layer"),x(this,"editor"),x(this,"selectedId",X),x(this,"hoveredId",X),x(this,"ogmaOptions"),x(this,"shouldDetect"),x(this,"isDragging"),x(this,"showeditorOnHover"),x(this,"maxHandleScale",1.5),x(this,"_onKeyUp",i=>{i.code===27&&this.selectedId!==X?this.unselect():(i.code===46||i.code===8)&&this.selectedId!==X&&this._canRemove()&&this.remove(this.selectedId)}),x(this,"_onClickMouseMove",i=>{if(!i.domEvent||this.isDragging||!this.shouldDetect||i.domEvent.type!=="mousemove"&&i.domEvent.target&&i.domEvent.target.tagName==="a")return;const h=this.ogma.view.screenToGraphCoordinates(i),c=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(h,0):void 0;i.domEvent.type==="mousemove"?c?this.hover(c.id):this.hoveredId!==X&&this.unhover():c?this.select(c.id):this.selectedId!==X&&this.unselect()}),this.ogma=e,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=e.getOptions(),e.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("frame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=e.layers.addSVGLayer({draw:i=>this.draw(i)}),this.layer.moveToTop(),this.editor=e.layers.addLayer(a),this.editor.hide()}_canRemove(){return!0}add(e){const a=this.getDefaultOptions(),i=Object.assign(e,{id:e.id===void 0?de():e.id,type:e.type,properties:{...a.properties,...e.properties||{},style:{...a.properties.style,...e.properties.style||{}}},geometry:{...a.geometry,...e.geometry}});return this.elements.push(i),this.layer.refresh(),this.emit(Ue,i),i}updateStyle(e,a){this.updateAnnotation(e,{properties:{style:a}})}updateGeometry(e,a){this.updateAnnotation(e,{geometry:a})}update(e,a){const i=this.getById(e);this.updateAnnotation(i,a)}updateAnnotation(e,a){if(!e)return;const i=e.id;Object.keys(a).forEach(h=>{if(h!=="id")if(h==="properties"){const c=a.properties||{style:{}};e.properties={...e.properties||{},...c||{},style:{...e.properties.style||{},...c.style||{}}}}else h==="geometry"?e.geometry={...e.geometry,...a.geometry}:e[h]=a[h]}),i===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(e){const a=Number(e);for(let i=0;i<this.elements.length;i++){const h=this.elements[i];if(!(h.id!==e&&h.id!==a))return h}}select(e){const a=this.getById(e);a&&(this.editor.show(),this.selectedId=e,this.refreshEditor(),this.layer.refresh(),this.emit(Ne,a))}hover(e){const a=this.getById(e);a&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=e,this.refreshEditor(),this.layer.refresh(),this.emit(Qr,a))}getSelectedFeature(){return this.selectedId===X?null:this.getById(this.selectedId)}unselect(){const e=this.getById(this.selectedId);return e&&this.emit(He,e),this.selectedId=X,this.hoveredId===X&&this.editor.hide(),this.layer.refresh(),this}unhover(){const e=this.getById(this.hoveredId);return this.emit(tn,e),this.hoveredId=X,this.selectedId===X&&this.editor.hide(),this.layer.refresh(),this}remove(e){const a=this.getById(e);e===this.hoveredId&&this.unhover(),e===this.selectedId&&this.unselect(),this.elements=this.elements.filter(i=>i.id!==e),a&&this.emit(Be,a),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 Tr="handle-line",kr="handle-start",Rr="handle-end";class sn extends _r{constructor(e,a={}){super(e,`
28
+ <div class="arrow-handle">
29
+ <div id="${Tr}" data-handle-id="0" class="handle line"></div>
30
+ <div id="${kr}" data-handle-id="1" class="handle"></div>
31
+ <div id="${Rr}" data-handle-id="2" class="handle"></div>
32
+ </div>
33
+ `),x(this,"draggedHandle",X),x(this,"start",{x:0,y:0}),x(this,"end",{x:0,y:0}),x(this,"arrow",{...yr}),x(this,"startX",0),x(this,"startY",0),x(this,"minArrowHeight",0),x(this,"maxArrowHeight",0),x(this,"handles",[]),x(this,"onHandleMouseDown",i=>{const h=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!h)return;const{x:c,y:g}=$e(i,this.ogma.getContainer());this.startDragging(h,c,g),this.draggedHandle=wr(i.target)}),x(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=X,this.emit(It,this.arrow))}),x(this,"onMouseMove",i=>{if(!this.isDragging||this.draggedHandle===X)return;const h=this.handles[this.draggedHandle],c=this.ogma.view.getAngle(),{x:g,y:m}=new G(i.clientX-this.startX,i.clientY-this.startY).divScalar(this.ogma.view.getZoom()).rotateRadians(c),f=h.id===Tr,s=h.id===kr,d=h.id===Rr;(f||s)&&vr(this.arrow,this.start.x+g,this.start.y+m),(f||d)&&br(this.arrow,this.end.x+g,this.end.y+m),this.emit(ve,this.arrow,f?"line":s?"start":"end"),this.refreshEditor(),this.layer.refresh()}),this.minArrowHeight=a.minArrowHeight||0,this.maxArrowHeight=a.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(i=>i.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(e,a,i=qr(e,a,e,a,Vt)){var h;this.disableDragging(),this.add(i),this.hoveredId=i.id;const c=this.ogma.view.graphToScreenCoordinates({x:e,y:a}),g=((h=this.ogma.getContainer())==null?void 0:h.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(i.id),c.x+(g==null?void 0:g.left),c.y+g.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(It,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=X)}startDragging(e,a,i){this.selectedId!==e.id&&this.select(this.hoveredId),this.arrow=e,this.startX=a,this.startY=i,this.start=qt(this.arrow),this.end=ge(this.arrow),this.disableDragging(),this.emit(be,this.arrow),this.isDragging=!0}detect(e,a=0){return this.elements.find(i=>{const{start:h,end:c}=ye(i),g=new G(e.x,e.y).sub(new G((h.x+c.x)/2,(h.y+c.y)/2)),m=new G(c.x,c.y).sub(new G(h.x,h.y)),f=m.length(),s=m.normalize(),d=xr(i);return Math.abs(s.dot(g))<f/2+a&&Math.abs(s.rotateRadians(Math.PI/2).dot(g))<d/2+a})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const e=this.selectedId!==X?this.getById(this.selectedId):this.getById(this.hoveredId),a=ye(e),i=this.ogma.view.graphToScreenCoordinates(a.start),h=this.ogma.view.graphToScreenCoordinates(a.end),c=Math.min(this.ogma.view.getZoom(),this.maxHandleScale),[g,m,f]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));m.style.transform=`translate(${i.x}px, ${i.y}px) translate(-50%, -50%) scale(${c})`,f.style.transform=`translate(${h.x}px, ${h.y}px) translate(-50%, -50%) scale(${c}`;const s={x:(h.x+i.x)/2,y:(h.y+i.y)/2},d=new G(h.x-i.x,h.y-i.y),A=d.mul(1/d.length()),_=Math.atan2(A.y,A.x);g.style.width=`${d.length()}px`,g.style.left=`${s.x}px`,g.style.top=`${s.y}px`,g.style.transform=`translate(-50%, -50%) rotate(${_}rad)`}getDefaultOptions(){return yr}draw(e){e.innerHTML="";const a=Xt("g"),i=this.ogma.view.getAngle();a.setAttribute("transform",`rotate(${-i*(180/Math.PI)})`),this.elements.forEach(h=>Jr(h,a,Vt,this.minArrowHeight,this.maxArrowHeight)),e.appendChild(a)}refreshDrawing(){const e=this.ogma.view.getAngle();this.layer.element.children[0].setAttribute("transform",`rotate(${-e*(180/Math.PI)})`)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const Ot={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},Ye={id:0,type:"Feature",properties:{type:"text",content:"",style:{...Ot}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},Cr={handleSize:3.5,placeholder:"Your text..."},on=(p=0,e=0,a=100,i=50,h="",c={...Ot})=>({id:de(),type:"Feature",properties:{type:"text",content:h,style:{...Ot,...c}},geometry:{type:"Polygon",coordinates:[[[p,e],[p+a,e],[p+a,e+i],[p,e+i],[p,e]]]}});var Pr={exports:{}};(function(p,e){(function(a,i){p.exports=i()})(Vr,()=>(()=>{var a={d:(r,n)=>{for(var l in n)a.o(n,l)&&!a.o(r,l)&&Object.defineProperty(r,l,{enumerable:!0,get:n[l]})},o:(r,n)=>Object.prototype.hasOwnProperty.call(r,n)},i={};function h(r){return h=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},h(r)}a.d(i,{default:()=>ur});var c=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,g=/\bsmall-caps\b/,m=/\b(?:italic|oblique)\b/,f=/\bbold(?:er)?\b/,s=13.3333333,d={"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 A(r){var n="",l=this;return l.style&&l.style!=="normal"&&(n+=l.style),l.variant&&l.variant!=="normal"&&(n+=(n?" ":"")+l.variant),l.weight&&l.weight!=="normal"&&(n+=(n?" ":"")+l.weight),l.size&&(n+=(n?" ":"")+l.size+"px",l.height!==l.size&&(n+="/"+l.height+"px")),l.family&&(n+=(n?" ":"")+l.family),r&&(n+="::"+l.baseline),r&&(n+="::"+l.color),n}var _={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:A,valueOf:A};function R(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=c.exec(r);n.family=(l[6]||"").trim();var t=d[l[2]]||parseFloat(l[2]);l[3]==="%"?t*=.16:l[3]==="em"?t*=16:l[3]==="pt"&&(t*=s),n.size=t;var o=parseFloat(l[4]);if(o!=="normal"&&o!=="inherit"&&o?l[5]&&l[5]!=="em"?l[5]==="pt"?n.height=o*s:l[5]==="%"?n.height=.01*t:n.height=o:n.height=o*t:n.height=Math.round(t*(7/6)),g.test(l[1])&&(n.variant="small-caps"),m.test(l[1])&&(n.style="italic"),f.test(l[1]))n.weight="bold";else{var u=parseInt(/\b(\d+)\b/.exec(l[1]),10);u>=100&&u!==400&&(n.weight=u)}return n}function P(){var r,n,l,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=14,y=12,v=null,w=null,b="";if(t&&t.nodeType){var S=t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView),I=S.getComputedStyle(t,null);r=I.getPropertyValue("font-family")||"",y=parseFloat(I.getPropertyValue("font-size")),u=I.getPropertyValue("line-height"),v=I.getPropertyValue("font-weight"),w=I.getPropertyValue("font-style"),b=I.getPropertyValue("font-variant")||""}else if(typeof t=="string"){var k=R(t);r=k.family,y=k.size,u=k.height,b=k.variant,w=k.style,v=k.weight}else h(t)==="object"&&(r=t.family,y=t.size,u=t.height,b=t.variant,v=t.weight,w=t.style,n=t.baseline,l=t.color);o.size&&o.size<3&&(y*=o.size),u=u!=="normal"&&u?parseFloat(u):y*(7/6),o.height&&o.height<3&&(u*=o.height);var C=Object.create(_);return C.family=o.family||r||"sans-serif",C.height=u??14,C.size=y??12,C.variant=o.variant||b||"",C.style=o.style||w||"",C.weight=o.weight||v||"",C.baseline=n||0,o.baseline!=null&&(C.baseline=o.baseline),C.color=o.color||l||"",C.id=A.call(C,!0),C}const E={"\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 D,j=function(r){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||r&&r.createElement("canvas");if(n&&n.getContext){var l=n.getContext("2d");if(l&&typeof l.measureText=="function")return function(t,o){return l.font=String(o),l.measureText(t).width}}}(typeof document<"u"?document:null)||(D={},function(r,n){if(!D[n]){var l=P(n);D[n]=l,/\bmonospace\b/.test(l.family)?l.size*=.6:(l.size*=.45,l.weight&&(l.size*=1.18))}return r.length*D[n].size}),T={},N={trim:!0,collapse:!0};function H(r,n,l){var t=Object.assign({},N,l),o=String(r);if(!o)return 0;if(o in E){var u=n.id+"/"+o;return u in T||(T[u]=j("_".concat(o,"_"),n)-j("__",n)),T[u]}return t.trim&&t.collapse?t.trim?o=o.trim():t.collapse&&(o=o.replace(/\s+/g," ")):o=o.replace(/\n/g," "),j(o,n)+n.size*(r.tracking||0)}function at(r){return at=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},at(r)}function At(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&Zt(r,n)}function Zt(r,n){return Zt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,t){return l.__proto__=t,l},Zt(r,n)}function Gt(r){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 l,t=jt(r);if(n){var o=jt(this).constructor;l=Reflect.construct(t,arguments,o)}else l=t.apply(this,arguments);return we(this,l)}}function we(r,n){if(n&&(at(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(l){if(l===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l}(r)}function jt(r){return jt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},jt(r)}function Mt(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function Kt(r,n){for(var l=0;l<n.length;l++){var t=n[l];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(o=function(u,y){if(at(u)!=="object"||u===null)return u;var v=u[Symbol.toPrimitive];if(v!==void 0){var w=v.call(u,y);if(at(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(t.key,"string"),at(o)==="symbol"?o:String(o)),t)}var o}function nt(r,n,l){return n&&Kt(r.prototype,n),l&&Kt(r,l),Object.defineProperty(r,"prototype",{writable:!1}),r}var L=function(){function r(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Mt(this,r),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return nt(r,[{key:"clone",value:function(){var n=new r(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}}]),r}(),ut=function(r){At(l,r);var n=Gt(l);function l(){return Mt(this,l),n.apply(this,arguments)}return nt(l)}(L),K=function(r){At(l,r);var n=Gt(l);function l(){return Mt(this,l),n.apply(this,arguments)}return nt(l)}(L),ct=function(r){At(l,r);var n=Gt(l);function l(){return Mt(this,l),n.apply(this,arguments)}return nt(l)}(L),Dt=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,xe=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,Jt=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Se=/^(?:[;\xAD%?…]|,(?!\d))/,Ae=/^[´±°¢£¤$¥\u2212]/;function Et(r,n){n!==!1&&(r=r.trim());for(var l,t,o=[],u=r.charAt(0),y=0,v=1,w=r.length;v<w;v++){l=r.charAt(v),t=r.charAt(v+1);var b=Dt.test(u),S=Dt.test(l),I=S||b,k=void 0;if((Ae.test(l)&&!Jt.test(u)||Se.test(u+t)&&!Jt.test(l))&&(I=!0),u!=="-"&&u!=="‐"&&u!=="–"&&u!=="—"||((k=Dt.test(r.charAt(v-2)))&&!S&&(I=!1),!k&&xe.test(l+t)&&(I=!0)),I){var C=r.slice(y,v);/\u00AD$/.test(C)?(o.push(new L(C.slice(0,-1))),o.push(new ct)):(o.push(new L(C)),o.push(new ut)),y=v}u=l}return o.push(new L(r.slice(y))),o}const Ee={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 Je=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,Qt=/^<\/([a-zA-Z0-9]+)([^>]*)>/,te=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Ft=/^<!--(.+?)-->/,ee=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,_t={b:function(r){r.weight="bold"},strong:function(r){r.weight="bold"},i:function(r){r.style="italic"},em:function(r){r.style="italic"},dfn:function(r){r.style="italic"},cite:function(r){r.style="italic"},code:function(r){r.family="monospace"},kbd:function(r){r.family="monospace"},samp:function(r){r.family="monospace"},var:function(r){r.family="monospace"},tt:function(r){r.family="monospace"},sub:function(r){r.sub=!0},sup:function(r){r.sup=!0}},Qe={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 re(r){return r.replace(ee,function(n,l,t,o){if(l||t){var u=l?10:16;return String.fromCharCode(parseInt(l||t,u))}return o in Ee?Ee[o]:n})}function tr(r){return r&&r.length>1&&(r[0]==='"'&&r[r.length-1]==='"'||r[0]==="'"&&r[r.length-1]==="'")?r.slice(1,-1):r}var er=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Lt(r){var n,l={};if(r){do if(n=er.exec(r)){var t=re(tr(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(l[n[1]]=t,(r=r.slice(n[0].length)).length&&/^\S/.test(r[0]))throw new Error("Attribute error")}while(n&&r.length);if(/\S/.test(r))throw new Error("Attribute error")}return l}const Tt={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 _e=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,Te=/^%[^\n]+(?:\n|$)/,zt=/^[^#$%&~_^\\{}]+/,rr=/^\\([&{}$%#_])/,nr=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,ne={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},U={bf:function(r){r.weight="bold"},it:function(r){r.style="italic"},sl:function(r){r.style="italic"},color:function(r,n){r.color=n},href:function(r,n){r.href=n},"^":function(r){r.sup=!0},_:function(r){r.sub=!0},par:function(r){this.tokens.push(new K,new K)},newline:function(r){this.tokens.push(new K)},url:function(r,n){this.open_context().href=n,this.add_token(new L(n)),this.close_context()}};U.textsuperscript=U["^"],U.textsubscript=U._,U.textsl=U.sl,U.mathbf=U.bf,U.mathit=U.it,U.textbf=U.bf,U.textit=U.it,U.textcolor=U.color;var ir=/[\r\n\xA0]+/g;function ke(r,n){r.sup&&(r.baseline=.45,r.size=.7),r.sub&&(r.baseline=-.3,r.size=.7);var l=n;return(r.style||r.weight||r.baseline||r.color||r.size||r.family)&&(l=P(n,r)),l}function ie(r,n,l){for(var t,o,u=r.width;u+l.width>n&&r.length;)o=(t=r[r.length-1]).width,t.width>l.width?(t.value=t.value.slice(0,-1),t.width=H(t,t.font),u+=t.width):r.pop(),u-=o;r[r.length-1]instanceof ct&&r.pop(),t=r[r.length-1]||t||{},l.font=P(l.font,t.bold,t.italic,""),l.href=r.length?t.href:null,l.rel=r.length?t.rel:null,l.target=r.length?t.target:null,r.push(l)}function lt(r){return Math.round(1e6*r)/1e6}function Re(r){return function(n){if(Array.isArray(n))return $t(n)}(r)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(r)||function(n,l){if(n){if(typeof n=="string")return $t(n,l);var t=Object.prototype.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?$t(n,l):void 0}}(r)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
34
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function $t(r,n){(n==null||n>r.length)&&(n=r.length);for(var l=0,t=new Array(n);l<n;l++)t[l]=r[l];return t}var Ce={center:"middle",right:"end"},se={middle:.5,center:.5,bottom:1,end:1},oe=function(r,n){return!r&&!n||r===n};function sr(r,n){var l=[],t=n.font(),o=t.size,u=t.family,y=n.align(),v=n.createElement();if(r.length){var w=t.height,b=n.valign(),S=n.height()(),I=n.width()(0),k=!isFinite(I)&&r.length===1,C=k?null:n.x(),F=lt(w/o),W=k?null:lt(w/(1.15*o+(w-o)/2));if(se[b]&&isFinite(S)){var z=b==="bottom"?1:.5;W+=(S*z-w*r.length*z)/o}var O=y==="justify",Y=0;y==="right"?Y=I:y==="center"&&(Y=I/2);for(var $=[],it="tspan",Q=null,V="",M=function(){if(V){var Rt=v(it,Q,V);$.push(Rt)}it="tspan",Q=null,V=""},ot=0,st=r.length;ot<st;ot++){var mt="",xt="",dt=0,vt=r[ot];if(vt.length){$=[];for(var Bt=0,ce=0,bt=void 0,tt=0,De=vt.length;tt<De;tt++){var q=vt[tt],et=q.font;q.whitespace&&Bt++,ce+=q.width,tt&&!q.tracking&&!dt&&oe(et.id,mt)&&oe(q.class,xt)&&oe(bt,q.href)?V+=q.value:(M(),V=q.value,Q={fontFamily:et.family!==u?et.family:null,fontSize:et.size!==o?et.size:null,fontWeight:et.weight||null,fontStyle:et.style||null,fontVariant:et.variant!=="normal"&&et.variant||null,fill:et.color||null,baselineShift:et.baseline?100*et.baseline+"%":null,className:q.class||null},dt&&(Q.dx=lt(dt),dt=0),q.tracking&&(dt=et.size*q.tracking),q.href&&!bt?(bt=q.href,it="a",Q.href=bt,Q.rel=q.rel,Q.target=q.target):bt=null,mt=et.id,xt=q.class)}if(M(),k)l.push.apply(l,Re($));else{var Fe=null,fe=ot===st-1||vt[vt.length-1]instanceof K;O&&vt.length>1&&!fe&&(Fe=lt((I-ce)/Bt)),l.push(v.apply(void 0,["tspan",{wordSpacing:Fe,x:C(ot)+Y,dy:lt(ot?F:W)+"em"}].concat(Re($))))}}else l.push(v("tspan",{x:C(ot),dy:lt(ot?F:W)+"em"}," "))}}return v.apply(void 0,["text",{fontFamily:u,fontSize:o,textAnchor:Ce[y]||"start"}].concat(l))}var or={middle:.5,center:.5,bottom:1,end:1};function ar(r,n,l){if(r.length){l.textBaseline="middle";var t=n.font(),o=t.height,u=t.size,y=n.valign(),v=n.height()(),w=n.width()(0),b=n.align(),S=b==="justify",I=.5*o,k=or[y];if(k&&isFinite(v)){var C=r.length*o;I+=v*k-C*k}r.forEach(function(F,W){var z=n.x()(W),O=W*o+I,Y=0,$=0;F.forEach(function(V){V.whitespace&&Y++,$+=V.width});var it=0,Q=W===r.length-1||F[F.length-1]instanceof K;S&&F.length>1&&!Q&&(it=(w-$)/Y),F.forEach(function(V){l.font=V.font;var M=V.font,ot=M.baseline?u*-M.baseline+.15*u:0;l.fillStyle=function(xt,dt){return xt.color?xt.color:dt.href?"#00C":"#000"}(M,V);var st=0;if(b==="right"?st+=w-$:b==="center"?st+=w/2-$/2:b==="justify"&&(V.whitespace||V instanceof K)&&(z+=it),l.fillText(V.value,z+st,O+ot),V.href){l.beginPath(),l.strokeStyle=l.fillStyle;var mt=Math.floor(O+.45*u)+.5;l.moveTo(z+st,mt),l.lineTo(z+st+V.width,mt),l.stroke()}z+=V.width})})}}function ae(r){return ae=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},ae(r)}function Pe(r){for(var n={},l=0;l<r.length;l++){var t=r[l];typeof t!="number"&&t!=null&&(typeof t=="string"?n.text=t:typeof t=="function"?n.fn=t:ae(t)==="object"&&t._groups?n.d3=t:t&&t.nodeType&&t.getContext?n.ctx=t.getContext("2d"):t&&t.fillText&&t.beginPath?n.ctx=t:t&&(n.text=t))}return n}function kt(r){return kt=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},kt(r)}function le(r,n){for(var l=0;l<n.length;l++){var t=n[l];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(o=function(u,y){if(kt(u)!=="object"||u===null)return u;var v=u[Symbol.toPrimitive];if(v!==void 0){var w=v.call(u,y);if(kt(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(t.key,"string"),kt(o)==="symbol"?o:String(o)),t)}var o}var Ie=P(),ft=function(r){return typeof r=="function"?r:function(){return r}},J=function(){function r(t){if(function(u,y){if(!(u instanceof y))throw new TypeError("Cannot call a class as a function")}(this,r),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:r.defaultparser},t)for(var o in t)typeof this[o]=="function"&&this[o](t[o])}var n,l;return n=r,l=[{key:"linebreak",value:function(t){var o=this,u=this.props.parser(String(t)),y=this.font(),v=function(w,b,S){if(!w.length)return[];var I=b.height(),k=b.width(),C=b.overflowLine(),F=b.overflowWrap(),W=P(S,!0,!1),z=isFinite(I())?Math.floor(I()/S.height):1/0;if(!I()&&!k(0)||!z)return[];for(var O=0,Y=0,$=0,it=[],Q=[],V=!1;O<w.length&&Y<z;){var M=w[O],ot=ke(M,S);if(M.width=H(M,ot),M.font=ot,M.line=Y,M.whitespace=M.value in E,M.value&&(M.value=M.value.replace(ir," ")),!(!$&&M.whitespace||V&&M.whitespace))if(M instanceof K)$=0,Q=[],it.push(O+1),Y++;else if(M instanceof ut||M instanceof ct)Q.push({index:O,width:$});else if(M.whitespace||$+M.width<k(Y))$+=M.width;else if(Q.length){var st=void 0,mt=void 0;do{mt=!0,st=Q.pop();var xt=w[st.index],dt=void 0;xt instanceof ct&&(dt=H("-",xt.font),st.width+dt>k(Y)&&(mt=!Q.length))}while(!mt);it.push(st.index+1),$=0,Y++,O=st.index,Q=[]}else if(F==="break-word"){var vt=k(Y);if($+M.width>vt){var Bt=M.clone();do M.value=M.value.slice(0,-1),M.width=H(M,M.font),$+=M.width;while(M.value&&M.width>vt);Bt.value=Bt.value.slice(M.value.length),w.splice(O+1,0,new ut,Bt)}it.push(O+1),$=0,Y++}else $+=M.width;O++,V=M.whitespace}O!==it[it.length-1]&&it.push(O);var ce=0,bt=0,tt=it.map(function(Rt){for(var rt,Ct=ce;(rt=w[Ct])&&(rt.whitespace||!rt.value);)Ct++;for(var St=Rt,cr=null;St>Ct&&(rt=w[St-1])&&(rt.whitespace||!(rt.value||rt instanceof ct));)rt instanceof K&&(cr=rt),St--;rt instanceof ct&&(rt.value="-",rt.width=H("-",rt.font)),ce=Rt;var Ut=w.slice(Ct,St).filter(function(fr){return fr.value});return cr&&Ut.push(cr),Ut.width=Ut.reduce(function(fr,xn){return fr+xn.width},0),Ut.width>bt&&(bt=Ut.width),Ut});if(tt.hasLineOverflow=!1,C){var De=C==="ellipsis"?"…":C;tt.forEach(function(Rt,rt){var Ct=k(rt);if(Rt.width>Ct){var St=new L(De);St.font=S,St.width=H(De,W),ie(Rt,Ct,St),tt.hasLineOverflow=!0}})}var q=b.overflow()==="ellipsis"?"…":b.overflow();if(q&&O!==w.length){var et=k(tt.length-1),Fe=tt[tt.length-1],fe=new L(q);fe.font=S,fe.width=H(q,W),ie(Fe,et,fe),tt.hasOverflow=!0}else tt.hasOverflow=!1;return tt.font=S,tt.width=bt,tt}(u,this,y);return v.height=v.length*y.height,v.render=function(w){return o.render(v,w)},v.svg=v.render,v.draw=v.render,v}},{key:"font",value:function(t){return arguments.length?(this.props.font=P(t),this):this.props.font||P(Ie)}},{key:"overflow",value:function(t){return arguments.length?(this.props.overflow=String(t),this):this.props.overflow}},{key:"overflowLine",value:function(t){return arguments.length?(this.props.lineclamp=String(t),this):this.props.lineclamp}},{key:"valign",value:function(t){return arguments.length?(this.props.valign=t,this):this.props.valign}},{key:"align",value:function(t){if(!arguments.length)return this.props.align;var o=String(t).toLowerCase();return o==="left"||o==="start"?(this.props.align="left",this.props.tAnchor=0):o==="center"||o==="middle"?(this.props.align="center",this.props.tAnchor=-.5):o==="end"||o==="right"?(this.props.align="right",this.props.tAnchor=-1):o==="justify"&&(this.props.align=t,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(t){if(!arguments.length)return this.props.overflowWrap||"normal";var o=String(t).toLowerCase();return o==="break-word"?this.props.overflowWrap="break-word":o!=="normal"&&t!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(t){return arguments.length?(this.props.width=ft(t),this):this.props.width}},{key:"height",value:function(t){return arguments.length?(this.props.height=ft(t),this):this.props.height}},{key:"x",value:function(t){return arguments.length?(this.props.x=ft(t),this):this.props.x}},{key:"parser",value:function(t){if(!arguments.length)return this.props.parser;if(typeof t=="string"){var o=r[t]||r[t+"parser"];typeof o=="function"&&(t=o)}if(typeof t!="function")throw new Error("Unknown parser: "+t);return this.props.parser=t,this}},{key:"createElement",value:function(t){return arguments.length?(this.props.createElement=t,this):this.props.createElement||r.createElement}},{key:"render",value:function(){var t=Pe(arguments);return typeof t.text=="string"&&(t.text=this.linebreak(t.text)),t.ctx?ar(t.text,this,t.ctx):sr(t.text,this)}}],l&&le(n.prototype,l),Object.defineProperty(n,"prototype",{writable:!1}),r}();function yt(r){return yt=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},yt(r)}function Nt(r,n){(n==null||n>r.length)&&(n=r.length);for(var l=0,t=new Array(n);l<n;l++)t[l]=r[l];return t}function lr(r,n){for(var l=0;l<n.length;l++){var t=n[l];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,(o=function(u,y){if(yt(u)!=="object"||u===null)return u;var v=u[Symbol.toPrimitive];if(v!==void 0){var w=v.call(u,y);if(yt(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(t.key,"string"),yt(o)==="symbol"?o:String(o)),t)}var o}var he=function(r){return typeof r=="function"?r:function(){return r}},Oe=function(){function r(t){if(function(u,y){if(!(u instanceof y))throw new TypeError("Cannot call a class as a function")}(this,r),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},t)for(var o in t)typeof this[o]=="function"&&this[o](t[o]);this.render=this.render.bind(this)}var n,l;return n=r,l=[{key:"anchor",value:function(t){var o=this.props,u=o.hAnchor,y=o.vAnchor,v=o.width,w=o.height;if(!arguments.length)return[u*v(0),y*w(0)];if(typeof t=="string"){var b=this.props;t.toLowerCase().trim().split(/\s+/).forEach(function(S){S==="top"&&(b.vAnchor=-0),S==="middle"&&(b.vAnchor=-.5),S==="bottom"&&(b.vAnchor=-1),S==="left"&&(b.hAnchor=-0),S==="center"&&(b.hAnchor=-.5),S==="right"&&(b.hAnchor=-1)})}return this}},{key:"width",value:function(t){return arguments.length?(this.props.width=he(t),this):this.props.width}},{key:"height",value:function(t){return arguments.length?(this.props.height=he(t),this):this.props.height}},{key:"rotate",value:function(t){return arguments.length?(this.props.rotation=t,this):this.props.rotation}},{key:"createElement",value:function(t){return arguments.length?(this.props.createElement=t,this):this.props.createElement||r.createElement}},{key:"canvas",value:function(t,o){var u,y=t.getContext?t.getContext("2d"):t;return y.save(),y.rotate(this.rotate()*Math.PI/180),y.translate.apply(y,function(v){if(Array.isArray(v))return Nt(v)}(u=this.anchor())||function(v){if(typeof Symbol<"u"&&v[Symbol.iterator]!=null||v["@@iterator"]!=null)return Array.from(v)}(u)||function(v,w){if(v){if(typeof v=="string")return Nt(v,w);var b=Object.prototype.toString.call(v).slice(8,-1);return b==="Object"&&v.constructor&&(b=v.constructor.name),b==="Map"||b==="Set"?Array.from(v):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?Nt(v,w):void 0}}(u)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
35
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),o(y),y.restore(),y}},{key:"render",value:function(){var t=Pe(arguments);if(t.d3)return t.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(t.ctx)return this.canvas(t.ctx,t.fn);if(t.text){var o=typeof t.text.render=="function"?t.text.render():t.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},o)}}}],l&&lr(n.prototype,l),Object.defineProperty(n,"prototype",{writable:!1}),r}(),je=Object.prototype.hasOwnProperty,Ht={};function hr(r){return Ht[r]||(Ht[r]=r.replace(/([a-z])([A-Z])/g,function(n,l,t){return l+"-"+t.toLowerCase()})),Ht[r]}function Me(r,n){if(Array.isArray(n))return n.forEach(function(l){return Me(r,l)});typeof n=="string"&&(n=document.createTextNode(n)),r.appendChild(n)}function ue(r,n){if(typeof document<"u"){var l=typeof r=="string"?document.createElementNS("http://www.w3.org/2000/svg",r):r;if(n&&l.setAttribute)for(var t in n)je.call(n,t)&&n[t]!=null&&l.setAttribute(t==="className"?"class":hr(t),n[t]);for(var o=arguments.length,u=new Array(o>2?o-2:0),y=2;y<o;y++)u[y-2]=arguments[y];return u!=null&&u.length&&u.forEach(function(v){Me(l,v)}),l}}J.createElement=ue,J.textparser=Et,J.defaultparser=Et,J.htmlparser=function(r){r=String(r||"").trim();for(var n,l,t={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},o=[],u=[],y=function(I){for(var k in t)t[k]&&(I[k]=t[k]);o.push(I)},v=function(I){var k=o.length,C=Qe[I];if(k&&C){for(var F=k-1;o[F]&&(o[F]instanceof ut||Je.test(o[F].value));)F--;for(;C&&o[F]&&o[F]instanceof K;)F--,C--;for(;C-- >0;)o.push(new K)}};r.length;){if(n=/^[^<]+/.exec(r))Et(re(n[0]),!1).forEach(y);else if(!(n=Ft.exec(r)))if(n=Qt.exec(r))u.length&&(t=u.pop()),v(n[1]);else if(n=te.exec(r)){var w=n[1];v(w),u.push(t),t=Object.create(t),_t[w]&&_t[w](t,"");var b=Lt(n[2]);w==="a"&&(b.href&&(t.href=b.href),b.rel&&(t.rel=b.rel),b.target&&(t.target=b.target)),b.class&&(t.class=t.class?t.class+" "+b.class:b.class),b.style&&(l=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(b.style))&&l[1]&&(t.color=l[1]),w==="br"&&o.push(new K)}else n=[r.slice(0,1)],y(new L(n[0]));r=r.slice(n[0].length)}for(var S=o[o.length-1];S instanceof K;)o.pop(),S=o[o.length-1];return o},J.latexparser=function(r){r=String(r||"").trim();var n=[0];r=r.replace(/\\verb,(.*?),/,function(z,O){return n.push(O),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(nr,function(z,O,Y){return Y.charAt(O-1)==="\\"?z:ne[z]}).replace(/\n\s+/g,function(z){return/\n/.test(z.slice(1))?"\\par ":z}).replace(/\\symbol\{(\d+)\}/,function(z,O,Y,$){return $.charAt(Y-1)==="\\"?z:String.fromCharCode(1*O)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(z,O,Y,$){return O+Y+"{"+$+"}"}).replace(/\\verb,(.*?),/,function(z,O){return"\\verb,".concat(n[+O],",")});for(var l,t={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},o=[],u=[],y=function(z){for(var O in t)t[O]&&(z[O]=t[O]);return o.push(z),z},v=function(){u.push(t),t=Object.create(t)},w=function(){if(!u.length)throw new Error("Unexpected }");t=u.pop()},b={tokens:o,open_context:v,close_context:w,add_token:y};r.length;){if(l=zt.exec(r))Et(l[0],!1).forEach(y);else if(l=rr.exec(r))y(new L(l[1]));else if(!(l=Te.exec(r))){if(l=/^\{/.exec(r))v();else if(l=/^\}/.exec(r))w();else if(!(l=/^\$/.exec(r)))if(l=/^\\verb,([^,]+),/.exec(r))y(new L(l[1]));else if(l=_e.exec(r)){var S=l[1].slice(1)||l[1],I=!!l[2];if(/^(La)?TeX$/i.test(S)){v(),t.family="serif";var k=void 0;S==="LaTeX"&&((k=y(new L("L"))).tracking=-.25,(k=y(new L("A"))).size=.7,k.baseline=.3,k.tracking=-.1),(k=y(new L("T"))).tracking=-.17,(k=y(new L("E"))).baseline=-.22,k.tracking=-.13,k=y(new L("X")),w()}else if(S in Tt)y(new L(Tt[S])),I&&v();else if(S in U){var C=[],F=U[S].length-1,W=void 0;if(F){for(I=!1,r=r.slice(l[0].length-1);F--;){if(!(W=/^\{([^}]+)\}/.exec(r)))throw new Error(S+" is missing an argument");C.push(W[1]),r=r.slice(W[0].length)}l[0]=/^\{/.exec(r)?"{":"",I=!!l[0]}I&&v(),U[S].apply(b,[t].concat(C))}else console.warn("unknown latex command",S),y(new L(l[1])),I&&v()}else l=[r.slice(0,1)],y(new L(l[0]))}r=r.slice(l[0].length)}return o},J.measureText=function(r,n,l){return H(r,P(n),l)},J.Token=L,J.Break=ut,J.LineBreak=K,J.SoftHyphen=ct,J.Rotator=Oe,Oe.createElement=ue;const ur=J;return i.default})())})(Pr);var an=Pr.exports;const Ir=ze(an);function Ve(p){return p.replace(/…$/,"")}function Xe(p){return p.children[0].innerHTML}function ln(p,e){const a=pt(p),{fontSize:i,font:h,padding:c=0}=p.properties.style||{};if(a.width===a.height&&a.width===0)return;const g=new Ir({font:`${i}px/${i}px ${h}`.replace(/(px)+/g,"px"),width:a.width-c*2,height:a.height-c*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Ir.createElement});g.overflowWrap("break-word");const m=g.linebreak(p.properties.content.replaceAll(`
36
+ `,"<br>")).render(),f=[...m.children];let s=0;const d=[];p.properties.content.split(`
37
+ `).forEach(R=>{let P=R;for(;P.length&&s<f.length;){if(f[s].innerHTML==="&nbsp;"){P.startsWith(`
38
+ `)||d.push(s),s++;break}const E=Ve(Xe(f[s]));P.startsWith(E)&&(P=P.slice(E.length).trim()),s++}}),d.forEach(R=>m.removeChild(f[R]));const A=p.properties.content.match(/(https?:\/\/.*)/gm),_=A?A.map(R=>R.split(" ")[0]):[];m.setAttribute("transform",`translate(${c}, ${c})`),_.forEach(R=>{let P=R;const E=[];for(;P.length>0;){const D=f.find(T=>!!T.children[0]&&T.children[0].tagName==="tspan"&&P.startsWith(Ve(Xe(T))));if(!D)break;E.push(D);const j=Ve(D.children[0].innerHTML).length;if(!j)break;P=P.slice(j)}E.forEach(D=>{const j=document.createElementNS("http://www.w3.org/2000/svg","a");j.setAttribute("href",R),j.setAttribute("target","_blank"),j.innerHTML=Xe(D),D.children[0].innerHTML="",D.children[0].appendChild(j)})}),e.appendChild(m)}const Or=20;class hn extends _r{constructor(e,a={}){super(e,`
39
+ <div class="annotation-text-handle">
40
+ <span class="handle line-handle top" data-handle-id="0"></span>
41
+ <span class="handle line-handle bottom" data-handle-id="1"></span>
42
+ <span class="handle line-handle left" data-handle-id="2"></span>
43
+ <span class="handle line-handle right" data-handle-id="3"></span>
44
+ <span class="handle top right point-handle top-right" data-handle-id="4"></span>
45
+ <span class="handle left top point-handle top-left" data-handle-id="5"></span>
46
+ <span class="handle bottom right point-handle bottom-right" data-handle-id="6"></span>
47
+ <span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
48
+ <textarea wrap="on"></textarea>
49
+ </div>
50
+ `),x(this,"textArea"),x(this,"handleSize"),x(this,"rect",{x:0,y:0,width:0,height:0}),x(this,"annotation",{...Ye}),x(this,"startX",0),x(this,"startY",0),x(this,"handles",[]),x(this,"draggedHandle",X),x(this,"isFocused",!1),x(this,"placeholder","Type your text here..."),x(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0}),x(this,"_onBlur",()=>{this.isFocused=!1}),x(this,"startDrawing",(h,c,g=on(h,c,0,0,"",Ot))=>{this.add(g);const m=this.ogma.view.graphToScreenCoordinates({x:h,y:c});this.select(g.id),this.startDragging(this.getById(g.id),m.x,m.y),this.draggedHandle=6}),x(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...Ye},this.draggedHandle=X,this.isDragging=!1,this.emit(It,this.annotation))}),x(this,"startDragging",(h,c,g)=>{this.annotation=h;const m=gt(this.annotation),f=pt(this.annotation);this.rect.x=m.x,this.rect.y=m.y,this.rect.width=f.width,this.rect.height=f.height,this.startX=c,this.startY=g,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(be,this.annotation),this.isDragging=!0}),x(this,"onHandleMouseDown",h=>{const c=this.getById(this.selectedId)||this.getById(this.hoveredId);if(!c)return;this.selectedId!==c.id&&this.select(this.hoveredId);const{x:g,y:m}=$e(h,this.ogma.getContainer());this.startDragging(c,g,m),this.draggedHandle=wr(h.target)}),x(this,"onMouseMove",h=>{requestAnimationFrame(()=>this._onMouseMove(h))}),x(this,"_onMouseMove",h=>{if(!this.isDragging)return;h.stopPropagation(),h.preventDefault();const c=this.handles[this.draggedHandle],g=c.classList.contains("top"),m=c.classList.contains("left"),f=c.classList.contains("right"),s=c.classList.contains("bottom"),d=c.classList.contains("line-handle"),{x:A,y:_}=$e(h,this.ogma.getContainer()),R=this.ogma.view.getZoom(),P=(A-this.startX)/R,E=(_-this.startY)/R,D=this.ogma.view.getAngle(),j=new G(P,E).rotateRadians(D);(s&&m||g&&f)&&(j.y=0,j.x=0);const T=m||d?this.rect.x+j.x:this.rect.x,N=g||d?this.rect.y+j.y:this.rect.y,H=Math.max(this.rect.width+P*(d||m?0:1),Or),at=Math.max(this.rect.height+E*(d||g?0:1),Or);Kr(this.annotation,T,N,H,at),this.emit(ve,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()}),x(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===X||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(It,this.annotation),this.isDragging=!1,this.draggedHandle=X)}),x(this,"_onMousedown",h=>{h.stopPropagation()}),x(this,"onViewChanged",()=>{const h=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/h}`)}),x(this,"_onInput",()=>{const h=this.getById(this.selectedId);h&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),h.properties.content=this.textArea.value,this.emit(We,h),this.layer.refresh())}),this.showeditorOnHover=!1,this.handleSize=Cr.handleSize,this.placeholder=Cr.placeholder;const i=this.textArea=this.editor.element.querySelector("textarea");i.addEventListener("input",this._onInput),i.addEventListener("focus",this._onFocus),i.addEventListener("blur",this._onBlur),i.addEventListener("mousedown",this._onMousedown),i.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(h=>h.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),e.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:e,y:a},i=0){const h=new G(e,a),c=this.ogma.view.getAngle();return this.elements.find(g=>{const{x:m,y:f}=gt(g),{width:s,height:d}=pt(g),A=new G(m,f),{x:_,y:R}=h.sub(A).rotateRadians(-c);return _>-i&&_<s+i&&R>-i&&R<d+i})}draw(e){e.innerHTML="";const a="",i=this.ogma.view.getAngle();this.elements.forEach((c,g)=>{const m=`class${g}`,f=pt(c),s=gt(c),d=c.id,{color:A,fontSize:_,font:R,strokeColor:P,strokeWidth:E,strokeType:D,background:j}=c.properties.style||Ot;if(d===this.selectedId)return;const T=Xt("g");T.classList.add("annotation-text"),T.setAttribute("fill",`${A}`),T.setAttribute("font-size",`${_}px`),T.setAttribute("font-family",`${R}`);const N=Xt("rect");let H=!1;D&&D!=="none"&&(H=!0,N.setAttribute("stroke",P||"black"),N.setAttribute("stroke-width",`${E}`),D==="dashed"&&N.setAttribute("stroke-dasharray","5,5")),(j&&j.length||H)&&(H=!0,N.setAttribute("fill",j||"transparent")),H&&(N.setAttribute("width",`${f.width}`),N.setAttribute("height",`${f.height}`)),T.appendChild(N),ln(c,T);const{x:at,y:At}=new G(s.x,s.y).rotateRadians(-i);T.setAttribute("transform",`translate(${at},${At})`),T.classList.add(m),T.setAttribute("data-annotation",`${c.id}`),T.setAttribute("data-annotation-type","text"),e.appendChild(T)});const h=Xt("style");h.innerHTML=a,e.firstChild&&e.insertBefore(h,e.firstChild)}refreshDrawing(){const e=this.ogma.view.getAngle();[...this.layer.element.children].forEach(a=>{const i=a.getAttribute("data-annotation");if(!i)return;const h=gt(this.getById(i)),{x:c,y:g}=new G(h.x,h.y).rotateRadians(-e);a.setAttribute("transform",`translate(${c},${g})`)})}getDefaultOptions(){return Ye}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const e=this.getById(this.selectedId)||this.getById(this.hoveredId),a=pt(e),i=this.ogma.view.graphToScreenCoordinates(gt(e)),h=this.ogma.view.getZoom(),{font:c,fontSize:g,color:m,background:f,padding:s=0}=e.properties.style||Ot,d=(g||1)*h;this.textArea.value=e.properties.content,this.editor.element.style.transform=`translate(${i.x}px, ${i.y}px)translate(-50%, -50%)translate(${a.width/2*h}px, ${a.height/2*h}px)`,this.editor.element.style.width=`${a.width*h}px`,this.editor.element.style.height=`${a.height*h}px`,this.textArea.style.font=`${d} ${c}`,this.textArea.style.fontFamily=c||"sans-serif",this.textArea.style.fontSize=`${d}px`,this.textArea.style.padding=`${h*s}px`,this.textArea.style.lineHeight=`${d}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=m||"black",this.textArea.style.background=f||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(e){super.select(e),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class un{constructor(){x(this,"links",{}),x(this,"linksByTargetId",{}),x(this,"linksByArrowId",{})}add(e,a,i,h,c){const g=de(),m=e.id,f={id:g,arrow:m,target:i,targetType:h,connectionPoint:c,side:a};return this.links[g]=f,this.linksByTargetId[i]||(this.linksByTargetId[i]=[]),this.linksByTargetId[i].push(g),this.linksByArrowId[m]||(this.linksByArrowId[m]={}),this.linksByArrowId[m][a]=g,e.properties.link=e.properties.link||{},e.properties.link[a]={id:i,side:a,type:h,magnet:c},this}arrowIsLinked(e,a){var i;return!!((i=this.linksByArrowId[e])!=null&&i[a])}remove(e,a){var i,h;const c=e.id,g=(i=this.linksByArrowId[c])==null?void 0:i[a];if((h=e.properties.link)==null||delete h[a],!g)return this;const m=this.links[g];delete this.links[g];const f=this.linksByTargetId[m.target];for(let s=0;s<f.length;s++)if(f[s]===g){f.splice(s,1);break}return delete this.linksByArrowId[c][a],this}getArrowLink(e,a){var i;const h=(i=this.linksByArrowId[e])==null?void 0:i[a];return h?this.links[h]:null}getTargetLinks(e,a){var i;return((i=this.linksByTargetId[e])==null?void 0:i.map(h=>this.links[h]).filter(h=>h.targetType===a))??[]}forEach(e){Object.values(this.links).forEach(e)}}const ht=p=>p.properties.type==="arrow",wt=p=>p.properties.type==="text",jr=p=>p.type==="FeatureCollection",cn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},Mr=["start","end"],Dr=[{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 fn extends Er{constructor(e,a={}){super(),x(this,"arrows"),x(this,"texts"),x(this,"links",new un),x(this,"layer"),x(this,"annotations"),x(this,"ogma"),x(this,"options"),x(this,"selected",null),x(this,"updateTimeout",0),x(this,"hoveredNode",null),x(this,"dragged",null),x(this,"textToMagnet"),x(this,"activeLinks",[]),x(this,"_render",i=>{if(!this.dragged||this.textToMagnet===void 0)return;i.beginPath(),i.fillStyle="green";const h=this.ogma.view.getZoom();Dr.forEach(c=>{if(!this.textToMagnet)return;const g=pt(this.textToMagnet),m=gt(this.textToMagnet),{x:f,y:s}=new G(c.x,c.y).mul({x:g.width,y:g.height}).rotateRadians(this.ogma.view.getAngle()).add(m);i.moveTo(f,s),i.arc(f,s,this.options.magnetHandleRadius/h,0,Math.PI*2)}),i.fill(),i.closePath()}),x(this,"_onFeatureDrag",(i,h)=>{const c=h;if(ht(i)&&c==="line")["start","end"].find(g=>{const m=g==="start"?qt(i):ge(i);return this._snapToText(i,c,m)||this._findAndSnapToNode(i,g,m)});else if(ht(i)&&c!=="line"){const g=c==="start"?qt(i):ge(i);this._snapToText(i,c,g)||this._findAndSnapToNode(i,c,g)}else wt(i)&&(this.activeLinks.forEach(({arrow:g,side:m,connectionPoint:f})=>{const s=this.getAnnotation(g),d=pt(i),A=gt(i),_=new G(f.x,f.y).mul({x:d.width,y:d.height}).rotateRadians(this.ogma.view.getAngle()).add(A);s.geometry.coordinates[m==="start"?0:1]=[_.x,_.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(ve,i,h)}),x(this,"_onFeatureDragEnd",i=>{this.dragged!==null&&ht(i)&&qt(this.dragged)&&Mr.forEach(h=>{this.links.getArrowLink(i.id,h)&&this.emit(rn,{arrow:i,link:this.links.getArrowLink(i.id,h)})}),(wt(i)||ht(i))&&this.onUpdate(i),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(h=>h.enableDetection()),this.layer.refresh(),this.emit(It,i)}),x(this,"_onFeatureDragStart",i=>{this.textToMagnet=void 0,ht(i)?this.dragged=i:wt(i)&&this.activeLinks.push(...this.links.getTargetLinks(i.id,"text")),this.annotations.forEach(h=>{const c=h.getSelectedFeature();c&&c!==i&&h.unhover().unselect(),h.disableDetection()}),this.emit(be,i)}),x(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()}),x(this,"_onNodesDrag",i=>{const{dx:h,dy:c}=i;this._moveNodes(i.nodes,h,c)}),x(this,"_onLayoutEnd",i=>{i.ids.forEach((h,c)=>{this.links.getTargetLinks(h,"node").forEach(g=>{const m=this.getAnnotation(g.arrow),f=g.side,s=pe(m,f==="start"?"end":"start"),d=i.positions.current[c],A=this.ogma.getNode(h).getAttribute("radius"),_=me(s,d,+A);Pt(m,f,_.x,_.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()}),x(this,"_onAdded",i=>{this.emit(Ue,i)}),x(this,"_onRemoved",i=>{this.emit(Be,i)}),x(this,"_onUnselect",i=>{this.selected=null,this.emit(He,i)}),x(this,"_onSelect",i=>{this.selected!==i&&(this.selected=i,this.emit(Ne,this.selected))}),x(this,"onUpdate",i=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(i))}),x(this,"_onUpdate",i=>{this.emit(We,i)}),this.options=this.setOptions({...cn,...a}),this.ogma=e,this.arrows=new sn(e,this.options),this.texts=new hn(e,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(i=>{i.on(be,this._onFeatureDragStart).on(ve,this._onFeatureDrag).on(It,this._onFeatureDragEnd).on(We,this.onUpdate).on(He,this._onUnselect).on(Ne,this._onSelect).on(Ue,this._onAdded).on(Be,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=e.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(e,a,i){e.forEach(h=>{const c=this.links.getTargetLinks(h.getId(),"node"),g=h.getPosition();c.forEach(m=>{const f=this.getAnnotation(m.arrow),s=m.side,d=pe(f,s==="start"?"end":"start");let A=g;const _=+h.getAttribute("radius"),R=1e-6;(m.connectionPoint.x-(g.x-a)>R||m.connectionPoint.y-(g.y-i)>R)&&(A=me(d,g,_)),Pt(f,s,A.x,A.y)})}),this.arrows.refreshLayer()}_snapToText(e,a,i){const h=this.texts.detect(i,this.options.detectMargin);if(this.links.remove(e,a),!h)return!1;this.textToMagnet=h;const c=this.findMagnetPoint(Dr,h,i);return c?(Pt(e,a,c.point.x,c.point.y),this.links.add(e,a,h.id,"text",c.magnet),!0):!1}_findAndSnapToNode(e,a,i){const h=this.ogma.view.graphToScreenCoordinates(i),c=this.ogma.view.getElementAt(h);this.links.remove(e,a),c&&c.isNode?(this.hoveredNode=c,this.hoveredNode.setSelected(!0),this._snapToNode(e,a,c,h)):(this.hoveredNode&&this.hoveredNode.setSelected(!1),this.hoveredNode=null)}_snapToNode(e,a,i,h){const c=i.getPositionOnScreen(),g=+i.getAttribute("radius"),m=g*this.ogma.view.getZoom(),f=h.x-c.x,s=h.y-c.y,d=Math.sqrt(f*f+s*s),A=i.getPosition();if(d<m+this.options.detectMargin){let _=A;if(d>m/2){const R=pe(e,a==="end"?"start":"end");_=me(R,_,g)}Pt(e,a,_.x,_.y),this.links.add(e,a,i.getId(),"node",_)}}refreshTextLinks(){let e=!1;this.links.forEach(({connectionPoint:a,targetType:i,target:h,arrow:c,side:g})=>{if(i!=="text")return;e=!0;const m=this.getAnnotation(h),f=this.getAnnotation(c),s=pt(m),d=gt(m),A=new G(a.x,a.y).mul({x:s.width,y:s.height}).rotateRadians(this.ogma.view.getAngle()).add(d);Pt(f,g,A.x,A.y)}),e&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(e,a,i){let h;for(const c of e){const g=pt(a),m=gt(a),f=new G(c.x,c.y).mul({x:g.width,y:g.height}).rotateRadians(this.ogma.view.getAngle()).add(m),s=f.sub(i).length(),d=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),g.width/2,g.height/2);if(s<Math.max(d,this.options.magnetHandleRadius)){h={point:f,magnet:c};break}}return h}setOptions(e={}){return this.options={...this.options||{},...e},this.options}select(e){const a=this.getAnnotations().features.find(i=>i.id===e);return a?(ht(a)?this.arrows.select(a.id):wt(a)&&this.texts.select(a.id),this):this}unselect(){return this.selected?(ht(this.selected)?this.arrows.unselect():wt(this.selected)&&this.texts.unselect(),this):this}add(e){if(jr(e)){const[a,i]=e.features.reduce((h,c)=>(ht(c)?h[1].push(c):wt(c)&&h[0].push(c),h),[[],[]]);return a.forEach(h=>this.add(h)),i.forEach(h=>this.add(h)),this.arrows.refreshLayer(),this}switch(e.properties.type){case"text":this.texts.add(e);break;default:this.arrows.add(e),this.loadLink(e);break}return this}remove(e){return jr(e)?(e.features.forEach(a=>this.remove(a)),this):(ht(e)?(this.links.remove(e,"start"),this.links.remove(e,"end"),this.arrows.remove(e.id)):this.texts.remove(e.id),this)}loadLink(e){if(e.properties.link)for(const a of Mr){const i=e.properties.link[a];if(!i)continue;const h=this.getAnnotation(i.id);if(i.type==="text"&&h)this.links.add(e,a,i.id,i.type,i.magnet);else if(i.type==="node"){const c=this.ogma.getNode(i.id);if(!c)continue;this.links.add(e,a,i.id,i.type,i.magnet);const g=c.getPosition(),m=c.getAttribute("radius")||0,f=pe(e,a==="start"?"end":"start"),s=me(f,g,+m);Pt(e,a,s.x,s.y)}}}startArrow(e,a,i){this.cancelDrawing(),this.arrows.startDrawing(e,a,i)}startText(e,a,i){this.cancelDrawing(),this.texts.startDrawing(e,a,i)}cancelDrawing(){this.annotations.forEach(e=>e.cancelDrawing()),this.emit(en)}updateStyle(e,a){const i=this.getAnnotations().features.find(h=>h.id===e);return i?(ht(i)?this.arrows.updateStyle(i,a):wt(i)&&this.texts.updateStyle(i,a),this.onUpdate(i),this):this}getAnnotations(){const e={type:"FeatureCollection",features:[]};return this.annotations.forEach(a=>{e.features=[...e.features,...a.getElements()]}),e}getAnnotation(e){return this.getAnnotations().features.find(a=>a.id===e)}destroy(){this.annotations.forEach(e=>e.destroy()),this.layer.destroy()}}const qe=[8,10,12,14,16,24,32,48,64,72],Ze="none",Ge="#333333",dn=["#FFFFFF","#F44E3B","#FE9200","#FCDC00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#1E88E5","#333333","#808080","#cccccc"],pn=["Roboto","Helvetica Neue","Helvetica","Arial","sans-serif","Georgia, serif","Menlo","Monaco","Consolas","Courier New","monospace"].sort((p,e)=>p.toLocaleLowerCase().localeCompare(e.toLocaleLowerCase())),Fr={head:"arrow",strokeColor:Ge,strokeWidth:5},Lr=.25,zr={font:"Roboto",fontSize:qe[2],padding:qe[2]*Lr,color:Ge,strokeType:Ze,background:Ze};function $r(p){return p.reduce((e,a)=>e+a,0)/p.length}function gn(p,e=0,a=1){return e+(a-e)*p}function yn(p,e=0,a=1){return(p-e)/(a-e)}function mn(){return Z.createContext(null)}const Ke=Z.createContext(void 0),vn=()=>Z.useContext(Ke),bn=(p,e)=>{switch(e.type){case"add":return{...p,features:[...p.features,e.payload]};case"remove":return{...p,features:p.features.filter(a=>a.id!==e.payload.id)};case"update":return{...p,features:p.features.map(a=>a.id===e.payload.id?e.payload:a)};default:return p}},wn=({children:p})=>{const e=Nr.useOgma(),[a,i]=Z.useReducer(bn,{type:"FeatureCollection",features:[]}),[h,c]=Z.useState(null),[g,m]=Z.useState(Fr),[f,s]=Z.useState(zr),[d,A]=Z.useState(),[_,R]=Z.useState(1),[P,E]=Z.useState(1);return Z.useEffect(()=>{if(!e)return;const D=new fn(e,{minArrowHeight:1}),j=$r(e.getNodes().getAttribute("radius"))/5,T=_;return m({...g,strokeWidth:(g.strokeWidth||1)*T}),R(T),E(j),D.on("select",N=>{ht(N)?m({...N.properties.style||{}}):wt(N)&&s({...N.properties.style||{}}),c(N)}).on("unselect",()=>{c(null)}),A(D),()=>{d==null||d.destroy()}},[e]),Z.useEffect(()=>{d&&h&&(h==null?void 0:h.properties.type)==="arrow"&&d.updateStyle(h.id,g)},[d,g,h]),Z.useEffect(()=>{d&&h&&(h==null?void 0:h.properties.type)==="text"&&d.updateStyle(h.id,f)},[d,f,h]),Ur.jsx(Ke.Provider,{value:{annotations:a,updateAnnotations:i,currentAnnotation:h,setCurrentAnnotation:c,textStyle:f,setTextStyle:s,arrowStyle:g,setArrowStyle:m,arrowWidthFactor:_,setArrowWidthFactor:R,textSizeFactor:P,setTextSizeFactor:E,editor:d,setEditor:A},children:p})};B.AnnotationsContext=Ke,B.AnnotationsContextProvider=wn,B.BLACK=Ge,B.RELATIVE_PADDING=Lr,B.TRANSPARENT=Ze,B.createAnnotationsContext=mn,B.defaultArrowStyle=Fr,B.defaultColors=dn,B.defaultTextStyle=zr,B.fontSizes=qe,B.fonts=pn,B.interpolate=gn,B.mean=$r,B.normalize=yn,B.useAnnotationsContext=vn,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});