!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.WMFJS=e():t.WMFJS=e()}(this,(()=>(()=>{"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 ".concat(t," ").concat(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 ".concat(t[0]," ").concat(t[1])}))},t.prototype.curveC=function(t,e,i,s,n,o){this._path+=" C ".concat(t," ").concat(e,", ").concat(i," ").concat(s,", ").concat(n," ").concat(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])},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"wmfjs_"+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=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>>0);return e},t.prototype.readNullTermString=function(t){var e="";if(t>0){t--;for(var i=0;ithis.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}(),u=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}(),d=function(){function t(t,e,i,s,n){null!=t?(this.bottom=t.readInt16(),this.right=t.readInt16(),this.top=t.readInt16(),this.left=t.readInt16()):(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}(),T=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}(),f=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])},t(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)}}(),E=function(t){function e(e,i){var s=t.call(this,"region")||this;if(null!=e){if(e.skip(2),6!==e.readInt16())throw new a("Invalid region identifier");e.skip(2),e.readInt16();var n=e.readInt16();e.skip(2);var o=e.readInt16(),r=e.readInt16(),h=e.readInt16(),l=e.readInt16();s.bounds=new d(null,o,r,h,l),s.scans=[];for(var c=0;c=t.top){var i=u.clone();u.bottom=t.top-1,i.top=t.top,u.top>=u.bottom?this.scans[e]=i:(c.log("[wmf] Region split top scan "+e+" for substraction"),this.scans.splice(++e,0,i));break}e++}for(var s=e;et.bottom);){if(u.bottom>t.bottom){i=u.clone(),u.bottom=t.bottom,i.top=t.bottom+1,u.top>=u.bottom?this.scans[e]=i:(c.log("[wmf] Region split bottom scan "+e+" for substraction"),this.scans.splice(++e,0,i));break}e++}if(s0){var f=u.scanlines[0];(null==r||f.lefta)&&(a=f.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("[wmf] Region subtraction -> "+this.toString())},e.prototype.intersect=function(t){if(c.log("[wmf] 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;e0&&(c.log("[wmf] Region remove "+e+" scans from top"),this.scans.splice(0,e),this.scans.length>0&&(this.scans[0].top=this.bounds.top)),e=0;ethis.bounds.bottom){c.log("[wmf] 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("[wmf] 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("[wmf] 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=t&&(o.right=t-1,o.left>=o.right)?this.scanlines.splice(i,1):i++;for(var s=i,n=0;ie){o.left=e,n=i-s,o.left>=o.right&&n++;break}i++}return n>0&&s0},t.prototype.intersect=function(t,e){for(var i=0;i=t||s.right>=t){i>0&&this.scanlines.splice(0,i);break}if(this.scanlines.length>0){var s;for((s=this.scanlines[0]).lefte){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.prototype.toString=function(){return"{ #scanlines: "+this.scanlines.length+"}"},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])},t(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)}}(),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<8?0:1<>4<<1)*this.height,this.bitsSize>e-10)throw new a("Bitmap should have "+this.bitsSize+" bytes, but has "+(e-10))}else{var i=e;this._reader=i._reader,this._offset=i._offset,this._size=i._size,this.type=i.type,this.width=i.width,this.height=i.height,this.widthBytes=i.widthBytes,this.planes=i.planes,this.bitsPixel=i.bitsPixel,this.bitsOffset=i.bitsOffset,this.bitsSize=i.bitsSize}}return t.prototype.getWidth=function(){return this.width},t.prototype.getHeight=function(){return this.height},t.prototype.clone=function(){return new t(null,this)},t}(),b=function(t){function e(e,i){var s=t.call(this,e,i)||this;return null!=e&&(s.bitsOffset+=22),s}return _(e,t),e.prototype.clone=function(){return new e(null,this)},e}(A),w=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])},t(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)}}(),R=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}(),O=function(t){function e(e,i){var s=t.call(this,"font")||this;if(null!=e){s.height=e.readInt16(),s.width=e.readInt16(),s.escapement=e.readInt16(),s.orientation=e.readInt16(),s.weight=e.readInt16(),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.readNullTermString(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 w(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return JSON.stringify(this)},e}(T),D=function(t){function e(e,i,s){var n=t.call(this,"brush")||this;if(null!=e){var o=i,r=e.pos;if(!0===s||!1===s)switch(n.style=e.readUint16(),s&&n.style!==c.GDI.BrushStyle.BS_PATTERN&&(n.style=c.GDI.BrushStyle.BS_DIBPATTERNPT),n.style){case c.GDI.BrushStyle.BS_SOLID:n.color=new R(e);break;case c.GDI.BrushStyle.BS_PATTERN:e.skip(s?2:6),n.pattern=new A(e,o-(e.pos-r));break;case c.GDI.BrushStyle.BS_DIBPATTERNPT:n.colorusage=s?e.readUint16():e.readUint32(),s||e.skip(2),n.dibpatternpt=new v(e,o-(e.pos-r));break;case c.GDI.BrushStyle.BS_HATCHED:n.color=new R(e),n.hatchstyle=e.readUint16()}else s instanceof b&&(n.style=c.GDI.BrushStyle.BS_PATTERN,n.pattern=s)}else if(null!=i)switch(i=i,n.style=i.style,n.style){case c.GDI.BrushStyle.BS_SOLID:n.color=i.color.clone();break;case c.GDI.BrushStyle.BS_PATTERN:n.pattern=i.pattern.clone();break;case c.GDI.BrushStyle.BS_DIBPATTERNPT:n.colorusage=i.colorusage,n.dibpatternpt=i.dibpatternpt;break;case c.GDI.BrushStyle.BS_HATCHED:n.color=i.color.clone(),n.hatchstyle=i.hatchstyle}return n}return w(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_DIBPATTERNPT:t+=", colorusage: "+this.colorusage;break;case c.GDI.BrushStyle.BS_HATCHED:t+=", color: "+this.color.toString()+", hatchstyle: "+this.hatchstyle}return t+"}"},e}(T),M=function(t){function e(e,i,s,n,o,r){var a=t.call(this,"pen")||this;return null!=e?(i=e.readUint16(),a.style=255&i,a.width=new u(e),a.color=new R(e),a.linecap=i&(c.GDI.PenStyle.PS_ENDCAP_SQUARE|c.GDI.PenStyle.PS_ENDCAP_FLAT),a.join=i&(c.GDI.PenStyle.PS_JOIN_BEVEL|c.GDI.PenStyle.PS_JOIN_MITER)):(a.style=i,a.width=s,a.color=n,a.linecap=o,a.join=r),a}return w(e,t),e.prototype.clone=function(){return new e(null,this.style,this.width.clone(),this.color.clone(),this.linecap,this.join)},e.prototype.toString=function(){return"{style: "+this.style+", width: "+this.width.toString()+", color: "+this.color.toString()+", linecap: "+this.linecap+", join: "+this.join+"}"},e}(T),P=function(){function t(t,e){null!=t?(this.flag=t.readUint8(),this.b=t.readUint8(),this.g=t.readUint8(),this.r=t.readUint8()):(this.flag=e.flag,this.b=e.b,this.g=e.g,this.r=e.r)}return t.prototype.clone=function(){return new t(null,this)},t}(),m=function(t){function e(e,i){var s=t.call(this,"palette")||this;if(null!=e){s.start=e.readUint16();var n=e.readUint16();for(s.entries=[];n>0;)s.entries.push(new P(e)),n--}else{s.start=i.start,s.entries=[];for(var o=i.entries.length,r=0;r1)throw new a("restoreDC: absolute restore not implemented")}this.state._svggroup=null},t.prototype.escape=function(t,e,i,s){c.log("[gdi] escape: func="+t+" offset="+i+" count="+s)},t.prototype.setStretchBltMode=function(t){c.log("[gdi] setStretchBltMode: stretchMode="+t)},t.prototype.stretchDib=function(t,e,i,s,n,o,r,a,h,l,p){c.log("[gdi] stretchDib: srcX="+t+" srcY="+e+" srcW="+i+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+r+" dstH="+a+" rasterOp=0x"+h.toString(16)),t=this._todevX(t),e=this._todevY(e),i=this._todevW(i),s=this._todevH(s),n=this._todevX(n),o=this._todevY(o),r=this._todevW(r),a=this._todevH(a),c.log("[gdi] stretchDib: TRANSLATED: srcX="+t+" srcY="+e+" srcW="+i+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+r+" dstH="+a+" rasterOp=0x"+h.toString(16)+" colorUsage=0x"+l.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,n,o,r,a,p.base64ref())},t.prototype.dibBits=function(t,e,i,s,n,o,r,a){c.log("[gdi] stretchDibBits: srcX="+t+" srcY="+e+" dstX="+i+" dstY="+s+" width="+n+" height="+o+" rasterOp=0x"+r.toString(16)),t=this._todevX(t),e=this._todevY(e),i=this._todevX(i),s=this._todevY(s),n=this._todevW(n),o=this._todevH(o),c.log("[gdi] dibBits: TRANSLATED: srcX="+t+" srcY="+e+NaN+i+" dstY="+s+" width="+n+" height="+o+" rasterOp=0x"+r.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,i,s,n,o,a.base64ref())},t.prototype.stretchDibBits=function(t,e,i,s,n,o,r,a,h,l){c.log("[gdi] stretchDibBits: srcX="+t+" srcY="+e+" srcW="+i+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+r+" dstH="+a+" rasterOp=0x"+h.toString(16)),t=this._todevX(t),e=this._todevY(e),i=this._todevW(i),s=this._todevH(s),n=this._todevX(n),o=this._todevY(o),r=this._todevW(r),a=this._todevH(a),c.log("[gdi] stretchDibBits: TRANSLATED: srcX="+t+" srcY="+e+" srcW="+i+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+r+" dstH="+a+" rasterOp=0x"+h.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,n,o,r,a,l.base64ref())},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.textOut=function(t,e,i){c.log("[gdi] textOut: x="+t+" y="+e+" text="+i+" with font "+this.state.selected.font.toString()),t=this._todevX(t),e=this._todevY(e),c.log("[gdi] textOut: TRANSLATED: x="+t+" y="+e),this._pushGroup();var s=this._applyOpts(null,!1,!1,!0);if(0!==this.state.selected.font.escapement&&(s.transform="rotate("+[-this.state.selected.font.escapement/10,t,e]+")",s.style="dominant-baseline: middle; text-anchor: start;"),this.state.bkmode===c.GDI.MixMode.OPAQUE){if(null==this.state._svgtextbkfilter){var n=c._makeUniqueId("f"),o=this._svg.filter(this._getSvgDef(),n,0,0,1,1);this._svg.filters.flood(o,null,"#"+this.state.bkcolor.toHex(),1),this._svg.filters.composite(o,null,null,"SourceGraphic"),this.state._svgtextbkfilter=o}s.filter="url(#"+this.state._svgtextbkfilter.id+")"}this._svg.text(this.state._svggroup,t,e,i,s)},t.prototype.extTextOut=function(t,e,i,s,n,o){c.log("[gdi] extTextOut: x="+t+" y="+e+" text="+i+" with font "+this.state.selected.font.toString()),t=this._todevX(t),e=this._todevY(e),c.log("[gdi] extTextOut: TRANSLATED: x="+t+" y="+e),this._pushGroup();var r=this._applyOpts(null,!1,!1,!0);if(0!==this.state.selected.font.escapement&&(r.transform="rotate("+[-this.state.selected.font.escapement/10,t,e]+")",r.style="dominant-baseline: middle; text-anchor: start;"),this.state.bkmode===c.GDI.MixMode.OPAQUE){if(null==this.state._svgtextbkfilter){var a=c._makeUniqueId("f"),h=this._svg.filter(this._getSvgDef(),a,0,0,1,1);this._svg.filters.flood(h,null,"#"+this.state.bkcolor.toHex(),1),this._svg.filters.composite(h,null,null,"SourceGraphic"),this.state._svgtextbkfilter=h}r.filter="url(#"+this.state._svgtextbkfilter.id+")"}this._svg.text(this.state._svggroup,t,e,i,r)},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.moveTo=function(t,e){c.log("[gdi] moveTo: x="+t+" y="+e),this.state.x=t,this.state.y=e},t.prototype.polygon=function(t,e){c.log("[gdi] polygon: points="+t+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var i=[],s=0;s65535?(c.log("[gdi] Too many objects!"),-1):(this.objects[e.toString()]=t,e)},t.prototype._getObject=function(t){var e=this.objects[t.toString()];return null==e&&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>8)!==e,x=t.readUint16()|t.readUint16()<<16,B=t.readInt16(),L=t.readInt16();G||t.skip(2);var k=t.readInt16(),U=t.readInt16(),H=t.readInt16(),F=t.readInt16();if(G){var j=2*e-(t.pos-s),X=new v(t,j);o._records.push((function(t){t.dibBits(L,B,F,H,U,k,x,X)}))}break;case c.GDI.RecordType.META_DIBSTRETCHBLT:G=3+(n>>8)!==e;var W=t.readUint16()|t.readUint16()<<16,Y=t.readInt16(),V=t.readInt16(),z=t.readInt16(),J=t.readInt16(),Z=t.readInt16(),q=t.readInt16(),K=t.readInt16(),Q=t.readInt16(),$=(j=2*e-(t.pos-s),new v(t,j));o._records.push((function(t){t.stretchDibBits(J,z,V,Y,Q,K,q,Z,W,$)}));break;case c.GDI.RecordType.META_STRETCHDIB:var tt=t.readUint16()|t.readUint16()<<16,et=t.readInt16(),it=t.readInt16(),st=t.readInt16(),nt=t.readInt16(),ot=t.readInt16(),rt=t.readInt16(),at=t.readInt16(),ht=t.readInt16(),lt=t.readInt16(),ct=(j=2*e-(t.pos-s),new v(t,j));o._records.push((function(t){t.stretchDib(ot,nt,st,it,lt,ht,at,rt,tt,et,ct)}));break;case c.GDI.RecordType.META_ESCAPE:var pt=t.readUint16(),ut=t.readUint16(),dt=t.pos,Tt=new p(t,dt);o._records.push((function(t){t.escape(pt,Tt,dt,ut)}));break;case c.GDI.RecordType.META_SETTEXTALIGN:var ft=t.readUint16();o._records.push((function(t){t.setTextAlign(ft)}));break;case c.GDI.RecordType.META_SETBKMODE:var Et=t.readUint16();o._records.push((function(t){t.setBkMode(Et)}));break;case c.GDI.RecordType.META_SETTEXTCOLOR:var gt=new R(t);o._records.push((function(t){t.setTextColor(gt)}));break;case c.GDI.RecordType.META_SETBKCOLOR:var _t=new R(t);o._records.push((function(t){t.setBkColor(_t)}));break;case c.GDI.RecordType.META_CREATEBRUSHINDIRECT:j=2*e-(t.pos-s);var yt=new D(t,j,!1);o._records.push((function(t){t.createBrush(yt)}));break;case c.GDI.RecordType.META_DIBCREATEPATTERNBRUSH:j=2*e-(t.pos-s);var St=new D(t,j,!0);o._records.push((function(t){t.createBrush(St)}));break;case c.GDI.RecordType.META_CREATEPENINDIRECT:var It=new M(t);o._records.push((function(t){t.createPen(It)}));break;case c.GDI.RecordType.META_CREATEFONTINDIRECT:j=2*e-(t.pos-s);var vt=new O(t,j);o._records.push((function(t){t.createFont(vt)}));break;case c.GDI.RecordType.META_SELECTOBJECT:var At=t.readUint16();o._records.push((function(t){t.selectObject(At,null)}));break;case c.GDI.RecordType.META_SELECTPALETTE:var bt=t.readUint16();o._records.push((function(t){t.selectObject(bt,"palette")}));break;case c.GDI.RecordType.META_SELECTCLIPREGION:var wt=t.readUint16();o._records.push((function(t){t.selectObject(wt,"region")}));break;case c.GDI.RecordType.META_DELETEOBJECT:var Rt=t.readUint16();o._records.push((function(t){t.deleteObject(Rt)}));break;case c.GDI.RecordType.META_RECTANGLE:var Ot=new d(t);o._records.push((function(t){t.rectangle(Ot,0,0)}));break;case c.GDI.RecordType.META_ROUNDRECT:var Dt=t.readInt16(),Mt=t.readInt16(),Pt=new d(t);o._records.push((function(t){t.rectangle(Pt,Mt,Dt)}));break;case c.GDI.RecordType.META_LINETO:var mt=t.readInt16(),Ct=t.readInt16();o._records.push((function(t){t.lineTo(Ct,mt)}));break;case c.GDI.RecordType.META_MOVETO:var Nt=t.readInt16(),Gt=t.readInt16();o._records.push((function(t){t.moveTo(Gt,Nt)}));break;case c.GDI.RecordType.META_TEXTOUT:if((Ht=t.readInt16())>0){var xt=t.readString(Ht);t.skip(Ht%2);var Bt=t.readInt16(),Lt=t.readInt16();o._records.push((function(t){t.textOut(Lt,Bt,xt)}))}break;case c.GDI.RecordType.META_EXTTEXTOUT:var kt=t.readInt16(),Ut=t.readInt16(),Ht=t.readInt16(),Ft=t.readUint16(),jt=null,Xt=null;2*e===14+Ht+Ht%2&&(jt=!1,Xt=!1),2*e===22+Ht+Ht%2&&(jt=!0,Xt=!1),2*e===14+Ht+Ht%2+2*Ht&&(jt=!1,Xt=!0),2*e===22+Ht+Ht%2+2*Ht&&(jt=!0,Xt=!0);var Wt=jt?new d(t):null;if(Ht>0){var Yt=t.readString(Ht);t.skip(Ht%2);var Vt=[];if(Xt)for(var zt=0;zt0;)Kt.push(new u(t)),qt--;o._records.push((function(t){t.polygon(Kt,!0)}));break;case c.GDI.RecordType.META_SETPOLYFILLMODE:var Qt=t.readUint16();o._records.push((function(t){t.setPolyFillMode(Qt)}));break;case c.GDI.RecordType.META_POLYPOLYGON:qt=t.readUint16();var $t=[];for(zt=0;zt0;)ne.push(new u(t)),qt--;o._records.push((function(t){t.polyline(ne)}));break;case c.GDI.RecordType.META_ELLIPSE:var oe=new d(t);o._records.push((function(t){t.ellipse(oe)}));break;case c.GDI.RecordType.META_CREATEPALETTE:var re=new m(t);o._records.push((function(t){t.createPalette(re)}));break;case c.GDI.RecordType.META_CREATEREGION:var ae=new E(t);o._records.push((function(t){t.createRegion(ae)}));break;case c.GDI.RecordType.META_CREATEPATTERNBRUSH:j=2*e-(t.pos-s);var he=new b(t,j),le=new D(t,j,he);o._records.push((function(t){t.createPatternBrush(le)}));break;case c.GDI.RecordType.META_OFFSETCLIPRGN:var ce=t.readInt16(),pe=t.readInt16();o._records.push((function(t){t.offsetClipRgn(pe,ce)}));break;case c.GDI.RecordType.META_REALIZEPALETTE:case c.GDI.RecordType.META_SETPALENTRIES:case c.GDI.RecordType.META_SETROP2:case c.GDI.RecordType.META_SETRELABS:case c.GDI.RecordType.META_SETTEXTCHAREXTRA:case c.GDI.RecordType.META_RESIZEPALETTE:case c.GDI.RecordType.META_SETLAYOUT:case c.GDI.RecordType.META_FILLREGION:case c.GDI.RecordType.META_SETMAPPERFLAGS:case c.GDI.RecordType.META_SETTEXTJUSTIFICATION:case c.GDI.RecordType.META_SCALEWINDOWEXT:case c.GDI.RecordType.META_SCALEVIEWPORTEXT:case c.GDI.RecordType.META_FLOODFILL:case c.GDI.RecordType.META_FRAMEREGION:case c.GDI.RecordType.META_ANIMATEPALETTE:case c.GDI.RecordType.META_EXTFLOODFILL:case c.GDI.RecordType.META_SETPIXEL:case c.GDI.RecordType.META_PATBLT:case c.GDI.RecordType.META_PIE:case c.GDI.RecordType.META_STRETCHBLT:case c.GDI.RecordType.META_INVERTREGION:case c.GDI.RecordType.META_PAINTREGION:case c.GDI.RecordType.META_ARC:case c.GDI.RecordType.META_CHORD:case c.GDI.RecordType.META_BITBLT:case c.GDI.RecordType.META_SETDIBTODEV:default:var ue="UNKNOWN";for(var de in c.GDI.RecordType)if(c.GDI.RecordType[de]===n){ue=de;break}c.log("[WMF] "+ue+" record (0x"+n.toString(16)+") at offset 0x"+s.toString(16)+" with "+2*e+" bytes")}s+=2*e},o=this;t:for(;!i&&"break-main_loop"!==n(););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>>16&65535),e){case c.GDI.MetafileType.MEMORYMETAFILE:case c.GDI.MetafileType.DISKMETAFILE:if(i===c.GDI.METAHEADER_SIZE/2){var h=o.readUint16();switch(h){case c.GDI.MetafileVersion.METAVERSION100:case c.GDI.MetafileVersion.METAVERSION300:this._img=new k(o,s,h,n+2*i)}}}if(null==this._img)throw new a("Format not recognized")},t.prototype._render=function(t,e,i,s){var n=new N(t);n.setViewportExt(i,s),n.setMapMode(e),c.log("[WMF] BEGIN RENDERING ---\x3e"),this._img.render(n),c.log("[WMF] <--- DONE RENDERING")},t}(),B=function(){function t(t){this.left=t.readInt16(),this.top=t.readInt16(),this.right=t.readInt16(),this.bottom=t.readInt16()}return t.prototype.toString=function(){return"{left: "+this.left+", top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+"}"},t}(),L=function(t){t.skip(2),this.boundingBox=new B(t),this.unitsPerInch=t.readInt16(),t.skip(4),t.skip(2),c.log("Got bounding box "+this.boundingBox+" and "+this.unitsPerInch+" units/inch")},k=function(){function t(t,e,i,s){this._version=i,this._hdrsize=s,this._placable=e,this._records=new G(t,this._hdrsize)}return t.prototype.render=function(t){this._records.play(t)},t}();return e})())); //# sourceMappingURL=WMFJS.bundle.min.js.map