text: !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EMFJS=e():t.EMFJS=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Error:()=>a,Renderer:()=>x,loggingEnabled:()=>l});var i,s=function(){function t(){}return t.prototype.flood=function(t,e,i,s,n){var o=document.createElementNS("http://www.w3.org/2000/svg","feFlood");e&&o.setAttribute("id",e),o.setAttribute("flood-color",i),o.setAttribute("flood-opacity",s.toString()),t.appendChild(o)},t.prototype.composite=function(t,e,i,s,n,o,r,a,h){var l=document.createElementNS("http://www.w3.org/2000/svg","feComposite");e&&l.setAttribute("id",e),l.setAttribute("in",i),l.setAttribute("in2",s),t.appendChild(l)},t}(),n=function(){function t(){this._path=""}return t.prototype.move=function(t,e){this._path+=" M "+t+" "+e},t.prototype.path=function(){return this._path.substr(1)},t.prototype.line=function(t){var e=this;t.forEach((function(t){e._path+=" L "+t[0]+" "+t[1]}))},t.prototype.curveC=function(t,e,i,s,n,o){this._path+=" C "+t+" "+e+", "+i+" "+s+", "+n+" "+o},t.prototype.close=function(){this._path+=" Z"},t}(),o=function(){function t(t){this.filters=new s,this._defs=void 0,this._svg=t}return t.prototype.svg=function(t,e,i,s,n,o){var r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("x",e.toString()),r.setAttribute("y",i.toString()),r.setAttribute("width",s.toString()),r.setAttribute("height",n.toString()),this._appendSettings(o,r),null!=t?t.appendChild(r):this._svg.appendChild(r),r},t.prototype.image=function(t,e,i,s,n,o,r){var a=document.createElementNS("http://www.w3.org/2000/svg","image");return a.setAttribute("x",e.toString()),a.setAttribute("y",i.toString()),a.setAttribute("width",s.toString()),a.setAttribute("height",n.toString()),a.setAttributeNS("http://www.w3.org/1999/xlink","href",o),this._appendSettings(r,a),t.appendChild(a),a},t.prototype.rect=function(t,e,i,s,n,o,r,a){var h=document.createElementNS("http://www.w3.org/2000/svg","rect");return h.setAttribute("x",e.toString()),h.setAttribute("y",i.toString()),h.setAttribute("width",s.toString()),h.setAttribute("height",n.toString()),void 0!==o&&(o instanceof Number?h.setAttribute("rx",o.toString()):o instanceof Object&&this._appendSettings(o,h)),void 0!==r&&h.setAttribute("ry",r.toString()),this._appendSettings(a,h),t.appendChild(h),h},t.prototype.line=function(t,e,i,s,n,o){var r=document.createElementNS("http://www.w3.org/2000/svg","line");return r.setAttribute("x1",e.toString()),r.setAttribute("y1",i.toString()),r.setAttribute("x2",s.toString()),r.setAttribute("y2",n.toString()),this._appendSettings(o,r),t.appendChild(r),r},t.prototype.polygon=function(t,e,i){var s=document.createElementNS("http://www.w3.org/2000/svg","polygon");return s.setAttribute("points",e.map((function(t){return t.join(",")})).join(" ")),this._appendSettings(i,s),t.appendChild(s),s},t.prototype.polyline=function(t,e,i){var s=document.createElementNS("http://www.w3.org/2000/svg","polyline");return s.setAttribute("points",e.map((function(t){return t.join(",")})).join(" ")),this._appendSettings(i,s),t.appendChild(s),s},t.prototype.ellipse=function(t,e,i,s,n,o){var r=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return r.setAttribute("cx",e.toString()),r.setAttribute("cy",i.toString()),r.setAttribute("rx",s.toString()),r.setAttribute("ry",n.toString()),this._appendSettings(o,r),t.appendChild(r),r},t.prototype.path=function(t,e,i){var s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d",e.path()),this._appendSettings(i,s),t.appendChild(s),s},t.prototype.text=function(t,e,i,s,n){var o=document.createElementNS("http://www.w3.org/2000/svg","text");o.setAttribute("x",e.toString()),o.setAttribute("y",i.toString()),this._appendSettings(n,o);var r=document.createTextNode(s);return o.appendChild(r),t.appendChild(o),o},t.prototype.filter=function(t,e,i,s,n,o,r){var a=document.createElementNS("http://www.w3.org/2000/svg","filter");return a.setAttribute("x",i.toString()),a.setAttribute("y",s.toString()),a.setAttribute("width",n.toString()),a.setAttribute("height",o.toString()),this._appendSettings(r,a),t.appendChild(a),a},t.prototype.pattern=function(t,e,i,s,n,o,r){var a=document.createElementNS("http://www.w3.org/2000/svg","pattern");return e&&a.setAttribute("id",e),a.setAttribute("x",i.toString()),a.setAttribute("y",s.toString()),a.setAttribute("width",n.toString()),a.setAttribute("height",o.toString()),this._appendSettings(r,a),t.appendChild(a),a},t.prototype.defs=function(){if(void 0===this._defs){var t=document.createElementNS("http://www.w3.org/2000/svg","defs");this._svg.appendChild(t),this._defs=t}return this._defs},t.prototype.clipPath=function(t,e,i,s){var n=document.createElementNS("http://www.w3.org/2000/svg","clipPath");return e&&n.setAttribute("id",e),void 0===i&&(i="userSpaceOnUse"),n.setAttribute("clipPathUnits",i),this._appendSettings(s,n),t.appendChild(n),n},t.prototype.createPath=function(){return new n},t.prototype._appendSettings=function(t,e){void 0!==t&&Object.keys(t).forEach((function(i){e.setAttribute(i,t[i])}))},t}(),r=(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}),a=function(t){function e(e){var i=this.constructor,s=t.call(this,e)||this;return Object.setPrototypeOf(s,i.prototype),s}return r(e,t),e}(Error),h=!0;function l(t){h=t}var c=function(){function t(){}return t.log=function(t){h&&console.log(t)},t._makeUniqueId=function(t){return"EMFJS_"+t+this._uniqueId++},t._writeUint32Val=function(t,e,i){t[e++]=255&i,t[e++]=i>>>8&255,t[e++]=i>>>16&255,t[e++]=i>>>24&255},t._blobToBinary=function(t){for(var e="",i=t.length,s=0;s<i;s++)e+=String.fromCharCode(t[s]);return e},t.GDI={FormatSignature:{ENHMETA_SIGNATURE:1179469088,EPS_SIGNATURE:1179865157},BITMAPINFOHEADER_SIZE:40,BITMAPCOREHEADER_SIZE:12,RecordType:{EMR_POLYBEZIER:2,EMR_POLYGON:3,EMR_POLYLINE:4,EMR_POLYBEZIERTO:5,EMR_POLYLINETO:6,EMR_POLYPOLYLINE:7,EMR_POLYPOLYGON:8,EMR_SETWINDOWEXTEX:9,EMR_SETWINDOWORGEX:10,EMR_SETVIEWPORTEXTEX:11,EMR_SETVIEWPORTORGEX:12,EMR_SETBRUSHORGEX:13,EMR_EOF:14,EMR_SETPIXELV:15,EMR_SETMAPPERFLAGS:16,EMR_SETMAPMODE:17,EMR_SETBKMODE:18,EMR_SETPOLYFILLMODE:19,EMR_SETROP2:20,EMR_SETSTRETCHBLTMODE:21,EMR_SETTEXTALIGN:22,EMR_SETCOLORADJUSTMENT:23,EMR_SETTEXTCOLOR:24,EMR_SETBKCOLOR:25,EMR_OFFSETCLIPRGN:26,EMR_MOVETOEX:27,EMR_SETMETARGN:28,EMR_EXCLUDECLIPRECT:29,EMR_INTERSECTCLIPRECT:30,EMR_SCALEVIEWPORTEXTEX:31,EMR_SCALEWINDOWEXTEX:32,EMR_SAVEDC:33,EMR_RESTOREDC:34,EMR_SETWORLDTRANSFORM:35,EMR_MODIFYWORLDTRANSFORM:36,EMR_SELECTOBJECT:37,EMR_CREATEPEN:38,EMR_CREATEBRUSHINDIRECT:39,EMR_DELETEOBJECT:40,EMR_ANGLEARC:41,EMR_ELLIPSE:42,EMR_RECTANGLE:43,EMR_ROUNDRECT:44,EMR_ARC:45,EMR_CHORD:46,EMR_PIE:47,EMR_SELECTPALETTE:48,EMR_CREATEPALETTE:49,EMR_SETPALETTEENTRIES:50,EMR_RESIZEPALETTE:51,EMR_REALIZEPALETTE:52,EMR_EXTFLOODFILL:53,EMR_LINETO:54,EMR_ARCTO:55,EMR_POLYDRAW:56,EMR_SETARCDIRECTION:57,EMR_SETMITERLIMIT:58,EMR_BEGINPATH:59,EMR_ENDPATH:60,EMR_CLOSEFIGURE:61,EMR_FILLPATH:62,EMR_STROKEANDFILLPATH:63,EMR_STROKEPATH:64,EMR_FLATTENPATH:65,EMR_WIDENPATH:66,EMR_SELECTCLIPPATH:67,EMR_ABORTPATH:68,EMR_COMMENT:70,EMR_FILLRGN:71,EMR_FRAMERGN:72,EMR_INVERTRGN:73,EMR_PAINTRGN:74,EMR_EXTSELECTCLIPRGN:75,EMR_BITBLT:76,EMR_STRETCHBLT:77,EMR_MASKBLT:78,EMR_PLGBLT:79,EMR_SETDIBITSTODEVICE:80,EMR_STRETCHDIBITS:81,EMR_EXTCREATEFONTINDIRECTW:82,EMR_EXTTEXTOUTA:83,EMR_EXTTEXTOUTW:84,EMR_POLYBEZIER16:85,EMR_POLYGON16:86,EMR_POLYLINE16:87,EMR_POLYBEZIERTO16:88,EMR_POLYLINETO16:89,EMR_POLYPOLYLINE16:90,EMR_POLYPOLYGON16:91,EMR_POLYDRAW16:92,EMR_CREATEMONOBRUSH:93,EMR_CREATEDIBPATTERNBRUSHPT:94,EMR_EXTCREATEPEN:95,EMR_POLYTEXTOUTA:96,EMR_POLYTEXTOUTW:97,EMR_SETICMMODE:98,EMR_CREATECOLORSPACE:99,EMR_SETCOLORSPACE:100,EMR_DELETECOLORSPACE:101,EMR_GLSRECORD:102,EMR_GLSBOUNDEDRECORD:103,EMR_PIXELFORMAT:104,EMR_DRAWESCAPE:105,EMR_EXTESCAPE:106,EMR_SMALLTEXTOUT:108,EMR_FORCEUFIMAPPING:109,EMR_NAMEDESCAPE:110,EMR_COLORCORRECTPALETTE:111,EMR_SETICMPROFILEA:112,EMR_SETICMPROFILEW:113,EMR_ALPHABLEND:114,EMR_SETLAYOUT:115,EMR_TRANSPARENTBLT:116,EMR_GRADIENTFILL:118,EMR_SETLINKEDUFIS:119,EMR_SETTEXTJUSTIFICATION:120,EMR_COLORMATCHTOTARGETW:121,EMR_CREATECOLORSPACEW:122},MetafileEscapes:{NEWFRAME:1,ABORTDOC:2,NEXTBAND:3,SETCOLORTABLE:4,GETCOLORTABLE:5,FLUSHOUT:6,DRAFTMODE:7,QUERYESCSUPPORT:8,SETABORTPROC:9,STARTDOC:10,ENDDOC:11,GETPHYSPAGESIZE:12,GETPRINTINGOFFSET:13,GETSCALINGFACTOR:14,META_ESCAPE_ENHANCED_METAFILE:15,SETPENWIDTH:16,SETCOPYCOUNT:17,SETPAPERSOURCE:18,PASSTHROUGH:19,GETTECHNOLOGY:20,SETLINECAP:21,SETLINEJOIN:22,SETMITERLIMIT:23,BANDINFO:24,DRAWPATTERNRECT:25,GETVECTORPENSIZE:26,GETVECTORBRUSHSIZE:27,ENABLEDUPLEX:28,GETSETPAPERBINS:29,GETSETPRINTORIENT:30,ENUMPAPERBINS:31,SETDIBSCALING:32,EPSPRINTING:33,ENUMPAPERMETRICS:34,GETSETPAPERMETRICS:35,POSTSCRIPT_DATA:37,POSTSCRIPT_IGNORE:38,GETDEVICEUNITS:42,GETEXTENDEDTEXTMETRICS:256,GETPAIRKERNTABLE:258,EXTTEXTOUT:512,GETFACENAME:513,DOWNLOADFACE:514,METAFILE_DRIVER:2049,QUERYDIBSUPPORT:3073,BEGIN_PATH:4096,CLIP_TO_PATH:4097,END_PATH:4098,OPEN_CHANNEL:4110,DOWNLOADHEADER:4111,CLOSE_CHANNEL:4112,POSTSCRIPT_PASSTHROUGH:4115,ENCAPSULATED_POSTSCRIPT:4116,POSTSCRIPT_IDENTIFY:4117,POSTSCRIPT_INJECTION:4118,CHECKJPEGFORMAT:4119,CHECKPNGFORMAT:4120,GET_PS_FEATURESETTING:4121,MXDC_ESCAPE:4122,SPCLPASSTHROUGH2:4568},MapMode:{MM_TEXT:1,MM_LOMETRIC:2,MM_HIMETRIC:3,MM_LOENGLISH:4,MM_HIENGLISH:5,MM_TWIPS:6,MM_ISOTROPIC:7,MM_ANISOTROPIC:8},StretchMode:{BLACKONWHITE:1,WHITEONBLACK:2,COLORONCOLOR:3,HALFTONE:4},MixMode:{TRANSPARENT:1,OPAQUE:2},BrushStyle:{BS_SOLID:0,BS_NULL:1,BS_HATCHED:2,BS_PATTERN:3,BS_INDEXED:4,BS_DIBPATTERN:5,BS_DIBPATTERNPT:6,BS_PATTERN8X8:7,BS_DIBPATTERN8X8:8,BS_MONOPATTERN:9},PenStyle:{PS_COSMETIC:0,PS_ENDCAP_ROUND:0,PS_JOIN_ROUND:0,PS_SOLID:0,PS_DASH:1,PS_DOT:2,PS_DASHDOT:3,PS_DASHDOTDOT:4,PS_NULL:5,PS_INSIDEFRAME:6,PS_USERSTYLE:7,PS_ALTERNATE:8,PS_ENDCAP_SQUARE:256,PS_ENDCAP_FLAT:512,PS_JOIN_BEVEL:4096,PS_JOIN_MITER:8192,PS_GEOMETRIC:65536},PolygonFillMode:{ALTERNATE:1,WINDING:2},BitmapCompression:{BI_RGB:0,BI_RLE8:1,BI_RLE4:2,BI_BITFIELDS:3,BI_JPEG:4,BI_PNG:5},RegionMode:{RGN_AND:1,RGN_OR:2,RGN_XOR:3,RGN_DIFF:4,RGN_COPY:5},StockObject:{WHITE_BRUSH:2147483648,LTGRAY_BRUSH:2147483649,GRAY_BRUSH:2147483650,DKGRAY_BRUSH:2147483651,BLACK_BRUSH:2147483652,NULL_BRUSH:2147483653,WHITE_PEN:2147483654,BLACK_PEN:2147483655,NULL_PEN:2147483656,OEM_FIXED_FONT:2147483658,ANSI_FIXED_FONT:2147483659,ANSI_VAR_FONT:2147483660,SYSTEM_FONT:2147483661,DEVICE_DEFAULT_FONT:2147483662,DEFAULT_PALETTE:2147483663,SYSTEM_FIXED_FONT:2147483664,DEFAULT_GUI_FONT:2147483665,DC_BRUSH:2147483666,DC_PEN:2147483667}},t._uniqueId=0,t}(),p=function(){function t(e,i){e instanceof t?(this.blob=e.blob,this.data=e.data,this.pos=i||e.pos):(this.blob=e,this.data=new Uint8Array(e),this.pos=i||0)}return t.prototype.eof=function(){return this.pos>=this.data.length},t.prototype.seek=function(t){if(t<0||t>this.data.length)throw new a("Invalid seek position");this.pos=t},t.prototype.skip=function(t){var e=this.pos+t;if(e>this.data.length)throw new a("Unexpected end of file");this.pos=e},t.prototype.readBinary=function(t){if(this.pos+t>this.data.length)throw new a("Unexpected end of file");for(var e="";t-- >0;)e+=String.fromCharCode(this.data[this.pos++]);return e},t.prototype.readInt8=function(){if(this.pos+1>this.data.length)throw new a("Unexpected end of file");return this.data[this.pos++]},t.prototype.readUint8=function(){return this.readInt8()>>>0},t.prototype.readInt32=function(){if(this.pos+4>this.data.length)throw new a("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8,(t|=this.data[this.pos++]<<16)|this.data[this.pos++]<<24},t.prototype.readUint32=function(){return this.readInt32()>>>0},t.prototype.readUint16=function(){if(this.pos+2>this.data.length)throw new a("Unexpected end of file");return this.data[this.pos++]|this.data[this.pos++]<<8},t.prototype.readInt16=function(){var t=this.readUint16();return t>32767&&(t-=65536),t},t.prototype.readString=function(t){if(this.pos+t>this.data.length)throw new a("Unexpected end of file");for(var e="",i=0;i<t;i++)e+=String.fromCharCode(this.data[this.pos++]>>>0);return e},t.prototype.readNullTermString=function(t){var e="";if(t>0){t--;for(var i=0;i<t;i++){if(this.pos+i+1>this.data.length)throw new a("Unexpected end of file");var s=this.data[this.pos+i]>>>0;if(0===s)break;e+=String.fromCharCode(s)}}return e},t.prototype.readFixedSizeUnicodeString=function(t){for(var e="",i=0;i<t;i++){var s=this.readUint16();if(0===s){++i<t&&this.skip(2*(t-i));break}e+=String.fromCharCode(s)}return e},t}(),E=function(){function t(t,e,i){null!=t?(this.x=t.readInt16(),this.y=t.readInt16()):(this.x=e,this.y=i)}return t.prototype.clone=function(){return new t(null,this.x,this.y)},t.prototype.toString=function(){return"{x: "+this.x+", y: "+this.y+"}"},t}(),u=function(){function t(t,e,i){null!=t?(this.x=t.readInt32(),this.y=t.readInt32()):(this.x=e,this.y=i)}return t.prototype.clone=function(){return new t(null,this.x,this.y)},t.prototype.toString=function(){return"{x: "+this.x+", y: "+this.y+"}"},t}(),d=function(){function t(t,e,i,s,n){null!=t?(this.left=t.readInt32(),this.top=t.readInt32(),this.right=t.readInt32(),this.bottom=t.readInt32()):(this.bottom=n,this.right=s,this.top=i,this.left=e)}return t.prototype.clone=function(){return new t(null,this.left,this.top,this.right,this.bottom)},t.prototype.toString=function(){return"{left: "+this.left+", top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+"}"},t.prototype.empty=function(){return this.left>=this.right||this.top>=this.bottom},t.prototype.intersect=function(e){return this.empty()||e.empty()||this.left>=e.right||this.top>=e.bottom||this.right<=e.left||this.bottom<=e.top?null:new t(null,Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom))},t}(),_=function(){function t(t,e,i){null!=t?(this.cx=t.readUint32(),this.cy=t.readUint32()):(this.cx=e,this.cy=i)}return t.prototype.clone=function(){return new t(null,this.cx,this.cy)},t.prototype.toString=function(){return"{cx: "+this.cx+", cy: "+this.cy+"}"},t}(),R=function(){function t(t){this.type=t}return t.prototype.clone=function(){throw new a("clone not implemented")},t.prototype.toString=function(){throw new a("toString not implemented")},t}(),T=function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),g=function(t){function e(e,i){var s=t.call(this,"region")||this;if(null!=e){if(32!==e.readUint32())throw new a("Invalid region header");e.skip(4);var n=e.readUint32();if(16*n!==e.readUint32())throw new a("Invalid region data");s.bounds=new d(e),s.scans=[];for(var o=void 0,r=0;r<n;r++){var h=new d(e);o||o.top!==h.top||o.bottom!==h.bottom?(o=new f(h),s.scans.push(o)):o.append(h)}s._updateComplexity()}else if(null!=i){if(s.bounds=null!=i.bounds?i.bounds.clone():null,null!=i.scans)for(s.scans=[],r=0;r<i.scans.length;r++)s.scans.push(i.scans[r].clone());else s.scans=null;s.complexity=i.complexity}else s.bounds=null,s.scans=null,s.complexity=0;return s}return T(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return"{complexity: "+["null","simple","complex"][this.complexity]+" bounds: "+(null!=this.bounds?this.bounds.toString():"[none]")+" #scans: "+(null!=this.scans?this.scans.length:"[none]")+"}"},e.prototype._updateComplexity=function(){if(null==this.bounds)this.complexity=0,this.scans=null;else if(this.bounds.empty())this.complexity=0,this.scans=null,this.bounds=null;else if(null==this.scans)this.complexity=1;else if(this.complexity=2,1===this.scans.length){var t=this.scans[0];if(t.top===this.bounds.top&&t.bottom===this.bounds.bottom&&1===t.scanlines.length){var e=t.scanlines[0];e.left===this.bounds.left&&e.right===this.bounds.right&&(this.scans=null,this.complexity=1)}}},e.prototype.subtract=function(t){if(c.log("[emf] Region "+this.toString()+" subtract "+t.toString()),null!=this.bounds&&null!=this.bounds.intersect(t)){null==this.scans&&(this.scans=[],this.scans.push(new f(new d(null,this.bounds.left,this.bounds.top,this.bounds.right,this.bounds.bottom))),this.complexity=2);for(var e=0;e<this.scans.length;){if((E=this.scans[e]).bottom>=t.top){var i=E.clone();E.bottom=t.top-1,i.top=t.top,E.top>=E.bottom?this.scans[e]=i:(c.log("[emf] Region split top scan "+e+" for substraction"),this.scans.splice(++e,0,i));break}e++}for(var s=e;e<this.scans.length&&!((E=this.scans[e]).top>t.bottom);){if(E.bottom>t.bottom){i=E.clone(),E.bottom=t.bottom,i.top=t.bottom+1,E.top>=E.bottom?this.scans[e]=i:(c.log("[emf] Region split bottom scan "+e+" for substraction"),this.scans.splice(++e,0,i));break}e++}if(s<this.scans.length){var n=e;for(e=s;e<n;)(E=this.scans[e]).subtract(t.left,t.right)?e++:(c.log("[emf] Region remove now empty scan "+e+" due to subtraction"),this.scans.splice(e,1),n--)}if(null!=this.scans){for(var o,r=void 0,a=void 0,h=void 0,l=this.scans.length,p=0;p<l;p++){var E=this.scans[p];0===p&&(o=E.top),p===l-1&&(h=E.bottom);var u=E.scanlines.length;if(u>0){var _=E.scanlines[0];(null==r||_.left<r)&&(r=_.left),_=E.scanlines[u-1],(null==a||_.right>a)&&(a=_.right)}}null!=r&&null!=o&&null!=a&&null!=h?(this.bounds=new d(null,r,o,a,h),this._updateComplexity()):(this.bounds=null,this.scans=null,this.complexity=0)}else this._updateComplexity()}c.log("[emf] Region subtraction -> "+this.toString())},e.prototype.intersect=function(t){if(c.log("[emf] Region "+this.toString()+" intersect with "+t.toString()),null!=this.bounds)if(this.bounds=this.bounds.intersect(t),null!=this.bounds){if(null!=this.scans){for(var e=0;e<this.scans.length&&(i=this.scans[e]).bottom<this.bounds.top;)e++;for(e>0&&(c.log("[emf] Region remove "+e+" scans from top"),this.scans.splice(0,e),this.scans.length>0&&(this.scans[0].top=this.bounds.top)),e=0;e<this.scans.length;){var i;if((i=this.scans[e]).top>this.bounds.bottom){c.log("[emf] Region remove "+(this.scans.length-e)+" scans from bottom"),this.scans.splice(e,this.scans.length-e);break}i.intersect(this.bounds.left,this.bounds.right)?e++:(c.log("[emf] Region remove now empty scan "+e+" due to intersection"),this.scans.splice(e,1))}this.scans.length>0&&(this.scans[this.scans.length-1].bottom=this.bounds.bottom),this._updateComplexity()}}else this.scans=null,this.complexity=0;c.log("[emf] Region intersection -> "+this.toString())},e.prototype.offset=function(t,e){if(null!=this.bounds&&(this.bounds.left+=t,this.bounds.top+=e,this.bounds.right+=t,this.bounds.bottom+=e),null!=this.scans)for(var i=this.scans.length,s=0;s<i;s++){var n=this.scans[s];n.top+=e,n.bottom+=e;for(var o=n.scanlines.length,r=0;r<o;r++){var a=n.scanlines[r];a.left+=t,a.right+=t}}},e}(R),f=function(){function t(t,e){if(null!=t)this.top=t.top,this.bottom=t.bottom,this.scanlines=[{left:t.left,right:t.right}];else if(null!=e){this.top=e.top,this.bottom=e.bottom,this.scanlines=[];for(var i=0;i<e.scanlines.length;i++){var s=e.scanlines[i];this.scanlines.push({left:s.left,right:s.right})}}}return t.prototype.clone=function(){return new t(null,this)},t.prototype.append=function(t){this.scanlines.push({left:t.left,right:t.right})},t.prototype.subtract=function(t,e){var i;for(i=0;i<this.scanlines.length&&(o=this.scanlines[i]).left<=t;)o.right>=t&&(o.right=t-1,o.left>=o.right)?this.scanlines.splice(i,1):i++;for(var s=i,n=0;i<this.scanlines.length;){var o;if((o=this.scanlines[i]).right>e){o.left=e,n=i-s,o.left>=o.right&&n++;break}i++}return n>0&&s<this.scanlines.length&&this.scanlines.splice(s,n),this.scanlines.length>0},t.prototype.intersect=function(t,e){for(var i=0;i<this.scanlines.length;i++)if((s=this.scanlines[i]).left>=t||s.right>=t){i>0&&this.scanlines.splice(0,i);break}if(this.scanlines.length>0){var s;for((s=this.scanlines[0]).left<t&&(s.left=t),i=0;i<this.scanlines.length;i++)if((s=this.scanlines[i]).left>e){this.scanlines.splice(i,this.scanlines.length-i);break}this.scanlines.length>0&&(s=this.scanlines[this.scanlines.length-1]).right>e&&(s.right=e)}return this.scanlines.length>0},t}(),y=function(){function t(t,e){e&&t.skip(4),this.width=t.readUint16(),this.height=t.readUint16(),this.planes=t.readUint16(),this.bitcount=t.readUint16()}return t.prototype.colors=function(){return this.bitcount<=8?1<<this.bitcount:0},t}(),S=function(){function t(t,e){e&&t.skip(4),this.width=t.readInt32(),this.height=t.readInt32(),this.planes=t.readUint16(),this.bitcount=t.readUint16(),this.compression=t.readUint32(),this.sizeimage=t.readUint32(),this.xpelspermeter=t.readInt32(),this.ypelspermeter=t.readInt32(),this.clrused=t.readUint32(),this.clrimportant=t.readUint32()}return t.prototype.colors=function(){return 0!==this.clrused?this.clrused<256?this.clrused:256:this.bitcount>8?0:1<<this.bitcount},t}(),I=function(){function t(t,e){this._usergb=e;var i=t.readUint32();if(this._infosize=i,i===c.GDI.BITMAPCOREHEADER_SIZE)this._header=new y(t,!1),this._infosize+=this._header.colors()*(e?3:2);else{this._header=new S(t,!1);var s=this._header.compression===c.GDI.BitmapCompression.BI_BITFIELDS?3:0;i<=c.GDI.BITMAPINFOHEADER_SIZE+4*s&&(this._infosize=c.GDI.BITMAPINFOHEADER_SIZE+4*s),this._infosize+=this._header.colors()*(e?4:2)}}return t.prototype.getWidth=function(){return this._header.width},t.prototype.getHeight=function(){return Math.abs(this._header.height)},t.prototype.infosize=function(){return this._infosize},t.prototype.header=function(){return this._header},t}(),v=function(){function t(t,e){this._reader=t,this._offset=t.pos,this._location=e,this._info=new I(t,!0)}return t.prototype.getWidth=function(){return this._info.getWidth()},t.prototype.getHeight=function(){return this._info.getHeight()},t.prototype.totalSize=function(){return this._location.header.size+this._location.data.size},t.prototype.makeBitmapFileHeader=function(){var t=new ArrayBuffer(14),e=new Uint8Array(t);return e[0]=66,e[1]=77,c._writeUint32Val(e,2,this.totalSize()+14),c._writeUint32Val(e,10,this._info.infosize()+14),c._blobToBinary(e)},t.prototype.base64ref=function(){var t=this._reader.pos;this._reader.seek(this._offset);var e,i="image/bmp",s=this._info.header();if(s instanceof S&&null!=s.compression)switch(s.compression){case c.GDI.BitmapCompression.BI_JPEG:i="data:image/jpeg";break;case c.GDI.BitmapCompression.BI_PNG:i="data:image/png";break;default:e=this.makeBitmapFileHeader()}else e=this.makeBitmapFileHeader();this._reader.seek(this._location.header.offset),null!=e?e+=this._reader.readBinary(this._location.header.size):e=this._reader.readBinary(this._location.header.size),this._reader.seek(this._location.data.offset),e+=this._reader.readBinary(this._location.data.size);var n="data:"+i+";base64,"+btoa(e);return this._reader.seek(t),n},t}(),O=function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),M=function(){function t(t,e,i,s){null!=t?(this.r=t.readUint8(),this.g=t.readUint8(),this.b=t.readUint8(),t.skip(1)):(this.r=e,this.g=i,this.b=s)}return t.prototype.clone=function(){return new t(null,this.r,this.g,this.b)},t.prototype.toHex=function(){return(16777216+(this.r<<16|this.g<<8|this.b)).toString(16).slice(1)},t.prototype.toString=function(){return"{r: "+this.r+", g: "+this.g+", b: "+this.b+"}"},t}(),b=function(t){function e(e,i){var s=t.call(this,"font")||this;if(null!=e){s.height=e.readInt32(),s.width=e.readInt32(),s.escapement=e.readInt32(),s.orientation=e.readInt32(),s.weight=e.readInt32(),s.italic=e.readUint8(),s.underline=e.readUint8(),s.strikeout=e.readUint8(),s.charset=e.readUint8(),s.outprecision=e.readUint8(),s.clipprecision=e.readUint8(),s.quality=e.readUint8();var n=e.readUint8();s.pitch=15&n,s.family=n>>6&3;var o=i,r=e.pos;s.facename=e.readFixedSizeUnicodeString(Math.min(o-(e.pos-r),32))}else null!=i?(i=i,s.height=i.height,s.width=i.width,s.escapement=i.escapement,s.orientation=i.orientation,s.weight=i.weight,s.italic=i.italic,s.underline=i.underline,s.strikeout=i.strikeout,s.charset=i.charset,s.outprecision=i.outprecision,s.clipprecision=i.clipprecision,s.quality=i.quality,s.pitch=i.pitch,s.family=i.family,s.facename=i.facename):(s.height=-80,s.width=0,s.escapement=0,s.orientation=0,s.weight=400,s.italic=0,s.underline=0,s.strikeout=0,s.charset=0,s.outprecision=0,s.clipprecision=0,s.quality=0,s.pitch=0,s.family=0,s.facename="Helvetica");return s}return O(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return JSON.stringify(this)},e}(R),w=function(t){function e(e,i){var s=t.call(this,"brush")||this;if(null!=e){var n=e.pos;switch(s.style=e.readUint32(),s.style){case c.GDI.BrushStyle.BS_SOLID:s.color=new M(e);break;case c.GDI.BrushStyle.BS_PATTERN:s.pattern=new v(e);break;case c.GDI.BrushStyle.BS_DIBPATTERNPT:s.dibpatternpt=new v(e);break;case c.GDI.BrushStyle.BS_HATCHED:s.color=new M(e),s.hatchstyle=e.readUint32()}e.seek(n+12)}else switch(s.style=i.style,s.style){case c.GDI.BrushStyle.BS_SOLID:s.color=i.color.clone();break;case c.GDI.BrushStyle.BS_PATTERN:s.pattern=i.pattern;break;case c.GDI.BrushStyle.BS_DIBPATTERNPT:s.dibpatternpt=i.dibpatternpt;break;case c.GDI.BrushStyle.BS_HATCHED:s.color=i.color.clone(),s.hatchstyle=i.hatchstyle}return s}return O(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){var t="{style: "+this.style;switch(this.style){case c.GDI.BrushStyle.BS_SOLID:t+=", color: "+this.color.toString();break;case c.GDI.BrushStyle.BS_HATCHED:t+=", color: "+this.color.toString()+", hatchstyle: "+this.hatchstyle}return t+"}"},e}(R),P=function(t){function e(e,i,s,n,o){var r=t.call(this,"pen")||this;return null!=e?null!=i?(r.style=255&e.readUint32(),r.width=e.readUint32(),r.brush=new w(e),r.color=null!=r.brush.color?r.brush.color.clone():new M(null,0,0,0)):(r.style=255&e.readUint32(),r.width=new u(e).x,r.color=new M(e)):(r.style=i,r.width=s,null!=n&&(r.color=n),null!=o&&(r.brush=o)),r}return O(e,t),e.prototype.clone=function(){return new e(null,this.style,this.width,null!=this.color?this.color.clone():null,null!=this.brush?this.brush.clone():null)},e.prototype.toString=function(){return"{style: "+this.style+", width: "+this.width+", color: "+(null!=this.color?this.color.toString():"none")+"}"},e}(R),D=function(){function t(t,e){var i=t.pos-8;if(this.size=e,this.bounds=new d(t),this.frame=new d(t),t.readUint32()!==c.GDI.FormatSignature.ENHMETA_SIGNATURE)throw new a("Invalid header signature");t.skip(4),t.skip(4),t.skip(4),t.skip(2),t.skip(2);var s=t.readUint32(),n=t.readUint32();this.nPalEntries=t.readUint32(),this.refDevCx=t.readUint32(),this.refDevCy=t.readUint32(),this.refDevCxMm=t.readUint32(),this.refDevCyMm=t.readUint32();var o=e;if(s>0){if(n<88)throw new a("Invalid header description offset");if((o=n+2*s)>e)throw new a("Invalid header description length");var r=t.pos;t.seek(i+n),this.description=t.readFixedSizeUnicodeString(s),t.seek(r)}else this.description="";if(o>=100){var h=t.readUint32(),l=t.readUint32();if(0!==t.readUint32())throw new a("OpenGL records are not yet supported");if(0!==l){if(l<100||l<o)throw new a("Invalid pixel format offset");if((o=l+h)>e)throw new a("Invalid pixel format size")}o>=108&&(this.displayDevCxUm=t.readUint32(),this.displayDevCyUm=t.readUint32())}}return t.prototype.toString=function(){return"{bounds: "+this.bounds.toString()+", frame: "+this.frame.toString()+", description: "+this.description+"}"},t}(),A=function(){function t(t,e){this._records=[],this._header=new D(t,e);var i=!1,s=e,n=function(){t.seek(s);var e=t.readUint32(),n=t.readUint32();if(n<8)throw new a("Invalid record size");switch(e){case c.GDI.RecordType.EMR_EOF:return i=!0,"break-main_loop";case c.GDI.RecordType.EMR_SETMAPMODE:var r=t.readInt32();o._records.push((function(t){t.setMapMode(r)}));break;case c.GDI.RecordType.EMR_SETWINDOWORGEX:var h=t.readInt32(),l=t.readInt32();o._records.push((function(t){t.setWindowOrgEx(h,l)}));break;case c.GDI.RecordType.EMR_SETWINDOWEXTEX:var p=t.readUint32(),R=t.readUint32();o._records.push((function(t){t.setWindowExtEx(p,R)}));break;case c.GDI.RecordType.EMR_SETVIEWPORTORGEX:var T=t.readInt32(),f=t.readInt32();o._records.push((function(t){t.setViewportOrgEx(T,f)}));break;case c.GDI.RecordType.EMR_SETVIEWPORTEXTEX:var y=t.readUint32(),S=t.readUint32();o._records.push((function(t){t.setViewportExtEx(y,S)}));break;case c.GDI.RecordType.EMR_SAVEDC:o._records.push((function(t){t.saveDC()}));break;case c.GDI.RecordType.EMR_RESTOREDC:var I=t.readInt32();o._records.push((function(t){t.restoreDC(I)}));break;case c.GDI.RecordType.EMR_SETBKMODE:var v=t.readUint32();o._records.push((function(t){t.setBkMode(v)}));break;case c.GDI.RecordType.EMR_SETBKCOLOR:var O=new M(t);o._records.push((function(t){t.setBkColor(O)}));break;case c.GDI.RecordType.EMR_CREATEBRUSHINDIRECT:var b=t.readUint32(),D=new w(t);o._records.push((function(t){t.createBrush(b,D)}));break;case c.GDI.RecordType.EMR_CREATEPEN:var A=t.readUint32(),L=new P(t,null);o._records.push((function(t){t.createPen(A,L)}));break;case c.GDI.RecordType.EMR_EXTCREATEPEN:var C=t.readUint32(),N=t.readUint32(),G=t.readUint32(),m=t.readUint32(),x=t.readUint32(),U=new P(t,{header:{off:N,size:G},data:{off:m,size:x}});o._records.push((function(t){t.createPen(C,U)}));break;case c.GDI.RecordType.EMR_SELECTOBJECT:var B=t.readUint32();o._records.push((function(t){t.selectObject(B,null)}));break;case c.GDI.RecordType.EMR_DELETEOBJECT:var k=t.readUint32();o._records.push((function(t){t.deleteObject(k)}));break;case c.GDI.RecordType.EMR_RECTANGLE:var F=new d(t);o._records.push((function(t){t.rectangle(F,0,0)}));break;case c.GDI.RecordType.EMR_ROUNDRECT:var H=new d(t),X=new _(t);o._records.push((function(t){t.rectangle(H,X.cx,X.cy)}));break;case c.GDI.RecordType.EMR_LINETO:var Y=t.readInt32(),W=t.readInt32();o._records.push((function(t){t.lineTo(Y,W)}));break;case c.GDI.RecordType.EMR_MOVETOEX:var j=t.readInt32(),z=t.readInt32();o._records.push((function(t){t.moveToEx(j,z)}));break;case c.GDI.RecordType.EMR_POLYGON:case c.GDI.RecordType.EMR_POLYGON16:for(var V=e===c.GDI.RecordType.EMR_POLYGON16,K=new d(t),Z=t.readUint32(),J=[];Z>0;)J.push(V?new E(t):new u(t)),Z--;o._records.push((function(t){t.polygon(J,K,!0)}));break;case c.GDI.RecordType.EMR_POLYPOLYGON:case c.GDI.RecordType.EMR_POLYPOLYGON16:V=e===c.GDI.RecordType.EMR_POLYPOLYGON16;var q=new d(t),Q=t.readUint32();t.skip(4);for(var $=[],tt=0;tt<Q;tt++)$.push(t.readUint32());var et=[];for(tt=0;tt<Q;tt++){for(var it=$[tt],st=[],nt=0;nt<it;nt++)st.push(V?new E(t):new u(t));et.push(st)}o._records.push((function(t){t.polyPolygon(et,q)}));break;case c.GDI.RecordType.EMR_SETPOLYFILLMODE:var ot=t.readUint32();o._records.push((function(t){t.setPolyFillMode(ot)}));break;case c.GDI.RecordType.EMR_POLYLINE16:case c.GDI.RecordType.EMR_POLYLINETO16:for(var rt=e===c.GDI.RecordType.EMR_POLYLINETO16,at=new d(t),ht=(Z=t.readUint32(),[]);Z>0;)ht.push(new E(t)),Z--;o._records.push((function(t){t.polyline(rt,ht,at)}));break;case c.GDI.RecordType.EMR_POLYBEZIER:case c.GDI.RecordType.EMR_POLYBEZIERTO:for(var lt=e===c.GDI.RecordType.EMR_POLYBEZIERTO,ct=new d(t),pt=(Z=t.readUint32(),[]);Z>0;)pt.push(new u(t)),Z--;o._records.push((function(t){t.polybezier(lt,pt,ct)}));break;case c.GDI.RecordType.EMR_POLYBEZIER16:for(var Et=new d(t),ut=new u(t),dt=(Z=t.readUint32(),[ut]);Z>0;)dt.push(new E(t)),Z--;o._records.push((function(t){t.polybezier(!1,dt,Et)}));break;case c.GDI.RecordType.EMR_POLYBEZIERTO16:for(var _t=new d(t),Rt=(Z=t.readUint32(),[]);Z>0;)Rt.push(new E(t)),Z--;o._records.push((function(t){t.polybezier(!0,Rt,_t)}));break;case c.GDI.RecordType.EMR_SETTEXTALIGN:var Tt=t.readUint32();o._records.push((function(t){t.setTextAlign(Tt)}));break;case c.GDI.RecordType.EMR_SETSTRETCHBLTMODE:var gt=t.readUint32();o._records.push((function(t){t.setStretchBltMode(gt)}));break;case c.GDI.RecordType.EMR_SETBRUSHORGEX:var ft=new u(t);o._records.push((function(t){t.setBrushOrgEx(ft)}));break;case c.GDI.RecordType.EMR_BEGINPATH:o._records.push((function(t){t.beginPath()}));break;case c.GDI.RecordType.EMR_ENDPATH:o._records.push((function(t){t.endPath()}));break;case c.GDI.RecordType.EMR_ABORTPATH:o._records.push((function(t){t.abortPath()}));break;case c.GDI.RecordType.EMR_CLOSEFIGURE:o._records.push((function(t){t.closeFigure()}));break;case c.GDI.RecordType.EMR_FILLPATH:var yt=new d(t);o._records.push((function(t){t.fillPath(yt)}));break;case c.GDI.RecordType.EMR_STROKEPATH:var St=new d(t);o._records.push((function(t){t.strokePath(St)}));break;case c.GDI.RecordType.EMR_SELECTCLIPPATH:var It=t.readUint32();o._records.push((function(t){t.selectClipPath(It)}));break;case c.GDI.RecordType.EMR_EXTSELECTCLIPRGN:t.skip(4);var vt=t.readUint32(),Ot=vt!==c.GDI.RegionMode.RGN_COPY?new g(t):null;o._records.push((function(t){t.selectClipRgn(vt,Ot)}));break;case c.GDI.RecordType.EMR_OFFSETCLIPRGN:var Mt=new u(t);o._records.push((function(t){t.offsetClipRgn(Mt)}));break;case c.GDI.RecordType.EMR_SETMITERLIMIT:var bt=t.readUint32();o._records.push((function(t){t.setMiterLimit(bt)}));break;case c.GDI.RecordType.EMR_POLYLINE:case c.GDI.RecordType.EMR_POLYLINETO:case c.GDI.RecordType.EMR_POLYPOLYLINE:case c.GDI.RecordType.EMR_SETPIXELV:case c.GDI.RecordType.EMR_SETMAPPERFLAGS:case c.GDI.RecordType.EMR_SETROP2:case c.GDI.RecordType.EMR_SETCOLORADJUSTMENT:case c.GDI.RecordType.EMR_SETTEXTCOLOR:case c.GDI.RecordType.EMR_SETMETARGN:case c.GDI.RecordType.EMR_EXCLUDECLIPRECT:case c.GDI.RecordType.EMR_INTERSECTCLIPRECT:case c.GDI.RecordType.EMR_SCALEVIEWPORTEXTEX:case c.GDI.RecordType.EMR_SCALEWINDOWEXTEX:case c.GDI.RecordType.EMR_SETWORLDTRANSFORM:case c.GDI.RecordType.EMR_MODIFYWORLDTRANSFORM:case c.GDI.RecordType.EMR_ANGLEARC:case c.GDI.RecordType.EMR_ELLIPSE:case c.GDI.RecordType.EMR_ARC:case c.GDI.RecordType.EMR_CHORD:case c.GDI.RecordType.EMR_PIE:case c.GDI.RecordType.EMR_SELECTPALETTE:case c.GDI.RecordType.EMR_CREATEPALETTE:case c.GDI.RecordType.EMR_SETPALETTEENTRIES:case c.GDI.RecordType.EMR_RESIZEPALETTE:case c.GDI.RecordType.EMR_REALIZEPALETTE:case c.GDI.RecordType.EMR_EXTFLOODFILL:case c.GDI.RecordType.EMR_ARCTO:case c.GDI.RecordType.EMR_POLYDRAW:case c.GDI.RecordType.EMR_SETARCDIRECTION:case c.GDI.RecordType.EMR_STROKEANDFILLPATH:case c.GDI.RecordType.EMR_FLATTENPATH:case c.GDI.RecordType.EMR_WIDENPATH:case c.GDI.RecordType.EMR_COMMENT:case c.GDI.RecordType.EMR_FILLRGN:case c.GDI.RecordType.EMR_FRAMERGN:case c.GDI.RecordType.EMR_INVERTRGN:case c.GDI.RecordType.EMR_PAINTRGN:case c.GDI.RecordType.EMR_BITBLT:case c.GDI.RecordType.EMR_STRETCHBLT:case c.GDI.RecordType.EMR_MASKBLT:case c.GDI.RecordType.EMR_PLGBLT:case c.GDI.RecordType.EMR_SETDIBITSTODEVICE:case c.GDI.RecordType.EMR_STRETCHDIBITS:case c.GDI.RecordType.EMR_EXTCREATEFONTINDIRECTW:case c.GDI.RecordType.EMR_EXTTEXTOUTA:case c.GDI.RecordType.EMR_EXTTEXTOUTW:case c.GDI.RecordType.EMR_POLYPOLYLINE16:case c.GDI.RecordType.EMR_POLYDRAW16:case c.GDI.RecordType.EMR_CREATEMONOBRUSH:case c.GDI.RecordType.EMR_CREATEDIBPATTERNBRUSHPT:case c.GDI.RecordType.EMR_POLYTEXTOUTA:case c.GDI.RecordType.EMR_POLYTEXTOUTW:case c.GDI.RecordType.EMR_SETICMMODE:case c.GDI.RecordType.EMR_CREATECOLORSPACE:case c.GDI.RecordType.EMR_SETCOLORSPACE:case c.GDI.RecordType.EMR_DELETECOLORSPACE:case c.GDI.RecordType.EMR_GLSRECORD:case c.GDI.RecordType.EMR_GLSBOUNDEDRECORD:case c.GDI.RecordType.EMR_PIXELFORMAT:case c.GDI.RecordType.EMR_DRAWESCAPE:case c.GDI.RecordType.EMR_EXTESCAPE:case c.GDI.RecordType.EMR_SMALLTEXTOUT:case c.GDI.RecordType.EMR_FORCEUFIMAPPING:case c.GDI.RecordType.EMR_NAMEDESCAPE:case c.GDI.RecordType.EMR_COLORCORRECTPALETTE:case c.GDI.RecordType.EMR_SETICMPROFILEA:case c.GDI.RecordType.EMR_SETICMPROFILEW:case c.GDI.RecordType.EMR_ALPHABLEND:case c.GDI.RecordType.EMR_SETLAYOUT:case c.GDI.RecordType.EMR_TRANSPARENTBLT:case c.GDI.RecordType.EMR_GRADIENTFILL:case c.GDI.RecordType.EMR_SETLINKEDUFIS:case c.GDI.RecordType.EMR_SETTEXTJUSTIFICATION:case c.GDI.RecordType.EMR_COLORMATCHTOTARGETW:case c.GDI.RecordType.EMR_CREATECOLORSPACEW:default:var wt="UNKNOWN";for(var Pt in c.GDI.RecordType)if(c.GDI.RecordType[Pt]===e){wt=Pt;break}c.log("[EMF] "+wt+" record (0x"+e.toString(16)+") at offset 0x"+s.toString(16)+" with "+n+" bytes")}s+=n},o=this;t:for(;!i;)switch(n()){case"break-main_loop":break t}if(!i)throw new a("Could not read all records")}return t.prototype.play=function(t){for(var e=this._records.length,i=0;i<e;i++)this._records[i](t)},t}(),L=function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),C=function(t){function e(e,i){var s=t.call(this,"path")||this;return s.svgPath=null!=e?e:i.svgPath,s}return L(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return"{[path]}"},e}(R),N=function(){var t=function(t,e,i){return new w(null,{style:c.GDI.BrushStyle.BS_SOLID,color:new M(null,t,e,i)})},e=function(t,e,i){return new P(null,c.GDI.PenStyle.PS_SOLID,1,new M(null,t,e,i),null)},i={WHITE_BRUSH:t(255,255,255),LTGRAY_BRUSH:t(212,208,200),GRAY_BRUSH:t(128,128,128),DKGRAY_BRUSH:t(64,64,64),BLACK_BRUSH:t(0,0,0),NULL_BRUSH:new w(null,{style:c.GDI.BrushStyle.BS_NULL}),WHITE_PEN:e(255,255,255),BLACK_PEN:e(0,0,0),NULL_PEN:new P(null,c.GDI.PenStyle.PS_NULL,0,null,null),OEM_FIXED_FONT:null,ANSI_FIXED_FONT:null,ANSI_VAR_FONT:null,SYSTEM_FONT:null,DEVICE_DEFAULT_FONT:null,DEFAULT_PALETTE:null,SYSTEM_FIXED_FONT:null,DEFAULT_GUI_FONT:null},s={};for(var n in i)s[(c.GDI.StockObject[n]-2147483648).toString()]=i[n];return s}(),G=function(t,e){if(null!=t)for(var i in this._svggroup=t._svggroup,this._svgclipChanged=t._svgclipChanged,this._svgtextbkfilter=t._svgtextbkfilter,this.mapmode=t.mapmode,this.stretchmode=t.stretchmode,this.textalign=t.textalign,this.bkmode=t.bkmode,this.textcolor=t.textcolor.clone(),this.bkcolor=t.bkcolor.clone(),this.polyfillmode=t.polyfillmode,this.miterlimit=t.miterlimit,this.wx=t.wx,this.wy=t.wy,this.ww=t.ww,this.wh=t.wh,this.vx=t.vx,this.vy=t.vy,this.vw=t.vw,this.vh=t.vh,this.x=t.x,this.y=t.y,this.nextbrx=t.nextbrx,this.nextbry=t.nextbry,this.brx=t.brx,this.bry=t.bry,this.clip=t.clip,this.ownclip=!1,this.selected={},t.selected)this.selected[i]=t.selected[i];else for(var i in this._svggroup=null,this._svgclipChanged=!1,this._svgtextbkfilter=null,this.mapmode=c.GDI.MapMode.MM_ANISOTROPIC,this.stretchmode=c.GDI.StretchMode.COLORONCOLOR,this.textalign=0,this.bkmode=c.GDI.MixMode.OPAQUE,this.textcolor=new M(null,0,0,0),this.bkcolor=new M(null,255,255,255),this.polyfillmode=c.GDI.PolygonFillMode.ALTERNATE,this.miterlimit=10,this.wx=0,this.wy=0,this.ww=0,this.wh=0,this.vx=0,this.vy=0,this.vw=0,this.vh=0,this.x=0,this.y=0,this.nextbrx=0,this.nextbry=0,this.brx=0,this.bry=0,this.clip=null,this.ownclip=!1,this.selected={},e){var s=e[i];this.selected[i]=null!=s?s.clone():null}},m=function(){function t(t){this._svg=t,this._svgdefs=null,this._svgPatterns={},this._svgClipPaths={},this._svgPath=null,this.defObjects={brush:new w(null,{style:c.GDI.BrushStyle.BS_SOLID,color:new M(null,0,0,0)}),pen:new P(null,c.GDI.PenStyle.PS_SOLID,1,new M(null,0,0,0),null),font:new b(null,null),palette:null,region:null},this.state=new G(null,this.defObjects),this.statestack=[this.state],this.objects={}}return t.prototype.setMapMode=function(t){c.log("[gdi] setMapMode: mode="+t),this.state.mapmode=t,this.state._svggroup=null},t.prototype.setWindowOrgEx=function(t,e){c.log("[gdi] setWindowOrgEx: x="+t+" y="+e),this.state.wx=t,this.state.wy=e,this.state._svggroup=null},t.prototype.setWindowExtEx=function(t,e){c.log("[gdi] setWindowExtEx: x="+t+" y="+e),this.state.ww=t,this.state.wh=e,this.state._svggroup=null},t.prototype.setViewportOrgEx=function(t,e){c.log("[gdi] setViewportOrgEx: x="+t+" y="+e),this.state.vx=t,this.state.vy=e,this.state._svggroup=null},t.prototype.setViewportExtEx=function(t,e){c.log("[gdi] setViewportExtEx: x="+t+" y="+e),this.state.vw=t,this.state.vh=e,this.state._svggroup=null},t.prototype.setBrushOrgEx=function(t){c.log("[gdi] setBrushOrgEx: x="+t.x+" y="+t.y),this.state.nextbrx=t.x,this.state.nextbry=t.y},t.prototype.saveDC=function(){c.log("[gdi] saveDC");var t=this.state;this.state=new G(this.state),this.statestack.push(t),this.state._svggroup=null},t.prototype.restoreDC=function(t){if(c.log("[gdi] restoreDC: saved="+t),!(this.statestack.length>1))throw new a("No saved contexts");if(-1===t)this.state=this.statestack.pop();else{if(t<-1)throw new a("restoreDC: relative restore not implemented");if(t>1)throw new a("restoreDC: absolute restore not implemented")}this.state._svggroup=null},t.prototype.setStretchBltMode=function(t){c.log("[gdi] setStretchBltMode: stretchMode="+t)},t.prototype.rectangle=function(t,e,i){c.log("[gdi] rectangle: rect="+t.toString()+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());var s=this._todevY(t.bottom),n=this._todevX(t.right),o=this._todevY(t.top),r=this._todevX(t.left);e=this._todevH(e),i=this._todevH(i),c.log("[gdi] rectangle: TRANSLATED: bottom="+s+" right="+n+" top="+o+" left="+r+" rh="+i+" rw="+e),this._pushGroup();var a=this._applyOpts(null,!0,!0,!1);this._svg.rect(this.state._svggroup,r,o,n-r,s-o,e/2,i/2,a)},t.prototype.lineTo=function(t,e){c.log("[gdi] lineTo: x="+t+" y="+e+" with pen "+this.state.selected.pen.toString());var i=this._todevX(t),s=this._todevY(e),n=this._todevX(this.state.x),o=this._todevY(this.state.y);this.state.x=t,this.state.y=e,c.log("[gdi] lineTo: TRANSLATED: toX="+i+" toY="+s+" fromX="+n+" fromY="+o),this._pushGroup();var r=this._applyOpts(null,!0,!1,!1);this._svg.line(this.state._svggroup,n,o,i,s,r)},t.prototype.moveToEx=function(t,e){c.log("[gdi] moveToEx: x="+t+" y="+e),this.state.x=t,this.state.y=e,null!=this._svgPath&&(this._svgPath.move(this.state.x,this.state.y),c.log("[gdi] new path: "+this._svgPath.path()))},t.prototype.polygon=function(t,e,i){c.log("[gdi] polygon: points="+t+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var s=[],n=0;n<t.length;n++){var o=t[n];s.push([this._todevX(o.x),this._todevY(o.y)])}i&&this._pushGroup();var r={"fill-rule":this.state.polyfillmode===c.GDI.PolygonFillMode.ALTERNATE?"evenodd":"nonzero"};this._applyOpts(r,!0,!0,!1),this._svg.polygon(this.state._svggroup,s,r)},t.prototype.polyPolygon=function(t,e){c.log("[gdi] polyPolygon: polygons.length="+t.length+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var i=t.length,s=0;s<i;s++)this.polygon(t[s],e,0===s)},t.prototype.polyline=function(t,e,i){c.log("[gdi] polyline: isLineTo="+t.toString()+", points="+e+", bounds="+i.toString()+" with pen "+this.state.selected.pen.toString());for(var s=[],n=0;n<e.length;n++){var o=e[n];s.push([this._todevX(o.x),this._todevY(o.y)])}if(null!=this._svgPath){if(t&&0!==s.length){var r=s[0];this._svgPath.move(r[0],r[1])}else this._svgPath.move(this._todevX(this.state.x),this._todevY(this.state.y));this._svgPath.line(s),c.log("[gdi] new path: "+this._svgPath.path())}else{this._pushGroup();var a=this._applyOpts(null,!0,!1,!1);if(t&&e.length>0){var h=e[0];h.x===this.state.x&&h.y===this.state.y||s.unshift([this._todevX(this.state.x),this._todevY(this.state.y)])}this._svg.polyline(this.state._svggroup,s,a)}if(e.length>0){var l=e[e.length-1];this.state.x=l.x,this.state.y=l.y}},t.prototype.polybezier=function(t,e,i){c.log("[gdi] polybezier: isPolyBezierTo="+t.toString()+", points="+e+", bounds="+i.toString()+" with pen "+this.state.selected.pen.toString());for(var s=[],n=0;n<e.length;n++){var o=e[n];s.push({x:this._todevX(o.x),y:this._todevY(o.y)})}if(null==this._svgPath)throw new a("polybezier not implemented (not a path)");if(t&&s.length>0){var r=s[0];this._svgPath.move(r.x,r.y)}else this._svgPath.move(this._todevX(this.state.x),this._todevY(this.state.y));if(s.length<(t?3:4))throw new a("Not enough points to draw bezier");for(n=t?1:0;n+3<=s.length;n+=3){var h=s[n],l=s[n+1],p=s[n+2];this._svgPath.curveC(h.x,h.y,l.x,l.y,p.x,p.y)}if(c.log("[gdi] new path: "+this._svgPath.path()),e.length>0){var E=e[e.length-1];this.state.x=E.x,this.state.y=E.y}},t.prototype.selectClipPath=function(t){c.log("[gdi] selectClipPath: rgnMode=0x"+t.toString(16))},t.prototype.selectClipRgn=function(t,e){if(c.log("[gdi] selectClipRgn: rgnMode=0x"+t.toString(16)),t!==c.GDI.RegionMode.RGN_COPY){if(null==e)throw new a("No clip region to select");throw new a("Not implemented: rgnMode=0x"+t.toString(16))}this.state.selected.region=e,this.state.clip=null,this.state.ownclip=!1,this.state._svgclipChanged=!0},t.prototype.offsetClipRgn=function(t){c.log("[gdi] offsetClipRgn: offset="+t.toString()),this._getClipRgn().offset(t.x,t.y)},t.prototype.setTextAlign=function(t){c.log("[gdi] setTextAlign: textAlignmentMode=0x"+t.toString(16)),this.state.textalign=t},t.prototype.setMiterLimit=function(t){c.log("[gdi] setMiterLimit: miterLimit="+t),this.state.miterlimit=t},t.prototype.setBkMode=function(t){c.log("[gdi] setBkMode: bkMode=0x"+t.toString(16)),this.state.bkmode=t},t.prototype.setBkColor=function(t){c.log("[gdi] setBkColor: bkColor="+t.toString()),this.state.bkcolor=t,this.state._svgtextbkfilter=null},t.prototype.setPolyFillMode=function(t){c.log("[gdi] setPolyFillMode: polyFillMode="+t),this.state.polyfillmode=t},t.prototype.createBrush=function(t,e){var i=this._storeObject(e,t);c.log("[gdi] createBrush: brush="+e.toString()+" with handle "+i)},t.prototype.createPen=function(t,e){var i=this._storeObject(e,t);c.log("[gdi] createPen: pen="+e.toString()+" width handle "+i)},t.prototype.createPenEx=function(t,e){var i=this._storeObject(e,t);c.log("[gdi] createPenEx: pen="+e.toString()+" width handle "+i)},t.prototype.selectObject=function(t,e){var i=this._getObject(t);null==i||null!=e&&i.type!==e?c.log("[gdi] selectObject: objIdx="+t+(i?" invalid object type: "+i.type:"[invalid index]")):(this._selectObject(i),c.log("[gdi] selectObject: objIdx="+t+(i?" selected "+i.type+": "+i.toString():"[invalid index]")))},t.prototype.abortPath=function(){c.log("[gdi] abortPath"),null!=this._svgPath&&(this._svgPath=null)},t.prototype.beginPath=function(){c.log("[gdi] beginPath"),null!=this._svgPath&&(this._svgPath=null),this._svgPath=this._svg.createPath()},t.prototype.closeFigure=function(){if(c.log("[gdi] closeFigure"),null==this._svgPath)throw new a("No path bracket: cannot close figure");this._svgPath.close()},t.prototype.fillPath=function(t){if(c.log("[gdi] fillPath"),null==this.state.selected.path)throw new a("No path selected");var e=this.state.selected.path,i=this._applyOpts(null,!0,!0,!1);this._svg.path(this.state._svggroup,e.svgPath,i),this._pushGroup(),this.state.selected.path=null},t.prototype.strokePath=function(t){if(c.log("[gdi] strokePath"),null==this.state.selected.path)throw new a("No path selected");var e=this.state.selected.path,i=this._applyOpts({fill:"none"},!0,!1,!1);this._svg.path(this.state._svggroup,e.svgPath,i),this._pushGroup(),this.state.selected.path=null},t.prototype.endPath=function(){if(c.log("[gdi] endPath"),null==this._svgPath)throw new a("No path bracket: cannot end path");this._pushGroup(),this._selectObject(new C(this._svgPath)),this._svgPath=null},t.prototype.deleteObject=function(t){var e=this._deleteObject(t);c.log("[gdi] deleteObject: objIdx="+t+(e?" deleted object":"[invalid index]"))},t.prototype._pushGroup=function(){if(null==this.state._svggroup||this.state._svgclipChanged){this.state._svgclipChanged=!1,this.state._svgtextbkfilter=null;var t={viewBox:[this.state.vx,this.state.vy,this.state.vw,this.state.vh].join(" "),preserveAspectRatio:"none"};null!=this.state.clip?(c.log("[gdi] new svg x="+this.state.vx+" y="+this.state.vy+" width="+this.state.vw+" height="+this.state.vh+" with clipping"),t["clip-path"]="url(#"+this._getSvgClipPathForRegion(this.state.clip)+")"):c.log("[gdi] new svg x="+this.state.vx+" y="+this.state.vy+" width="+this.state.vw+" height="+this.state.vh+" without clipping"),this.state._svggroup=this._svg.svg(this.state._svggroup,this.state.vx,this.state.vy,this.state.vw,this.state.vh,t)}},t.prototype._getStockObject=function(t){return t>=2147483648&&t<=2147483665?N[(t-2147483648).toString()]:t===c.GDI.StockObject.DC_BRUSH?this.state.selected.brush:t===c.GDI.StockObject.DC_PEN?this.state.selected.pen:null},t.prototype._storeObject=function(t,e){if(!e){for(e=0;null!=this.objects[e.toString()]&&e<=65535;)e++;if(e>65535)return c.log("[gdi] Too many objects!"),-1}return this.objects[e.toString()]=t,e},t.prototype._getObject=function(t){var e=this.objects[t.toString()];return null==e&&null==(e=this._getStockObject(t))&&c.log("[gdi] No object with handle "+t),e},t.prototype._getSvgDef=function(){return null==this._svgdefs&&(this._svgdefs=this._svg.defs()),this._svgdefs},t.prototype._getSvgClipPathForRegion=function(t){for(var e in this._svgClipPaths)if(this._svgClipPaths[e]===t)return e;var i=c._makeUniqueId("c"),s=this._svg.clipPath(this._getSvgDef(),i,"userSpaceOnUse");switch(t.complexity){case 1:this._svg.rect(s,this._todevX(t.bounds.left),this._todevY(t.bounds.top),this._todevW(t.bounds.right-t.bounds.left),this._todevH(t.bounds.bottom-t.bounds.top),{fill:"black","stroke-width":0});break;case 2:for(var n=0;n<t.scans.length;n++)for(var o=t.scans[n],r=0;r<o.scanlines.length;r++){var a=o.scanlines[r];this._svg.rect(s,this._todevX(a.left),this._todevY(o.top),this._todevW(a.right-a.left),this._todevH(o.bottom-o.top),{fill:"black","stroke-width":0})}}return this._svgClipPaths[i]=t,i},t.prototype._getSvgPatternForBrush=function(t){for(var e in this._svgPatterns)if(this._svgPatterns[e]===t)return e;var i,s,n;switch(t.style){case c.GDI.BrushStyle.BS_PATTERN:i=t.pattern.getWidth(),s=t.pattern.getHeight();break;case c.GDI.BrushStyle.BS_DIBPATTERNPT:i=t.dibpatternpt.getWidth(),s=t.dibpatternpt.getHeight(),n=t.dibpatternpt.base64ref();break;default:throw new a("Invalid brush style")}var o=c._makeUniqueId("p"),r=this._svg.pattern(this._getSvgDef(),o,this.state.brx,this.state.bry,i,s,{patternUnits:"userSpaceOnUse"});return this._svg.image(r,0,0,i,s,n),this._svgPatterns[o]=t,o},t.prototype._selectObject=function(t){switch(this.state.selected[t.type]=t,t.type){case"region":this.state._svgclipChanged=!0;break;case"brush":this.state.brx=this.state.nextbrx,this.state.bry=this.state.nextbry}},t.prototype._deleteObject=function(t){var e=this.objects[t.toString()];if(null!=e){for(var i=0;i<this.statestack.length;i++){var s=this.statestack[i];s.selected[e.type]===e&&(s.selected[e.type]=this.defObjects[e.type].clone())}return delete this.objects[t.toString()],!0}return c.log("[gdi] Cannot delete object with invalid handle "+t),!1},t.prototype._getClipRgn=function(){var t,e,i,s,n;return null!=this.state.clip?this.state.ownclip||(this.state.clip=this.state.clip.clone()):null!=this.state.selected.region?this.state.clip=this.state.selected.region.clone():this.state.clip=(t=this.state.wx,e=this.state.wy,i=this.state.wx+this.state.ww,s=this.state.wy+this.state.wh,(n=new g(null,null)).bounds=new d(null,t,e,i,s),n._updateComplexity(),n),this.state.ownclip=!0,this.state.clip},t.prototype._todevX=function(t){return Math.floor((t-this.state.wx)*(this.state.vw/this.state.ww))+this.state.vx},t.prototype._todevY=function(t){return Math.floor((t-this.state.wy)*(this.state.vh/this.state.wh))+this.state.vy},t.prototype._todevW=function(t){return Math.floor(t*(this.state.vw/this.state.ww))+this.state.vx},t.prototype._todevH=function(t){return Math.floor(t*(this.state.vh/this.state.wh))+this.state.vy},t.prototype._tologicalX=function(t){return Math.floor((t-this.state.vx)/(this.state.vw/this.state.ww))+this.state.wx},t.prototype._tologicalY=function(t){return Math.floor((t-this.state.vy)/(this.state.vh/this.state.wh))+this.state.wy},t.prototype._tologicalW=function(t){return Math.floor(t/(this.state.vw/this.state.ww))+this.state.wx},t.prototype._tologicalH=function(t){return Math.floor(t/(this.state.vh/this.state.wh))+this.state.wy},t.prototype._applyOpts=function(t,e,i,s){if(null==t&&(t={}),e){var n=this.state.selected.pen;if(n.style!==c.GDI.PenStyle.PS_NULL){t.stroke="#"+n.color.toHex(),t["stroke-width"]=n.width,t["stroke-miterlimit"]=this.state.miterlimit,t["stroke-linecap"]="round";var o=1;t["stroke-linejoin"]="round";var r=4*t["stroke-width"],a=2*t["stroke-width"];switch(n.style){case c.GDI.PenStyle.PS_DASH:t["stroke-dasharray"]=[r,a].toString();break;case c.GDI.PenStyle.PS_DOT:t["stroke-dasharray"]=[o,a].toString();break;case c.GDI.PenStyle.PS_DASHDOT:t["stroke-dasharray"]=[r,a,o,a].toString();break;case c.GDI.PenStyle.PS_DASHDOTDOT:t["stroke-dasharray"]=[r,a,o,a,o,a].toString()}}}if(i){var h=this.state.selected.brush;switch(h.style){case c.GDI.BrushStyle.BS_SOLID:t.fill="#"+h.color.toHex();break;case c.GDI.BrushStyle.BS_PATTERN:case c.GDI.BrushStyle.BS_DIBPATTERNPT:t.fill="url(#"+this._getSvgPatternForBrush(h)+")";break;case c.GDI.BrushStyle.BS_NULL:t.fill="none";break;default:c.log("[gdi] unsupported brush style: "+h.style),t.fill="none"}}if(s){var l=this.state.selected.font;t["font-family"]=l.facename,t["font-size"]=Math.abs(l.height),t.fill="#"+this.state.textcolor.toHex()}return t},t}(),x=function(){function t(t){this.parse(t),c.log("EMFJS.Renderer instantiated")}return t.prototype.render=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");return this._render(new o(e),t.mapMode,t.wExt,t.hExt,t.xExt,t.yExt),e.setAttribute("viewBox",[0,0,t.xExt,t.yExt].join(" ")),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("width",t.width),e.setAttribute("height",t.height),e},t.prototype.parse=function(t){this._img=null;var e=new p(t);if(1!==e.readUint32())throw new a("Not an EMF file");var i=e.readUint32();if(i%4!=0)throw new a("Not an EMF file");if(this._img=new U(e,i),null==this._img)throw new a("Format not recognized")},t.prototype._render=function(t,e,i,s,n,o){var r=new m(t);r.setWindowExtEx(i,s),r.setViewportExtEx(n,o),r.setMapMode(e),c.log("[EMF] BEGIN RENDERING ---\x3e"),this._img.render(r),c.log("[EMF] <--- DONE RENDERING")},t}(),U=function(){function t(t,e){this._hdrsize=e,this._records=new A(t,this._hdrsize)}return t.prototype.render=function(t){this._records.play(t)},t}();return e})()}));
  //# sourceMappingURL=EMFJS.bundle.min.js.map