@antv/g-plugin-svg-renderer
Advanced tools
Comparing version 2.0.12-alpha.1 to 2.0.12
@@ -1,2 +0,2 @@ | ||
!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.SVGRenderer={}),t.window.G)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r=function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},r.apply(this,arguments)};function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,i=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return o}"function"==typeof SuppressedError&&SuppressedError;var i=function(t){return null==t},o={}.toString,c=function(t,e){return o.call(t)==="[object "+e+"]"},l=function(t){return c(t,"String")},s=function(t,e,n){return e>t?e:t>n?n:t},u="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var t=new u(16);return u!=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 p(t,e){var n=e[0],r=e[1],a=e[2],i=e[3],o=e[4],c=e[5],l=e[6],s=e[7],u=e[8],d=e[9],p=e[10],f=e[11],h=e[12],m=e[13],v=e[14],b=e[15],y=n*c-r*o,g=n*l-a*o,A=n*s-i*o,E=r*l-a*c,S=r*s-i*c,x=a*s-i*l,C=u*m-d*h,O=u*v-p*h,M=u*b-f*h,w=d*v-p*m,G=d*b-f*m,T=p*b-f*v,k=y*T-g*G+A*w+E*M-S*O+x*C;return k?(t[0]=(c*T-l*G+s*w)*(k=1/k),t[1]=(a*G-r*T-i*w)*k,t[2]=(m*x-v*S+b*E)*k,t[3]=(p*S-d*x-f*E)*k,t[4]=(l*M-o*T-s*O)*k,t[5]=(n*T-a*M+i*O)*k,t[6]=(v*A-h*x-b*g)*k,t[7]=(u*x-p*A+f*g)*k,t[8]=(o*G-c*M+s*C)*k,t[9]=(r*M-n*G-i*C)*k,t[10]=(h*S-m*A+b*y)*k,t[11]=(d*A-u*S-f*y)*k,t[12]=(c*O-o*w-l*C)*k,t[13]=(n*w-r*O+a*C)*k,t[14]=(m*g-h*E-v*y)*k,t[15]=(u*E-d*g+p*y)*k,t):null}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var f=function(){function t(){}return t.tag="c-svg-element",t}();function h(t,e){var n=e.src,r=void 0===n?"":n,a=e.x,i=e.y,o=void 0===i?0:i,c=e.width,s=e.height;if(t.setAttribute("x","".concat(void 0===a?0:a)),t.setAttribute("y","".concat(o)),l(r))t.setAttribute("href",r);else if(r instanceof Image)c||t.setAttribute("width","".concat(r.width)),s||t.setAttribute("height","".concat(r.height)),t.setAttribute("href",r.src);else if(r instanceof HTMLElement&&l(r.nodeName)&&"CANVAS"===r.nodeName.toUpperCase())t.setAttribute("href",r.toDataURL());else if(r instanceof ImageData){var u=document.createElement("canvas");u.setAttribute("width","".concat(r.width)),u.setAttribute("height","".concat(r.height));var d=u.getContext("2d");d&&(d.putImageData(r,0,0),c||t.setAttribute("width","".concat(r.width)),s||t.setAttribute("height","".concat(r.height)),t.setAttribute("href",u.toDataURL()))}}function m(t,n){var r=n.x1,a=n.y1,i=n.x2,o=n.y2,c=n.markerStart,l=n.markerEnd,s=n.markerStartOffset,u=n.markerEndOffset,d=0,p=0,f=0,h=0,m=0;c&&e.isDisplayObject(c)&&s&&(d=Math.cos(m=Math.atan2(o-a,i-r))*(s||0),p=Math.sin(m)*(s||0)),l&&e.isDisplayObject(l)&&u&&(f=Math.cos(m=Math.atan2(a-o,r-i))*(u||0),h=Math.sin(m)*(u||0)),t.setAttribute("x1","".concat(r+d)),t.setAttribute("y1","".concat(a+p)),t.setAttribute("x2","".concat(i+f)),t.setAttribute("y2","".concat(o+h))}function v(t,n){var r=n.d,i=n.markerStart,o=n.markerEnd,c=n.markerStartOffset,l=n.markerEndOffset,s=0,u=0,d=0,p=0,f=0;if(i&&e.isDisplayObject(i)&&c){var h=a(i.parentNode.getStartTangent(),2);s=Math.cos(f=Math.atan2((m=h[0])[1]-(v=h[1])[1],m[0]-v[0]))*(c||0),u=Math.sin(f)*(c||0)}if(o&&e.isDisplayObject(o)&&l){var m,v,b=a(o.parentNode.getEndTangent(),2);d=Math.cos(f=Math.atan2((m=b[0])[1]-(v=b[1])[1],m[0]-v[0]))*(l||0),p=Math.sin(f)*(l||0)}t.setAttribute("d",e.translatePathToString(r.absolutePath,s,u,d,p))}function b(t,n){var r=n.points.points,a=n.markerStart,i=n.markerStartOffset,o=n.markerEnd,c=n.markerEndOffset,l=r.length;if(r&&l>=2){var s=0,u=0,d=0,p=0,f=0;a&&e.isDisplayObject(a)&&i&&(s=Math.cos(f=Math.atan2(r[1][1]-r[0][1],r[1][0]-r[0][0]))*(i||0),u=Math.sin(f)*(i||0)),o&&e.isDisplayObject(o)&&c&&(d=Math.cos(f=Math.atan2(r[l-2][1]-r[l-1][1],r[l-2][0]-r[l-1][0]))*(c||0),p=Math.sin(f)*(c||0)),t.setAttribute("points",r.map((function(t,e){var n=0,r=0;return 0===e?(n=s,r=u):e===l-1&&(n=d,r=p),"".concat(t[0]+n,",").concat(t[1]+r)})).join(" "))}}function y(t,e){var n=e.radius,r=e.x,i=void 0===r?0:r,o=e.y,c=void 0===o?0:o,l=e.width,u=e.height;if(isFinite(l)&&isFinite(u)){var d="";if(n&&n.some((function(t){return 0!==t}))){var p=a(n.map((function(t){return s(t,0,Math.min(Math.abs(l)/2,Math.abs(u)/2))})),4),f=p[0],h=p[1],m=p[2],v=p[3],b=l>0?1:-1,y=u>0?1:-1,g=b+y!==0?1:0;d=[["M ".concat(b*f+i,",").concat(c)],["l ".concat(l-b*(f+h),",0")],["a ".concat(h,",").concat(h,",0,0,").concat(g,",").concat(b*h,",").concat(y*h)],["l 0,".concat(u-y*(h+m))],["a ".concat(m,",").concat(m,",0,0,").concat(g,",").concat(-b*m,",").concat(y*m)],["l ".concat(b*(m+v)-l,",0")],["a ".concat(v,",").concat(v,",0,0,").concat(g,",").concat(-b*v,",").concat(-y*v)],["l 0,".concat(y*(v+f)-u)],["a ".concat(f,",").concat(f,",0,0,").concat(g,",").concat(b*f,",").concat(-y*f)],["z"]].join(" ")}else d="M ".concat(i,",").concat(c," l ").concat(l,",0 l 0,").concat(u," l").concat(-l," 0 z");t.setAttribute("d",d)}}function g(t,e){return(e||document).createElementNS("http://www.w3.org/2000/svg",t)}var A="g-filter-";function E(t,e,n,r,a){var i=A+n.entity,o=e.querySelectorAll("[name=".concat(i,"]"));if(o.length&&o.forEach((function(t){e.removeChild(t)})),0===a.length)null==r||r.removeAttribute("filter");else{var c=a.map((function(n,r){var a=n.name,o=n.params,c=g("filter",t);return c.setAttribute("filterUnits","userSpaceOnUse"),"blur"===a?function(t,e,n){var r=g("feGaussianBlur",t);r.setAttribute("in","SourceGraphic"),r.setAttribute("stdDeviation","".concat(n[0].value)),e.appendChild(r)}(t,c,o):"brightness"===a?function(t,e,n){var r=S(n[0]);x(t,e,{type:"linear",slope:r,intercept:0})}(t,c,o):"drop-shadow"===a?function(t,e,n){var r=n[0].value,a=n[1].value,i=n[2].value,o=n[3].formatted,c=g("feGaussianBlur",t);c.setAttribute("in","SourceAlpha"),c.setAttribute("stdDeviation","".concat(i)),e.appendChild(c);var l=g("feOffset",t);l.setAttribute("dx","".concat(r)),l.setAttribute("dy","".concat(a)),l.setAttribute("result","offsetblur"),e.appendChild(l);var s=g("feFlood",t);s.setAttribute("flood-color",o),e.appendChild(s);var u=g("feComposite",t);u.setAttribute("in2","offsetblur"),u.setAttribute("operator","in"),e.appendChild(u);var d=g("feMerge",t);e.appendChild(d);var p=g("feMergeNode",t),f=g("feMergeNode",t);f.setAttribute("in","SourceGraphic"),d.appendChild(p),d.appendChild(f)}(t,c,o):"contrast"===a?function(t,e,n){var r=S(n[0]);x(t,e,{type:"linear",slope:r,intercept:-.5*r+.5})}(t,c,o):"grayscale"===a?function(t,e,n){var r=S(n[0]);C(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"===a?function(t,e,n){var r=S(n[0]);C(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"===a?function(t,e,n){var r=S(n[0]),a=g("feColorMatrix",t);a.setAttribute("type","saturate"),a.setAttribute("values","".concat(r)),e.appendChild(a)}(t,c,o):"hue-rotate"===a?function(t,e,n){var r=g("feColorMatrix",t);r.setAttribute("type","hueRotate"),r.setAttribute("values","".concat(n[0].value)),e.appendChild(r)}(t,c,o):"invert"===a&&function(t,e,n){var r=S(n[0]);x(t,e,{type:"table",tableValues:"".concat(r," ").concat(1-r)})}(t,c,o),c.id="".concat(i,"-").concat(r),c.setAttribute("name",i),e.appendChild(c),c.id}));setTimeout((function(){null==r||r.setAttribute("filter",c.map((function(t){return"url(#".concat(t,")")})).join(" "))}))}}function S(t){return t.unit===e.UnitType.kPercentage?t.value/100:t.value}function x(t,e,n){var r=n.type,a=n.slope,i=n.intercept,o=n.tableValues,c=g("feComponentTransfer",t);[g("feFuncR",t),g("feFuncG",t),g("feFuncB",t)].forEach((function(t){t.setAttribute("type",r),"table"===r?t.setAttribute("tableValues","".concat(o)):(t.setAttribute("slope","".concat(a)),t.setAttribute("intercept","".concat(i))),c.appendChild(t)})),e.appendChild(c)}function C(t,e,n){var r=g("feColorMatrix",t);r.setAttribute("type","matrix"),r.setAttribute("values",n.join(" ")),e.appendChild(r)}var O="g-pattern-",M={},w=0;function G(t,n,r,a,i,o,c,s){if(!i)return"";if(!e.isCSSRGB(i)){if(e.isPattern(i)){var u=function(t,n,r,a,i,o){var c=T(a),s=n.querySelector("#".concat(c));if(!s){var u=a.image,d="";if(l(u)?d=u:e.isBrowser&&(u instanceof HTMLImageElement?d=u.src:u instanceof HTMLCanvasElement&&(d=u.toDataURL())),d){var p,f=g("image",t);f.setAttribute("href",d),i?p=i(d):e.isBrowser&&(p=new window.Image),d.match(/^data:/i)||(p.crossOrigin="Anonymous",f.setAttribute("crossorigin","anonymous")),p.src=d;var h=function(){var e=k(t,n,r,a,c,p.width,p.height);n.appendChild(e),e.appendChild(f),f.setAttribute("x","0"),f.setAttribute("y","0"),f.setAttribute("width","".concat(p.width)),f.setAttribute("height","".concat(p.height))};p.complete?h():p.onload=h}if("rect"===u.nodeName){var m=u.parsedStyle,v=k(t,n,u,a,c,m.width,m.height);u.forEach((function(e){o.createSVGDom(t,e,null);var n=e.elementSVG,r=e.getLocalTransform();o.applyTransform(n.$groupEl,r)})),v.appendChild(u.elementSVG.$groupEl)}}return c}(t,n,r,i,c,s);return a.style[o]="url(#".concat(u,")"),u}if(1===i.length){var d=L(t,r,n,a,i[0]);return null==a||a.setAttribute(o,"url(#".concat(d,")")),d}var p=function(t,e,n,r,a){var i=A+e.entity+"-gradient",o=n.querySelector("#".concat(i));o||((o=g("filter",t)).setAttribute("filterUnits","userSpaceOnUse"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.id=i,n.appendChild(o));var c=0;a.forEach((function(a,l){var s=L(t,e,n,r,a),u=s+"_rect",d=g("rect",t);d.setAttribute("x","0"),d.setAttribute("y","0"),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill","url(#".concat(s,")")),d.id=u,n.appendChild(d);var p=g("feImage",t);if(p.setAttribute("href","#".concat(u)),p.setAttribute("result","".concat(i,"-").concat(l)),o.appendChild(p),l>0){var f=g("feBlend",t);f.setAttribute("in",1===l?"".concat(i,"-").concat(l-1):"".concat(i,"-blended-").concat(c-1)),f.setAttribute("in2","".concat(i,"-").concat(l)),f.setAttribute("result","".concat(i,"-blended-").concat(c++)),f.setAttribute("mode","multiply"),o.appendChild(f)}}));var l=g("feComposite",t);return l.setAttribute("in","".concat(i,"-blended-").concat(c)),l.setAttribute("in2","SourceGraphic"),l.setAttribute("operator","in"),o.appendChild(l),i}(t,r,n,a,i);return null==a||a.setAttribute("filter","url(#".concat(p,")")),null==a||a.setAttribute("fill","black"),p}return"currentColor"===r.style[o]?null==a||a.setAttribute(o,"currentColor"):null==a||a.setAttribute(o,i.isNone?"none":""+i),""}function T(t,n){void 0===n&&(n={});var a="";if(e.isCSSGradientValue(t)){var i=t.type;if(i===e.GradientType.LinearGradient||i===e.GradientType.RadialGradient){var o=r(r({},t.value),n),c=o.x,s=o.y,u=o.width,d=o.height,p=o.steps,f=o.angle,h=o.cx,m=o.cy,v=o.size;a="gradient-".concat(o.type,"-").concat((null==c?void 0:""+c)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==f?void 0:""+f)||0,"-").concat((null==h?void 0:""+h)||0,"-").concat((null==m?void 0:""+m)||0,"-").concat((null==v?void 0:""+v)||0,"-").concat(u,"-").concat(d,"-").concat(p.map((function(t){var e=t.color;return"".concat(t.offset).concat(e)})).join("-"))}}else e.isPattern(t)&&(a=l(t.image)?"pattern-".concat(t.image,"-").concat(t.repetition):"rect"===t.image.nodeName?"pattern-rect-".concat(t.image.entity):"pattern-".concat(w));return a&&(M[a]||(M[a]=O+"".concat(w++))),M[a]}function k(t,n,r,i,o,c,l){var s=i.repetition,u=i.transform,d=g("pattern",t);u&&d.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)return r=(null==n?void 0:n.map((function(t){return t.value})))||[1],"scale(".concat(r[0],", 1)");if("scaleY"===e)return r=(null==n?void 0:n.map((function(t){return t.value})))||[1],"scale(1, ".concat(r[0],")");if("skew"===e){var i=(null==n?void 0:n.map((function(t){return t.value})))||[0,0];return"skewX(".concat(i[0],") skewY(").concat(i[1],")")}if("skewZ"===e)return i=(null==n?void 0:n.map((function(t){return t.value})))||[0],"skewX(".concat(i[0],")");if("skewY"===e)return i=(null==n?void 0:n.map((function(t){return t.value})))||[0],"skewY(".concat(i[0],")");if("matrix"===e){var o=a(n.map((function(t){return t.value})),6),c=o[1],l=o[2],s=o[3],u=o[4],d=o[5];return"matrix(".concat(o[0]," ").concat(c," ").concat(l," ").concat(s," ").concat(u," ").concat(d,")")}})).join(" ")}(u)),d.setAttribute("patternUnits","userSpaceOnUse"),d.id=o,n.appendChild(d);var p=r.getGeometryBounds(),f=p.halfExtents,h=p.min;d.setAttribute("x","".concat(h[0])),d.setAttribute("y","".concat(h[1]));var m=c,v=l;return"repeat-x"===s?v=2*f[1]:"repeat-y"===s?m=2*f[0]:"no-repeat"===s&&(m=2*f[0],v=2*f[1]),d.setAttribute("width","".concat(m)),d.setAttribute("height","".concat(v)),d}function L(t,n,r,a,i){var o=n.getGeometryBounds(),c=o&&2*o.halfExtents[0]||0,l=o&&2*o.halfExtents[1]||0,s=o&&o.min||[0,0],u=T(i,{x:s[0],y:s[1],width:c,height:l}),d=r.querySelector("#".concat(u));if(!d){(d=g(i.type===e.GradientType.LinearGradient?"linearGradient":"radialGradient",t)).setAttribute("gradientUnits","userSpaceOnUse");var p="";i.value.steps.sort((function(t,e){return t.offset.value-e.offset.value})).forEach((function(t){var e=t.color;p+='<stop offset="'.concat(t.offset.value/100,'" stop-color="').concat(e,'"></stop>')})),d.innerHTML=p,d.id=u,r.appendChild(d)}if(i.type===e.GradientType.LinearGradient){var f=e.computeLinearGradient([s[0],s[1]],c,l,i.value.angle),h=f.y1,m=f.x2,v=f.y2;d.setAttribute("x1","".concat(f.x1)),d.setAttribute("y1","".concat(h)),d.setAttribute("x2","".concat(m)),d.setAttribute("y2","".concat(v))}else{var b=i.value,y=e.computeRadialGradient([s[0],s[1]],c,l,b.cx,b.cy,b.size),A=y.y,E=y.r;d.setAttribute("cx","".concat(y.x)),d.setAttribute("cy","".concat(A)),d.setAttribute("r","".concat(E))}return u}var P=/url\("?#(.*)\)/,D=function(){function t(t){this.context=t,this.gradientCache={}}return t.prototype.getDefElement=function(){return this.$def},t.prototype.init=function(){var t=this.context.config.document,e=this.context.contextService.getContext();this.$def=g("defs",t),e.appendChild(this.$def)},t.prototype.clear=function(t){var e=this;Object.keys(this.gradientCache).forEach((function(n){e.clearUnusedDefElement(e.gradientCache,n,t)}))},t.prototype.clearUnusedDefElement=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)}},t.prototype.createOrUpdateGradientAndPattern=function(t,n,r,a,i){var o=this.context.config,c=o.document,l=o.createImage;if(n){var s=(e.isPattern(r)?n.style[a]:n.getAttribute(a)||"").match(P);s&&s.length>1&&this.clearUnusedDefElement(this.gradientCache,s[1].replace('"',""),t.entity);var u=G(c||document,this.$def,t,n,r,a,l,i);u&&(this.gradientCache[u]||(this.gradientCache[u]=new Set),this.gradientCache[u].add(t.entity))}},t.prototype.createOrUpdateShadow=function(t,e,n){!function(t,e,n,r,a){var o=n.parsedStyle,c=o.shadowType,l=void 0===c?"outer":c,s=o.shadowBlur,u=o.shadowColor,d=o.shadowOffsetX,p=o.shadowOffsetY,f=!i(u)&&s>0,h="g-filter-dropshadow-"+n.entity,m=e.querySelector("#".concat(h));if(m&&(m.getAttribute("data-type")===l&&f||(m.remove(),m=null)),f){if(null==r||r.setAttribute("filter","url(#".concat(h,")")),!m){if((m=g("filter",t)).setAttribute("data-type",l),"outer"===l)(w=g("feDropShadow",t)).setAttribute("dx","".concat((d||0)/2)),w.setAttribute("dy","".concat((p||0)/2)),w.setAttribute("stdDeviation","".concat((s||0)/4)),w.setAttribute("flood-color",""+u),m.appendChild(w);else if("inner"===l){var v=g("feComponentTransfer",t);v.setAttribute("in","SourceAlpha");var b=g("feFuncA",t);b.setAttribute("type","table"),b.setAttribute("tableValues","1 0"),v.appendChild(b),m.appendChild(v),(C=g("feGaussianBlur",t)).setAttribute("stdDeviation","".concat((s||0)/4)),m.appendChild(C),(O=g("feOffset",t)).setAttribute("dx","".concat((d||0)/2)),O.setAttribute("dy","".concat((p||0)/2)),O.setAttribute("result","offsetblur"),m.appendChild(O),(M=g("feFlood",t)).setAttribute("flood-color",""+u),M.setAttribute("result","color"),m.appendChild(M);var y=g("feComposite",t);y.setAttribute("in2","offsetblur"),y.setAttribute("operator","in"),m.appendChild(y);var A=g("feComposite",t);A.setAttribute("in2","SourceAlpha"),A.setAttribute("operator","in"),m.appendChild(A);var E=g("feMerge",t);m.appendChild(E);var S=g("feMergeNode",t);S.setAttribute("in","SourceGraphic");var x=g("feMergeNode",t);E.appendChild(S),E.appendChild(x)}return m.id=h,m.setAttribute("filterUnits","userSpaceOnUse"),void e.appendChild(m)}if("inner"===l){var C=m.children[1],O=m.children[2],M=m.children[3];"shadowColor"===a?M.setAttribute("flood-color",""+u):"shadowBlur"===a?C.setAttribute("stdDeviation","".concat((s||0)/4)):"shadowOffsetX"===a?O.setAttribute("dx","".concat((d||0)/2)):"shadowOffsetY"===a&&O.setAttribute("dy","".concat((p||0)/2))}else if("outer"===l){var w=m.children[0];"shadowColor"===a?w.setAttribute("flood-color",""+u):"shadowBlur"===a?w.setAttribute("stdDeviation","".concat((s||0)/4)):"shadowOffsetX"===a?w.setAttribute("dx","".concat((d||0)/2)):"shadowOffsetY"===a&&w.setAttribute("dy","".concat((p||0)/2))}}else null==r||r.removeAttribute("filter")}(this.context.config.document||document,this.$def,t,e,n)},t.prototype.createOrUpdateFilter=function(t,e,n){E(this.context.config.document||document,this.$def,t,e,n)},t}();function V(t){return t.toFixed(6).replace(".000000","")}function U(t){return t.replace(/[&|<|>|"|']/g,(function(t){return"&"===t?"&":"<"===t?"<":">"===t?">":'"'===t?""":"'"}))}var N,R,I={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"},$={textAlign:{inherit:"inherit",left:"left",start:"left",center:"middle",right:"end",end:"end"}},H={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)"},F="g-svg",_="clip-path-",j="text-path-",B=function(){function t(t,e,n){this.pluginOptions=t,this.defElementManager=e,this.context=n,this.svgElementMap=new WeakMap,this.renderQueue=[],this.dirtyAttributes=new WeakMap,this.pendingReorderQueue=new Set,this.clipPathUseMap=new WeakMap}return t.prototype.apply=function(n){var r=this,a=n.renderingService,i=n.renderingContext;this.context=n,this.context.svgElementMap=this.svgElementMap;var o=i.root.ownerDocument.defaultView,c=this.context.config.document,l=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)},s=function(t){var e=t.target;r.defElementManager.clear(e.entity),r.clipPathUseMap.delete(e),r.removeSVGDom(e)},u=function(t){var e,n,a=t.parentNode,i=null===(n=null===(e=t.parentNode)||void 0===e?void 0:e.elementSVG)||void 0===n?void 0:n.$groupEl,o=((null==a?void 0:a.children)||[]).slice();i&&r.reorderChildren(c,i,o)},f=function(t){u(t.target)},h=function(t){var e=t.target;if(e.elementSVG){var n=t.attrName,a=r.dirtyAttributes.get(e);a||(r.dirtyAttributes.set(e,[]),a=r.dirtyAttributes.get(e)),a.push(n)}},m=function(t){var n,a=t.target,i=null===(n=a.elementSVG)||void 0===n?void 0:n.$el,o=a.parsedStyle,c=o.fill,l=o.stroke,s=o.clipPath;if(c&&!e.isCSSRGB(c)&&r.defElementManager.createOrUpdateGradientAndPattern(a,i,c,"fill",r),l&&!e.isCSSRGB(l)&&r.defElementManager.createOrUpdateGradientAndPattern(a,i,l,"stroke",r),s){var u=p(d(),a.getWorldTransform()),f=_+s.entity+"-"+a.entity,h=r.defElementManager.getDefElement().querySelector("#".concat(f));h&&r.applyTransform(h,u)}};a.hooks.init.tap(t.tag,(function(){var t=r.context.config,n=t.background,a=t.document;r.defElementManager.init();var i=r.context.contextService.getContext();n&&(i.style.background=n),i.setAttribute("color-interpolation-filters","sRGB"),r.$camera=g("g",a),r.$camera.id="".concat(F,"-camera"),r.applyTransform(r.$camera,r.context.camera.getOrthoMatrix()),i.appendChild(r.$camera),o.addEventListener(e.ElementEvent.MOUNTED,l),o.addEventListener(e.ElementEvent.UNMOUNTED,s),o.addEventListener(e.ElementEvent.REPARENT,f),o.addEventListener(e.ElementEvent.ATTR_MODIFIED,h),o.addEventListener(e.ElementEvent.BOUNDS_CHANGED,m)})),a.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(e.ElementEvent.MOUNTED,l),o.removeEventListener(e.ElementEvent.UNMOUNTED,s),o.removeEventListener(e.ElementEvent.REPARENT,f),o.removeEventListener(e.ElementEvent.ATTR_MODIFIED,h),o.removeEventListener(e.ElementEvent.BOUNDS_CHANGED,m),w=0,M={}})),a.hooks.render.tap(t.tag,(function(t){r.renderQueue.push(t)})),a.hooks.beginFrame.tap(t.tag,(function(){var t=r.context.config.document;r.pendingReorderQueue.size&&(r.pendingReorderQueue.forEach((function(e){var n,a=((null==e?void 0:e.children)||[]).slice(),i=null===(n=null==e?void 0:e.elementSVG)||void 0===n?void 0:n.$groupEl;i&&r.reorderChildren(t||c,i,a||[])})),r.pendingReorderQueue.clear())})),a.hooks.endFrame.tap(t.tag,(function(){i.renderReasons.has(e.RenderReason.CAMERA_CHANGED)&&r.applyTransform(r.$camera,r.context.camera.getOrthoMatrix()),r.renderQueue.forEach((function(t){var e,n,a=null===(e=t.elementSVG)||void 0===e?void 0:e.$el,i=null===(n=t.elementSVG)||void 0===n?void 0:n.$groupEl;if(a&&i){var o=t.getLocalTransform();r.applyTransform(i,o);var c=r.clipPathUseMap.get(t);c&&c.length&&c.forEach((function(e){r.applyTransform(e,t.getWorldTransform())})),t.renderable.dirty=!1}var l=r.dirtyAttributes.get(t);l&&(l.forEach((function(e){"zIndex"===e?u(t):"increasedLineWidthForHitTesting"===e&&r.createOrUpdateHitArea(t,a,i),r.updateAttribute(t,[e])})),r.dirtyAttributes.delete(t))})),r.renderQueue=[]}))},t.prototype.getId=function(t){return t.id||"".concat(F,"-").concat(t.entity)},t.prototype.reorderChildren=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)}},t.prototype.applyTransform=function(t,e){var n="matrix(".concat(V(e[0]),",").concat(V(e[1]),",").concat(V(e[4]),",").concat(V(e[5]),",").concat(V(e[12]),",").concat(V(e[13]),")");n!==t.getAttribute("transform")&&t.setAttribute("transform",n),n===H.transform&&t.removeAttribute("transform")},t.prototype.applyAttributes=function(t){var n=t.elementSVG,r=null==n?void 0:n.$el;if(r&&(null==n?void 0:n.$groupEl)){var a=t.nodeName,i=t.attributes;a!==e.Shape.HTML&&r.setAttribute("fill","none"),a===e.Shape.IMAGE&&r.setAttribute("preserveAspectRatio","none"),this.updateAttribute(t,Object.keys(i))}},t.prototype.updateAttribute=function(t,n){var r=this,a=this.context.enableCSSParsing,o=this.context.config.document,c=t.elementSVG,l=c.$el,s=c.$groupEl,u=c.$hitTestingEl,d=t.parsedStyle,p=t.computedStyle,f=t.nodeName;n.some((function(e){return r.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(t,e)}))&&l&&[l,u].forEach((function(e){e&&r.context.SVGElementLifeCycleContribution.updateElementAttribute(t,e,r.svgElementMap)})),n.forEach((function(n){var c,h,m=I[n],v=a?p[n]:d[n],b=!i(v)&&""+v,y=(null===(c=$[n])||void 0===c?void 0:c[b])||b,g=d[n],A=m&&!!(null===(h=e.propertyMetadataCache[n])||void 0===h?void 0:h.inh);if(f===e.Shape.HTML)"fill"===n?l.style.background=""+g:"stroke"===n?(l.style["border-color"]=""+g,l.style["border-style"]="solid"):"lineWidth"===n?l.style["border-width"]="".concat(g||0,"px"):"lineDash"===n?l.style["border-style"]="dashed":"innerHTML"===n?r.createOrUpdateInnerHTML(o,l,g):"width"===n||"height"===n||"class"===n?l.setAttribute(n,""+g):i(t.style[n])||""===t.style[n]||(l.style[n]=t.style[n]);else{if(!m||(f===e.Shape.GROUP||t.isCustomElement)&&!a&&(A||"fill"===m||"stroke"===m))return;"fill"===n||"stroke"===n?r.defElementManager.createOrUpdateGradientAndPattern(t,l,g,m,r):a&&A?"unset"!==b&&b!==H[n]?null==s||s.setAttribute(m,y):null==s||s.removeAttribute(m):"clipPath"===n?r.createOrUpdateClipOrTextPath(o,g,t):"textPath"===n?r.createOrUpdateClipOrTextPath(o,g,t,!0):"shadowType"===n||"shadowColor"===n||"shadowBlur"===n||"shadowOffsetX"===n||"shadowOffsetY"===n?r.defElementManager.createOrUpdateShadow(t,l,n):"filter"===n?r.defElementManager.createOrUpdateFilter(t,l,g):i(v)||[l,u].forEach((function(t){t&&m&&("unset"!==b&&b!==H[n]?t.setAttribute(m,y):t.removeAttribute(m))}))}}))},t.prototype.createSVGDom=function(t,n,r,a){var i;void 0===a&&(a=!1),n.elementSVG=new f;var o=n.elementSVG,c=this.context.SVGElementLifeCycleContribution.createElement(n,this.svgElementMap);if(c){var l=void 0;n.nodeName===e.Shape.HTML&&(n.parsedStyle.$el=c),this.pluginOptions.outputSVGElementId&&(c.id=this.getId(n)),this.pluginOptions.outputSVGElementName&&n.name&&c.setAttribute("name",n.name),!c.hasAttribute("data-wrapgroup")&&"g"===c.nodeName||a?l=c:(l=g("g",t)).appendChild(c),o.$el=c,o.$groupEl=l,this.applyAttributes(n),this.createOrUpdateHitArea(n,c,l);var s=r||n.parentNode&&(null===(i=n.parentNode.elementSVG)||void 0===i?void 0:i.$groupEl);s&&(s.appendChild(l),this.pendingReorderQueue.add(n.parentNode))}},t.prototype.removeSVGDom=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))},t.prototype.createOrUpdateHitArea=function(t,e,n){var r=t.elementSVG,a=r.$hitTestingEl,i=Number(t.parsedStyle.increasedLineWidthForHitTesting);if(i){if(!a){a=e.cloneNode(),["filter"].forEach((function(t){a.removeAttribute(t)}));var o="none"!==e.getAttribute("fill");a.setAttribute("fill",o?"transparent":"none"),a.setAttribute("stroke","transparent"),n.appendChild(a),r.$hitTestingEl=a,this.svgElementMap.set(a,t)}a.setAttribute("stroke-width","".concat(i+t.parsedStyle.lineWidth))}else a&&(n.removeChild(a),r.$hitTestingEl=null)},t.prototype.createOrUpdateInnerHTML=function(t,e,n){var r=(t||document).createElement("div");"string"==typeof n?r.innerHTML=n:r.appendChild(n),e.innerHTML="",e.appendChild(r)},t.prototype.createOrUpdateClipOrTextPath=function(t,e,n,r){void 0===r&&(r=!1);var a=n.elementSVG.$groupEl,i=r?"g":"clipPath",o=r?"text-path":"clip-path";if(e){var c=(r?j:_)+e.entity+"-"+n.entity,l=this.defElementManager.getDefElement();if(!l.querySelector("#".concat(c))){var s=void 0;if(r)this.createSVGDom(t,e,null,!0),s=e.elementSVG.$el;else{if(!e.isConnected)l.querySelector("#".concat(this.getId(e)))||this.createSVGDom(t,e,l,!0);s=g(i,t);var u=g("use",t);u.setAttribute("href","#".concat(e.elementSVG.$el.id)),s.appendChild(u);var f=this.clipPathUseMap.get(e);f||(this.clipPathUseMap.set(e,[]),f=this.clipPathUseMap.get(e)),f.push(u),this.applyTransform(u,e.getWorldTransform());var h=p(d(),n.getWorldTransform());this.applyTransform(s,h)}this.pluginOptions.outputSVGElementId&&(s.id=c),l.appendChild(s)}this.applyAttributes(e),r||a.setAttribute(o,"url(#".concat(c,")"))}else r||a.removeAttribute(o)},t.tag="SVGRenderer",t}(),W={top:"hanging",middle:"central",bottom:"text-after-edge",alphabetic:"alphabetic",ideographic:"ideographic",hanging:"hanging"};function X(t,e,n,r){n.getBounds();var a=e.lineWidth,i=void 0===a?1:a,o=e.x,c=void 0===o?0:o,l=e.y,s=void 0===l?0:l,u=e.dx,d=void 0===u?0:u,p=e.dy,f=void 0===p?0:p,h=e.textPath,m=e.textPathSide,v=void 0===m?"left":m,b=e.textPathStartOffset,y=void 0===b?0:b,A=e.textDecorationLine,E=void 0===A?"":A,S=e.textDecorationColor,x=void 0===S?"":S,C=e.textDecorationStyle,O=void 0===C?"":C,M=e.metrics,w=e.textBaseline,G=void 0===w?"alphabetic":w;r.enableCSSParsing||"alphabetic"!==G||(G="bottom"),t.setAttribute("dominant-baseline",W[G]),t.setAttribute("paint-order","stroke");var T=M.lines,k=M.lineHeight,L=M.height,P=T.length,D="";if(0===d&&0===f||(D+="transform:translate(".concat(d,"px, ").concat(f,"px);")),E&&"none"!==E&&(D+="text-decoration:".concat(E," ").concat(O," ").concat(x,";")),D&&t.setAttribute("style",D),0!==c&&t.setAttribute("x","".concat(c)),0!==s&&t.setAttribute("y","".concat(s)),1===P){var V=U(T[0]);if(t.setAttribute("dx","".concat(i/2)),"bottom"!==G&&"top"!==G||(t.setAttribute("dominant-baseline",W.middle),t.setAttribute("dy","bottom"===G?"-".concat(L/2,"px"):"".concat(L/2,"px"))),h){t.innerHTML="";var N=g("textPath",t.ownerDocument);N.setAttribute("href","#".concat(j+h.entity)),"left"!==v&&N.setAttribute("side",v),0!==y&&N.setAttribute("startOffset","".concat(y)),N.innerHTML=V,t.appendChild(N)}else t.innerHTML=V}else t.innerHTML=T.map((function(t,e){var n=i/2,r=0;return 0===e?"middle"===G?r=k/2-L/2:"top"===G||"hanging"===G?r=0:"bottom"!==G&&"alphabetic"!==G&&"ideographic"!==G||(r=-k*(P-1)):r=k,"<tspan x=".concat(c,' dx="').concat(n,'" dy="').concat(r,'">').concat(U(t),"</tspan>")})).join("")}var Y=((N={})[e.Shape.RECT]="path",N[e.Shape.CIRCLE]="circle",N[e.Shape.ELLIPSE]="ellipse",N[e.Shape.IMAGE]="image",N[e.Shape.GROUP]="g",N[e.Shape.LINE]="line",N[e.Shape.POLYLINE]="polyline",N[e.Shape.POLYGON]="polygon",N[e.Shape.TEXT]="text",N[e.Shape.PATH]="path",N[e.Shape.HTML]="foreignObject",N),q=((R={})[e.Shape.CIRCLE]=["cx","cy","r"],R[e.Shape.ELLIPSE]=["cx","cy","rx","ry"],R[e.Shape.RECT]=["x","y","width","height","radius"],R[e.Shape.IMAGE]=["x","y","src","width","height"],R[e.Shape.LINE]=["x1","y1","x2","y2","markerStart","markerEnd","markerStartOffset","markerEndOffset"],R[e.Shape.POLYLINE]=["points","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"],R[e.Shape.POLYGON]=["points","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"],R[e.Shape.PATH]=["d","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"],R[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"],R),z=function(){function t(t,e){this.context=t,this.runtime=e}return t.prototype.createElement=function(t,e){var n=g(Y[t.nodeName]||"g",this.context.config.document||document);return e.set(n,t),n},t.prototype.destroyElement=function(t,e){},t.prototype.shouldUpdateElementAttribute=function(t,e){return(q[t.nodeName]||[]).indexOf(e)>-1},t.prototype.updateElementAttribute=function(t){var n=t.elementSVG.$el,r=t.parsedStyle;switch(t.nodeName){case e.Shape.IMAGE:h(n,r);break;case e.Shape.RECT:y(n,r);break;case e.Shape.LINE:m(n,r);break;case e.Shape.POLYGON:case e.Shape.POLYLINE:b(n,r);break;case e.Shape.PATH:v(n,r);break;case e.Shape.TEXT:X(n,r,t,this.runtime)}},t}(),Q=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="svg-renderer",n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.init=function(t){var e=this.options,n=e.outputSVGElementId,r=e.outputSVGElementName,a=new D(this.context),o=new z(this.context,t);this.context.defaultElementLifeCycleContribution=o,this.context.SVGElementLifeCycleContribution=o;var c={outputSVGElementId:!!i(n)||!!n,outputSVGElementName:!!i(r)||!!r};this.addRenderingPlugin(new B(c,a,this.context))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultElementLifeCycleContribution,delete this.context.SVGElementLifeCycleContribution},e}(e.AbstractRendererPlugin);t.CLIP_PATH_PREFIX=_,t.DEFAULT_VALUE_MAP=H,t.DefaultElementLifeCycleContribution=z,t.ElementSVG=f,t.G_SVG_PREFIX=F,t.Plugin=Q,t.SHAPE2TAGS=Y,t.SHAPE_UPDATE_DEPS=q,t.SVGRendererPlugin=B,t.SVG_ATTR_MAP=I,t.TEXT_PATH_PREFIX=j,t.createSVGElement=g,t.updateImageElementAttribute=h,t.updateLineElementAttribute=m,t.updatePathElementAttribute=v,t.updatePolylineElementAttribute=b,t.updateRectElementAttribute=y,t.updateTextElementAttribute=X})); | ||
!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.SVGRenderer={}),t.window.G)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r=function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},r.apply(this,arguments)};function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,i=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return o}"function"==typeof SuppressedError&&SuppressedError;var i=function(t){return null==t},o={}.toString,c=function(t,e){return o.call(t)==="[object "+e+"]"},l=function(t){return c(t,"String")},s=function(t,e,n){return e>t?e:t>n?n:t},u="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var t=new u(16);return u!=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 p(t,e){var n=e[0],r=e[1],a=e[2],i=e[3],o=e[4],c=e[5],l=e[6],s=e[7],u=e[8],d=e[9],p=e[10],f=e[11],h=e[12],m=e[13],v=e[14],b=e[15],y=n*c-r*o,g=n*l-a*o,A=n*s-i*o,E=r*l-a*c,S=r*s-i*c,x=a*s-i*l,C=u*m-d*h,O=u*v-p*h,M=u*b-f*h,w=d*v-p*m,G=d*b-f*m,T=p*b-f*v,k=y*T-g*G+A*w+E*M-S*O+x*C;return k?(t[0]=(c*T-l*G+s*w)*(k=1/k),t[1]=(a*G-r*T-i*w)*k,t[2]=(m*x-v*S+b*E)*k,t[3]=(p*S-d*x-f*E)*k,t[4]=(l*M-o*T-s*O)*k,t[5]=(n*T-a*M+i*O)*k,t[6]=(v*A-h*x-b*g)*k,t[7]=(u*x-p*A+f*g)*k,t[8]=(o*G-c*M+s*C)*k,t[9]=(r*M-n*G-i*C)*k,t[10]=(h*S-m*A+b*y)*k,t[11]=(d*A-u*S-f*y)*k,t[12]=(c*O-o*w-l*C)*k,t[13]=(n*w-r*O+a*C)*k,t[14]=(m*g-h*E-v*y)*k,t[15]=(u*E-d*g+p*y)*k,t):null}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var f=function(){function t(){}return t.tag="c-svg-element",t}();function h(t,e){var n=e.src,r=void 0===n?"":n,a=e.x,i=e.y,o=void 0===i?0:i,c=e.width,s=e.height;if(t.setAttribute("x","".concat(void 0===a?0:a)),t.setAttribute("y","".concat(o)),l(r))t.setAttribute("href",r);else if(r instanceof Image)c||t.setAttribute("width","".concat(r.width)),s||t.setAttribute("height","".concat(r.height)),t.setAttribute("href",r.src);else if(r instanceof HTMLElement&&l(r.nodeName)&&"CANVAS"===r.nodeName.toUpperCase())t.setAttribute("href",r.toDataURL());else if(r instanceof ImageData){var u=document.createElement("canvas");u.setAttribute("width","".concat(r.width)),u.setAttribute("height","".concat(r.height));var d=u.getContext("2d");d&&(d.putImageData(r,0,0),c||t.setAttribute("width","".concat(r.width)),s||t.setAttribute("height","".concat(r.height)),t.setAttribute("href",u.toDataURL()))}}function m(t,n){var r=n.x1,a=n.y1,i=n.x2,o=n.y2,c=n.markerStart,l=n.markerEnd,s=n.markerStartOffset,u=n.markerEndOffset,d=0,p=0,f=0,h=0,m=0;c&&e.isDisplayObject(c)&&s&&(d=Math.cos(m=Math.atan2(o-a,i-r))*(s||0),p=Math.sin(m)*(s||0)),l&&e.isDisplayObject(l)&&u&&(f=Math.cos(m=Math.atan2(a-o,r-i))*(u||0),h=Math.sin(m)*(u||0)),t.setAttribute("x1","".concat(r+d)),t.setAttribute("y1","".concat(a+p)),t.setAttribute("x2","".concat(i+f)),t.setAttribute("y2","".concat(o+h))}function v(t,n){var r=n.d,i=n.markerStart,o=n.markerEnd,c=n.markerStartOffset,l=n.markerEndOffset,s=0,u=0,d=0,p=0,f=0;if(i&&e.isDisplayObject(i)&&c){var h=a(i.parentNode.getStartTangent(),2);s=Math.cos(f=Math.atan2((m=h[0])[1]-(v=h[1])[1],m[0]-v[0]))*(c||0),u=Math.sin(f)*(c||0)}if(o&&e.isDisplayObject(o)&&l){var m,v,b=a(o.parentNode.getEndTangent(),2);d=Math.cos(f=Math.atan2((m=b[0])[1]-(v=b[1])[1],m[0]-v[0]))*(l||0),p=Math.sin(f)*(l||0)}t.setAttribute("d",e.translatePathToString(r.absolutePath,s,u,d,p))}function b(t,n){var r=n.points.points,a=n.markerStart,i=n.markerStartOffset,o=n.markerEnd,c=n.markerEndOffset,l=r.length;if(r&&l>=2){var s=0,u=0,d=0,p=0,f=0;a&&e.isDisplayObject(a)&&i&&(s=Math.cos(f=Math.atan2(r[1][1]-r[0][1],r[1][0]-r[0][0]))*(i||0),u=Math.sin(f)*(i||0)),o&&e.isDisplayObject(o)&&c&&(d=Math.cos(f=Math.atan2(r[l-2][1]-r[l-1][1],r[l-2][0]-r[l-1][0]))*(c||0),p=Math.sin(f)*(c||0)),t.setAttribute("points",r.map((function(t,e){var n=0,r=0;return 0===e?(n=s,r=u):e===l-1&&(n=d,r=p),"".concat(t[0]+n,",").concat(t[1]+r)})).join(" "))}}function y(t,e){var n=e.radius,r=e.x,i=void 0===r?0:r,o=e.y,c=void 0===o?0:o,l=e.width,u=e.height;if(isFinite(l)&&isFinite(u)){var d="";if(n&&n.some((function(t){return 0!==t}))){var p=a(n.map((function(t){return s(t,0,Math.min(Math.abs(l)/2,Math.abs(u)/2))})),4),f=p[0],h=p[1],m=p[2],v=p[3],b=l>0?1:-1,y=u>0?1:-1,g=b+y!==0?1:0;d=[["M ".concat(b*f+i,",").concat(c)],["l ".concat(l-b*(f+h),",0")],["a ".concat(h,",").concat(h,",0,0,").concat(g,",").concat(b*h,",").concat(y*h)],["l 0,".concat(u-y*(h+m))],["a ".concat(m,",").concat(m,",0,0,").concat(g,",").concat(-b*m,",").concat(y*m)],["l ".concat(b*(m+v)-l,",0")],["a ".concat(v,",").concat(v,",0,0,").concat(g,",").concat(-b*v,",").concat(-y*v)],["l 0,".concat(y*(v+f)-u)],["a ".concat(f,",").concat(f,",0,0,").concat(g,",").concat(b*f,",").concat(-y*f)],["z"]].join(" ")}else d="M ".concat(i,",").concat(c," l ").concat(l,",0 l 0,").concat(u," l").concat(-l," 0 z");t.setAttribute("d",d)}}function g(t,e){return(e||document).createElementNS("http://www.w3.org/2000/svg",t)}var A="g-filter-";function E(t,e,n,r,a){var i=A+n.entity,o=e.querySelectorAll("[name=".concat(i,"]"));if(o.length&&o.forEach((function(t){e.removeChild(t)})),0===a.length)null==r||r.removeAttribute("filter");else{var c=a.map((function(n,r){var a=n.name,o=n.params,c=g("filter",t);return c.setAttribute("filterUnits","userSpaceOnUse"),"blur"===a?function(t,e,n){var r=g("feGaussianBlur",t);r.setAttribute("in","SourceGraphic"),r.setAttribute("stdDeviation","".concat(n[0].value)),e.appendChild(r)}(t,c,o):"brightness"===a?function(t,e,n){var r=S(n[0]);x(t,e,{type:"linear",slope:r,intercept:0})}(t,c,o):"drop-shadow"===a?function(t,e,n){var r=n[0].value,a=n[1].value,i=n[2].value,o=n[3].formatted,c=g("feGaussianBlur",t);c.setAttribute("in","SourceAlpha"),c.setAttribute("stdDeviation","".concat(i)),e.appendChild(c);var l=g("feOffset",t);l.setAttribute("dx","".concat(r)),l.setAttribute("dy","".concat(a)),l.setAttribute("result","offsetblur"),e.appendChild(l);var s=g("feFlood",t);s.setAttribute("flood-color",o),e.appendChild(s);var u=g("feComposite",t);u.setAttribute("in2","offsetblur"),u.setAttribute("operator","in"),e.appendChild(u);var d=g("feMerge",t);e.appendChild(d);var p=g("feMergeNode",t),f=g("feMergeNode",t);f.setAttribute("in","SourceGraphic"),d.appendChild(p),d.appendChild(f)}(t,c,o):"contrast"===a?function(t,e,n){var r=S(n[0]);x(t,e,{type:"linear",slope:r,intercept:-.5*r+.5})}(t,c,o):"grayscale"===a?function(t,e,n){var r=S(n[0]);C(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"===a?function(t,e,n){var r=S(n[0]);C(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"===a?function(t,e,n){var r=S(n[0]),a=g("feColorMatrix",t);a.setAttribute("type","saturate"),a.setAttribute("values","".concat(r)),e.appendChild(a)}(t,c,o):"hue-rotate"===a?function(t,e,n){var r=g("feColorMatrix",t);r.setAttribute("type","hueRotate"),r.setAttribute("values","".concat(n[0].value)),e.appendChild(r)}(t,c,o):"invert"===a&&function(t,e,n){var r=S(n[0]);x(t,e,{type:"table",tableValues:"".concat(r," ").concat(1-r)})}(t,c,o),c.id="".concat(i,"-").concat(r),c.setAttribute("name",i),e.appendChild(c),c.id}));setTimeout((function(){null==r||r.setAttribute("filter",c.map((function(t){return"url(#".concat(t,")")})).join(" "))}))}}function S(t){return t.unit===e.UnitType.kPercentage?t.value/100:t.value}function x(t,e,n){var r=n.type,a=n.slope,i=n.intercept,o=n.tableValues,c=g("feComponentTransfer",t);[g("feFuncR",t),g("feFuncG",t),g("feFuncB",t)].forEach((function(t){t.setAttribute("type",r),"table"===r?t.setAttribute("tableValues","".concat(o)):(t.setAttribute("slope","".concat(a)),t.setAttribute("intercept","".concat(i))),c.appendChild(t)})),e.appendChild(c)}function C(t,e,n){var r=g("feColorMatrix",t);r.setAttribute("type","matrix"),r.setAttribute("values",n.join(" ")),e.appendChild(r)}var O="g-pattern-",M={},w=0;function G(t,n,r,a,i,o,c,s){if(!i)return"";if(!e.isCSSRGB(i)){if(e.isPattern(i)){var u=function(t,n,r,a,i,o){var c=T(a),s=n.querySelector("#".concat(c));if(!s){var u=a.image,d="";if(l(u)?d=u:e.isBrowser&&(u instanceof HTMLImageElement?d=u.src:u instanceof HTMLCanvasElement&&(d=u.toDataURL())),d){var p,f=g("image",t);f.setAttribute("href",d),i?p=i(d):e.isBrowser&&(p=new window.Image),d.match(/^data:/i)||(p.crossOrigin="Anonymous",f.setAttribute("crossorigin","anonymous")),p.src=d;var h=function(){var e=k(t,n,r,a,c,p.width,p.height);n.appendChild(e),e.appendChild(f),f.setAttribute("x","0"),f.setAttribute("y","0"),f.setAttribute("width","".concat(p.width)),f.setAttribute("height","".concat(p.height))};p.complete?h():p.onload=h}if("rect"===u.nodeName){var m=u.parsedStyle,v=k(t,n,u,a,c,m.width,m.height);u.forEach((function(e){o.createSVGDom(t,e,null);var n=e.elementSVG,r=e.getLocalTransform();o.applyTransform(n.$groupEl,r)})),v.appendChild(u.elementSVG.$groupEl)}}return c}(t,n,r,i,c,s);return a.style[o]="url(#".concat(u,")"),u}if(1===i.length){var d=L(t,r,n,a,i[0]);return null==a||a.setAttribute(o,"url(#".concat(d,")")),d}var p=function(t,e,n,r,a){var i=A+e.entity+"-gradient",o=n.querySelector("#".concat(i));o||((o=g("filter",t)).setAttribute("filterUnits","userSpaceOnUse"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.id=i,n.appendChild(o));var c=0;a.forEach((function(a,l){var s=L(t,e,n,r,a),u=s+"_rect",d=g("rect",t);d.setAttribute("x","0"),d.setAttribute("y","0"),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill","url(#".concat(s,")")),d.id=u,n.appendChild(d);var p=g("feImage",t);if(p.setAttribute("href","#".concat(u)),p.setAttribute("result","".concat(i,"-").concat(l)),o.appendChild(p),l>0){var f=g("feBlend",t);f.setAttribute("in",1===l?"".concat(i,"-").concat(l-1):"".concat(i,"-blended-").concat(c-1)),f.setAttribute("in2","".concat(i,"-").concat(l)),f.setAttribute("result","".concat(i,"-blended-").concat(c++)),f.setAttribute("mode","multiply"),o.appendChild(f)}}));var l=g("feComposite",t);return l.setAttribute("in","".concat(i,"-blended-").concat(c)),l.setAttribute("in2","SourceGraphic"),l.setAttribute("operator","in"),o.appendChild(l),i}(t,r,n,a,i);return null==a||a.setAttribute("filter","url(#".concat(p,")")),null==a||a.setAttribute("fill","black"),p}return"currentColor"===r.style[o]?null==a||a.setAttribute(o,"currentColor"):null==a||a.setAttribute(o,i.isNone?"none":""+i),""}function T(t,n){void 0===n&&(n={});var a="";if(e.isCSSGradientValue(t)){var i=t.type;if(i===e.GradientType.LinearGradient||i===e.GradientType.RadialGradient){var o=r(r({},t.value),n),c=o.x,s=o.y,u=o.width,d=o.height,p=o.steps,f=o.angle,h=o.cx,m=o.cy,v=o.size;a="gradient-".concat(o.type,"-").concat((null==c?void 0:""+c)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==f?void 0:""+f)||0,"-").concat((null==h?void 0:""+h)||0,"-").concat((null==m?void 0:""+m)||0,"-").concat((null==v?void 0:""+v)||0,"-").concat(u,"-").concat(d,"-").concat(p.map((function(t){var e=t.color;return"".concat(t.offset).concat(e)})).join("-"))}}else e.isPattern(t)&&(a=l(t.image)?"pattern-".concat(t.image,"-").concat(t.repetition):"rect"===t.image.nodeName?"pattern-rect-".concat(t.image.entity):"pattern-".concat(w));return a&&(M[a]||(M[a]=O+"".concat(w++))),M[a]}function k(t,n,r,i,o,c,l){var s=i.repetition,u=i.transform,d=g("pattern",t);u&&d.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)return r=(null==n?void 0:n.map((function(t){return t.value})))||[1],"scale(".concat(r[0],", 1)");if("scaley"===e)return r=(null==n?void 0:n.map((function(t){return t.value})))||[1],"scale(1, ".concat(r[0],")");if("skew"===e){var i=(null==n?void 0:n.map((function(t){return t.value})))||[0,0];return"skewX(".concat(i[0],") skewY(").concat(i[1],")")}if("skewx"===e)return i=(null==n?void 0:n.map((function(t){return t.value})))||[0],"skewX(".concat(i[0],")");if("skewy"===e)return i=(null==n?void 0:n.map((function(t){return t.value})))||[0],"skewY(".concat(i[0],")");if("matrix"===e){var o=a(n.map((function(t){return t.value})),6),c=o[1],l=o[2],s=o[3],u=o[4],d=o[5];return"matrix(".concat(o[0]," ").concat(c," ").concat(l," ").concat(s," ").concat(u," ").concat(d,")")}})).join(" ")}(u)),d.setAttribute("patternUnits","userSpaceOnUse"),d.id=o,n.appendChild(d);var p=r.getGeometryBounds(),f=p.halfExtents,h=p.min;d.setAttribute("x","".concat(h[0])),d.setAttribute("y","".concat(h[1]));var m=c,v=l;return"repeat-x"===s?v=2*f[1]:"repeat-y"===s?m=2*f[0]:"no-repeat"===s&&(m=2*f[0],v=2*f[1]),d.setAttribute("width","".concat(m)),d.setAttribute("height","".concat(v)),d}function L(t,n,r,a,i){var o=n.getGeometryBounds(),c=o&&2*o.halfExtents[0]||0,l=o&&2*o.halfExtents[1]||0,s=o&&o.min||[0,0],u=T(i,{x:s[0],y:s[1],width:c,height:l}),d=r.querySelector("#".concat(u));if(!d){(d=g(i.type===e.GradientType.LinearGradient?"linearGradient":"radialGradient",t)).setAttribute("gradientUnits","userSpaceOnUse");var p="";i.value.steps.sort((function(t,e){return t.offset.value-e.offset.value})).forEach((function(t){var e=t.color;p+='<stop offset="'.concat(t.offset.value/100,'" stop-color="').concat(e,'"></stop>')})),d.innerHTML=p,d.id=u,r.appendChild(d)}if(i.type===e.GradientType.LinearGradient){var f=e.computeLinearGradient([s[0],s[1]],c,l,i.value.angle),h=f.y1,m=f.x2,v=f.y2;d.setAttribute("x1","".concat(f.x1)),d.setAttribute("y1","".concat(h)),d.setAttribute("x2","".concat(m)),d.setAttribute("y2","".concat(v))}else{var b=i.value,y=e.computeRadialGradient([s[0],s[1]],c,l,b.cx,b.cy,b.size),A=y.y,E=y.r;d.setAttribute("cx","".concat(y.x)),d.setAttribute("cy","".concat(A)),d.setAttribute("r","".concat(E))}return u}var P=/url\("?#(.*)\)/,D=function(){function t(t){this.context=t,this.gradientCache={}}return t.prototype.getDefElement=function(){return this.$def},t.prototype.init=function(){var t=this.context.config.document,e=this.context.contextService.getContext();this.$def=g("defs",t),e.appendChild(this.$def)},t.prototype.clear=function(t){var e=this;Object.keys(this.gradientCache).forEach((function(n){e.clearUnusedDefElement(e.gradientCache,n,t)}))},t.prototype.clearUnusedDefElement=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)}},t.prototype.createOrUpdateGradientAndPattern=function(t,n,r,a,i){var o=this.context.config,c=o.document,l=o.createImage;if(n){var s=(e.isPattern(r)?n.style[a]:n.getAttribute(a)||"").match(P);s&&s.length>1&&this.clearUnusedDefElement(this.gradientCache,s[1].replace('"',""),t.entity);var u=G(c||document,this.$def,t,n,r,a,l,i);u&&(this.gradientCache[u]||(this.gradientCache[u]=new Set),this.gradientCache[u].add(t.entity))}},t.prototype.createOrUpdateShadow=function(t,e,n){!function(t,e,n,r,a){var o=n.parsedStyle,c=o.shadowType,l=void 0===c?"outer":c,s=o.shadowBlur,u=o.shadowColor,d=o.shadowOffsetX,p=o.shadowOffsetY,f=!i(u)&&s>0,h="g-filter-dropshadow-"+n.entity,m=e.querySelector("#".concat(h));if(m&&(m.getAttribute("data-type")===l&&f||(m.remove(),m=null)),f){if(null==r||r.setAttribute("filter","url(#".concat(h,")")),!m){if((m=g("filter",t)).setAttribute("data-type",l),"outer"===l)(w=g("feDropShadow",t)).setAttribute("dx","".concat((d||0)/2)),w.setAttribute("dy","".concat((p||0)/2)),w.setAttribute("stdDeviation","".concat((s||0)/4)),w.setAttribute("flood-color",""+u),m.appendChild(w);else if("inner"===l){var v=g("feComponentTransfer",t);v.setAttribute("in","SourceAlpha");var b=g("feFuncA",t);b.setAttribute("type","table"),b.setAttribute("tableValues","1 0"),v.appendChild(b),m.appendChild(v),(C=g("feGaussianBlur",t)).setAttribute("stdDeviation","".concat((s||0)/4)),m.appendChild(C),(O=g("feOffset",t)).setAttribute("dx","".concat((d||0)/2)),O.setAttribute("dy","".concat((p||0)/2)),O.setAttribute("result","offsetblur"),m.appendChild(O),(M=g("feFlood",t)).setAttribute("flood-color",""+u),M.setAttribute("result","color"),m.appendChild(M);var y=g("feComposite",t);y.setAttribute("in2","offsetblur"),y.setAttribute("operator","in"),m.appendChild(y);var A=g("feComposite",t);A.setAttribute("in2","SourceAlpha"),A.setAttribute("operator","in"),m.appendChild(A);var E=g("feMerge",t);m.appendChild(E);var S=g("feMergeNode",t);S.setAttribute("in","SourceGraphic");var x=g("feMergeNode",t);E.appendChild(S),E.appendChild(x)}return m.id=h,m.setAttribute("filterUnits","userSpaceOnUse"),void e.appendChild(m)}if("inner"===l){var C=m.children[1],O=m.children[2],M=m.children[3];"shadowColor"===a?M.setAttribute("flood-color",""+u):"shadowBlur"===a?C.setAttribute("stdDeviation","".concat((s||0)/4)):"shadowOffsetX"===a?O.setAttribute("dx","".concat((d||0)/2)):"shadowOffsetY"===a&&O.setAttribute("dy","".concat((p||0)/2))}else if("outer"===l){var w=m.children[0];"shadowColor"===a?w.setAttribute("flood-color",""+u):"shadowBlur"===a?w.setAttribute("stdDeviation","".concat((s||0)/4)):"shadowOffsetX"===a?w.setAttribute("dx","".concat((d||0)/2)):"shadowOffsetY"===a&&w.setAttribute("dy","".concat((p||0)/2))}}else null==r||r.removeAttribute("filter")}(this.context.config.document||document,this.$def,t,e,n)},t.prototype.createOrUpdateFilter=function(t,e,n){E(this.context.config.document||document,this.$def,t,e,n)},t}();function V(t){return t.toFixed(6).replace(".000000","")}function U(t){return t.replace(/[&|<|>|"|']/g,(function(t){return"&"===t?"&":"<"===t?"<":">"===t?">":'"'===t?""":"'"}))}var N,R,I={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"},$={textAlign:{inherit:"inherit",left:"left",start:"left",center:"middle",right:"end",end:"end"}},H={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)"},F="g-svg",_="clip-path-",j="text-path-",B=function(){function t(t,e,n){this.pluginOptions=t,this.defElementManager=e,this.context=n,this.svgElementMap=new WeakMap,this.renderQueue=[],this.dirtyAttributes=new WeakMap,this.pendingReorderQueue=new Set,this.clipPathUseMap=new WeakMap}return t.prototype.apply=function(n){var r=this,a=n.renderingService,i=n.renderingContext;this.context=n,this.context.svgElementMap=this.svgElementMap;var o=i.root.ownerDocument.defaultView,c=this.context.config.document,l=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)},s=function(t){var e=t.target;r.defElementManager.clear(e.entity),r.clipPathUseMap.delete(e),r.removeSVGDom(e)},u=function(t){var e,n,a=t.parentNode,i=null===(n=null===(e=t.parentNode)||void 0===e?void 0:e.elementSVG)||void 0===n?void 0:n.$groupEl,o=((null==a?void 0:a.children)||[]).slice();i&&r.reorderChildren(c,i,o)},f=function(t){u(t.target)},h=function(t){var e=t.target;if(e.elementSVG){var n=t.attrName,a=r.dirtyAttributes.get(e);a||(r.dirtyAttributes.set(e,[]),a=r.dirtyAttributes.get(e)),a.push(n)}},m=function(t){var n,a=t.target,i=null===(n=a.elementSVG)||void 0===n?void 0:n.$el,o=a.parsedStyle,c=o.fill,l=o.stroke,s=o.clipPath;if(c&&!e.isCSSRGB(c)&&r.defElementManager.createOrUpdateGradientAndPattern(a,i,c,"fill",r),l&&!e.isCSSRGB(l)&&r.defElementManager.createOrUpdateGradientAndPattern(a,i,l,"stroke",r),s){var u=p(d(),a.getWorldTransform()),f=_+s.entity+"-"+a.entity,h=r.defElementManager.getDefElement().querySelector("#".concat(f));h&&r.applyTransform(h,u)}};a.hooks.init.tap(t.tag,(function(){var t=r.context.config,n=t.background,a=t.document;r.defElementManager.init();var i=r.context.contextService.getContext();n&&(i.style.background=n),i.setAttribute("color-interpolation-filters","sRGB"),r.$camera=g("g",a),r.$camera.id="".concat(F,"-camera"),r.applyTransform(r.$camera,r.context.camera.getOrthoMatrix()),i.appendChild(r.$camera),o.addEventListener(e.ElementEvent.MOUNTED,l),o.addEventListener(e.ElementEvent.UNMOUNTED,s),o.addEventListener(e.ElementEvent.REPARENT,f),o.addEventListener(e.ElementEvent.ATTR_MODIFIED,h),o.addEventListener(e.ElementEvent.BOUNDS_CHANGED,m)})),a.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(e.ElementEvent.MOUNTED,l),o.removeEventListener(e.ElementEvent.UNMOUNTED,s),o.removeEventListener(e.ElementEvent.REPARENT,f),o.removeEventListener(e.ElementEvent.ATTR_MODIFIED,h),o.removeEventListener(e.ElementEvent.BOUNDS_CHANGED,m),w=0,M={}})),a.hooks.render.tap(t.tag,(function(t){r.renderQueue.push(t)})),a.hooks.beginFrame.tap(t.tag,(function(){var t=r.context.config.document;r.pendingReorderQueue.size&&(r.pendingReorderQueue.forEach((function(e){var n,a=((null==e?void 0:e.children)||[]).slice(),i=null===(n=null==e?void 0:e.elementSVG)||void 0===n?void 0:n.$groupEl;i&&r.reorderChildren(t||c,i,a||[])})),r.pendingReorderQueue.clear())})),a.hooks.endFrame.tap(t.tag,(function(){i.renderReasons.has(e.RenderReason.CAMERA_CHANGED)&&r.applyTransform(r.$camera,r.context.camera.getOrthoMatrix()),r.renderQueue.forEach((function(t){var e,n,a=null===(e=t.elementSVG)||void 0===e?void 0:e.$el,i=null===(n=t.elementSVG)||void 0===n?void 0:n.$groupEl;if(a&&i){var o=t.getLocalTransform();r.applyTransform(i,o);var c=r.clipPathUseMap.get(t);c&&c.length&&c.forEach((function(e){r.applyTransform(e,t.getWorldTransform())})),t.renderable.dirty=!1}var l=r.dirtyAttributes.get(t);l&&(l.forEach((function(e){"zIndex"===e?u(t):"increasedLineWidthForHitTesting"===e&&r.createOrUpdateHitArea(t,a,i),r.updateAttribute(t,[e])})),r.dirtyAttributes.delete(t))})),r.renderQueue=[]}))},t.prototype.getId=function(t){return t.id||"".concat(F,"-").concat(t.entity)},t.prototype.reorderChildren=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)}},t.prototype.applyTransform=function(t,e){var n="matrix(".concat(V(e[0]),",").concat(V(e[1]),",").concat(V(e[4]),",").concat(V(e[5]),",").concat(V(e[12]),",").concat(V(e[13]),")");n!==t.getAttribute("transform")&&t.setAttribute("transform",n),n===H.transform&&t.removeAttribute("transform")},t.prototype.applyAttributes=function(t){var n=t.elementSVG,r=null==n?void 0:n.$el;if(r&&(null==n?void 0:n.$groupEl)){var a=t.nodeName,i=t.attributes;a!==e.Shape.HTML&&r.setAttribute("fill","none"),a===e.Shape.IMAGE&&r.setAttribute("preserveAspectRatio","none"),this.updateAttribute(t,Object.keys(i))}},t.prototype.updateAttribute=function(t,n){var r=this,a=this.context.enableCSSParsing,o=this.context.config.document,c=t.elementSVG,l=c.$el,s=c.$groupEl,u=c.$hitTestingEl,d=t.parsedStyle,p=t.computedStyle,f=t.nodeName;n.some((function(e){return r.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(t,e)}))&&l&&[l,u].forEach((function(e){e&&r.context.SVGElementLifeCycleContribution.updateElementAttribute(t,e,r.svgElementMap)})),n.forEach((function(n){var c,h,m=I[n],v=a?p[n]:d[n],b=!i(v)&&""+v,y=(null===(c=$[n])||void 0===c?void 0:c[b])||b,g=d[n],A=m&&!!(null===(h=e.propertyMetadataCache[n])||void 0===h?void 0:h.inh);if(f===e.Shape.HTML)"fill"===n?l.style.background=""+g:"stroke"===n?(l.style["border-color"]=""+g,l.style["border-style"]="solid"):"lineWidth"===n?l.style["border-width"]="".concat(g||0,"px"):"lineDash"===n?l.style["border-style"]="dashed":"innerHTML"===n?r.createOrUpdateInnerHTML(o,l,g):"width"===n||"height"===n||"class"===n?l.setAttribute(n,""+g):i(t.style[n])||""===t.style[n]||(l.style[n]=t.style[n]);else{if(!m||(f===e.Shape.GROUP||t.isCustomElement)&&!a&&(A||"fill"===m||"stroke"===m))return;"fill"===n||"stroke"===n?r.defElementManager.createOrUpdateGradientAndPattern(t,l,g,m,r):a&&A?"unset"!==b&&b!==H[n]?null==s||s.setAttribute(m,y):null==s||s.removeAttribute(m):"clipPath"===n?r.createOrUpdateClipOrTextPath(o,g,t):"textPath"===n?r.createOrUpdateClipOrTextPath(o,g,t,!0):"shadowType"===n||"shadowColor"===n||"shadowBlur"===n||"shadowOffsetX"===n||"shadowOffsetY"===n?r.defElementManager.createOrUpdateShadow(t,l,n):"filter"===n?r.defElementManager.createOrUpdateFilter(t,l,g):i(v)||[l,u].forEach((function(t){t&&m&&("unset"!==b&&b!==H[n]?t.setAttribute(m,y):t.removeAttribute(m))}))}}))},t.prototype.createSVGDom=function(t,n,r,a){var i;void 0===a&&(a=!1),n.elementSVG=new f;var o=n.elementSVG,c=this.context.SVGElementLifeCycleContribution.createElement(n,this.svgElementMap);if(c){var l=void 0;n.nodeName===e.Shape.HTML&&(n.parsedStyle.$el=c),this.pluginOptions.outputSVGElementId&&(c.id=this.getId(n)),this.pluginOptions.outputSVGElementName&&n.name&&c.setAttribute("name",n.name),!c.hasAttribute("data-wrapgroup")&&"g"===c.nodeName||a?l=c:(l=g("g",t)).appendChild(c),o.$el=c,o.$groupEl=l,this.applyAttributes(n),this.createOrUpdateHitArea(n,c,l);var s=r||n.parentNode&&(null===(i=n.parentNode.elementSVG)||void 0===i?void 0:i.$groupEl);s&&(s.appendChild(l),this.pendingReorderQueue.add(n.parentNode))}},t.prototype.removeSVGDom=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))},t.prototype.createOrUpdateHitArea=function(t,e,n){var r=t.elementSVG,a=r.$hitTestingEl,i=Number(t.parsedStyle.increasedLineWidthForHitTesting);if(i){if(!a){a=e.cloneNode(),["filter"].forEach((function(t){a.removeAttribute(t)}));var o="none"!==e.getAttribute("fill");a.setAttribute("fill",o?"transparent":"none"),a.setAttribute("stroke","transparent"),n.appendChild(a),r.$hitTestingEl=a,this.svgElementMap.set(a,t)}a.setAttribute("stroke-width","".concat(i+t.parsedStyle.lineWidth))}else a&&(n.removeChild(a),r.$hitTestingEl=null)},t.prototype.createOrUpdateInnerHTML=function(t,e,n){var r=(t||document).createElement("div");"string"==typeof n?r.innerHTML=n:r.appendChild(n),e.innerHTML="",e.appendChild(r)},t.prototype.createOrUpdateClipOrTextPath=function(t,e,n,r){void 0===r&&(r=!1);var a=n.elementSVG.$groupEl,i=r?"g":"clipPath",o=r?"text-path":"clip-path";if(e){var c=(r?j:_)+e.entity+"-"+n.entity,l=this.defElementManager.getDefElement();if(!l.querySelector("#".concat(c))){var s=void 0;if(r)this.createSVGDom(t,e,null,!0),s=e.elementSVG.$el;else{if(!e.isConnected)l.querySelector("#".concat(this.getId(e)))||this.createSVGDom(t,e,l,!0);s=g(i,t);var u=g("use",t);u.setAttribute("href","#".concat(e.elementSVG.$el.id)),s.appendChild(u);var f=this.clipPathUseMap.get(e);f||(this.clipPathUseMap.set(e,[]),f=this.clipPathUseMap.get(e)),f.push(u),this.applyTransform(u,e.getWorldTransform());var h=p(d(),n.getWorldTransform());this.applyTransform(s,h)}this.pluginOptions.outputSVGElementId&&(s.id=c),l.appendChild(s)}this.applyAttributes(e),r||a.setAttribute(o,"url(#".concat(c,")"))}else r||a.removeAttribute(o)},t.tag="SVGRenderer",t}(),W={top:"hanging",middle:"central",bottom:"text-after-edge",alphabetic:"alphabetic",ideographic:"ideographic",hanging:"hanging"};function X(t,e,n,r){n.getBounds();var a=e.lineWidth,i=void 0===a?1:a,o=e.x,c=void 0===o?0:o,l=e.y,s=void 0===l?0:l,u=e.dx,d=void 0===u?0:u,p=e.dy,f=void 0===p?0:p,h=e.textPath,m=e.textPathSide,v=void 0===m?"left":m,b=e.textPathStartOffset,y=void 0===b?0:b,A=e.textDecorationLine,E=void 0===A?"":A,S=e.textDecorationColor,x=void 0===S?"":S,C=e.textDecorationStyle,O=void 0===C?"":C,M=e.metrics,w=e.textBaseline,G=void 0===w?"alphabetic":w;r.enableCSSParsing||"alphabetic"!==G||(G="bottom"),t.setAttribute("dominant-baseline",W[G]),t.setAttribute("paint-order","stroke");var T=M.lines,k=M.lineHeight,L=M.height,P=T.length,D="";if(0===d&&0===f||(D+="transform:translate(".concat(d,"px, ").concat(f,"px);")),E&&"none"!==E&&(D+="text-decoration:".concat(E," ").concat(O," ").concat(x,";")),D&&t.setAttribute("style",D),0!==c&&t.setAttribute("x","".concat(c)),0!==s&&t.setAttribute("y","".concat(s)),1===P){var V=U(T[0]);if(t.setAttribute("dx","".concat(i/2)),"bottom"!==G&&"top"!==G||(t.setAttribute("dominant-baseline",W.middle),t.setAttribute("dy","bottom"===G?"-".concat(L/2,"px"):"".concat(L/2,"px"))),h){t.innerHTML="";var N=g("textPath",t.ownerDocument);N.setAttribute("href","#".concat(j+h.entity)),"left"!==v&&N.setAttribute("side",v),0!==y&&N.setAttribute("startOffset","".concat(y)),N.innerHTML=V,t.appendChild(N)}else t.innerHTML=V}else t.innerHTML=T.map((function(t,e){var n=i/2,r=0;return 0===e?"middle"===G?r=k/2-L/2:"top"===G||"hanging"===G?r=0:"bottom"!==G&&"alphabetic"!==G&&"ideographic"!==G||(r=-k*(P-1)):r=k,"<tspan x=".concat(c,' dx="').concat(n,'" dy="').concat(r,'">').concat(U(t),"</tspan>")})).join("")}var q=((N={})[e.Shape.RECT]="path",N[e.Shape.CIRCLE]="circle",N[e.Shape.ELLIPSE]="ellipse",N[e.Shape.IMAGE]="image",N[e.Shape.GROUP]="g",N[e.Shape.LINE]="line",N[e.Shape.POLYLINE]="polyline",N[e.Shape.POLYGON]="polygon",N[e.Shape.TEXT]="text",N[e.Shape.PATH]="path",N[e.Shape.HTML]="foreignObject",N),Y=((R={})[e.Shape.CIRCLE]=["cx","cy","r"],R[e.Shape.ELLIPSE]=["cx","cy","rx","ry"],R[e.Shape.RECT]=["x","y","width","height","radius"],R[e.Shape.IMAGE]=["x","y","src","width","height"],R[e.Shape.LINE]=["x1","y1","x2","y2","markerStart","markerEnd","markerStartOffset","markerEndOffset"],R[e.Shape.POLYLINE]=["points","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"],R[e.Shape.POLYGON]=["points","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"],R[e.Shape.PATH]=["d","markerStart","markerEnd","markerMid","markerStartOffset","markerEndOffset"],R[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"],R),z=function(){function t(t,e){this.context=t,this.runtime=e}return t.prototype.createElement=function(t,e){var n=g(q[t.nodeName]||"g",this.context.config.document||document);return e.set(n,t),n},t.prototype.destroyElement=function(t,e){},t.prototype.shouldUpdateElementAttribute=function(t,e){return(Y[t.nodeName]||[]).indexOf(e)>-1},t.prototype.updateElementAttribute=function(t){var n=t.elementSVG.$el,r=t.parsedStyle;switch(t.nodeName){case e.Shape.IMAGE:h(n,r);break;case e.Shape.RECT:y(n,r);break;case e.Shape.LINE:m(n,r);break;case e.Shape.POLYGON:case e.Shape.POLYLINE:b(n,r);break;case e.Shape.PATH:v(n,r);break;case e.Shape.TEXT:X(n,r,t,this.runtime)}},t}(),Q=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="svg-renderer",n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.init=function(t){var e=this.options,n=e.outputSVGElementId,r=e.outputSVGElementName,a=new D(this.context),o=new z(this.context,t);this.context.defaultElementLifeCycleContribution=o,this.context.SVGElementLifeCycleContribution=o;var c={outputSVGElementId:!!i(n)||!!n,outputSVGElementName:!!i(r)||!!r};this.addRenderingPlugin(new B(c,a,this.context))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultElementLifeCycleContribution,delete this.context.SVGElementLifeCycleContribution},e}(e.AbstractRendererPlugin);t.CLIP_PATH_PREFIX=_,t.DEFAULT_VALUE_MAP=H,t.DefaultElementLifeCycleContribution=z,t.ElementSVG=f,t.G_SVG_PREFIX=F,t.Plugin=Q,t.SHAPE2TAGS=q,t.SHAPE_UPDATE_DEPS=Y,t.SVGRendererPlugin=B,t.SVG_ATTR_MAP=I,t.TEXT_PATH_PREFIX=j,t.createSVGElement=g,t.updateImageElementAttribute=h,t.updateLineElementAttribute=m,t.updatePathElementAttribute=v,t.updatePolylineElementAttribute=b,t.updateRectElementAttribute=y,t.updateTextElementAttribute=X})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@antv/g-plugin-svg-renderer", | ||
"version": "2.0.12-alpha.1", | ||
"version": "2.0.12", | ||
"description": "A G plugin of renderer implementation with SVG", | ||
@@ -38,7 +38,6 @@ "keywords": [ | ||
"tslib": "^2.5.3", | ||
"@antv/g-lite": "2.0.10-alpha.1" | ||
"@antv/g-lite": "2.0.10" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "alpha" | ||
"access": "public" | ||
}, | ||
@@ -45,0 +44,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
484790
+ Added@antv/g-lite@2.0.10(transitive)
- Removed@antv/g-lite@2.0.10-alpha.1(transitive)
Updated@antv/g-lite@2.0.10