!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jspdf")):"function"==typeof define&&define.amd?define(["exports","jspdf"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).svg2pdf={},t.jspdf)}(this,(function(t,e){"use strict";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b}}return t.prototype.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t.prototype.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+(this.a||"1")+")"},t.prototype.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},t.prototype.getHelpXML=function(){for(var e=[],r=0;r "+l.toRGB()+" -> "+l.toHex());o.appendChild(u),o.appendChild(h),s.appendChild(o)}catch(t){}return s},t}(),h=function(){function t(t){this.color=t}return t.prototype.getFillData=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,void 0]}))}))},t}(),c=function(){function t(){this.xmlSpace="",this.whiteSpace="",this.fill=null,this.fillOpacity=1,this.fontFamily="",this.fontSize=16,this.fontStyle="",this.fontWeight="",this.opacity=1,this.stroke=null,this.strokeDasharray=null,this.strokeDashoffset=0,this.strokeLinecap="",this.strokeLinejoin="",this.strokeMiterlimit=4,this.strokeOpacity=1,this.strokeWidth=1,this.alignmentBaseline="",this.textAnchor="",this.visibility="",this.color=null,this.contextFill=null,this.contextStroke=null,this.fillRule=null}return t.prototype.clone=function(){var e=new t;return e.xmlSpace=this.xmlSpace,e.whiteSpace=this.whiteSpace,e.fill=this.fill,e.fillOpacity=this.fillOpacity,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontStyle=this.fontStyle,e.fontWeight=this.fontWeight,e.opacity=this.opacity,e.stroke=this.stroke,e.strokeDasharray=this.strokeDasharray,e.strokeDashoffset=this.strokeDashoffset,e.strokeLinecap=this.strokeLinecap,e.strokeLinejoin=this.strokeLinejoin,e.strokeMiterlimit=this.strokeMiterlimit,e.strokeOpacity=this.strokeOpacity,e.strokeWidth=this.strokeWidth,e.textAnchor=this.textAnchor,e.alignmentBaseline=this.alignmentBaseline,e.visibility=this.visibility,e.color=this.color,e.fillRule=this.fillRule,e.contextFill=this.contextFill,e.contextStroke=this.contextStroke,e},t.default=function(){var e=new t;return e.xmlSpace="default",e.whiteSpace="normal",e.fill=new h(new u("rgb(0, 0, 0)")),e.fillOpacity=1,e.fontFamily="times",e.fontSize=16,e.fontStyle="normal",e.fontWeight="normal",e.opacity=1,e.stroke=null,e.strokeDasharray=null,e.strokeDashoffset=0,e.strokeLinecap="butt",e.strokeLinejoin="miter",e.strokeMiterlimit=4,e.strokeOpacity=1,e.strokeWidth=1,e.alignmentBaseline="baseline",e.textAnchor="start",e.visibility="visible",e.color=new u("rgb(0, 0, 0)"),e.fillRule="nonzero",e.contextFill=null,e.contextStroke=null,e},t.getContextColors=function(t,e){void 0===e&&(e=!1);var r={};return t.attributeState.contextFill&&(r.contextFill=t.attributeState.contextFill),t.attributeState.contextStroke&&(r.contextStroke=t.attributeState.contextStroke),e&&t.attributeState.color&&(r.color=t.attributeState.color),r},t}(),f=function(){function t(t,e){var r,i,n;this.pdf=t,this.svg2pdfParameters=e.svg2pdfParameters,this.attributeState=e.attributeState?e.attributeState.clone():c.default(),this.viewport=e.viewport,this.refsHandler=e.refsHandler,this.styleSheets=e.styleSheets,this.textMeasure=e.textMeasure,this.transform=null!==(r=e.transform)&&void 0!==r?r:this.pdf.unitMatrix,this.withinClipPath=null!==(i=e.withinClipPath)&&void 0!==i&&i,this.withinUse=null!==(n=e.withinUse)&&void 0!==n&&n}return t.prototype.clone=function(e){var r,i,n,a;return void 0===e&&(e={}),new t(this.pdf,{svg2pdfParameters:this.svg2pdfParameters,attributeState:e.attributeState?e.attributeState.clone():this.attributeState.clone(),viewport:null!==(r=e.viewport)&&void 0!==r?r:this.viewport,refsHandler:this.refsHandler,styleSheets:this.styleSheets,textMeasure:this.textMeasure,transform:null!==(i=e.transform)&&void 0!==i?i:this.transform,withinClipPath:null!==(n=e.withinClipPath)&&void 0!==n?n:this.withinClipPath,withinUse:null!==(a=e.withinUse)&&void 0!==a?a:this.withinUse})},t}();function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t} /*! https://mths.be/cssesc v3.0.0 by @mathias */var d=function(){if(l)return o;l=1;var t={}.hasOwnProperty,e=/[ -,\.\/:-@\[-\^`\{-~]/,r=/[ -,\.\/:-@\[\]\^`\{-~]/,i=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,n=function n(a,s){"single"!=(s=function(e,r){if(!e)return r;var i={};for(var n in r)i[n]=t.call(e,n)?e[n]:r[n];return i}(s,n.options)).quotes&&"double"!=s.quotes&&(s.quotes="single");for(var o="double"==s.quotes?'"':"'",l=s.isIdentifier,u=a.charAt(0),h="",c=0,f=a.length;c126){if(d>=55296&&d<=56319&&c=0}function B(t,e,r,i){var n;void 0===i&&(i=r);var a=null===(n=t.style)||void 0===n?void 0:n.getPropertyValue(i);if(a)return a;var s=e.getPropertyValue(t,i);return s||(t.hasAttribute(r)&&t.getAttribute(r)||void 0)}function N(t,e,r){if("none"===B(t.element,r.styleSheets,"display"))return!1;var i=e,n=B(t.element,r.styleSheets,"visibility");return n&&(i="hidden"!==n),i}function E(t,e,r){var i=N(t,e,r);return 0!==t.element.childNodes.length&&(t.children.forEach((function(t){t.isVisible(i,r)&&(i=!0)})),i)}var O,L,I=function(){function t(){this.markers=[]}return t.prototype.addMarker=function(t){this.markers.push(t)},t.prototype.draw=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n,a,o,l,u;return s(this,(function(s){switch(s.label){case 0:e=0,s.label=1;case 1:return e=0?y+=(n-f*d)/2:l.indexOf("xMax")>=0&&(y+=n-f*d),l.indexOf("YMid")>=0?b+=(a-p*g)/2:l.indexOf("YMax")>=0&&(b+=a-p*g);var x=s.pdf.Matrix(1,0,0,1,y,b),S=s.pdf.Matrix(d,0,0,g,0,0);return s.pdf.matrixMult(S,x)}function Z(t,e){if(!t||"none"===t)return e.pdf.unitMatrix;for(var r,i,n=/^[\s,]*matrix\(([^)]+)\)\s*/,a=/^[\s,]*translate\(([^)]+)\)\s*/,s=/^[\s,]*rotate\(([^)]+)\)\s*/,o=/^[\s,]*scale\(([^)]+)\)\s*/,l=/^[\s,]*skewX\(([^)]+)\)\s*/,u=/^[\s,]*skewY\(([^)]+)\)\s*/,h=e.pdf.unitMatrix;t.length>0&&t.length!==i;){i=t.length;var c=n.exec(t);if(c&&(r=V(c[1]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],r[1],r[2],r[3],r[4],r[5]),h),t=t.substr(c[0].length)),c=s.exec(t)){r=V(c[1]);var f=Math.PI*r[0]/180;if(h=e.pdf.matrixMult(e.pdf.Matrix(Math.cos(f),Math.sin(f),-Math.sin(f),Math.cos(f),0,0),h),r[1]||r[2]){var p=e.pdf.Matrix(1,0,0,1,r[1],r[2]),d=e.pdf.Matrix(1,0,0,1,-r[1],-r[2]);h=e.pdf.matrixMult(d,e.pdf.matrixMult(h,p))}t=t.substr(c[0].length)}(c=a.exec(t))&&(r=V(c[1]),h=e.pdf.matrixMult(e.pdf.Matrix(1,0,0,1,r[0],r[1]||0),h),t=t.substr(c[0].length)),(c=o.exec(t))&&((r=V(c[1]))[1]||(r[1]=r[0]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],0,0,r[1],0,0),h),t=t.substr(c[0].length)),(c=l.exec(t))&&(r=parseFloat(c[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,0,Math.tan(r),1,0,0),h),t=t.substr(c[0].length)),(c=u.exec(t))&&(r=parseFloat(c[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,Math.tan(r),0,1,0,0),h),t=t.substr(c[0].length))}return h}var J=function(){function t(t,e){this.element=t,this.children=e,this.parent=null}return t.prototype.setParent=function(t){this.parent=t},t.prototype.getParent=function(){return this.parent},t.prototype.getBoundingBox=function(t){return"none"===B(this.element,t.styleSheets,"display")?[0,0,0,0]:this.getBoundingBoxCore(t)},t.prototype.computeNodeTransform=function(t){var e=this.computeNodeTransformCore(t),r=B(this.element,t.styleSheets,"transform");return r?t.pdf.matrixMult(e,Z(r,t)):e},t}(),tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.render=function(t){return Promise.resolve()},e.prototype.getBoundingBoxCore=function(t){return[]},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(J),et=function(t){function r(e,r,i){var n=t.call(this,r,i)||this;return n.pdfGradientType=e,n.contextColor=void 0,n}return i(r,t),r.prototype.apply=function(t){return a(this,void 0,void 0,(function(){var r,i,n,a,o,l;return s(this,(function(s){return(r=this.element.getAttribute("id"))?(i=this.getStops(t.styleSheets),n=0,a=!1,i.forEach((function(t){var e=t.opacity;e&&1!==e&&(n+=e,a=!0)})),a&&(o=new e.GState({opacity:n/i.length})),l=new e.ShadingPattern(this.pdfGradientType,this.getCoordinates(),i,o),t.pdf.addShadingPattern(r,l),[2]):[2]}))}))},r.prototype.getStops=function(t){var e=this;if(this.stops)return this.stops;if(void 0===this.contextColor){this.contextColor=null;for(var i=this;i;){var n=B(i.element,t,"color");if(n){this.contextColor=W(n,null);break}i=i.getParent()}}var a=[];return this.children.forEach((function(i){if("stop"===i.element.tagName.toLowerCase()){var n=B(i.element,t,"color"),s=W(B(i.element,t,"stop-color")||"",n?{color:W(n,null)}:{color:e.contextColor}),o=parseFloat(B(i.element,t,"stop-opacity")||"1");a.push({offset:r.parseGradientOffset(i.element.getAttribute("offset")||"0"),color:[s.r,s.g,s.b],opacity:o})}})),this.stops=a},r.prototype.getBoundingBoxCore=function(t){return $(this.element,t)},r.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},r.prototype.isVisible=function(t,e){return E(this,t,e)},r.parseGradientOffset=function(t){var e=parseFloat(t);return!isNaN(e)&&t.indexOf("%")>=0?e/100:e},r}(tt),rt=function(t){function e(e,r){return t.call(this,"axial",e,r)||this}return i(e,t),e.prototype.getCoordinates=function(){return[parseFloat(this.element.getAttribute("x1")||"0"),parseFloat(this.element.getAttribute("y1")||"0"),parseFloat(this.element.getAttribute("x2")||"1"),parseFloat(this.element.getAttribute("y2")||"0")]},e}(et),it=function(t){function e(e,r){return t.call(this,"radial",e,r)||this}return i(e,t),e.prototype.getCoordinates=function(){var t=this.element.getAttribute("cx"),e=this.element.getAttribute("cy"),r=this.element.getAttribute("fx"),i=this.element.getAttribute("fy");return[parseFloat(r||t||"0.5"),parseFloat(i||e||"0.5"),0,parseFloat(t||"0.5"),parseFloat(e||"0.5"),parseFloat(this.element.getAttribute("r")||"0.5")]},e}(et),nt=function(){function t(t,e){this.key=t,this.gradient=e}return t.prototype.getFillData=function(t,e){return a(this,void 0,void 0,(function(){var r,i,n;return s(this,(function(a){switch(a.label){case 0:return[4,e.refsHandler.getRendered(this.key,null,(function(t){return t.apply(new f(e.pdf,{refsHandler:e.refsHandler,textMeasure:e.textMeasure,styleSheets:e.styleSheets,viewport:e.viewport,svg2pdfParameters:e.svg2pdfParameters}))}))];case 1:return a.sent(),this.gradient.element.hasAttribute("gradientUnits")&&"objectboundingbox"!==this.gradient.element.getAttribute("gradientUnits").toLowerCase()?r=e.pdf.unitMatrix:(i=t.getBoundingBox(e),r=e.pdf.Matrix(i[2],0,0,i[3],i[0],i[1])),n=Z(B(this.gradient.element,e.styleSheets,"gradientTransform","transform"),e),[2,{key:this.key,matrix:e.pdf.matrixMult(n,r)}]}}))}))},t}(),at=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return i(r,t),r.prototype.apply=function(t){return a(this,void 0,void 0,(function(){var r,i,n,a,o;return s(this,(function(s){switch(s.label){case 0:if(!(r=this.element.getAttribute("id")))return[2];i=this.getBoundingBox(t),n=new e.TilingPattern([i[0],i[1],i[0]+i[2],i[1]+i[3]],i[2],i[3]),t.pdf.beginTilingPattern(n),a=0,o=this.children,s.label=1;case 1:return a=0?(a=t,!0):(t=t.toLowerCase(),!!U.hasOwnProperty(t)&&(a=t,!0))}))||(a="times"),a}(t.attributeState,F,t)}var A=B(i,t.styleSheets,"font-size");if(A){var T=t.pdf.getFontSize();t.attributeState.fontSize=j(A,T)}var P=B(i,t.styleSheets,"vertical-align")||B(i,t.styleSheets,"alignment-baseline");if(P){var N=P.match(/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/);N&&(t.attributeState.alignmentBaseline=N[0])}var E=B(i,t.styleSheets,"text-anchor");E&&(t.attributeState.textAnchor=E);var O=B(i,t.styleSheets,"fill-rule");O&&(t.attributeState.fillRule=O)}function ut(t,r,i){var n=1,a=1;n*=t.attributeState.fillOpacity,n*=t.attributeState.opacity,t.attributeState.fill instanceof h&&void 0!==t.attributeState.fill.color.a&&(n*=t.attributeState.fill.color.a),a*=t.attributeState.strokeOpacity,a*=t.attributeState.opacity,t.attributeState.stroke instanceof h&&void 0!==t.attributeState.stroke.color.a&&(a*=t.attributeState.stroke.color.a);var s,o,l=n<1,u=a<1;if(P(i,"use")?(l=!0,u=!0,n*=t.attributeState.fill?1:0,a*=t.attributeState.stroke?1:0):t.withinUse&&(t.attributeState.fill!==r.attributeState.fill?(l=!0,n*=t.attributeState.fill?1:0):l&&!t.attributeState.fill&&(n=0),t.attributeState.stroke!==r.attributeState.stroke?(u=!0,a*=t.attributeState.stroke?1:0):u&&!t.attributeState.stroke&&(a=0)),l||u){var c={};l&&(c.opacity=n),u&&(c["stroke-opacity"]=a),t.pdf.setGState(new e.GState(c))}if(t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof h&&t.attributeState.fill.color.ok&&!P(i,"text")&&t.pdf.setFillColor(t.attributeState.fill.color.r,t.attributeState.fill.color.g,t.attributeState.fill.color.b),t.attributeState.strokeWidth!==r.attributeState.strokeWidth&&t.pdf.setLineWidth(t.attributeState.strokeWidth),t.attributeState.stroke!==r.attributeState.stroke&&t.attributeState.stroke instanceof h&&t.pdf.setDrawColor(t.attributeState.stroke.color.r,t.attributeState.stroke.color.g,t.attributeState.stroke.color.b),t.attributeState.strokeLinecap!==r.attributeState.strokeLinecap&&t.pdf.setLineCap(t.attributeState.strokeLinecap),t.attributeState.strokeLinejoin!==r.attributeState.strokeLinejoin&&t.pdf.setLineJoin(t.attributeState.strokeLinejoin),t.attributeState.strokeDasharray===r.attributeState.strokeDasharray&&t.attributeState.strokeDashoffset===r.attributeState.strokeDashoffset||!t.attributeState.strokeDasharray||t.pdf.setLineDashPattern(t.attributeState.strokeDasharray,t.attributeState.strokeDashoffset),t.attributeState.strokeMiterlimit!==r.attributeState.strokeMiterlimit&&t.pdf.setLineMiterLimit(t.attributeState.strokeMiterlimit),t.attributeState.fontFamily!==r.attributeState.fontFamily&&(s=U.hasOwnProperty(t.attributeState.fontFamily)?U[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof h&&t.attributeState.fill.color.ok){var f=t.attributeState.fill.color;t.pdf.setTextColor(f.r,f.g,f.b)}t.attributeState.fontWeight===r.attributeState.fontWeight&&t.attributeState.fontStyle===r.attributeState.fontStyle||(o=X(t.attributeState.fontStyle,t.attributeState.fontWeight)),void 0===s&&void 0===o||(void 0===s&&(s=U.hasOwnProperty(t.attributeState.fontFamily)?U[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.pdf.setFont(s,o)),t.attributeState.fontSize!==r.attributeState.fontSize&&t.pdf.setFontSize(t.attributeState.fontSize*t.pdf.internal.scaleFactor)}function ht(t,e,r){var i=H.exec(t);if(i){var n=i[1];return r.refsHandler.get(n)||void 0}}function ct(t,e,r){return a(this,void 0,void 0,(function(){var i,n;return s(this,(function(a){switch(a.label){case 0:return i=r.clone(),e.element.hasAttribute("clipPathUnits")&&"objectboundingbox"===e.element.getAttribute("clipPathUnits").toLowerCase()&&(n=t.getBoundingBox(r),i.transform=r.pdf.matrixMult(r.pdf.Matrix(n[2],0,0,n[3],n[0],n[1]),r.transform)),[4,e.apply(i)];case 1:return a.sent(),[2]}}))}))}var ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.render=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n;return s(this,(function(a){switch(a.label){case 0:return this.isVisible("hidden"!==t.attributeState.visibility,t)?((e=t.clone()).transform=e.pdf.matrixMult(this.computeNodeTransform(e),t.transform),lt(e,this),r=B(this.element,e.styleSheets,"clip-path"),(i=r&&"none"!==r)?(n=ht(r,0,e))?n.isVisible(!0,e)?(e.pdf.saveGraphicsState(),[4,ct(this,n,e)]):[3,2]:[3,4]:[3,5]):[2];case 1:return a.sent(),[3,3];case 2:return[2];case 3:return[3,5];case 4:i=!1,a.label=5;case 5:return e.withinClipPath||e.pdf.saveGraphicsState(),ut(e,t,this.element),[4,this.renderCore(e)];case 6:return a.sent(),e.withinClipPath||e.pdf.restoreGraphicsState(),i&&e.pdf.restoreGraphicsState(),[2]}}))}))},e}(J),pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(ft),dt=function(t){function e(e,r,i){var n=t.call(this,r,i)||this;return n.cachedPath=null,n.hasMarkers=e,n}return i(e,t),e.prototype.renderCore=function(t){return a(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return null===(e=this.getCachedPath(t))||0===e.segments.length?[2]:(t.withinClipPath?e.transform(t.transform):t.pdf.setCurrentTransformationMatrix(t.transform),e.draw(t),[4,this.fillOrStroke(t)]);case 1:return r.sent(),this.hasMarkers?[4,this.drawMarkers(t,e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.getCachedPath=function(t){return this.cachedPath||(this.cachedPath=this.getPath(t))},e.prototype.drawMarkers=function(t,e){return a(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.getMarkers(e,t).draw(t.clone({transform:t.pdf.unitMatrix}))];case 1:return r.sent(),[2]}}))}))},e.prototype.fillOrStroke=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n,a;return s(this,(function(s){switch(s.label){case 0:return t.withinClipPath?[2]:(e=t.attributeState.fill,r=t.attributeState.stroke&&0!==t.attributeState.strokeWidth,e?[4,e.getFillData(this,t)]:[3,2]);case 1:return n=s.sent(),[3,3];case 2:n=void 0,s.label=3;case 3:return i=n,a="evenodd"===t.attributeState.fillRule,e&&r||t.withinUse?a?t.pdf.fillStrokeEvenOdd(i):t.pdf.fillStroke(i):e?a?t.pdf.fillEvenOdd(i):t.pdf.fill(i):r?t.pdf.stroke():t.pdf.discardPath(),[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){var e=this.getCachedPath(t);if(!e||!e.segments.length)return[0,0,0,0];for(var r=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=0,o=0,l=0;lt){var i=s[r-1];c=(i instanceof C||i instanceof F||i instanceof A)&&i}}));var p=n&&(t===s.length-1||!(s[t]instanceof C)&&s[t+1]instanceof C),d=i&&t>0&&!(1===t&&s[t-1]instanceof C),g=s[t-1]||null;if(g instanceof C||g instanceof F||g instanceof A){if(e instanceof A)f&&a.addMarker(new _(r,[g.x,g.y],v(c?[c.x,c.y]:[g.x,g.y],[e.x1,e.y1]),!0)),p&&a.addMarker(new _(n,[e.x,e.y],v([e.x2,e.y2],[e.x,e.y]))),d&&(l=S([g.x,g.y],[e.x1,e.y1]),l=g instanceof C?l:x(w(o,l)),a.addMarker(new _(i,[g.x,g.y],Math.atan2(l[1],l[0])))),o=S([e.x2,e.y2],[e.x,e.y]);else if(e instanceof C||e instanceof F){if(l=S([g.x,g.y],[e.x,e.y]),f){var m=c?S([c.x,c.y],[e.x,e.y]):l;a.addMarker(new _(r,[g.x,g.y],Math.atan2(m[1],m[0]),!0))}if(p&&a.addMarker(new _(n,[e.x,e.y],Math.atan2(l[1],l[0]))),d){m=e instanceof C?o:g instanceof C?l:x(w(o,l));a.addMarker(new _(i,[g.x,g.y],Math.atan2(m[1],m[0])))}o=l}else if(e instanceof T){if(l=S([g.x,g.y],[u.x,u.y]),d){m=g instanceof C?l:x(w(o,l));a.addMarker(new _(i,[g.x,g.y],Math.atan2(m[1],m[0])))}if(p){m=x(w(l,h));a.addMarker(new _(n,[u.x,u.y],Math.atan2(m[1],m[0])))}o=l}}else{u=e instanceof C&&e;var y=s[t+1];(y instanceof C||y instanceof F||y instanceof A)&&(h=S([u.x,u.y],[y.x,y.y]))}},p=0;p=0;t--){if("preserve"===this.contexts[t].attributeState.xmlSpace||"pre"===this.contexts[t].attributeState.whiteSpace||(this.texts[t]=this.texts[t].replace(/\s+$/,"")),this.texts[t].match(/[^\s]/))return!1}return!0},t.prototype.measureText=function(t){for(var e=0;e0&&(g=t.textMeasure.measureTextWidth(d,t.attributeState),!("preserve"===t.attributeState.xmlSpace||"pre"===t.attributeState.whiteSpace)&&f.match(/^\s/)&&(i=0),r=(h-g)/(d.length-i)||0),"visible"===c&&(m=t.attributeState.alignmentBaseline,v=kt(t.attributeState),t.pdf.text(d,a+l-e,o+u,{baseline:q(m),angle:t.transform,renderingMode:"fill"===v?void 0:v,charSpace:0===r?void 0:r}),this.boundingBox=[a+l-e,o+u+.1*n,t.textMeasure.measureTextWidth(d,t.attributeState),n]);else{for(y=[],b=new Vt(this,t.attributeState.textAnchor,a+l,o+u),y.push({type:"",chunk:b}),x=this.processTSpans(this,this.element,t,y,b,{prevText:" ",prevContext:t}),i=x?0:1,S=!0,w=y.length-1;w>=0;w--)S&&(S=y[w].chunk.rightTrimText());h>0&&(k=0,M=0,y.forEach((function(e){var r=e.chunk;r.measureText(t),r.textMeasures.forEach((function(t){var e=t.width,r=t.length;k+=e,M+=r}))})),r=(h-k)/(M-i)),y.reduce((function(e,i){var n=i.type,a=i.chunk;return"x"===n?a.setX(e[0]):"y"===n&&a.setY(e[1]),a.put(t,r)}),[0,0])}return t.pdf.restoreGraphicsState(),[2]}))}))},e.prototype.isVisible=function(t,e){return E(this,t,e)},e.prototype.getBoundingBoxCore=function(t){return this.boundingBox.length>0?this.boundingBox:$(this.element,t)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(pt);function Gt(){if(Nt)return Bt;function t(){if(!(this instanceof t))return new t;this.queue=[],this.cache=null}return Nt=1,t.prototype.matrix=function(t){return 1===t[0]&&0===t[1]&&0===t[2]&&1===t[3]&&0===t[4]&&0===t[5]||(this.cache=null,this.queue.push(t)),this},t.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},t.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},t.prototype.rotate=function(t,e,r){var i,n,a;return 0!==t&&(this.translate(e,r),i=t*Math.PI/180,n=Math.cos(i),a=Math.sin(i),this.queue.push([n,a,-a,n,0,0]),this.cache=null,this.translate(-e,-r)),this},t.prototype.skewX=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,0,Math.tan(t*Math.PI/180),1,0,0])),this},t.prototype.skewY=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,Math.tan(t*Math.PI/180),0,1,0,0])),this},t.prototype.toArray=function(){if(this.cache)return this.cache;if(!this.queue.length)return this.cache=[1,0,0,1,0,0],this.cache;if(this.cache=this.queue[0],1===this.queue.length)return this.cache;for(var t=1;t1&&(n=1),n<-1&&(n=-1),(t*i-e*r<0?-1:1)*Math.acos(n)}function r(t,e){var r=4/3*Math.tan(e/4),i=Math.cos(t),n=Math.sin(t),a=Math.cos(t+e),s=Math.sin(t+e);return[i,n,i-n*r,n+i*r,a+s*r,s-a*r,a,s]}return Lt=function(i,n,a,s,o,l,u,h,c){var f=Math.sin(c*t/360),p=Math.cos(c*t/360),d=p*(i-a)/2+f*(n-s)/2,g=-f*(i-a)/2+p*(n-s)/2;if(0===d&&0===g)return[];if(0===u||0===h)return[];u=Math.abs(u),h=Math.abs(h);var m=d*d/(u*u)+g*g/(h*h);m>1&&(u*=Math.sqrt(m),h*=Math.sqrt(m));var v=function(r,i,n,a,s,o,l,u,h,c){var f=c*(r-n)/2+h*(i-a)/2,p=-h*(r-n)/2+c*(i-a)/2,d=l*l,g=u*u,m=f*f,v=p*p,y=d*g-d*v-g*m;y<0&&(y=0),y/=d*v+g*m;var b=(y=Math.sqrt(y)*(s===o?-1:1))*l/u*p,x=y*-u/l*f,S=c*b-h*x+(r+n)/2,w=h*b+c*x+(i+a)/2,k=(f-b)/l,M=(p-x)/u,C=(-f-b)/l,F=(-p-x)/u,A=e(1,0,k,M),T=e(k,M,C,F);return 0===o&&T>0&&(T-=t),1===o&&T<0&&(T+=t),[S,w,A,T]}(i,n,a,s,o,l,u,h,f,p),y=[],b=v[2],x=v[3],S=Math.max(Math.ceil(Math.abs(x)/(t/4)),1);x/=S;for(var w=0;wMath.abs(c-o)?(c-s)/h:h/(c-o))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(c),this.ry=Math.sqrt(f)):(this.ax+=90,this.rx=Math.sqrt(f),this.ry=Math.sqrt(c)),this},r.prototype.isDegenerate=function(){return this.rx=48&&t<=57}function i(t){return t>=48&&t<=57||43===t||45===t||46===t}function n(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function a(t){for(;t.index=5760&&e.indexOf(r)>=0);)t.index++;var r}function s(t){var e=t.path.charCodeAt(t.index);return 48===e?(t.param=0,void t.index++):49===e?(t.param=1,void t.index++):void(t.err="SvgPath: arc flag can be 0 or 1 only (at pos "+t.index+")")}function o(t){var e,i=t.index,n=i,a=t.max,s=!1,o=!1,l=!1,u=!1;if(n>=a)t.err="SvgPath: missed param (at pos "+n+")";else if(43!==(e=t.path.charCodeAt(n))&&45!==e||(e=++n2&&(e.result.push([r,n[0],n[1]]),n=n.slice(2),i="l",r="m"===r?"l":"L"),"r"===i)e.result.push([r].concat(n));else for(;n.length>=t[i]&&(e.result.push([r].concat(n.splice(0,t[i]))),t[i]););}function u(e){var r,n,u,h,c,f=e.max;if(e.segmentStart=e.index,n=97==(32|(r=e.path.charCodeAt(e.index))),function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}(r))if(h=t[e.path[e.index].toLowerCase()],e.index++,a(e),e.data=[],h){for(u=!1;;){for(c=h;c>0;c--){if(!n||3!==c&&4!==c?o(e):s(e),e.err.length)return;e.data.push(e.param),a(e),u=!1,e.index=e.max)break;if(!i(e.path.charCodeAt(e.index)))break}}l(e)}else l(e);else e.err="SvgPath: bad command "+e.path[e.index]+" (at pos "+e.index+")"}return Tt=function(t){var e=new n(t),r=e.max;for(a(e);e.index0,u=["m",(l=t.calc(i[1],i[2],c))[0],l[1]];break;default:for(u=[h=i[0]],c=h.toLowerCase()===h,e=1;e=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},a.prototype.toString=function(){var t="",e="",r=!1;this.__evaluateStack();for(var i=0,n=this.segments.length;i=0&&(t+=" "):l>=0&&(t+=" "),t+=l}e=s}return t},a.prototype.translate=function(t,e){return this.__stack.push(r().translate(t,e||0)),this},a.prototype.scale=function(t,e){return this.__stack.push(r().scale(t,e||0===e?e:t)),this},a.prototype.rotate=function(t,e,i){return this.__stack.push(r().rotate(t,e||0,i||0)),this},a.prototype.skewX=function(t){return this.__stack.push(r().skewX(t)),this},a.prototype.skewY=function(t){return this.__stack.push(r().skewY(t)),this},a.prototype.matrix=function(t){return this.__stack.push(r().matrix(t)),this},a.prototype.transform=function(t){return t.trim()?(this.__stack.push(e(t)),this):this},a.prototype.round=function(t){var e,r=0,i=0,n=0,a=0;return t=t||0,this.__evaluateStack(),this.segments.forEach((function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=a),a=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return n=r,void(a=i);case"M":case"m":return o&&(s[1]+=n,s[2]+=a),n=s[1]-s[1].toFixed(t),a=s[2]-s[2].toFixed(t),r=n,i=a,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=n,s[7]+=a),n=s[6]-s[6].toFixed(t),a=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=n,s[e-1]+=a),n=s[e-2]-s[e-2].toFixed(t),a=s[e-1]-s[e-1].toFixed(t),void s.forEach((function(e,r){r&&(s[r]=+s[r].toFixed(t))}))}})),this},a.prototype.iterate=function(t,e){var r,i,n,a=this.segments,s={},o=!1,l=0,u=0,h=0,c=0;if(e||this.__evaluateStack(),a.forEach((function(e,r){var i=t(e,r,l,u);Array.isArray(i)&&(s[r]=i,o=!0);var n=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return l=e[1]+(n?l:0),u=e[2]+(n?u:0),h=l,void(c=u);case"h":case"H":return void(l=e[1]+(n?l:0));case"v":case"V":return void(u=e[1]+(n?u:0));case"z":case"Z":return l=h,void(u=c);default:l=e[e.length-2]+(n?l:0),u=e[e.length-1]+(n?u:0)}})),!o)return this;for(n=[],r=0;r0&&!!B(this.children[0].element,t.styleSheets,"clip-rule"),a=n?this.getClipRuleAttr(this.children[0].element,t.styleSheets):this.getClipRuleAttr(this.element,t.styleSheets),t.pdf.clip(a).discardPath(),t.pdf.setCurrentTransformationMatrix(e.inversed()),[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){return Q(t,this)},e.prototype.isVisible=function(t,e){return E(this,t,e)},e.prototype.getClipRuleAttr=function(t,e){return"evenodd"===B(t,e,"clip-rule")?"evenodd":void 0},e}(tt);function ue(t,e){var r,i=[];switch(function(t,e){for(var r=[],i=0;i~\.\[:\)]+)/g,"a"),e(/(\.[^\s\+>~\.\[:\)]+)/g,"b"),e(/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,"c"),e(/(:(?!not|global|local)[\w-]+\([^\)]*\))/gi,"b"),e(/(:(?!not|global|local)[^\s\+>~\.\[:]+)/g,"b"),i=(i=(i=(i=(i=(i=i.replace(/[\*\s\+>~]/g," ")).replace(/[#\.]/g," ")).replace(/:not/g," ")).replace(/:local/g," ")).replace(/:global/g," ")).replace(/[\(\)]/g," "),e(/([^\s\+>~\.\[:]+)/g,"c"),a.sort((function(t,e){return t.index-e.index})),{selector:t,specificity:"0,"+n.a.toString()+","+n.b.toString()+","+n.c.toString(),specificityArray:[0,n.a,n.b,n.c],parts:a}},ce=function(){function t(t,e){this.rootSvg=t,this.loadExternalSheets=e,this.styleSheets=[]}return t.prototype.load=function(){return a(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.collectStyleSheetTexts()];case 1:return t=e.sent(),this.parseCssSheets(t),[2]}}))}))},t.prototype.collectStyleSheetTexts=function(){return a(this,void 0,void 0,(function(){var e,r,i,n,a;return s(this,(function(s){switch(s.label){case 0:if(e=[],this.loadExternalSheets&&this.rootSvg.ownerDocument)for(n=0;n=0;l--){var u=o.cssRules[l];if(u instanceof CSSStyleRule){var h=u;if(h.selectorText.indexOf(",")>=0){o.deleteRule(l);for(var c=h.cssText.substring(h.selectorText.length),f=t.splitSelectorAtCommas(h.selectorText),p=0;pi[n])return 1}return 0}(t.selectorText,r.selectorText)};return r.reduce((function(t,e){return 1===l(t,e)?t:e})).style.getPropertyValue(e)||void 0}},t}(),fe=function(){function t(){this.measureMethods={}}return t.prototype.getTextOffset=function(t,e){var r=e.textAnchor;if("start"===r)return 0;var i=this.measureTextWidth(t,e),n=0;switch(r){case"end":n=i;break;case"middle":n=i/2}return n},t.prototype.measureTextWidth=function(t,e){if(0===t.length)return 0;var r=e.fontFamily;return this.getMeasureFunction(r).call(this,t,e.fontFamily,e.fontSize+"px",e.fontStyle,e.fontWeight)},t.prototype.getMeasurementTextNode=function(){if(!this.textMeasuringTextElement){this.textMeasuringTextElement=document.createElementNS(D,"text");var t=document.createElementNS(D,"svg");t.appendChild(this.textMeasuringTextElement),t.style.setProperty("position","absolute"),t.style.setProperty("visibility","hidden"),document.body.appendChild(t)}return this.textMeasuringTextElement},t.prototype.canvasTextMeasure=function(t,e,r,i,n){var a=document.createElement("canvas").getContext("2d");return null!=a?(a.font=[i,n,r,e].join(" "),a.measureText(t).width):0},t.prototype.svgTextMeasure=function(t,e,r,i,n,a){void 0===a&&(a=this.getMeasurementTextNode());var s=a;return s.setAttribute("font-family",e),s.setAttribute("font-size",r),s.setAttribute("font-style",i),s.setAttribute("font-weight",n),s.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),s.textContent=t,s.getBBox().width},t.prototype.getMeasureFunction=function(e){var r=this.measureMethods[e];if(!r){var i="16px",n="normal",a="normal",s=this.canvasTextMeasure(t.testString,e,i,n,a),o=this.svgTextMeasure(t.testString,e,i,n,a);r=Math.abs(s-o)",t.epsilon=.1,t}();function pe(t,e){return a(this,arguments,void 0,(function(t,e,r){var i,a,o,l,u,h,c,p,d,g,v,y,b,x;return void 0===r&&(r={}),s(this,(function(s){switch(s.label){case 0:return i=null!==(y=r.x)&&void 0!==y?y:0,a=null!==(b=r.y)&&void 0!==b?b:0,o=null!==(x=r.loadExternalStyleSheets)&&void 0!==x&&x,u=new m(l={}),[4,(h=new ce(t,o)).load()];case 1:return s.sent(),c=new yt(e.internal.pageSize.getWidth(),e.internal.pageSize.getHeight()),p=n(n({},r),{element:t}),d=new fe,g=new f(e,{refsHandler:u,styleSheets:h,viewport:c,svg2pdfParameters:p,textMeasure:d}),e.advancedAPI(),e.saveGraphicsState(),e.setCurrentTransformationMatrix(e.Matrix(1,0,0,1,i,a)),e.setLineWidth(g.attributeState.strokeWidth),v=g.attributeState.fill.color,e.setFillColor(v.r,v.g,v.b),e.setFont(g.attributeState.fontFamily),e.setFontSize(g.attributeState.fontSize*e.internal.scaleFactor),[4,ue(t,l).render(g)];case 2:return s.sent(),e.restoreGraphicsState(),e.compatAPI(),g.textMeasure.cleanupTextMeasuring(),[2,e]}}))}))}e.jsPDF.API.svg=function(t,e){return void 0===e&&(e={}),pe(t,this,e)},t.svg2pdf=pe})); //# sourceMappingURL=svg2pdf.umd.min.js.map