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