!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./jquery.svg"),require("./jquery.svgfilter"),require("jquery")):"function"==typeof define&&define.amd?define(["./jquery.svg","./jquery.svgfilter","jquery"],e):"object"==typeof exports?exports.WMFJS=e(require("./jquery.svg"),require("./jquery.svgfilter"),require("jquery")):t.WMFJS=e(t.$,t.$,t.$)}(this,function(t,e,r){return function(t){var e={};function r(s){if(e[s])return e[s].exports;var i=e[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,s){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(s,i,function(e){return t[e]}.bind(null,i));return s},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=35)}([,function(e,r){e.exports=t},function(t,r){t.exports=e},,function(t,e){t.exports=r},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(t,e,r){"use strict";r.r(e);r(1),r(2);var s=r(36);r.d(e,"Renderer",function(){return s.Renderer});var i=r(38);r.d(e,"Error",function(){return i.WMFJSError}),r.d(e,"loggingEnabled",function(){return i.loggingEnabled})},function(t,e,r){"use strict";r.r(e),r.d(e,"Renderer",function(){return a}),r.d(e,"WMFRect16",function(){return h}),r.d(e,"WMFPlacable",function(){return p}),r.d(e,"WMF",function(){return c});var s=r(4),i=r(37),n=r(39),o=r(38),l=r(44),a=function(){function t(t){this.parse(t),o.Helper.log("WMFJS.Renderer instantiated")}return t.prototype.render=function(t){var e=this,r=s("
").svg({onLoad:function(r){return e._render(r,t.mapMode,t.xExt,t.yExt)},settings:{viewBox:[0,0,t.xExt,t.yExt].join(" "),preserveAspectRatio:"none"}}),i=s(r[0]).svg("get");return s(i.root()).attr("width",t.width).attr("height",t.height)},t.prototype.parse=function(t){this._img=null;var e,r,s,n,l=new i.Blob(t),a=l.readUint32();switch(2596720087===a?(s=new p(l),n=l.pos,e=l.readUint16(),r=l.readUint16()):(n=0,e=65535&a,r=a>>>16&65535),e){case o.Helper.GDI.MetafileType.MEMORYMETAFILE:case o.Helper.GDI.MetafileType.DISKMETAFILE:if(r===o.Helper.GDI.METAHEADER_SIZE/2){var h=l.readUint16();switch(h){case o.Helper.GDI.MetafileVersion.METAVERSION100:case o.Helper.GDI.MetafileVersion.METAVERSION300:this._img=new c(l,s,h,n+2*r)}}}if(null==this._img)throw new o.WMFJSError("Format not recognized")},t.prototype._render=function(t,e,r,s){var i=new n.GDIContext(t);i.setViewportExt(r,s),i.setMapMode(e),o.Helper.log("[WMF] BEGIN RENDERING ---\x3e"),this._img.render(i),o.Helper.log("[WMF] <--- DONE RENDERING")},t}(),h=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}(),p=function(){return function(t){t.skip(2),this.boundingBox=new h(t),this.unitsPerInch=t.readInt16(),t.skip(4),t.skip(2),o.Helper.log("Got bounding box "+this.boundingBox+" and "+this.unitsPerInch+" units/inch")}}(),c=function(){function t(t,e,r,s){this._version=r,this._hdrsize=s,this._placable=e,this._records=new l.WMFRecords(t,this._hdrsize)}return t.prototype.render=function(t){this._records.play(t)},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"Blob",function(){return i});var s=r(38),i=function(){function t(e,r){e instanceof t?(this.blob=e.blob,this.data=e.data,this.pos=r||e.pos):(this.blob=e,this.data=new Uint8Array(e),this.pos=r||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 s.WMFJSError("Invalid seek position");this.pos=t},t.prototype.skip=function(t){var e=this.pos+t;if(e>this.data.length)throw new s.WMFJSError("Unexpected end of file");this.pos=e},t.prototype.readBinary=function(t){if(this.pos+t>this.data.length)throw new s.WMFJSError("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 s.WMFJSError("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 s.WMFJSError("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8,t|=this.data[this.pos++]<<16,t|=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 s.WMFJSError("Unexpected end of file");var t=this.data[this.pos++];return t|=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 s.WMFJSError("Unexpected end of file");for(var e="",r=0;r>>0);return e},t.prototype.readNullTermString=function(t){var e="";if(t>0){t--;for(var r=0;rthis.data.length)throw new s.WMFJSError("Unexpected end of file");var i=this.data[this.pos+r]>>>0;if(0===i)break;e+=String.fromCharCode(i)}}return e},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"WMFJSError",function(){return s}),r.d(e,"loggingEnabled",function(){return n}),r.d(e,"Helper",function(){return o});var s=function(t){this.name="WMFJSError",this.message=t,this.stack=(new Error).stack};s.prototype=new Error;var i=!0;function n(t){i=t}var o=function(){function t(){}return t.log=function(t){i&&console.log(t)},t._makeUniqueId=function(t){return"wmfjs_"+t+this._uniqueId++},t._writeUint32Val=function(t,e,r){t[e++]=255&r,t[e++]=r>>>8&255,t[e++]=r>>>16&255,t[e++]=r>>>24&255},t._blobToBinary=function(t){for(var e="",r=t.length,s=0;s1)throw new i.WMFJSError("restoreDC: absolute restore not implemented")}this.state._svggroup=null},t.prototype.escape=function(t,e,r,s){i.Helper.log("[gdi] escape: func="+t+" offset="+r+" count="+s)},t.prototype.setStretchBltMode=function(t){i.Helper.log("[gdi] setStretchBltMode: stretchMode="+t)},t.prototype.stretchDib=function(t,e,r,s,n,o,l,a,h,p,c){i.Helper.log("[gdi] stretchDib: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)),t=this._todevX(t),e=this._todevY(e),r=this._todevW(r),s=this._todevH(s),n=this._todevX(n),o=this._todevY(o),l=this._todevW(l),a=this._todevH(a),i.Helper.log("[gdi] stretchDib: TRANSLATED: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)+" colorUsage=0x"+p.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,n,o,l,a,c.base64ref())},t.prototype.stretchDibBits=function(t,e,r,s,n,o,l,a,h,p){i.Helper.log("[gdi] stretchDibBits: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)),t=this._todevX(t),e=this._todevY(e),r=this._todevW(r),s=this._todevH(s),n=this._todevX(n),o=this._todevY(o),l=this._todevW(l),a=this._todevH(a),i.Helper.log("[gdi] stretchDibBits: TRANSLATED: srcX="+t+" srcY="+e+" srcW="+r+" srcH="+s+" dstX="+n+" dstY="+o+" dstW="+l+" dstH="+a+" rasterOp=0x"+h.toString(16)),this._pushGroup(),this._svg.image(this.state._svggroup,n,o,l,a,p.base64ref())},t.prototype.rectangle=function(t,e,r){i.Helper.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),l=this._todevX(t.left);e=this._todevH(e),r=this._todevH(r),i.Helper.log("[gdi] rectangle: TRANSLATED: bottom="+s+" right="+n+" top="+o+" left="+l+" rh="+r+" rw="+e),this._pushGroup();var a=this._applyOpts(null,!0,!0,!1);this._svg.rect(this.state._svggroup,l,o,n-l,s-o,e/2,r/2,a)},t.prototype.textOut=function(t,e,r){i.Helper.log("[gdi] textOut: x="+t+" y="+e+" text="+r+" with font "+this.state.selected.font.toString()),t=this._todevX(t),e=this._todevY(e),i.Helper.log("[gdi] textOut: TRANSLATED: x="+t+" y="+e),this._pushGroup();var n=this._applyOpts(null,!1,!1,!0);if(0!==this.state.selected.font.escapement&&(n.transform="rotate("+[-this.state.selected.font.escapement/10,t,e]+")",n.style="dominant-baseline: middle; text-anchor: start;"),this.state.bkmode===i.Helper.GDI.MixMode.OPAQUE){if(null==this.state._svgtextbkfilter){var o=i.Helper._makeUniqueId("f"),l=this._svg.filter(this._getSvgDef(),o,0,0,1,1);this._svg.filters.flood(l,null,"#"+this.state.bkcolor.toHex(),1),this._svg.filters.composite(l,null,null,"SourceGraphic"),this.state._svgtextbkfilter=l}n.filter="url(#"+s(this.state._svgtextbkfilter).attr("id")+")"}this._svg.text(this.state._svggroup,t,e,r,n)},t.prototype.extTextOut=function(t,e,r,n,o,l){i.Helper.log("[gdi] extTextOut: x="+t+" y="+e+" text="+r+" with font "+this.state.selected.font.toString()),t=this._todevX(t),e=this._todevY(e),i.Helper.log("[gdi] extTextOut: TRANSLATED: x="+t+" y="+e),this._pushGroup();var a=this._applyOpts(null,!1,!1,!0);if(0!==this.state.selected.font.escapement&&(a.transform="rotate("+[-this.state.selected.font.escapement/10,t,e]+")",a.style="dominant-baseline: middle; text-anchor: start;"),this.state.bkmode===i.Helper.GDI.MixMode.OPAQUE){if(null==this.state._svgtextbkfilter){var h=i.Helper._makeUniqueId("f"),p=this._svg.filter(this._getSvgDef(),h,0,0,1,1);this._svg.filters.flood(p,null,"#"+this.state.bkcolor.toHex(),1),this._svg.filters.composite(p,null,null,"SourceGraphic"),this.state._svgtextbkfilter=p}a.filter="url(#"+s(this.state._svgtextbkfilter).attr("id")+")"}this._svg.text(this.state._svggroup,t,e,r,a)},t.prototype.lineTo=function(t,e){i.Helper.log("[gdi] lineTo: x="+t+" y="+e+" with pen "+this.state.selected.pen.toString());var r=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,i.Helper.log("[gdi] lineTo: TRANSLATED: toX="+r+" toY="+s+" fromX="+n+" fromY="+o),this._pushGroup();var l=this._applyOpts(null,!0,!1,!1);this._svg.line(this.state._svggroup,n,o,r,s,l)},t.prototype.moveTo=function(t,e){i.Helper.log("[gdi] moveTo: x="+t+" y="+e),this.state.x=t,this.state.y=e},t.prototype.polygon=function(t,e){i.Helper.log("[gdi] polygon: points="+t+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var r=[],s=0;s65535?(i.Helper.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&&i.Helper.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 r=i.Helper._makeUniqueId("c"),s=this._svg.clipPath(this._getSvgDef(),r,"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",strokeWidth:0});break;case 2:for(var n=0;n=this.right||this.top>=this.bottom},t.prototype.intersect=function(e){return this.empty()||e.empty()?null: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}(),o=function(){function t(t){this.type=t}return t.prototype.clone=function(){throw new s.WMFJSError("clone not implemented")},t.prototype.toString=function(){throw new s.WMFJSError("toString not implemented")},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"Region",function(){return o}),r.d(e,"CreateSimpleRegion",function(){return l}),r.d(e,"Scan",function(){return a});var s=r(38),i=r(40),n=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function s(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),o=function(t){function e(e,r){var n=t.call(this,"region")||this;if(null!=e){if(e.skip(2),6!==e.readInt16())throw new s.WMFJSError("Invalid region identifier");e.skip(2);e.readInt16();var o=e.readInt16();e.skip(2);var l=e.readInt16(),h=e.readInt16(),p=e.readInt16(),c=e.readInt16();n.bounds=new i.Rect(null,l,h,p,c),n.scans=[];for(var u=0;u=t.top){var r=f.clone();f.bottom=t.top-1,r.top=t.top,f.top>=f.bottom?this.scans[e]=r:(s.Helper.log("[wmf] Region split top scan "+e+" for substraction"),this.scans.splice(++e,0,r));break}e++}for(var n=e;et.bottom)break;if(f.bottom>t.bottom){r=f.clone();f.bottom=t.bottom,r.top=t.bottom+1,f.top>=f.bottom?this.scans[e]=r:(s.Helper.log("[wmf] Region split bottom scan "+e+" for substraction"),this.scans.splice(++e,0,r));break}e++}if(n0){var T=f.scanlines[0];(null==h||T.leftp)&&(p=T.right)}}null!=h&&null!=l&&null!=p&&null!=c?(this.bounds=new i.Rect(null,h,l,p,c),this._updateComplexity()):(this.bounds=null,this.scans=null,this.complexity=0)}else this._updateComplexity()}s.Helper.log("[wmf] Region subtraction -> "+this.toString())},e.prototype.intersect=function(t){if(s.Helper.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&&(s.Helper.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){s.Helper.log("[wmf] Region remove "+(this.scans.length-e)+" scans from bottom"),this.scans.splice(e,this.scans.length-e);break}r.intersect(this.bounds.left,this.bounds.right)?e++:(s.Helper.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;s.Helper.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 r=this.scans.length,s=0;s=t&&(n.right=t-1,n.left>=n.right)?this.scanlines.splice(r,1):r++}for(var s=r,i=0;re){n.left=e,i=r-s,n.left>=n.right&&i++;break}r++}return i>0&&s0},t.prototype.intersect=function(t,e){for(var r=0;r=t||s.right>=t){r>0&&this.scanlines.splice(0,r);break}}if(this.scanlines.length>0){var s;(s=this.scanlines[0]).lefte){this.scanlines.splice(r,this.scanlines.length-r);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(t,e,r){"use strict";r.r(e),r.d(e,"ColorRef",function(){return l}),r.d(e,"Font",function(){return a}),r.d(e,"Brush",function(){return h}),r.d(e,"Pen",function(){return p}),r.d(e,"PaletteEntry",function(){return c}),r.d(e,"Palette",function(){return u});var s=r(43),i=r(38),n=r(40),o=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function s(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),l=function(){function t(t,e,r,s){null!=t?(this.r=t.readUint8(),this.g=t.readUint8(),this.b=t.readUint8(),t.skip(1)):(this.r=e,this.g=r,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}(),a=function(t){function e(e,r){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 i=e.readUint8();s.pitch=15&i,s.family=i>>6&3;var n=r,o=e.pos;s.facename=e.readNullTermString(Math.min(n-(e.pos-o),32))}else null!=r?(r=r,s.height=r.height,s.width=r.width,s.escapement=r.escapement,s.orientation=r.orientation,s.weight=r.weight,s.italic=r.italic,s.underline=r.underline,s.strikeout=r.strikeout,s.charset=r.charset,s.outprecision=r.outprecision,s.clipprecision=r.clipprecision,s.quality=r.quality,s.pitch=r.pitch,s.family=r.family,s.facename=r.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}(n.Obj),h=function(t){function e(e,r,n){var o=t.call(this,"brush")||this;if(null!=e){var a=r,h=e.pos;if(!0===n||!1===n)switch(o.style=e.readUint16(),n&&o.style!==i.Helper.GDI.BrushStyle.BS_PATTERN&&(o.style=i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT),o.style){case i.Helper.GDI.BrushStyle.BS_SOLID:o.color=new l(e);break;case i.Helper.GDI.BrushStyle.BS_PATTERN:e.skip(n?2:6),o.pattern=new s.Bitmap16(e,a-(e.pos-h));break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:o.colorusage=n?e.readUint16():e.readUint32(),n||e.skip(2),o.dibpatternpt=new s.DIBitmap(e,a-(e.pos-h));break;case i.Helper.GDI.BrushStyle.BS_HATCHED:o.color=new l(e),o.hatchstyle=e.readUint16()}else n instanceof s.PatternBitmap16&&(o.style=i.Helper.GDI.BrushStyle.BS_PATTERN,o.pattern=n)}else if(null!=r)switch(r=r,o.style=r.style,o.style){case i.Helper.GDI.BrushStyle.BS_SOLID:o.color=r.color.clone();break;case i.Helper.GDI.BrushStyle.BS_PATTERN:o.pattern=r.pattern.clone();break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:o.colorusage=r.colorusage,o.dibpatternpt=r.dibpatternpt;break;case i.Helper.GDI.BrushStyle.BS_HATCHED:o.color=r.color.clone(),o.hatchstyle=r.hatchstyle}return o}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 i.Helper.GDI.BrushStyle.BS_SOLID:t+=", color: "+this.color.toString();break;case i.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:t+=", colorusage: "+this.colorusage;break;case i.Helper.GDI.BrushStyle.BS_HATCHED:t+=", color: "+this.color.toString()+", hatchstyle: "+this.hatchstyle}return t+"}"},e}(n.Obj),p=function(t){function e(e,r,s,o,a,h){var p=t.call(this,"pen")||this;return null!=e?(r=e.readUint16(),p.style=255&r,p.width=new n.PointS(e),p.color=new l(e),p.linecap=r&(i.Helper.GDI.PenStyle.PS_ENDCAP_SQUARE|i.Helper.GDI.PenStyle.PS_ENDCAP_FLAT),p.join=r&(i.Helper.GDI.PenStyle.PS_JOIN_BEVEL|i.Helper.GDI.PenStyle.PS_JOIN_MITER)):(p.style=r,p.width=s,p.color=o,p.linecap=a,p.join=h),p}return o(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}(n.Obj),c=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}(),u=function(t){function e(e,r){var s=t.call(this,"palette")||this;if(null!=e){s.start=e.readUint16();var i=e.readUint16();for(s.entries=[];i>0;)s.entries.push(new c(e))}else{s.start=r.start,s.entries=[];for(var n=r.entries.length,o=0;o8?0:1<>4<<1)*i.height,i.bitsSize>r-10)throw new s.WMFJSError("Bitmap should have "+i.bitsSize+" bytes, but has "+(r-10))}else{var n=r;i._reader=n._reader,i._offset=n._offset,i._size=n._size,i.type=n.type,i.width=n.width,i.height=n.height,i.widthBytes=n.widthBytes,i.planes=n.planes,i.bitsPixel=n.bitsPixel,i.bitsOffset=n.bitsOffset,i.bitsSize=n.bitsSize}return i}return i(e,t),e.prototype.getWidth=function(){return this.width},e.prototype.getHeight=function(){return this.height},e.prototype.clone=function(){return new e(null,this)},e}(n),c=function(t){function e(e,r){var s=t.call(this,e,r)||this;return null!=e&&(s.bitsOffset+=22),s}return i(e,t),e.prototype.clone=function(){return new e(null,this)},e}(p)},function(t,e,r){"use strict";r.r(e),r.d(e,"WMFRecords",function(){return h});var s=r(43),i=r(37),n=r(38),o=r(40),l=r(41),a=r(42),h=function(){function t(t,e){this._records=[];var r=!1,h=e,p=function(){t.seek(h);var e=t.readUint32();if(e<3)throw new n.WMFJSError("Invalid record size");var p=t.readUint16();switch(p){case n.Helper.GDI.RecordType.META_EOF:return r=!0,"break-main_loop";case n.Helper.GDI.RecordType.META_SETMAPMODE:var u=t.readUint16();c._records.push(function(t){t.setMapMode(u)});break;case n.Helper.GDI.RecordType.META_SETWINDOWORG:var d=t.readInt16(),f=t.readInt16();c._records.push(function(t){t.setWindowOrg(f,d)});break;case n.Helper.GDI.RecordType.META_SETWINDOWEXT:var E=t.readInt16(),T=t.readInt16();c._records.push(function(t){t.setWindowExt(T,E)});break;case n.Helper.GDI.RecordType.META_OFFSETWINDOWORG:var g=t.readInt16(),_=t.readInt16();c._records.push(function(t){t.offsetWindowOrg(_,g)});break;case n.Helper.GDI.RecordType.META_SETVIEWPORTORG:var I=t.readInt16(),y=t.readInt16();c._records.push(function(t){t.setViewportOrg(y,I)});break;case n.Helper.GDI.RecordType.META_SETVIEWPORTEXT:var S=t.readInt16(),v=t.readInt16();c._records.push(function(t){t.setViewportExt(v,S)});break;case n.Helper.GDI.RecordType.META_OFFSETVIEWPORTORG:var A=t.readInt16(),R=t.readInt16();c._records.push(function(t){t.offsetViewportOrg(R,A)});break;case n.Helper.GDI.RecordType.META_SAVEDC:c._records.push(function(t){t.saveDC()});break;case n.Helper.GDI.RecordType.META_RESTOREDC:var b=t.readInt16();c._records.push(function(t){t.restoreDC(b)});break;case n.Helper.GDI.RecordType.META_SETSTRETCHBLTMODE:var M=t.readUint16();c._records.push(function(t){t.setStretchBltMode(M)});break;case n.Helper.GDI.RecordType.META_DIBSTRETCHBLT:var O=t.readUint16()|t.readUint16()<<16,H=t.readInt16(),D=t.readInt16(),w=t.readInt16(),P=t.readInt16(),m=t.readInt16(),C=t.readInt16(),G=t.readInt16(),B=t.readInt16(),N=2*e-(t.pos-h),x=new s.DIBitmap(t,N);c._records.push(function(t){t.stretchDibBits(P,w,D,H,B,G,C,m,O,x)});break;case n.Helper.GDI.RecordType.META_STRETCHDIB:var L=t.readUint16()|t.readUint16()<<16,k=t.readInt16(),U=t.readInt16(),F=t.readInt16(),W=t.readInt16(),j=t.readInt16(),X=t.readInt16(),Y=t.readInt16(),V=t.readInt16(),J=t.readInt16(),q=(N=2*e-(t.pos-h),new s.DIBitmap(t,N));c._records.push(function(t){t.stretchDib(j,W,F,U,J,V,Y,X,L,k,q)});break;case n.Helper.GDI.RecordType.META_ESCAPE:var z=t.readUint16(),Z=t.readUint16(),K=t.pos,Q=new i.Blob(t,K);c._records.push(function(t){t.escape(z,Q,K,Z)});break;case n.Helper.GDI.RecordType.META_SETTEXTALIGN:var $=t.readUint16();c._records.push(function(t){t.setTextAlign($)});break;case n.Helper.GDI.RecordType.META_SETBKMODE:var tt=t.readUint16();c._records.push(function(t){t.setBkMode(tt)});break;case n.Helper.GDI.RecordType.META_SETTEXTCOLOR:var et=new a.ColorRef(t);c._records.push(function(t){t.setTextColor(et)});break;case n.Helper.GDI.RecordType.META_SETBKCOLOR:var rt=new a.ColorRef(t);c._records.push(function(t){t.setBkColor(rt)});break;case n.Helper.GDI.RecordType.META_CREATEBRUSHINDIRECT:N=2*e-(t.pos-h);var st=new a.Brush(t,N,!1);c._records.push(function(t){t.createBrush(st)});break;case n.Helper.GDI.RecordType.META_DIBCREATEPATTERNBRUSH:N=2*e-(t.pos-h);var it=new a.Brush(t,N,!0);c._records.push(function(t){t.createBrush(it)});break;case n.Helper.GDI.RecordType.META_CREATEPENINDIRECT:var nt=new a.Pen(t);c._records.push(function(t){t.createPen(nt)});break;case n.Helper.GDI.RecordType.META_CREATEFONTINDIRECT:N=2*e-(t.pos-h);var ot=new a.Font(t,N);c._records.push(function(t){t.createFont(ot)});break;case n.Helper.GDI.RecordType.META_SELECTOBJECT:var lt=t.readUint16();c._records.push(function(t){t.selectObject(lt,null)});break;case n.Helper.GDI.RecordType.META_SELECTPALETTE:var at=t.readUint16();c._records.push(function(t){t.selectObject(at,"palette")});break;case n.Helper.GDI.RecordType.META_SELECTCLIPREGION:var ht=t.readUint16();c._records.push(function(t){t.selectObject(ht,"region")});break;case n.Helper.GDI.RecordType.META_DELETEOBJECT:var pt=t.readUint16();c._records.push(function(t){t.deleteObject(pt)});break;case n.Helper.GDI.RecordType.META_RECTANGLE:var ct=new o.Rect(t);c._records.push(function(t){t.rectangle(ct,0,0)});break;case n.Helper.GDI.RecordType.META_ROUNDRECT:var ut=t.readInt16(),dt=t.readInt16(),ft=new o.Rect(t);c._records.push(function(t){t.rectangle(ft,dt,ut)});break;case n.Helper.GDI.RecordType.META_LINETO:var Et=t.readInt16(),Tt=t.readInt16();c._records.push(function(t){t.lineTo(Tt,Et)});break;case n.Helper.GDI.RecordType.META_MOVETO:var gt=t.readInt16(),_t=t.readInt16();c._records.push(function(t){t.moveTo(_t,gt)});break;case n.Helper.GDI.RecordType.META_TEXTOUT:if((Rt=t.readInt16())>0){var It=t.readString(Rt);t.skip(Rt%2);var yt=t.readInt16(),St=t.readInt16();c._records.push(function(t){t.textOut(St,yt,It)})}break;case n.Helper.GDI.RecordType.META_EXTTEXTOUT:var vt=t.readInt16(),At=t.readInt16(),Rt=t.readInt16(),bt=t.readUint16(),Mt=null,Ot=null;2*e===14+Rt+Rt%2&&(Mt=!1,Ot=!1),2*e===22+Rt+Rt%2&&(Mt=!0,Ot=!1),2*e===14+Rt+Rt%2+2*Rt&&(Mt=!1,Ot=!0),2*e===22+Rt+Rt%2+2*Rt&&(Mt=!0,Ot=!0);var Ht=Mt?new o.Rect(t):null;if(Rt>0){var Dt=t.readString(Rt);t.skip(Rt%2);var wt=[];if(Ot)for(var Pt=0;Pt0;)Bt.push(new o.PointS(t)),Gt--;c._records.push(function(t){t.polygon(Bt,!0)});break;case n.Helper.GDI.RecordType.META_SETPOLYFILLMODE:var Nt=t.readUint16();c._records.push(function(t){t.setPolyFillMode(Nt)});break;case n.Helper.GDI.RecordType.META_POLYPOLYGON:Gt=t.readUint16();var xt=[];for(Pt=0;Pt0;)Wt.push(new o.PointS(t)),Gt--;c._records.push(function(t){t.polyline(Wt)});break;case n.Helper.GDI.RecordType.META_ELLIPSE:var jt=new o.Rect(t);c._records.push(function(t){t.ellipse(jt)});break;case n.Helper.GDI.RecordType.META_CREATEPALETTE:var Xt=new a.Palette(t);c._records.push(function(t){t.createPalette(Xt)});break;case n.Helper.GDI.RecordType.META_CREATEREGION:var Yt=new l.Region(t);c._records.push(function(t){t.createRegion(Yt)});break;case n.Helper.GDI.RecordType.META_CREATEPATTERNBRUSH:N=2*e-(t.pos-h);var Vt=new s.PatternBitmap16(t,N),Jt=new a.Brush(t,N,Vt);c._records.push(function(t){t.createPatternBrush(Jt)});break;case n.Helper.GDI.RecordType.META_OFFSETCLIPRGN:var qt=t.readInt16(),zt=t.readInt16();c._records.push(function(t){t.offsetClipRgn(zt,qt)});break;case n.Helper.GDI.RecordType.META_REALIZEPALETTE:case n.Helper.GDI.RecordType.META_SETPALENTRIES:case n.Helper.GDI.RecordType.META_SETROP2:case n.Helper.GDI.RecordType.META_SETRELABS:case n.Helper.GDI.RecordType.META_SETTEXTCHAREXTRA:case n.Helper.GDI.RecordType.META_RESIZEPALETTE:case n.Helper.GDI.RecordType.META_SETLAYOUT:case n.Helper.GDI.RecordType.META_FILLREGION:case n.Helper.GDI.RecordType.META_SETMAPPERFLAGS:case n.Helper.GDI.RecordType.META_SETTEXTJUSTIFICATION:case n.Helper.GDI.RecordType.META_SCALEWINDOWEXT:case n.Helper.GDI.RecordType.META_SCALEVIEWPORTEXT:case n.Helper.GDI.RecordType.META_FLOODFILL:case n.Helper.GDI.RecordType.META_FRAMEREGION:case n.Helper.GDI.RecordType.META_ANIMATEPALETTE:case n.Helper.GDI.RecordType.META_EXTFLOODFILL:case n.Helper.GDI.RecordType.META_SETPIXEL:case n.Helper.GDI.RecordType.META_PATBLT:case n.Helper.GDI.RecordType.META_PIE:case n.Helper.GDI.RecordType.META_STRETCHBLT:case n.Helper.GDI.RecordType.META_INVERTREGION:case n.Helper.GDI.RecordType.META_PAINTREGION:case n.Helper.GDI.RecordType.META_ARC:case n.Helper.GDI.RecordType.META_CHORD:case n.Helper.GDI.RecordType.META_BITBLT:case n.Helper.GDI.RecordType.META_SETDIBTODEV:case n.Helper.GDI.RecordType.META_DIBBITBLT:default:var Zt="UNKNOWN";for(var Kt in n.Helper.GDI.RecordType){if(n.Helper.GDI.RecordType[Kt]===p){Zt=Kt;break}}n.Helper.log("[WMF] "+Zt+" record (0x"+p.toString(16)+") at offset 0x"+h.toString(16)+" with "+2*e+" bytes")}h+=2*e},c=this;t:for(;!r;){switch(p()){case"break-main_loop":break t}}if(!r)throw new n.WMFJSError("Could not read all records")}return t.prototype.play=function(t){for(var e=this._records.length,r=0;r