@antv/g-svg
Version:
A renderer implemented by SVG
13 lines (12 loc) • 49 kB
JavaScript
/*!
* @antv/g-svg
* @description A renderer implemented by SVG
* @version 2.1.1
* @date 12/24/2025, 11:57:09 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.SVG={}),t.window.G)}(this,function(t,e){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function r(t){var e=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==n(e)?e:e+""}function i(t,e){for(var n=0;e.length>n;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(u=function(){return!!t})()}function l(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function s(t,e,n){return e=c(e),l(t,u()?Reflect.construct(e,n||[],c(t).constructor):e.apply(t,n))}function f(t,e){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},f(t,e)}function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&f(t,e)}function p(t){return null==t}function h(t){return"string"==typeof t}var v=function(t,e,n){return e>t?e:t>n?n:t},m="undefined"!=typeof Float32Array?Float32Array:Array;function y(){var t=new m(16);return m!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function g(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],c=e[5],u=e[6],l=e[7],s=e[8],f=e[9],d=e[10],p=e[11],h=e[12],v=e[13],m=e[14],y=e[15],g=n*c-r*o,b=n*u-i*o,A=n*l-a*o,E=r*u-i*c,S=r*l-a*c,x=i*l-a*u,O=s*v-f*h,w=s*m-d*h,C=s*y-p*h,k=f*m-d*v,G=f*y-p*v,T=d*y-p*m,P=g*T-b*G+A*k+E*C-S*w+x*O;return P?(t[0]=(c*T-u*G+l*k)*(P=1/P),t[1]=(i*G-r*T-a*k)*P,t[2]=(v*x-m*S+y*E)*P,t[3]=(d*S-f*x-p*E)*P,t[4]=(u*C-o*T-l*w)*P,t[5]=(n*T-i*C+a*w)*P,t[6]=(m*A-h*x-y*b)*P,t[7]=(s*x-d*A+p*b)*P,t[8]=(o*G-c*C+l*O)*P,t[9]=(r*C-n*G-a*O)*P,t[10]=(h*S-v*A+y*g)*P,t[11]=(f*A-s*S-p*g)*P,t[12]=(c*w-o*k-u*O)*P,t[13]=(n*k-r*w+i*O)*P,t[14]=(v*b-h*E-m*g)*P,t[15]=(s*E-f*b+d*g)*P,t):null}var b=a(function t(){o(this,t)});function A(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E(t,e){var n=e.src,r=void 0===n?"":n,i=e.x,a=e.y,o=void 0===a?0:a,c=e.width,u=e.height;if(t.setAttribute("x","".concat(void 0===i?0:i)),t.setAttribute("y","".concat(o)),h(r))t.setAttribute("href",r);else if(r instanceof Image)c||t.setAttribute("width","".concat(r.width)),u||t.setAttribute("height","".concat(r.height)),t.setAttribute("href",r.src);else if(r instanceof HTMLElement&&h(r.nodeName)&&"CANVAS"===r.nodeName.toUpperCase())t.setAttribute("href",r.toDataURL());else if(r instanceof ImageData){var l=document.createElement("canvas");l.setAttribute("width","".concat(r.width)),l.setAttribute("height","".concat(r.height));var s=l.getContext("2d");s&&(s.putImageData(r,0,0),c||t.setAttribute("width","".concat(r.width)),u||t.setAttribute("height","".concat(r.height)),t.setAttribute("href",l.toDataURL()))}}function S(t,n){var r=n.x1,i=n.y1,a=n.x2,o=n.y2,c=n.markerStart,u=n.markerEnd,l=n.markerStartOffset,s=n.markerEndOffset,f=0,d=0,p=0,h=0,v=0;c&&e.isDisplayObject(c)&&l&&(f=Math.cos(v=Math.atan2(o-i,a-r))*(l||0),d=Math.sin(v)*(l||0)),u&&e.isDisplayObject(u)&&s&&(p=Math.cos(v=Math.atan2(i-o,r-a))*(s||0),h=Math.sin(v)*(s||0)),t.setAttribute("x1","".concat(r+f)),t.setAttribute("y1","".concat(i+d)),t.setAttribute("x2","".concat(a+p)),t.setAttribute("y2","".concat(o+h))}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r}function O(t,e){if(t){if("string"==typeof t)return x(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(t,e):void 0}}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,a,o,c=[],u=!0,l=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){l=!0,i=t}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return c}}(t,e)||O(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(t,n){var r=n.d,i=n.markerStart,a=n.markerEnd,o=n.markerStartOffset,c=n.markerEndOffset,u=0,l=0,s=0,f=0,d=0;if(i&&e.isDisplayObject(i)&&o){var p=w(i.parentNode.getStartTangent(),2),h=p[0],v=p[1];u=Math.cos(d=Math.atan2(h[1]-v[1],h[0]-v[0]))*(o||0),l=Math.sin(d)*(o||0)}if(a&&e.isDisplayObject(a)&&c){var m=w(a.parentNode.getEndTangent(),2),y=m[0],g=m[1];s=Math.cos(d=Math.atan2(y[1]-g[1],y[0]-g[0]))*(c||0),f=Math.sin(d)*(c||0)}t.setAttribute("d",e.translatePathToString(r.absolutePath,u,l,s,f))}function k(t,n){var r=n.points.points,i=n.markerStart,a=n.markerStartOffset,o=n.markerEnd,c=n.markerEndOffset,u=r.length;if(r&&u>=2){var l=0,s=0,f=0,d=0,p=0;i&&e.isDisplayObject(i)&&a&&(l=Math.cos(p=Math.atan2(r[1][1]-r[0][1],r[1][0]-r[0][0]))*(a||0),s=Math.sin(p)*(a||0)),o&&e.isDisplayObject(o)&&c&&(f=Math.cos(p=Math.atan2(r[u-2][1]-r[u-1][1],r[u-2][0]-r[u-1][0]))*(c||0),d=Math.sin(p)*(c||0)),t.setAttribute("points",r.map(function(t,e){var n=0,r=0;return 0===e?(n=l,r=s):e===u-1&&(n=f,r=d),"".concat(t[0]+n,",").concat(t[1]+r)}).join(" "))}}function G(t,e){var n=e.radius,r=e.x,i=void 0===r?0:r,a=e.y,o=void 0===a?0:a,c=e.width,u=e.height;if(isFinite(c)&&isFinite(u)){var l="";if(n&&n.some(function(t){return 0!==t})){var s=w(n.map(function(t){return v(t,0,Math.min(Math.abs(c)/2,Math.abs(u)/2))}),4),f=s[0],d=s[1],p=s[2],h=s[3],m=c>0?1:-1,y=u>0?1:-1,g=m+y!==0?1:0;l=[["M ".concat(m*f+i,",").concat(o)],["l ".concat(c-m*(f+d),",0")],["a ".concat(d,",").concat(d,",0,0,").concat(g,",").concat(m*d,",").concat(y*d)],["l 0,".concat(u-y*(d+p))],["a ".concat(p,",").concat(p,",0,0,").concat(g,",").concat(-m*p,",").concat(y*p)],["l ".concat(m*(p+h)-c,",0")],["a ".concat(h,",").concat(h,",0,0,").concat(g,",").concat(-m*h,",").concat(-y*h)],["l 0,".concat(y*(h+f)-u)],["a ".concat(f,",").concat(f,",0,0,").concat(g,",").concat(m*f,",").concat(-y*f)],["z"]].join(" ")}else l="M ".concat(i,",").concat(o," l ").concat(c,",0 l 0,").concat(u," l").concat(-c," 0 z");t.setAttribute("d",l)}}function T(t,e){return(e||document).createElementNS("http://www.w3.org/2000/svg",t)}b.tag="c-svg-element";var P="g-filter-";function M(t,e,n,r,i){var a=P+n.entity,o=e.querySelectorAll("[name=".concat(a,"]"));if(o.length&&o.forEach(function(t){e.removeChild(t)}),0===i.length)null==r||r.removeAttribute("filter");else{var c=i.map(function(n,r){var i=n.name,o=n.params,c=T("filter",t);return c.setAttribute("filterUnits","userSpaceOnUse"),"blur"===i?function(t,e,n){var r=T("feGaussianBlur",t);r.setAttribute("in","SourceGraphic"),r.setAttribute("stdDeviation","".concat(n[0].value)),e.appendChild(r)}(t,c,o):"brightness"===i?function(t,e,n){var r=D(n[0]);L(t,e,{type:"linear",slope:r,intercept:0})}(t,c,o):"drop-shadow"===i?function(t,e,n){var r=n[0].value,i=n[1].value,a=n[2].value,o=n[3].formatted,c=T("feGaussianBlur",t);c.setAttribute("in","SourceAlpha"),c.setAttribute("stdDeviation","".concat(a)),e.appendChild(c);var u=T("feOffset",t);u.setAttribute("dx","".concat(r)),u.setAttribute("dy","".concat(i)),u.setAttribute("result","offsetblur"),e.appendChild(u);var l=T("feFlood",t);l.setAttribute("flood-color",o),e.appendChild(l);var s=T("feComposite",t);s.setAttribute("in2","offsetblur"),s.setAttribute("operator","in"),e.appendChild(s);var f=T("feMerge",t);e.appendChild(f);var d=T("feMergeNode",t),p=T("feMergeNode",t);p.setAttribute("in","SourceGraphic"),f.appendChild(d),f.appendChild(p)}(t,c,o):"contrast"===i?function(t,e,n){var r=D(n[0]);L(t,e,{type:"linear",slope:r,intercept:-.5*r+.5})}(t,c,o):"grayscale"===i?function(t,e,n){var r=D(n[0]);j(t,e,[.2126+.7874*(1-r),.7152-.7152*(1-r),.0722-.0722*(1-r),0,0,.2126-.2126*(1-r),.7152+.2848*(1-r),.0722-.0722*(1-r),0,0,.2126-.2126*(1-r),.7152-.7152*(1-r),.0722+.9278*(1-r),0,0,0,0,0,1,0])}(t,c,o):"sepia"===i?function(t,e,n){var r=D(n[0]);j(t,e,[.393+.607*(1-r),.769-.769*(1-r),.189-.189*(1-r),0,0,.349-.349*(1-r),.686+.314*(1-r),.168-.168*(1-r),0,0,.272-.272*(1-r),.534-.534*(1-r),.131+.869*(1-r),0,0,0,0,0,1,0])}(t,c,o):"saturate"===i?function(t,e,n){var r=D(n[0]),i=T("feColorMatrix",t);i.setAttribute("type","saturate"),i.setAttribute("values","".concat(r)),e.appendChild(i)}(t,c,o):"hue-rotate"===i?function(t,e,n){var r=T("feColorMatrix",t);r.setAttribute("type","hueRotate"),r.setAttribute("values","".concat(n[0].value)),e.appendChild(r)}(t,c,o):"invert"===i&&function(t,e,n){var r=D(n[0]);L(t,e,{type:"table",tableValues:"".concat(r," ").concat(1-r)})}(t,c,o),c.id="".concat(a,"-").concat(r),c.setAttribute("name",a),e.appendChild(c),c.id});setTimeout(function(){null==r||r.setAttribute("filter",c.map(function(t){return"url(#".concat(t,")")}).join(" "))})}}function D(t){return t.unit===e.UnitType.kPercentage?t.value/100:t.value}function L(t,e,n){var r=n.type,i=n.slope,a=n.intercept,o=n.tableValues,c=T("feComponentTransfer",t);[T("feFuncR",t),T("feFuncG",t),T("feFuncB",t)].forEach(function(t){t.setAttribute("type",r),"table"===r?t.setAttribute("tableValues","".concat(o)):(t.setAttribute("slope","".concat(i)),t.setAttribute("intercept","".concat(a))),c.appendChild(t)}),e.appendChild(c)}function j(t,e,n){var r=T("feColorMatrix",t);r.setAttribute("type","matrix"),r.setAttribute("values",n.join(" ")),e.appendChild(r)}function N(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function R(t){for(var e=1;arguments.length>e;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?N(Object(n),!0).forEach(function(e){A(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}var V={},$=0;function U(t,n,r,i,a,o,c,u){if(!a)return"";if(!e.isCSSRGB(a)){if(e.isPattern(a)){var l=function(t,n,r,i,a,o){var c=I(i),u=n.querySelector("#".concat(c));if(!u){var l=i.image,s="";if(h(l)?s=l:e.isBrowser&&(l instanceof HTMLImageElement?s=l.src:l instanceof HTMLCanvasElement&&(s=l.toDataURL())),s){var f=T("image",t);f.setAttribute("href",s);var d=a();s.match(/^data:/i)||(d.crossOrigin="Anonymous",f.setAttribute("crossorigin","anonymous")),d.src=s;var p=function(){var e=_(t,n,r,i,c,d.width,d.height);n.appendChild(e),e.appendChild(f),f.setAttribute("x","0"),f.setAttribute("y","0"),f.setAttribute("width","".concat(d.width)),f.setAttribute("height","".concat(d.height))};d.complete?p():d.onload=p}if("rect"===l.nodeName){var v=l.parsedStyle,m=_(t,n,l,i,c,v.width,v.height);l.forEach(function(e){o.createSVGDom(t,e,null);var n=e.elementSVG,r=e.getLocalTransform();o.applyTransform(n.$groupEl,r)}),m.appendChild(l.elementSVG.$groupEl)}}return c}(t,n,r,a,c,u);return i.style[o]="url(#".concat(l,")"),l}if(1===a.length){var s=F(t,r,n,i,a[0]);return null==i||i.setAttribute(o,"url(#".concat(s,")")),s}var f=function(t,e,n,r,i){var a="".concat(P+e.entity,"-gradient"),o=n.querySelector("#".concat(a));o||((o=T("filter",t)).setAttribute("filterUnits","userSpaceOnUse"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.id=a,n.appendChild(o));var c=0;i.forEach(function(i,u){var l=F(t,e,n,r,i),s="".concat(l,"_rect"),f=T("rect",t);f.setAttribute("x","0"),f.setAttribute("y","0"),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.setAttribute("fill","url(#".concat(l,")")),f.id=s,n.appendChild(f);var d=T("feImage",t);if(d.setAttribute("href","#".concat(s)),d.setAttribute("result","".concat(a,"-").concat(u)),o.appendChild(d),u>0){var p=T("feBlend",t);p.setAttribute("in",1===u?"".concat(a,"-").concat(u-1):"".concat(a,"-blended-").concat(c-1)),p.setAttribute("in2","".concat(a,"-").concat(u)),p.setAttribute("result","".concat(a,"-blended-").concat(c++)),p.setAttribute("mode","multiply"),o.appendChild(p)}});var u=T("feComposite",t);return u.setAttribute("in","".concat(a,"-blended-").concat(c)),u.setAttribute("in2","SourceGraphic"),u.setAttribute("operator","in"),o.appendChild(u),a}(t,r,n,i,a);return null==i||i.setAttribute("filter","url(#".concat(f,")")),null==i||i.setAttribute("fill","black"),f}return"currentColor"===r.style[o]?null==i||i.setAttribute(o,"currentColor"):null==i||i.setAttribute(o,a.isNone?"none":""+a),""}function I(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="";if(e.isCSSGradientValue(t)){var i=t.type;if(i===e.GradientType.LinearGradient||i===e.GradientType.RadialGradient){var a=R(R({},t.value),n),o=a.x,c=a.y,u=a.width,l=a.height,s=a.steps,f=a.angle,d=a.cx,p=a.cy,v=a.size;r="gradient-".concat(a.type,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==c?void 0:""+c)||0,"-").concat((null==f?void 0:""+f)||0,"-").concat((null==d?void 0:""+d)||0,"-").concat((null==p?void 0:""+p)||0,"-").concat((null==v?void 0:""+v)||0,"-").concat(u,"-").concat(l,"-").concat(s.map(function(t){var e=t.color;return"".concat(t.offset).concat(e)}).join("-"))}}else e.isPattern(t)&&(r=h(t.image)?"pattern-".concat(t.image,"-").concat(t.repetition):"rect"===t.image.nodeName?"pattern-rect-".concat(t.image.entity):"pattern-".concat($));return r&&(V[r]||(V[r]="".concat("g-pattern-").concat($++))),V[r]}function _(t,n,r,i,a,o,c){var u=i.repetition,l=i.transform,s=T("pattern",t);l&&s.setAttribute("patternTransform",function(t){return e.parseTransform(t).map(function(t){var e=t.t,n=t.d;if("translate"===e)return"translate(".concat(n[0].value," ").concat(n[1].value,")");if("translateX"===e)return"translate(".concat(n[0].value," 0)");if("translateY"===e)return"translate(0 ".concat(n[0].value,")");if("rotate"===e)return"rotate(".concat(n[0].value,")");if("scale"===e){var r=(null==n?void 0:n.map(function(t){return t.value}))||[1,1];return"scale(".concat(r[0],", ").concat(r[1],")")}if("scaleX"===e){var i=(null==n?void 0:n.map(function(t){return t.value}))||[1];return"scale(".concat(i[0],", 1)")}if("scaleY"===e){var a=(null==n?void 0:n.map(function(t){return t.value}))||[1];return"scale(1, ".concat(a[0],")")}if("skew"===e){var o=(null==n?void 0:n.map(function(t){return t.value}))||[0,0];return"skewX(".concat(o[0],") skewY(").concat(o[1],")")}if("skewZ"===e){var c=(null==n?void 0:n.map(function(t){return t.value}))||[0];return"skewX(".concat(c[0],")")}if("skewY"===e){var u=(null==n?void 0:n.map(function(t){return t.value}))||[0];return"skewY(".concat(u[0],")")}if("matrix"===e){var l=w(n.map(function(t){return t.value}),6),s=l[1],f=l[2],d=l[3],p=l[4],h=l[5];return"matrix(".concat(l[0]," ").concat(s," ").concat(f," ").concat(d," ").concat(p," ").concat(h,")")}return null}).filter(function(t){return null!==t}).join(" ")}(l)),s.setAttribute("patternUnits","userSpaceOnUse"),s.id=a,n.appendChild(s);var f=r.getGeometryBounds(),d=f.halfExtents,p=f.min;s.setAttribute("x","".concat(p[0])),s.setAttribute("y","".concat(p[1]));var h=o,v=c;return"repeat-x"===u?v=2*d[1]:"repeat-y"===u?h=2*d[0]:"no-repeat"===u&&(h=2*d[0],v=2*d[1]),s.setAttribute("width","".concat(h)),s.setAttribute("height","".concat(v)),s}function F(t,n,r,i,a){var o=n.getGeometryBounds(),c=o&&2*o.halfExtents[0]||0,u=o&&2*o.halfExtents[1]||0,l=o&&o.min||[0,0],s=I(a,{x:l[0],y:l[1],width:c,height:u}),f=r.querySelector("#".concat(s));if(!f){(f=T(a.type===e.GradientType.LinearGradient?"linearGradient":"radialGradient",t)).setAttribute("gradientUnits","userSpaceOnUse");var d="";a.value.steps.sort(function(t,e){return t.offset.value-e.offset.value}).forEach(function(t){var e=t.color;d+='<stop offset="'.concat(t.offset.value/100,'" stop-color="').concat(e,'"></stop>')}),f.innerHTML=d,f.id=s,r.appendChild(f)}if(a.type===e.GradientType.LinearGradient){var p=e.computeLinearGradient([l[0],l[1]],c,u,a.value.angle),h=p.y1,v=p.x2,m=p.y2;f.setAttribute("x1","".concat(p.x1)),f.setAttribute("y1","".concat(h)),f.setAttribute("x2","".concat(v)),f.setAttribute("y2","".concat(m))}else{var y=a.value,g=e.computeRadialGradient([l[0],l[1]],c,u,y.cx,y.cy,y.size),b=g.y,A=g.r;f.setAttribute("cx","".concat(g.x)),f.setAttribute("cy","".concat(b)),f.setAttribute("r","".concat(A))}return s}var H=/url\("?#(.*)\)/,B=function(){return a(function t(e){o(this,t),this.gradientCache={},this.context=e},[{key:"getDefElement",value:function(){return this.$def}},{key:"init",value:function(){var t=this.context.config.document,e=this.context.contextService.getContext();this.$def=T("defs",t),e.appendChild(this.$def)}},{key:"clear",value:function(t){var e=this;Object.keys(this.gradientCache).forEach(function(n){e.clearUnusedDefElement(e.gradientCache,n,t)})}},{key:"clearUnusedDefElement",value:function(t,e,n){if(t[e]&&1===t[e].size&&t[e].has(n)){var r=this.$def.querySelector("#".concat(e));r&&this.$def.removeChild(r)}}},{key:"createOrUpdateGradientAndPattern",value:function(t,n,r,i,a){var o=this.context.config,c=o.document,u=o.createImage;if(n){var l=(e.isPattern(r)?n.style[i]:n.getAttribute(i)||"").match(H);l&&l.length>1&&this.clearUnusedDefElement(this.gradientCache,l[1].replace('"',""),t.entity);var s=U(c||document,this.$def,t,n,r,i,u,a);s&&(this.gradientCache[s]||(this.gradientCache[s]=new Set),this.gradientCache[s].add(t.entity))}}},{key:"createOrUpdateShadow",value:function(t,e,n){!function(t,e,n,r,i){var a=n.parsedStyle,o=a.shadowType,c=void 0===o?"outer":o,u=a.shadowBlur,l=a.shadowColor,s=a.shadowOffsetX,f=a.shadowOffsetY,d=!p(l)&&u>0,h="g-filter-dropshadow-"+n.entity,v=e.querySelector("#".concat(h));if(v&&(v.getAttribute("data-type")===c&&d||(v.remove(),v=null)),d){if(null==r||r.setAttribute("filter","url(#".concat(h,")")),!v){if((v=T("filter",t)).setAttribute("data-type",c),"outer"===c){var m=T("feDropShadow",t);m.setAttribute("dx","".concat((s||0)/2)),m.setAttribute("dy","".concat((f||0)/2)),m.setAttribute("stdDeviation","".concat((u||0)/4)),m.setAttribute("flood-color",""+l),v.appendChild(m)}else if("inner"===c){var y=T("feComponentTransfer",t);y.setAttribute("in","SourceAlpha");var g=T("feFuncA",t);g.setAttribute("type","table"),g.setAttribute("tableValues","1 0"),y.appendChild(g),v.appendChild(y);var b=T("feGaussianBlur",t);b.setAttribute("stdDeviation","".concat((u||0)/4)),v.appendChild(b);var A=T("feOffset",t);A.setAttribute("dx","".concat((s||0)/2)),A.setAttribute("dy","".concat((f||0)/2)),A.setAttribute("result","offsetblur"),v.appendChild(A);var E=T("feFlood",t);E.setAttribute("flood-color",""+l),E.setAttribute("result","color"),v.appendChild(E);var S=T("feComposite",t);S.setAttribute("in2","offsetblur"),S.setAttribute("operator","in"),v.appendChild(S);var x=T("feComposite",t);x.setAttribute("in2","SourceAlpha"),x.setAttribute("operator","in"),v.appendChild(x);var O=T("feMerge",t);v.appendChild(O);var w=T("feMergeNode",t);w.setAttribute("in","SourceGraphic");var C=T("feMergeNode",t);O.appendChild(w),O.appendChild(C)}return v.id=h,v.setAttribute("filterUnits","userSpaceOnUse"),void e.appendChild(v)}if("inner"===c){var k=v.children[1],G=v.children[2];"shadowColor"===i?v.children[3].setAttribute("flood-color",""+l):"shadowBlur"===i?k.setAttribute("stdDeviation","".concat((u||0)/4)):"shadowOffsetX"===i?G.setAttribute("dx","".concat((s||0)/2)):"shadowOffsetY"===i&&G.setAttribute("dy","".concat((f||0)/2))}else if("outer"===c){var P=v.children[0];"shadowColor"===i?P.setAttribute("flood-color",""+l):"shadowBlur"===i?P.setAttribute("stdDeviation","".concat((u||0)/4)):"shadowOffsetX"===i?P.setAttribute("dx","".concat((s||0)/2)):"shadowOffsetY"===i&&P.setAttribute("dy","".concat((f||0)/2))}}else null==r||r.removeAttribute("filter")}(this.context.config.document||document,this.$def,t,e,n)}},{key:"createOrUpdateFilter",value:function(t,e,n){M(this.context.config.document||document,this.$def,t,e,n)}}])}();function W(t){return t.toFixed(6).replace(".000000","")}function X(t){return t.replace(/[&|<|>|"|']/g,function(t){return"&"===t?"&":"<"===t?"<":">"===t?">":'"'===t?""":"'"})}var Y={opacity:"opacity",fillStyle:"fill",fill:"fill",fillRule:"fill-rule",fillOpacity:"fill-opacity",strokeStyle:"stroke",strokeOpacity:"stroke-opacity",stroke:"stroke",clipPath:"clip-path",textPath:"text-path",r:"r",cx:"cx",cy:"cy",rx:"rx",ry:"ry",x:"x",y:"y",width:"width",height:"height",lineCap:"stroke-linecap",lineJoin:"stroke-linejoin",lineWidth:"stroke-width",lineDash:"stroke-dasharray",lineDashOffset:"stroke-dashoffset",miterLimit:"stroke-miterlimit",font:"font",fontSize:"font-size",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",fontFamily:"font-family",letterSpacing:"letter-spacing",startArrow:"marker-start",endArrow:"marker-end",class:"class",id:"id",preserveAspectRatio:"preserveAspectRatio",visibility:"visibility",shadowColor:"flood-color",shadowBlur:"stdDeviation",shadowOffsetX:"dx",shadowOffsetY:"dy",filter:"filter",innerHTML:"innerHTML",textAlign:"text-anchor",pointerEvents:"pointer-events"},z={textAlign:{inherit:"inherit",left:"left",start:"left",center:"middle",right:"end",end:"end"}},q={textAlign:"inherit",lineCap:"butt",lineJoin:"miter",lineWidth:"1px",opacity:"1",fillOpacity:"1",fillRule:"nonzero",strokeOpacity:"1",strokeWidth:"0",strokeMiterLimit:"4",letterSpacing:"0",fontSize:"inherit",fontFamily:"inherit",pointerEvents:"auto",transform:"matrix(1,0,0,1,0,0)"},Q="g-svg",J="clip-path-",K="text-path-",Z=function(){function t(e,n,r){o(this,t),this.svgElementMap=new WeakMap,this.renderQueue=[],this.dirtyAttributes=new WeakMap,this.pendingReorderQueue=new Set,this.clipPathUseMap=new WeakMap,this.pluginOptions=e,this.defElementManager=n,this.context=r}return a(t,[{key:"apply",value:function(n){var r=this,i=n.renderingService,a=n.renderingContext;this.context=n,this.context.svgElementMap=this.svgElementMap;var o=a.root.ownerDocument.defaultView,c=this.context.config.document,u=function(t){var e=t.target;if(r.clipPathUseMap.get(e)){var n=r.defElementManager.getDefElement().querySelector("#".concat(r.getId(e)));n&&n.remove()}r.createSVGDom(c,e,r.$camera)},l=function(t){var e=t.target;r.defElementManager.clear(e.entity),r.clipPathUseMap.delete(e),r.removeSVGDom(e)},s=function(t){var e,n=t.parentNode,i=null===(e=t.parentNode)||void 0===e||null===(e=e.elementSVG)||void 0===e?void 0:e.$groupEl,a=((null==n?void 0:n.children)||[]).slice();i&&r.reorderChildren(c,i,a)},f=function(t){s(t.target)},d=function(t){var e=t.target;if(e.elementSVG){var n=t.attrName,i=r.dirtyAttributes.get(e);i||(r.dirtyAttributes.set(e,[]),i=r.dirtyAttributes.get(e)),i.push(n)}},p=function(t){for(var n=t.detail,i=function(){var t=n[a].target;(t.nodeName===e.Shape.FRAGMENT?t.childNodes:[t]).forEach(function(n){var i,a=null===(i=t.elementSVG)||void 0===i?void 0:i.$el,o=t.parsedStyle,c=o.fill,u=o.stroke,l=o.clipPath;if(c&&!e.isCSSRGB(c)&&r.defElementManager.createOrUpdateGradientAndPattern(t,a,c,"fill",r),u&&!e.isCSSRGB(u)&&r.defElementManager.createOrUpdateGradientAndPattern(t,a,u,"stroke",r),l){var s=g(y(),t.getWorldTransform()),f="".concat(J+l.entity,"-").concat(t.entity),d=r.defElementManager.getDefElement().querySelector("#".concat(f));d&&r.applyTransform(d,s)}})},a=0;n.length>a;a++)i()};i.hooks.init.tap(t.tag,function(){var t=r.context.config,n=t.background,i=t.document;r.defElementManager.init();var a=r.context.contextService.getContext();n&&(a.style.background=n),a.setAttribute("color-interpolation-filters","sRGB"),r.$camera=T("g",i),r.$camera.id="".concat(Q,"-camera"),r.applyTransform(r.$camera,r.context.camera.getOrthoMatrix()),a.appendChild(r.$camera),o.addEventListener(e.ElementEvent.MOUNTED,u),o.addEventListener(e.ElementEvent.UNMOUNTED,l),o.addEventListener(e.ElementEvent.REPARENT,f),o.addEventListener(e.ElementEvent.ATTR_MODIFIED,d),o.addEventListener(e.ElementEvent.BOUNDS_CHANGED,p)}),i.hooks.destroy.tap(t.tag,function(){o.removeEventListener(e.ElementEvent.MOUNTED,u),o.removeEventListener(e.ElementEvent.UNMOUNTED,l),o.removeEventListener(e.ElementEvent.REPARENT,f),o.removeEventListener(e.ElementEvent.ATTR_MODIFIED,d),o.removeEventListener(e.ElementEvent.BOUNDS_CHANGED,p),$=0,V={}}),i.hooks.render.tap(t.tag,function(t){r.renderQueue.push(t)}),i.hooks.beginFrame.tap(t.tag,function(){var t=r.context.config.document;r.pendingReorderQueue.size&&(r.pendingReorderQueue.forEach(function(e){var n,i=((null==e?void 0:e.children)||[]).slice(),a=null==e||null===(n=e.elementSVG)||void 0===n?void 0:n.$groupEl;a&&r.reorderChildren(t||c,a,i||[])}),r.pendingReorderQueue.clear())}),i.hooks.endFrame.tap(t.tag,function(){a.renderReasons.has(e.RenderReason.CAMERA_CHANGED)&&r.applyTransform(r.$camera,r.context.camera.getOrthoMatrix()),r.renderQueue.forEach(function(t){var e,n,i=null===(e=t.elementSVG)||void 0===e?void 0:e.$el,a=null===(n=t.elementSVG)||void 0===n?void 0:n.$groupEl;if(i&&a){var o=t.getLocalTransform();r.applyTransform(a,o);var c=r.clipPathUseMap.get(t);c&&c.length&&c.forEach(function(e){r.applyTransform(e,t.getWorldTransform())}),t.renderable.dirty=!1}var u=r.dirtyAttributes.get(t);u&&(u.forEach(function(e){"zIndex"===e?s(t):"increasedLineWidthForHitTesting"===e&&r.createOrUpdateHitArea(t,i,a),r.updateAttribute(t,[e])}),r.dirtyAttributes.delete(t))}),r.renderQueue=[]})}},{key:"getId",value:function(t){return t.id||"".concat(Q,"-").concat(t.entity)}},{key:"reorderChildren",value:function(t,e,n){if(n.sort(function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder}),n.length){var r=(t||document).createDocumentFragment();n.forEach(function(t){if(t.isConnected){var e=t.elementSVG.$groupEl;e&&r.appendChild(e)}}),e.appendChild(r)}}},{key:"applyTransform",value:function(t,e){var n="matrix(".concat(W(e[0]),",").concat(W(e[1]),",").concat(W(e[4]),",").concat(W(e[5]),",").concat(W(e[12]),",").concat(W(e[13]),")");n!==t.getAttribute("transform")&&t.setAttribute("transform",n),n===q.transform&&t.removeAttribute("transform")}},{key:"applyAttributes",value:function(t){var n=t.elementSVG,r=null==n?void 0:n.$el;if(r&&(null==n?void 0:n.$groupEl)){var i=t.nodeName,a=t.attributes;i!==e.Shape.HTML&&r.setAttribute("fill","none"),i===e.Shape.IMAGE&&r.setAttribute("preserveAspectRatio","none"),this.updateAttribute(t,Object.keys(a))}}},{key:"updateAttribute",value:function(t,n){var r=this,i=this.context.config.document,a=t.elementSVG,o=a.$el,c=a.$hitTestingEl,u=t.parsedStyle,l=t.nodeName;n.some(function(e){return r.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(t,e)})&&o&&[o,c].forEach(function(e){e&&r.context.SVGElementLifeCycleContribution.updateElementAttribute(t,e,r.svgElementMap)}),n.forEach(function(n){var a,s,f=Y[n],d=u[n],h=!p(d)&&""+d,v=(null===(a=z[n])||void 0===a?void 0:a[h])||h,m=u[n],y=f&&!(null===(s=e.propertyMetadataCache[n])||void 0===s||!s.inh);if(l===e.Shape.HTML)"fill"===n?o.style.background=""+m:"stroke"===n?(o.style["border-color"]=""+m,o.style["border-style"]="solid"):"lineWidth"===n?o.style["border-width"]="".concat(m||0,"px"):"lineDash"===n?o.style["border-style"]="dashed":"innerHTML"===n?r.createOrUpdateInnerHTML(i,o,m):"width"===n||"height"===n||"class"===n||"x"===n||"y"===n?o.setAttribute(n,""+m):p(t.style[n])||""===t.style[n]||(o.style[n]=t.style[n]);else{if(!f||(l===e.Shape.GROUP||t.isCustomElement)&&(y||"fill"===f||"stroke"===f))return;"fill"===n||"stroke"===n?r.defElementManager.createOrUpdateGradientAndPattern(t,o,m,f,r):"clipPath"===n?r.createOrUpdateClipOrTextPath(i,m,t):"textPath"===n?r.createOrUpdateClipOrTextPath(i,m,t,!0):"shadowType"===n||"shadowColor"===n||"shadowBlur"===n||"shadowOffsetX"===n||"shadowOffsetY"===n?r.defElementManager.createOrUpdateShadow(t,o,n):"filter"===n?r.defElementManager.createOrUpdateFilter(t,o,m):p(d)||[o,c].forEach(function(t){t&&f&&("unset"!==h&&h!==q[n]?t.setAttribute(f,v):t.removeAttribute(f))})}})}},{key:"createSVGDom",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];n.elementSVG=new b;var a=n.elementSVG,o=this.context.SVGElementLifeCycleContribution.createElement(n,this.svgElementMap);if(o){var c,u;n.nodeName===e.Shape.HTML&&(n.parsedStyle.$el=o),this.pluginOptions.outputSVGElementId&&(o.id=this.getId(n)),this.pluginOptions.outputSVGElementName&&n.name&&o.setAttribute("name",n.name),!o.hasAttribute("data-wrapgroup")&&"g"===o.nodeName||i?u=o:(u=T("g",t)).appendChild(o),a.$el=o,a.$groupEl=u,this.applyAttributes(n),this.createOrUpdateHitArea(n,o,u);var l=r||n.parentNode&&(null===(c=n.parentNode.elementSVG)||void 0===c?void 0:c.$groupEl);l&&(l.appendChild(u),this.pendingReorderQueue.add(n.parentNode))}}},{key:"removeSVGDom",value:function(t){var e,n=null===(e=t.elementSVG)||void 0===e?void 0:e.$groupEl;n&&n.parentNode&&(n.parentNode.removeChild(n),this.context.SVGElementLifeCycleContribution.destroyElement(t,n))}},{key:"createOrUpdateHitArea",value:function(t,e,n){var r=t.elementSVG,i=r.$hitTestingEl,a=Number(t.parsedStyle.increasedLineWidthForHitTesting);if(a){if(!i){i=e.cloneNode(),["filter"].forEach(function(t){i.removeAttribute(t)});var o="none"!==e.getAttribute("fill");i.setAttribute("fill",o?"transparent":"none"),i.setAttribute("stroke","transparent"),n.appendChild(i),r.$hitTestingEl=i,this.svgElementMap.set(i,t)}i.setAttribute("stroke-width","".concat(a+t.parsedStyle.lineWidth))}else i&&(n.removeChild(i),r.$hitTestingEl=null)}},{key:"createOrUpdateInnerHTML",value:function(t,e,n){var r=(t||document).createElement("div");"string"==typeof n?r.innerHTML=n:r.appendChild(n),e.innerHTML="",e.appendChild(r)}},{key:"createOrUpdateClipOrTextPath",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=n.elementSVG.$groupEl,a=r?"g":"clipPath",o=r?"text-path":"clip-path";if(e){var c="".concat((r?K:J)+e.entity,"-").concat(n.entity),u=this.defElementManager.getDefElement();if(!u.querySelector("#".concat(c))){var l;if(r)this.createSVGDom(t,e,null,!0),l=e.elementSVG.$el;else{if(!e.isConnected)u.querySelector("#".concat(this.getId(e)))||this.createSVGDom(t,e,u,!0);l=T(a,t);var s=T("use",t);s.setAttribute("href","#".concat(e.elementSVG.$el.id)),l.appendChild(s);var f=this.clipPathUseMap.get(e);f||(this.clipPathUseMap.set(e,[]),f=this.clipPathUseMap.get(e)),f.push(s),this.applyTransform(s,e.getWorldTransform());var d=g(y(),n.getWorldTransform());this.applyTransform(l,d)}this.pluginOptions.outputSVGElementId&&(l.id=c),u.appendChild(l)}this.applyAttributes(e),r||i.setAttribute(o,"url(#".concat(c,")"))}else r||i.removeAttribute(o)}}])}();Z.tag="SVGRenderer";var tt,et={top:"hanging",middle:"central",bottom:"text-after-edge",alphabetic:"alphabetic",ideographic:"ideographic",hanging:"hanging"};function nt(t,e,n,r){n.getBounds();var i=e.lineWidth,a=void 0===i?1:i,o=e.x,c=void 0===o?0:o,u=e.y,l=void 0===u?0:u,s=e.dx,f=void 0===s?0:s,d=e.dy,p=void 0===d?0:d,h=e.textPath,v=e.textPathSide,m=void 0===v?"left":v,y=e.textPathStartOffset,g=void 0===y?0:y,b=e.textDecorationLine,A=void 0===b?"":b,E=e.textDecorationColor,S=void 0===E?"":E,x=e.textDecorationStyle,O=void 0===x?"":x,w=e.textDecorationThickness,C=void 0===w?1:w,k=e.metrics,G=e.textBaseline,P=void 0===G?"alphabetic":G;"alphabetic"===P&&(P="bottom"),t.setAttribute("dominant-baseline",et[P]),t.setAttribute("paint-order","stroke");var M=k.lines,D=k.lineHeight,L=k.height,j=M.length,N="transform:translate(".concat(f,"px, ").concat(p,"px);");if(A&&"none"!==A&&(N+="text-decoration:".concat(A," ").concat(O," ").concat(S,";text-decoration-thickness:").concat(C,";")),N&&t.setAttribute("style",N),0!==c&&t.setAttribute("x","".concat(c)),0!==l&&t.setAttribute("y","".concat(l)),1===j){var R=X(M[0]);if(t.setAttribute("dx","".concat(a/2)),"bottom"===P||"top"===P?(t.setAttribute("dominant-baseline",et.middle),t.setAttribute("dy","bottom"===P?"-".concat(L/2,"px"):"".concat(L/2,"px"))):t.setAttribute("dy","0px"),h){t.innerHTML="";var V=T("textPath",t.ownerDocument);V.setAttribute("href","#".concat(K+h.entity)),"left"!==m&&V.setAttribute("side",m),0!==g&&V.setAttribute("startOffset","".concat(g)),V.innerHTML=R,t.appendChild(V)}else t.innerHTML=R}else t.innerHTML=M.map(function(t,e){var n=a/2,r=0;return 0===e?"middle"===P?r=D/2-L/2:"top"===P||"hanging"===P?r=0:"bottom"!==P&&"ideographic"!==P||(r=-D*(j-1)):r=D,"<tspan x=".concat(c,' dx="').concat(n,'" dy="').concat(r,'">').concat(X(t),"</tspan>")}).join("")}var rt=(A(A(A(A(A(A(A(A(A(A(tt={},e.Shape.RECT,"path"),e.Shape.CIRCLE,"circle"),e.Shape.ELLIPSE,"ellipse"),e.Shape.IMAGE,"image"),e.Shape.GROUP,"g"),e.Shape.LINE,"line"),e.Shape.POLYLINE,"polyline"),e.Shape.POLYGON,"polygon"),e.Shape.TEXT,"text"),e.Shape.PATH,"path"),A(tt,e.Shape.HTML,"foreignObject")),it=A(A(A(A(A(A(A(A(A({},e.Shape.CIRCLE,["cx","cy","r"]),e.Shape.ELLIPSE,["cx","cy","rx","ry"]),e.Shape.RECT,["x","y","width","height","radius"]),e.Shape.IMAGE,["x","y","src","width","height"]),e.Shape.LINE,["x1","y1","x2","y2","markerStart","markerEnd","markerStartOffset","markerEndOffset"]),e.Shape.POLYLINE,["points","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"]),e.Shape.POLYGON,["points","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"]),e.Shape.PATH,["d","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"]),e.Shape.TEXT,["text","font","fontSize","fontFamily","fontStyle","fontWeight","fontVariant","lineHeight","letterSpacing","wordWrap","wordWrapWidth","maxLines","leading","textBaseline","textAlign","textTransform","textOverflow","textPath","textPathSide","textPathStartOffset","textDecorationLine","textDecorationColor","textDecorationStyle","dx","dy"]),at=function(){return a(function t(e,n){o(this,t),this.context=e,this.runtime=n},[{key:"createElement",value:function(t,e){var n=T(rt[t.nodeName]||"g",this.context.config.document||document);return e.set(n,t),n}},{key:"destroyElement",value:function(t,e){}},{key:"shouldUpdateElementAttribute",value:function(t,e){return(it[t.nodeName]||[]).indexOf(e)>-1}},{key:"updateElementAttribute",value:function(t){var n=t.elementSVG.$el,r=t.parsedStyle;switch(t.nodeName){case e.Shape.IMAGE:E(n,r);break;case e.Shape.RECT:G(n,r);break;case e.Shape.LINE:S(n,r);break;case e.Shape.POLYGON:case e.Shape.POLYLINE:k(n,r);break;case e.Shape.PATH:C(n,r);break;case e.Shape.TEXT:nt(n,r,t)}}}])}(),ot=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(this,e),(t=s(this,e)).name="svg-renderer",t.options=n,t}return d(e,t),a(e,[{key:"init",value:function(t){var e=this.options,n=e.outputSVGElementId,r=e.outputSVGElementName,i=new B(this.context),a=new at(this.context,t);this.context.defaultElementLifeCycleContribution=a,this.context.SVGElementLifeCycleContribution=a;var o={outputSVGElementId:!!p(n)||!!n,outputSVGElementName:!!p(r)||!!r};this.addRenderingPlugin(new Z(o,i,this.context))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultElementLifeCycleContribution,delete this.context.SVGElementLifeCycleContribution}}])}(e.AbstractRendererPlugin),ct=Object.freeze({__proto__:null,CLIP_PATH_PREFIX:J,DEFAULT_VALUE_MAP:q,DefaultElementLifeCycleContribution:at,ElementSVG:b,G_SVG_PREFIX:Q,Plugin:ot,SHAPE2TAGS:rt,SHAPE_UPDATE_DEPS:it,SVGRendererPlugin:Z,SVG_ATTR_MAP:Y,TEXT_PATH_PREFIX:K,createSVGElement:T,updateImageElementAttribute:E,updateLineElementAttribute:S,updatePathElementAttribute:C,updatePolylineElementAttribute:k,updateRectElementAttribute:G,updateTextElementAttribute:nt});function ut(t,e){this.v=t,this.k=e}function lt(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}lt=function(t,e,n,r){function a(e,n){lt(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(a("next",0),a("throw",1),a("return",2))},lt(t,e,n,r)}function st(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function a(n,r,i,a){var u=Object.create((r&&r.prototype instanceof c?r:c).prototype);return lt(u,"_invoke",function(n,r,i){var a,c,u,l=0,s=i||[],f=!1,d={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return a=e,c=0,u=t,d.n=n,o}};function p(n,r){for(c=n,u=r,e=0;!f&&l&&!i&&s.length>e;e++){var i,a=s[e],p=d.p,h=a[2];n>3?(i=h===r)&&(u=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=t):p>=a[0]&&((i=2>n&&a[1]>p)?(c=0,d.v=r,d.n=a[1]):h>p&&(i=3>n||a[0]>r||r>h)&&(a[4]=n,a[5]=r,d.n=h,c=0))}if(i||n>1)return o;throw f=!0,r}return function(i,s,h){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&p(s,h),c=s,u=h;(e=2>c?t:u)||!f;){a||(c?3>c?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(l=2,a){if(c||(i="next"),e=a[i]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,2>c&&(c=0)}else 1===c&&(e=a.return)&&e.call(a),2>c&&(u=TypeError("The iterator does not provide a '"+i+"' method"),c=1);a=t}else if((e=(f=0>d.n)?u:n.call(r,d))!==o)break}catch(e){a=t,c=1,u=e}finally{l=1}}return{value:e,done:f}}}(n,i,a),!0),u}var o={};function c(){}function u(){}function l(){}e=Object.getPrototypeOf;var s=[][r]?e(e([][r]())):(lt(e={},r,function(){return this}),e),f=l.prototype=c.prototype=Object.create(s);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,lt(t,i,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=l,lt(f,"constructor",l),lt(l,"constructor",u),u.displayName="GeneratorFunction",lt(l,i,"GeneratorFunction"),lt(f),lt(f,i,"Generator"),lt(f,r,function(){return this}),lt(f,"toString",function(){return"[object Generator]"}),(st=function(){return{w:a,m:d}})()}function ft(t,e){function n(r,i,a,o){try{var c=t[r](i),u=c.value;return u instanceof ut?e.resolve(u.v).then(function(t){n("next",t,a,o)},function(t){n("throw",t,a,o)}):e.resolve(u).then(function(t){c.value=t,a(c)},function(t){return n("throw",t,a,o)})}catch(t){o(t)}}var r;this.next||(lt(ft.prototype),lt(ft.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),lt(this,"_invoke",function(t,i,a){function o(){return new e(function(e,r){n(t,a,e,r)})}return r=r?r.then(o,o):o()},!0)}function dt(t,e,n,r,i){return new ft(st().w(t,e,n,r),i||Promise)}function pt(t,e,n,r,i){var a=dt(t,e,n,r,i);return a.next().then(function(t){return t.done?t.value:a.next()})}function ht(t){var e=Object(t),n=[];for(var r in e)n.unshift(r);return function t(){for(;n.length;)if((r=n.pop())in e)return t.value=r,t.done=!1,t;return t.done=!0,t}}function vt(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}throw new TypeError(n(t)+" is not iterable")}function mt(){var t=st(),e=t.m(mt),n=(Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__).constructor;function r(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===n||"GeneratorFunction"===(e.displayName||e.name))}var i={throw:1,return:2,break:3,continue:3};function a(t){var e,n;return function(r){e||(e={stop:function(){return n(r.a,2)},catch:function(){return r.v},abrupt:function(t,e){return n(r.a,i[t],e)},delegateYield:function(t,i,a){return e.resultName=i,n(r.d,vt(t),a)},finish:function(t){return n(r.f,t)}},n=function(t,n,i){r.p=e.prev,r.n=e.next;try{return t(n,i)}finally{e.next=r.n}}),e.resultName&&(e[e.resultName]=r.v,e.resultName=void 0),e.sent=r.v,e.next=r.n;try{return t.call(this,e)}finally{r.p=e.prev,r.n=e.next}}}return(mt=function(){return{wrap:function(e,n,r,i){return t.w(a(e),n,r,i&&i.reverse())},isGeneratorFunction:r,mark:t.m,awrap:function(t,e){return new ut(t,e)},AsyncIterator:ft,async:function(t,e,n,i,o){return(r(e)?dt:pt)(a(t),e,n,i,o)},keys:ht,values:vt}})()}function yt(t,e,n,r,i,a,o){try{var c=t[a](o),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,i)}function gt(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var a=t.apply(e,n);function o(t){yt(a,r,i,o,c,"next",t)}function c(t){yt(a,r,i,o,c,"throw",t)}o(void 0)})}}var bt=function(){function t(){o(this,t)}return a(t,[{key:"apply",value:function(e,n){var r=this,i=e.config.document,a=e.renderingService,o=e.svgElementMap;a.hooks.pick.tapPromise(t.tag,function(){var t=gt(mt().mark(function t(e){return mt().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",r.pick(o,i,e));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),a.hooks.pickSync.tap(t.tag,function(t){return r.pick(o,i,t)})}},{key:"pick",value:function(t,e,n){var r=n.topmost,i=n.position,a=i.clientX,o=i.clientY;try{var c,u=[],l=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=O(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return t.length>r?{done:!1,value:t[r++]}:{done:!0}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){c=!0,a=t},f:function(){try{o||null==n.return||n.return()}finally{if(c)throw a}}}}((e||document).elementsFromPoint(a,o));try{for(l.s();!(c=l.n()).done;){var s=c.value;if(s.shadowRoot&&s.shadowRoot!==e)return this.pick(t,s.shadowRoot,n);var f=t.get(s);if(f&&f.isInteractive()&&(u.push(f),r))return n.picked=u,n}}catch(t){l.e(t)}finally{l.f()}n.picked=u}catch(t){n.picked=[]}return n}}])}();bt.tag="SVGPicker";var At=function(t){function e(){var t;o(this,e);for(var n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];return(t=s(this,e,[].concat(r))).name="svg-picker",t}return d(e,t),a(e,[{key:"init",value:function(){this.addRenderingPlugin(new bt)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(e.AbstractRendererPlugin),Et=Object.freeze({__proto__:null,Plugin:At});function St(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;a.length>r;r++)-1===e.indexOf(n=a[r])&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var xt=["offset","composite","computedOffset","easing"],Ot=["offset","composite","computedOffset","easing","transformOrigin"],wt=["offset","composite","computedOffset","easing","transformOrigin"],Ct=["offset","composite","computedOffset","easing","transformOrigin"],kt=function(){return a(function t(e){o(this,t),this.context=e,this.canvasConfig=e.config},[{key:"init",value:function(){var t=this.canvasConfig,e=t.container,n=t.document,r=t.devicePixelRatio;if(this.$container=h(e)?(n||document).getElementById(e):e,this.$container){this.$container.style.position||(this.$container.style.position="relative");var i=T("svg",n);i.setAttribute("width","".concat(this.canvasConfig.width)),i.setAttribute("height","".concat(this.canvasConfig.height)),this.$container.appendChild(i),this.$namespace=i}this.dpr=r}},{key:"getDomElement",value:function(){return this.$namespace}},{key:"getContext",value:function(){return this.$namespace}},{key:"getDPR",value:function(){return this.dpr}},{key:"getBoundingClientRect",value:function(){var t;return null===(t=this.$namespace)||void 0===t?void 0:t.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$namespace&&this.$namespace.parentNode&&this.$container.removeChild(this.$namespace)}},{key:"resize",value:function(t,e){this.$namespace&&(this.$namespace.setAttribute("width","".concat(t)),this.$namespace.setAttribute("height","".concat(e)))}},{key:"applyCursorStyle",value:function(t){this.$container&&(this.$container.style.cursor=t)}},{key:"generateCSSText",value:function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=r.duration,o=r.easing,c=r.delay,u=r.direction,l=r.iterations,s=r.fill;return"@keyframes ".concat(t,"{").concat(n.map(function(t){var e=t.computedOffset,n=St(t,xt),r=Object.keys(n).map(function(t){return"".concat(t,":").concat(i[t]||"").concat(n[t],";")}).join("");return"".concat(100*e,"%{").concat(r,"}")}).join(""),"}")+"".concat(e," {animation: ").concat(t," ").concat(a,"ms ").concat(o," ").concat(c,"ms ").concat(l===1/0?"infinite":l," ").concat(u," ").concat(s,";}")}},{key:"toDataURL",value:(t=gt(mt().mark(function t(){var n,r,i,a,o,c,u=this;return mt().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.$namespace.cloneNode(!0),r=this.canvasConfig.document,i=0,a=null,this.context.renderingContext.root.forEach(function(t){var o=t.getAnimations();if(o.length){a||(a=(r||document).createElement("style"),n.appendChild(a));var c=t.elementSVG,l="#".concat(c.$el.id),s="#".concat(c.$groupEl.id),f="",d="";o.forEach(function(t){var n=t.effect.getKeyframes();if(n.length){var r=[],a=[],o=n[0],p=St(o,Ot);if(Object.keys(p).forEach(function(t){var n;"transform"===t&&a.push(t),null!==(n=e.propertyMetadataCache[t])&&void 0!==n&&n.inh?a.push(t):"transform"!==t&&r.push(t)}),a.length){var h=n.map(function(t){var e=t.offset,n=t.composite,r=t.computedOffset,i=t.easing,o=St(t,wt),c={offset:e,composite:n,computedOffset:r,easing:i};return Object.keys(o).forEach(function(e){a.includes(e)&&(c[e]=t[e])}),c});d+=u.generateCSSText("a".concat(i++),s,h,t.effect.getComputedTiming(),{transform:c.$groupEl.getAttribute("transform")})}if(r.length){var v=n.map(function(t){var e=t.offset,n=t.composite,i=t.computedOffset,a=t.easing,o=St(t,Ct),c={offset:e,composite:n,computedOffset:i,easing:a};return Object.keys(o).forEach(function(e){r.includes(e)&&(c[e]=t[e])}),c});f+=u.generateCSSText("a".concat(i++),l,v,t.effect.getComputedTiming())}}}),a.textContent+=f+d}}),o=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),(c=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",o)).replaceChild(n,c.documentElement),t.abrupt("return","data:image/svg+xml;charset=utf8,".concat(encodeURIComponent((new XMLSerializer).serializeToString(c))));case 1:case"end":return t.stop()}},t,this)})),function(){return t.apply(this,arguments)})}]);var t}(),Gt=function(t){function e(){var t;o(this,e);for(var n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];return(t=s(this,e,[].concat(r))).name="svg-context-register",t}return d(e,t),a(e,[{key:"init",value:function(){this.context.ContextService=kt}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(e.AbstractRendererPlugin),Tt=function(t){function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(this,n),(t=s(this,n,[r])).registerPlugin(new Gt),t.registerPlugin(new ot({outputSVGElementId:r.outputSVGElementId})),t.registerPlugin(new e.DomInteraction.Plugin),t.registerPlugin(new At),t}return d(n,t),a(n)}(e.AbstractRenderer);Object.defineProperty(t,"DomInteraction",{enumerable:!0,get:function(){return e.DomInteraction}}),t.G_SVG_PREFIX=Q,t.Renderer=Tt,t.SVGPicker=Et,t.SVGRenderer=ct,t.createSVGElement=T});
//# sourceMappingURL=index.umd.min.js.map