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