text: Autodesk.Extensions.Markup=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=15)}([function(t,e,i){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var i=function(t,e){var i=t[1]||"",n=t[3];if(!n)return i;if(e&&"function"==typeof btoa){var s=(r=n,a=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),h="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(h," */")),o=n.sources.map(function(t){return"/*# sourceURL=".concat(n.sourceRoot).concat(t," */")});return[i].concat(o).concat([s]).join("\n")}var r,a,h;return[i].join("\n")}(e,t);return e[2]?"@media ".concat(e[2],"{").concat(i,"}"):i}).join("")},e.i=function(t,i){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},s=0;s<this.length;s++){var o=this[s][0];null!=o&&(n[o]=!0)}for(var r=0;r<t.length;r++){var a=t[r];null!=a[0]&&n[a[0]]||(i&&!a[2]?a[2]=i:i&&(a[2]="(".concat(a[2],") and (").concat(i,")")),e.push(a))}},e}},function(t,e,i){"use strict";var n,s={},o=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var t={};return function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}t[e]=i}return t[e]}}();function a(t,e){for(var i=[],n={},s=0;s<t.length;s++){var o=t[s],r=e.base?o[0]+e.base:o[0],a={css:o[1],media:o[2],sourceMap:o[3]};n[r]?n[r].parts.push(a):i.push(n[r]={id:r,parts:[a]})}return i}function h(t,e){for(var i=0;i<t.length;i++){var n=t[i],o=s[n.id],r=0;if(o){for(o.refs++;r<o.parts.length;r++)o.parts[r](n.parts[r]);for(;r<n.parts.length;r++)o.parts.push(y(n.parts[r],e))}else{for(var a=[];r<n.parts.length;r++)a.push(y(n.parts[r],e));s[n.id]={id:n.id,refs:1,parts:a}}}}function l(t){var e=document.createElement("style");if(void 0===t.attributes.nonce){var n=i.nc;n&&(t.attributes.nonce=n)}if(Object.keys(t.attributes).forEach(function(i){e.setAttribute(i,t.attributes[i])}),"function"==typeof t.insert)t.insert(e);else{var s=r(t.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(e)}return e}var u,d=(u=[],function(t,e){return u[t]=e,u.filter(Boolean).join("\n")});function c(t,e,i,n){var s=i?"":n.css;if(t.styleSheet)t.styleSheet.cssText=d(e,s);else{var o=document.createTextNode(s),r=t.childNodes;r[e]&&t.removeChild(r[e]),r.length?t.insertBefore(o,r[e]):t.appendChild(o)}}var p=null,f=0;function y(t,e){var i,n,s;if(e.singleton){var o=f++;i=p||(p=l(e)),n=c.bind(null,i,o,!1),s=c.bind(null,i,o,!0)}else i=l(e),n=function(t,e,i){var n=i.css,s=i.media,o=i.sourceMap;if(s&&t.setAttribute("media",s),o&&btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,i,e),s=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(i)};return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else s()}}t.exports=function(t,e){(e=e||{}).attributes="object"==typeof e.attributes?e.attributes:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o());var i=a(t,e);return h(i,e),function(t){for(var n=[],o=0;o<i.length;o++){var r=i[o],l=s[r.id];l&&(l.refs--,n.push(l))}t&&h(a(t,e),e);for(var u=0;u<n.length;u++){var d=n[u];if(0===d.refs){for(var c=0;c<d.parts.length;c++)d.parts[c]();delete s[d.id]}}}}},,,,,,,function(t,e,i){t.exports=function(t,e,i){"use strict";return t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,i=i&&i.hasOwnProperty("default")?i.default:i,function(i){i.exports;var n,s=!1;(n=window).DOMParser=window.DOMParser;var o=n.document,r=800,a=600;function h(t,e){var i;return(i=o.createElement("canvas")).width=t,i.height=e,i}var l,u=function(i,d,c){if(null!=i||null!=d||null!=c){var p=function(i){var u={opts:i,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,rootEmSize:12,emSize:12,log:function(){}};1==u.opts.log&&"undefined"!=typeof console&&(u.log=function(t){console.log(t)}),u.init=function(t){var e=0;u.UniqueId=function(){return"canvg"+ ++e},u.Definitions={},u.Styles={},u.StylesSpecificity={},u.Animations=[],u.Images=[],u.ctx=t,u.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(t,e){this.viewPorts.push({width:t,height:e})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(t){return null!=t&&"number"==typeof t?t:"x"==t?this.width():"y"==t?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}},u.init(),u.ImagesLoaded=function(){for(var t=0;t<u.Images.length;t++)if(!u.Images[t].loaded)return!1;return!0},u.trim=function(t){return t.replace(/^\s+|\s+$/g,"")},u.compressSpaces=function(t){return t.replace(/(?!\u3000)\s+/gm," ")},u.ajax=function(t){var e;return(e=n.XMLHttpRequest?new n.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"))?(e.open("GET",t,!1),e.send(null),e.responseText):null},u.parseXml=function(t){if("undefined"!=typeof Windows&&void 0!==Windows.Data&&void 0!==Windows.Data.Xml){var e=new Windows.Data.Xml.Dom.XmlDocument,s=new Windows.Data.Xml.Dom.XmlLoadSettings;return s.prohibitDtd=!1,e.loadXml(t,s),e}if(!n.DOMParser){t=t.replace(/<!DOCTYPE svg[^>]*>/,"");var e=new ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}try{var o=i.xmldom?new n.DOMParser(i.xmldom):new n.DOMParser;return o.parseFromString(t,"image/svg+xml")}catch(e){return(o=i.xmldom?new n.DOMParser(i.xmldom):new n.DOMParser).parseFromString(t,"text/xml")}},u.Property=function(t,e){this.name=t,this.value=e},u.Property.prototype.getValue=function(){return this.value},u.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value},u.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);return(this.value+"").match(/%$/)&&(t/=100),t},u.Property.prototype.valueOrDefault=function(t){return this.hasValue()?this.value:t},u.Property.prototype.numValueOrDefault=function(t){return this.hasValue()?this.numValue():t},u.Property.prototype.addOpacity=function(e){var i=this.value;if(null!=e.value&&""!=e.value&&"string"==typeof this.value){var n=new t(this.value);n.ok&&(i="rgba("+n.r+", "+n.g+", "+n.b+", "+e.numValue()+")")}return new u.Property(this.name,i)},u.Property.prototype.getDefinition=function(){var t=this.value.match(/#([^\)'"]+)/);return t&&(t=t[1]),t||(t=this.value),u.Definitions[t]},u.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")},u.Property.prototype.getFillStyleDefinition=function(t,e){var i=this.getDefinition();if(null!=i&&i.createGradient)return i.createGradient(u.ctx,t,e);if(null!=i&&i.createPattern){if(i.getHrefAttribute().hasValue()){var n=i.attribute("patternTransform");i=i.getHrefAttribute().getDefinition(),n.hasValue()&&(i.attribute("patternTransform",!0).value=n.value)}return i.createPattern(u.ctx,t)}return null},u.Property.prototype.getDPI=function(){return 96},u.Property.prototype.getREM=function(){return u.rootEmSize},u.Property.prototype.getEM=function(){return u.emSize},u.Property.prototype.getUnits=function(){var t=this.value+"";return t.replace(/[0-9\.\-]/g,"")},u.Property.prototype.isPixels=function(){if(!this.hasValue())return!1;var t=this.value+"";return!!t.match(/px$/)||!!t.match(/^[0-9]+$/)},u.Property.prototype.toPixels=function(t,e){if(!this.hasValue())return 0;var i=this.value+"";if(i.match(/rem$/))return this.numValue()*this.getREM(t);if(i.match(/em$/))return this.numValue()*this.getEM(t);if(i.match(/ex$/))return this.numValue()*this.getEM(t)/2;if(i.match(/px$/))return this.numValue();if(i.match(/pt$/))return this.numValue()*this.getDPI(t)*(1/72);if(i.match(/pc$/))return 15*this.numValue();if(i.match(/cm$/))return this.numValue()*this.getDPI(t)/2.54;if(i.match(/mm$/))return this.numValue()*this.getDPI(t)/25.4;if(i.match(/in$/))return this.numValue()*this.getDPI(t);if(i.match(/%$/))return this.numValue()*u.ViewPort.ComputeSize(t);var n=this.numValue();return e&&n<1?n*u.ViewPort.ComputeSize(t):n},u.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var t=this.value+"";return t.match(/s$/)?1e3*this.numValue():(t.match(/ms$/),this.numValue())},u.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var t=this.value+"";return t.match(/deg$/)?this.numValue()*(Math.PI/180):t.match(/grad$/)?this.numValue()*(Math.PI/200):t.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)};var d={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};return u.Property.prototype.toTextBaseline=function(){return this.hasValue()?d[this.value]:null},u.Font=new function(){this.Styles="normal|italic|oblique|inherit",this.Variants="normal|small-caps|inherit",this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",this.CreateFont=function(t,e,i,n,s,o){var r=null!=o?this.Parse(o):this.CreateFont("","","","","",u.ctx.font);return{fontFamily:s=s||r.fontFamily,fontSize:n||r.fontSize,fontStyle:t||r.fontStyle,fontWeight:i||r.fontWeight,fontVariant:e||r.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var t=this;this.Parse=function(e){for(var i={},n=u.trim(u.compressSpaces(e||"")).split(" "),s={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},o="",r=0;r<n.length;r++)s.fontStyle||-1==t.Styles.indexOf(n[r])?s.fontVariant||-1==t.Variants.indexOf(n[r])?s.fontWeight||-1==t.Weights.indexOf(n[r])?s.fontSize?"inherit"!=n[r]&&(o+=n[r]):("inherit"!=n[r]&&(i.fontSize=n[r].split("/")[0]),s.fontStyle=s.fontVariant=s.fontWeight=s.fontSize=!0):("inherit"!=n[r]&&(i.fontWeight=n[r]),s.fontStyle=s.fontVariant=s.fontWeight=!0):("inherit"!=n[r]&&(i.fontVariant=n[r]),s.fontStyle=s.fontVariant=!0):("inherit"!=n[r]&&(i.fontStyle=n[r]),s.fontStyle=!0);return""!=o&&(i.fontFamily=o),i}},u.ToNumberArray=function(t){for(var e=u.trim(u.compressSpaces((t||"").replace(/,/g," "))).split(" "),i=0;i<e.length;i++)e[i]=parseFloat(e[i]);return e},u.Point=function(t,e){this.x=t,this.y=e},u.Point.prototype.angleTo=function(t){return Math.atan2(t.y-this.y,t.x-this.x)},u.Point.prototype.applyTransform=function(t){var e=this.x*t[0]+this.y*t[2]+t[4],i=this.x*t[1]+this.y*t[3]+t[5];this.x=e,this.y=i},u.CreatePoint=function(t){var e=u.ToNumberArray(t);return new u.Point(e[0],e[1])},u.CreatePath=function(t){for(var e=u.ToNumberArray(t),i=[],n=0;n<e.length;n+=2)i.push(new u.Point(e[n],e[n+1]));return i},u.BoundingBox=function(t,e,i,n){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.x=function(){return this.x1},this.y=function(){return this.y1},this.width=function(){return this.x2-this.x1},this.height=function(){return this.y2-this.y1},this.addPoint=function(t,e){null!=t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},this.addX=function(t){this.addPoint(t,null)},this.addY=function(t){this.addPoint(null,t)},this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)},this.addQuadraticCurve=function(t,e,i,n,s,o){var r=t+2/3*(i-t),a=e+2/3*(n-e),h=r+1/3*(s-t),l=a+1/3*(o-e);this.addBezierCurve(t,e,r,h,a,l,s,o)},this.addBezierCurve=function(t,e,i,n,s,o,r,a){var h=[t,e],l=[i,n],u=[s,o],d=[r,a];this.addPoint(h[0],h[1]),this.addPoint(d[0],d[1]);for(var c=0;c<=1;c++){var p=function(t){return Math.pow(1-t,3)*h[c]+3*Math.pow(1-t,2)*t*l[c]+3*(1-t)*Math.pow(t,2)*u[c]+Math.pow(t,3)*d[c]},f=6*h[c]-12*l[c]+6*u[c],y=-3*h[c]+9*l[c]-9*u[c]+3*d[c],g=3*l[c]-3*h[c];if(0!=y){var v=Math.pow(f,2)-4*g*y;if(!(v<0)){var m=(-f+Math.sqrt(v))/(2*y);0<m&&m<1&&(0==c&&this.addX(p(m)),1==c&&this.addY(p(m)));var x=(-f-Math.sqrt(v))/(2*y);0<x&&x<1&&(0==c&&this.addX(p(x)),1==c&&this.addY(p(x)))}}else{if(0==f)continue;var b=-g/f;0<b&&b<1&&(0==c&&this.addX(p(b)),1==c&&this.addY(p(b)))}}},this.isPointInBox=function(t,e){return this.x1<=t&&t<=this.x2&&this.y1<=e&&e<=this.y2},this.addPoint(t,e),this.addPoint(i,n)},u.Transform=function(t){var e=this;this.Type={},this.Type.translate=function(t){this.p=u.CreatePoint(t),this.apply=function(t){t.translate(this.p.x||0,this.p.y||0)},this.unapply=function(t){t.translate(-1*this.p.x||0,-1*this.p.y||0)},this.applyToPoint=function(t){t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},this.Type.rotate=function(t){var e=u.ToNumberArray(t);this.angle=new u.Property("angle",e[0]),this.cx=e[1]||0,this.cy=e[2]||0,this.apply=function(t){t.translate(this.cx,this.cy),t.rotate(this.angle.toRadians()),t.translate(-this.cx,-this.cy)},this.unapply=function(t){t.translate(this.cx,this.cy),t.rotate(-1*this.angle.toRadians()),t.translate(-this.cx,-this.cy)},this.applyToPoint=function(t){var e=this.angle.toRadians();t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]),t.applyTransform([Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0]),t.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}},this.Type.scale=function(t){this.p=u.CreatePoint(t),this.apply=function(t){t.scale(this.p.x||1,this.p.y||this.p.x||1)},this.unapply=function(t){t.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)},this.applyToPoint=function(t){t.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}},this.Type.matrix=function(t){this.m=u.ToNumberArray(t),this.apply=function(t){t.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])},this.unapply=function(t){var e=this.m[0],i=this.m[2],n=this.m[4],s=this.m[1],o=this.m[3],r=this.m[5],a=1/(e*(1*o-0*r)-i*(1*s-0*r)+n*(0*s-0*o));t.transform(a*(1*o-0*r),a*(0*r-1*s),a*(0*n-1*i),a*(1*e-0*n),a*(i*r-n*o),a*(n*s-e*r))},this.applyToPoint=function(t){t.applyTransform(this.m)}},this.Type.SkewBase=function(t){this.base=e.Type.matrix,this.base(t),this.angle=new u.Property("angle",t)},this.Type.SkewBase.prototype=new this.Type.matrix,this.Type.skewX=function(t){this.base=e.Type.SkewBase,this.base(t),this.m=[1,0,Math.tan(this.angle.toRadians()),1,0,0]},this.Type.skewX.prototype=new this.Type.SkewBase,this.Type.skewY=function(t){this.base=e.Type.SkewBase,this.base(t),this.m=[1,Math.tan(this.angle.toRadians()),0,1,0,0]},this.Type.skewY.prototype=new this.Type.SkewBase,this.transforms=[],this.apply=function(t){for(var e=0;e<this.transforms.length;e++)this.transforms[e].apply(t)},this.unapply=function(t){for(var e=this.transforms.length-1;e>=0;e--)this.transforms[e].unapply(t)},this.applyToPoint=function(t){for(var e=0;e<this.transforms.length;e++)this.transforms[e].applyToPoint(t)};for(var i=u.trim(u.compressSpaces(t)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/),n=0;n<i.length;n++)if("none"!==i[n]){var s=u.trim(i[n].split("(")[0]),o=i[n].split("(")[1].replace(")",""),r=this.Type[s];if(void 0!==r){var a=new r(o);a.type=s,this.transforms.push(a)}}},u.AspectRatio=function(t,e,i,n,s,o,r,a,h,l){var d=(e=(e=u.compressSpaces(e)).replace(/^defer\s/,"")).split(" ")[0]||"xMidYMid",c=e.split(" ")[1]||"meet",p=i/n,f=s/o,y=Math.min(p,f),g=Math.max(p,f);"meet"==c&&(n*=y,o*=y),"slice"==c&&(n*=g,o*=g),h=new u.Property("refX",h),l=new u.Property("refY",l),h.hasValue()&&l.hasValue()?t.translate(-y*h.toPixels("x"),-y*l.toPixels("y")):(d.match(/^xMid/)&&("meet"==c&&y==f||"slice"==c&&g==f)&&t.translate(i/2-n/2,0),d.match(/YMid$/)&&("meet"==c&&y==p||"slice"==c&&g==p)&&t.translate(0,s/2-o/2),d.match(/^xMax/)&&("meet"==c&&y==f||"slice"==c&&g==f)&&t.translate(i-n,0),d.match(/YMax$/)&&("meet"==c&&y==p||"slice"==c&&g==p)&&t.translate(0,s-o)),"none"==d?t.scale(p,f):"meet"==c?t.scale(y,y):"slice"==c&&t.scale(g,g),t.translate(null==r?0:-r,null==a?0:-a)},u.Element={},u.EmptyProperty=new u.Property("EMPTY",""),u.Element.ElementBase=function(t){this.attributes={},this.styles={},this.stylesSpecificity={},this.children=[],this.attribute=function(t,e){var i=this.attributes[t];return null!=i?i:(1==e&&(i=new u.Property(t,""),this.attributes[t]=i),i||u.EmptyProperty)},this.getHrefAttribute=function(){for(var t in this.attributes)if("href"==t||t.match(/:href$/))return this.attributes[t];return u.EmptyProperty},this.style=function(t,e,i){var n=this.styles[t];if(null!=n)return n;var s=this.attribute(t);if(null!=s&&s.hasValue())return this.styles[t]=s,s;if(1!=i){var o=this.parent;if(null!=o){var r=o.style(t);if(null!=r&&r.hasValue())return r}}return 1==e&&(n=new u.Property(t,""),this.styles[t]=n),n||u.EmptyProperty},this.render=function(t){if("none"!=this.style("display").value&&"hidden"!=this.style("visibility").value){if(t.save(),this.style("mask").hasValue()){var e=this.style("mask").getDefinition();null!=e&&e.apply(t,this)}else if(this.style("filter").hasValue()){var i=this.style("filter").getDefinition();null!=i&&i.apply(t,this)}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}},this.setContext=function(){},this.clearContext=function(){},this.renderChildren=function(t){for(var e=0;e<this.children.length;e++)this.children[e].render(t)},this.addChild=function(t,e){var i=t;e&&(i=u.CreateElement(t)),i.parent=this,"title"!=i.type&&this.children.push(i)},this.addStylesFromStyleDefinition=function(){for(var e in u.Styles)if("@"!=e[0]&&l(t,e)){var i=u.Styles[e],n=u.StylesSpecificity[e];if(null!=i)for(var s in i){var o=this.stylesSpecificity[s];void 0===o&&(o="000"),n>=o&&(this.styles[s]=i[s],this.stylesSpecificity[s]=n)}}};var e=new RegExp("^[A-Z-]+$"),i=function(t){return e.test(t)?t.toLowerCase():t};if(null!=t&&1==t.nodeType){for(var n=0;n<t.attributes.length;n++){var s=t.attributes[n],o=i(s.nodeName);this.attributes[o]=new u.Property(o,s.value)}if(this.addStylesFromStyleDefinition(),this.attribute("style").hasValue()){var r=this.attribute("style").value.split(";");for(n=0;n<r.length;n++)if(""!=u.trim(r[n])){var a=r[n].split(":"),h=u.trim(a[0]),d=u.trim(a[1]);this.styles[h]=new u.Property(h,d)}}for(this.attribute("id").hasValue()&&null==u.Definitions[this.attribute("id").value]&&(u.Definitions[this.attribute("id").value]=this),n=0;n<t.childNodes.length;n++){var c=t.childNodes[n];if(1==c.nodeType&&this.addChild(c,!0),this.captureTextNodes&&(3==c.nodeType||4==c.nodeType)){var p=c.value||c.text||c.textContent||"";""!=u.compressSpaces(p)&&this.addChild(new u.Element.tspan(c),!1)}}}},u.Element.RenderedElementBase=function(t){this.base=u.Element.ElementBase,this.base(t),this.calculateOpacity=function(){for(var t=1,e=this;null!=e;){var i=e.style("opacity",!1,!0);i.hasValue()&&(t*=i.numValue()),e=e.parent}return t},this.setContext=function(t,e){if(!e){var i;if(this.style("fill").isUrlDefinition())null!=(i=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity")))&&(t.fillStyle=i);else if(this.style("fill").hasValue()){var n;"currentColor"==(n=this.style("fill")).value&&(n.value=this.style("color").value),"inherit"!=n.value&&(t.fillStyle="none"==n.value?"rgba(0,0,0,0)":n.value)}if(this.style("fill-opacity").hasValue()&&(n=(n=new u.Property("fill",t.fillStyle)).addOpacity(this.style("fill-opacity")),t.fillStyle=n.value),this.style("stroke").isUrlDefinition())null!=(i=this.style("stroke").getFillStyleDefinition(this,this.style("stroke-opacity")))&&(t.strokeStyle=i);else if(this.style("stroke").hasValue()){var s;"currentColor"==(s=this.style("stroke")).value&&(s.value=this.style("color").value),"inherit"!=s.value&&(t.strokeStyle="none"==s.value?"rgba(0,0,0,0)":s.value)}if(this.style("stroke-opacity").hasValue()&&(s=(s=new u.Property("stroke",t.strokeStyle)).addOpacity(this.style("stroke-opacity")),t.strokeStyle=s.value),this.style("stroke-width").hasValue()){var o=this.style("stroke-width").toPixels();t.lineWidth=0==o?.001:o}if(this.style("stroke-linecap").hasValue()&&(t.lineCap=this.style("stroke-linecap").value),this.style("stroke-linejoin").hasValue()&&(t.lineJoin=this.style("stroke-linejoin").value),this.style("stroke-miterlimit").hasValue()&&(t.miterLimit=this.style("stroke-miterlimit").value),this.style("paint-order").hasValue()&&(t.paintOrder=this.style("paint-order").value),this.style("stroke-dasharray").hasValue()&&"none"!=this.style("stroke-dasharray").value){var r=u.ToNumberArray(this.style("stroke-dasharray").value);void 0!==t.setLineDash?t.setLineDash(r):void 0!==t.webkitLineDash?t.webkitLineDash=r:void 0===t.mozDash||1==r.length&&0==r[0]||(t.mozDash=r);var a=this.style("stroke-dashoffset").toPixels();void 0!==t.lineDashOffset?t.lineDashOffset=a:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=a:void 0!==t.mozDashOffset&&(t.mozDashOffset=a)}}if(void 0!==t.font){t.font=u.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString();var h=this.style("font-size",!1,!1);h.isPixels()&&(u.emSize=h.toPixels())}if(this.style("transform",!1,!0).hasValue()&&new u.Transform(this.style("transform",!1,!0).value).apply(t),this.style("clip-path",!1,!0).hasValue()){var l=this.style("clip-path",!1,!0).getDefinition();null!=l&&l.apply(t)}t.globalAlpha=this.calculateOpacity()}},u.Element.RenderedElementBase.prototype=new u.Element.ElementBase,u.Element.PathElementBase=function(t){this.base=u.Element.RenderedElementBase,this.base(t),this.path=function(t){return null!=t&&t.beginPath(),new u.BoundingBox},this.renderChildren=function(t){this.path(t),u.Mouse.checkPath(this,t),""!=t.fillStyle&&("inherit"!=this.style("fill-rule").valueOrDefault("inherit")?t.fill(this.style("fill-rule").value):t.fill()),""!=t.strokeStyle&&t.stroke();var e=this.getMarkers();if(null!=e){if(this.style("marker-start").isUrlDefinition()&&(i=this.style("marker-start").getDefinition()).render(t,e[0][0],e[0][1]),this.style("marker-mid").isUrlDefinition())for(var i=this.style("marker-mid").getDefinition(),n=1;n<e.length-1;n++)i.render(t,e[n][0],e[n][1]);this.style("marker-end").isUrlDefinition()&&(i=this.style("marker-end").getDefinition()).render(t,e[e.length-1][0],e[e.length-1][1])}},this.getBoundingBox=function(){return this.path()},this.getMarkers=function(){return null}},u.Element.PathElementBase.prototype=new u.Element.RenderedElementBase,u.Element.svg=function(t){this.base=u.Element.RenderedElementBase,this.base(t),this.baseClearContext=this.clearContext,this.clearContext=function(t){this.baseClearContext(t),u.ViewPort.RemoveCurrent()},this.baseSetContext=this.setContext,this.setContext=function(t){if(t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4,t.canvas.style&&void 0!==t.font&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(t.canvas).getPropertyValue("font");var e=new u.Property("fontSize",u.Font.Parse(t.font).fontSize);e.hasValue()&&(u.rootEmSize=u.emSize=e.toPixels("y"))}this.baseSetContext(t),this.attribute("x").hasValue()||(this.attribute("x",!0).value=0),this.attribute("y").hasValue()||(this.attribute("y",!0).value=0),t.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var i=u.ViewPort.width(),s=u.ViewPort.height();if(this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%"),this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%"),void 0===this.root){i=this.attribute("width").toPixels("x"),s=this.attribute("height").toPixels("y");var o=0,r=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(o=-this.attribute("refX").toPixels("x"),r=-this.attribute("refY").toPixels("y")),"visible"!=this.attribute("overflow").valueOrDefault("hidden")&&(t.beginPath(),t.moveTo(o,r),t.lineTo(i,r),t.lineTo(i,s),t.lineTo(o,s),t.closePath(),t.clip())}if(u.ViewPort.SetCurrent(i,s),this.attribute("viewBox").hasValue()){var a=u.ToNumberArray(this.attribute("viewBox").value),h=a[0],l=a[1];i=a[2],s=a[3],u.AspectRatio(t,this.attribute("preserveAspectRatio").value,u.ViewPort.width(),i,u.ViewPort.height(),s,h,l,this.attribute("refX").value,this.attribute("refY").value),u.ViewPort.RemoveCurrent(),u.ViewPort.SetCurrent(a[2],a[3])}}},u.Element.svg.prototype=new u.Element.RenderedElementBase,u.Element.rect=function(t){this.base=u.Element.PathElementBase,this.base(t),this.path=function(t){var e=this.attribute("x").toPixels("x"),i=this.attribute("y").toPixels("y"),n=this.attribute("width").toPixels("x"),s=this.attribute("height").toPixels("y"),o=this.attribute("rx").toPixels("x"),r=this.attribute("ry").toPixels("y");if(this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(r=o),this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(o=r),o=Math.min(o,n/2),r=Math.min(r,s/2),null!=t){var a=(Math.sqrt(2)-1)/3*4;t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+n-o,i),t.bezierCurveTo(e+n-o+a*o,i,e+n,i+r-a*r,e+n,i+r),t.lineTo(e+n,i+s-r),t.bezierCurveTo(e+n,i+s-r+a*r,e+n-o+a*o,i+s,e+n-o,i+s),t.lineTo(e+o,i+s),t.bezierCurveTo(e+o-a*o,i+s,e,i+s-r+a*r,e,i+s-r),t.lineTo(e,i+r),t.bezierCurveTo(e,i+r-a*r,e+o-a*o,i,e+o,i),t.closePath()}return new u.BoundingBox(e,i,e+n,i+s)}},u.Element.rect.prototype=new u.Element.PathElementBase,u.Element.circle=function(t){this.base=u.Element.PathElementBase,this.base(t),this.path=function(t){var e=this.attribute("cx").toPixels("x"),i=this.attribute("cy").toPixels("y"),n=this.attribute("r").toPixels();return null!=t&&(t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!1),t.closePath()),new u.BoundingBox(e-n,i-n,e+n,i+n)}},u.Element.circle.prototype=new u.Element.PathElementBase,u.Element.ellipse=function(t){this.base=u.Element.PathElementBase,this.base(t),this.path=function(t){var e=(Math.sqrt(2)-1)/3*4,i=this.attribute("rx").toPixels("x"),n=this.attribute("ry").toPixels("y"),s=this.attribute("cx").toPixels("x"),o=this.attribute("cy").toPixels("y");return null!=t&&(t.beginPath(),t.moveTo(s+i,o),t.bezierCurveTo(s+i,o+e*n,s+e*i,o+n,s,o+n),t.bezierCurveTo(s-e*i,o+n,s-i,o+e*n,s-i,o),t.bezierCurveTo(s-i,o-e*n,s-e*i,o-n,s,o-n),t.bezierCurveTo(s+e*i,o-n,s+i,o-e*n,s+i,o),t.closePath()),new u.BoundingBox(s-i,o-n,s+i,o+n)}},u.Element.ellipse.prototype=new u.Element.PathElementBase,u.Element.line=function(t){this.base=u.Element.PathElementBase,this.base(t),this.getPoints=function(){return[new u.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new u.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]},this.path=function(t){var e=this.getPoints();return null!=t&&(t.beginPath(),t.moveTo(e[0].x,e[0].y),t.lineTo(e[1].x,e[1].y)),new u.BoundingBox(e[0].x,e[0].y,e[1].x,e[1].y)},this.getMarkers=function(){var t=this.getPoints(),e=t[0].angleTo(t[1]);return[[t[0],e],[t[1],e]]}},u.Element.line.prototype=new u.Element.PathElementBase,u.Element.polyline=function(t){this.base=u.Element.PathElementBase,this.base(t),this.points=u.CreatePath(this.attribute("points").value),this.path=function(t){var e=new u.BoundingBox(this.points[0].x,this.points[0].y);null!=t&&(t.beginPath(),t.moveTo(this.points[0].x,this.points[0].y));for(var i=1;i<this.points.length;i++)e.addPoint(this.points[i].x,this.points[i].y),null!=t&&t.lineTo(this.points[i].x,this.points[i].y);return e},this.getMarkers=function(){for(var t=[],e=0;e<this.points.length-1;e++)t.push([this.points[e],this.points[e].angleTo(this.points[e+1])]);return t.length>0&&t.push([this.points[this.points.length-1],t[t.length-1][1]]),t}},u.Element.polyline.prototype=new u.Element.PathElementBase,u.Element.polygon=function(t){this.base=u.Element.polyline,this.base(t),this.basePath=this.path,this.path=function(t){var e=this.basePath(t);return null!=t&&(t.lineTo(this.points[0].x,this.points[0].y),t.closePath()),e}},u.Element.polygon.prototype=new u.Element.polyline,u.Element.path=function(t){this.base=u.Element.PathElementBase,this.base(t);var e=this.attribute("d").value;e=e.replace(/,/gm," ");for(var i=0;i<2;i++)e=e.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");for(e=(e=e.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2")).replace(/([0-9])([+\-])/gm,"$1 $2"),i=0;i<2;i++)e=e.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");e=e.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 "),e=u.compressSpaces(e),e=u.trim(e),this.PathParser=new function(t){this.tokens=t.split(" "),this.reset=function(){this.i=-1,this.command="",this.previousCommand="",this.start=new u.Point(0,0),this.control=new u.Point(0,0),this.current=new u.Point(0,0),this.points=[],this.angles=[]},this.isEnd=function(){return this.i>=this.tokens.length-1},this.isCommandOrEnd=function(){return!!this.isEnd()||null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},this.getToken=function(){return this.i++,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var t=new u.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(t)},this.getAsControlPoint=function(){var t=this.getPoint();return this.control=t,t},this.getAsCurrentPoint=function(){var t=this.getPoint();return this.current=t,t},this.getReflectedControlPoint=function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new u.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},this.makeAbsolute=function(t){return this.isRelativeCommand()&&(t.x+=this.current.x,t.y+=this.current.y),t},this.addMarker=function(t,e,i){null!=i&&this.angles.length>0&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(i)),this.addMarkerAngle(t,null==e?null:e.angleTo(t))},this.addMarkerAngle=function(t,e){this.points.push(t),this.angles.push(e)},this.getMarkerPoints=function(){return this.points},this.getMarkerAngles=function(){for(var t=0;t<this.angles.length;t++)if(null==this.angles[t])for(var e=t+1;e<this.angles.length;e++)if(null!=this.angles[e]){this.angles[t]=this.angles[e];break}return this.angles}}(e),this.path=function(t){var e=this.PathParser;e.reset();var i=new u.BoundingBox;for(null!=t&&t.beginPath();!e.isEnd();)switch(e.nextCommand(),e.command){case"M":case"m":var n=e.getAsCurrentPoint();for(e.addMarker(n),i.addPoint(n.x,n.y),null!=t&&t.moveTo(n.x,n.y),e.start=e.current;!e.isCommandOrEnd();)n=e.getAsCurrentPoint(),e.addMarker(n,e.start),i.addPoint(n.x,n.y),null!=t&&t.lineTo(n.x,n.y);break;case"L":case"l":for(;!e.isCommandOrEnd();){var s=e.current;n=e.getAsCurrentPoint(),e.addMarker(n,s),i.addPoint(n.x,n.y),null!=t&&t.lineTo(n.x,n.y)}break;case"H":case"h":for(;!e.isCommandOrEnd();){var o=new u.Point((e.isRelativeCommand()?e.current.x:0)+e.getScalar(),e.current.y);e.addMarker(o,e.current),e.current=o,i.addPoint(e.current.x,e.current.y),null!=t&&t.lineTo(e.current.x,e.current.y)}break;case"V":case"v":for(;!e.isCommandOrEnd();)o=new u.Point(e.current.x,(e.isRelativeCommand()?e.current.y:0)+e.getScalar()),e.addMarker(o,e.current),e.current=o,i.addPoint(e.current.x,e.current.y),null!=t&&t.lineTo(e.current.x,e.current.y);break;case"C":case"c":for(;!e.isCommandOrEnd();){var r=e.current,a=e.getPoint(),h=e.getAsControlPoint(),l=e.getAsCurrentPoint();e.addMarker(l,h,a),i.addBezierCurve(r.x,r.y,a.x,a.y,h.x,h.y,l.x,l.y),null!=t&&t.bezierCurveTo(a.x,a.y,h.x,h.y,l.x,l.y)}break;case"S":case"s":for(;!e.isCommandOrEnd();)r=e.current,a=e.getReflectedControlPoint(),h=e.getAsControlPoint(),l=e.getAsCurrentPoint(),e.addMarker(l,h,a),i.addBezierCurve(r.x,r.y,a.x,a.y,h.x,h.y,l.x,l.y),null!=t&&t.bezierCurveTo(a.x,a.y,h.x,h.y,l.x,l.y);break;case"Q":case"q":for(;!e.isCommandOrEnd();)r=e.current,h=e.getAsControlPoint(),l=e.getAsCurrentPoint(),e.addMarker(l,h,h),i.addQuadraticCurve(r.x,r.y,h.x,h.y,l.x,l.y),null!=t&&t.quadraticCurveTo(h.x,h.y,l.x,l.y);break;case"T":case"t":for(;!e.isCommandOrEnd();)r=e.current,h=e.getReflectedControlPoint(),e.control=h,l=e.getAsCurrentPoint(),e.addMarker(l,h,h),i.addQuadraticCurve(r.x,r.y,h.x,h.y,l.x,l.y),null!=t&&t.quadraticCurveTo(h.x,h.y,l.x,l.y);break;case"A":case"a":for(;!e.isCommandOrEnd();){r=e.current;var d=e.getScalar(),c=e.getScalar(),p=e.getScalar()*(Math.PI/180),f=e.getScalar(),y=e.getScalar(),g=(l=e.getAsCurrentPoint(),new u.Point(Math.cos(p)*(r.x-l.x)/2+Math.sin(p)*(r.y-l.y)/2,-Math.sin(p)*(r.x-l.x)/2+Math.cos(p)*(r.y-l.y)/2)),v=Math.pow(g.x,2)/Math.pow(d,2)+Math.pow(g.y,2)/Math.pow(c,2);v>1&&(d*=Math.sqrt(v),c*=Math.sqrt(v));var m=(f==y?-1:1)*Math.sqrt((Math.pow(d,2)*Math.pow(c,2)-Math.pow(d,2)*Math.pow(g.y,2)-Math.pow(c,2)*Math.pow(g.x,2))/(Math.pow(d,2)*Math.pow(g.y,2)+Math.pow(c,2)*Math.pow(g.x,2)));isNaN(m)&&(m=0);var x=new u.Point(m*d*g.y/c,m*-c*g.x/d),b=new u.Point((r.x+l.x)/2+Math.cos(p)*x.x-Math.sin(p)*x.y,(r.y+l.y)/2+Math.sin(p)*x.x+Math.cos(p)*x.y),M=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))},E=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(M(t)*M(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(E(t,e))},k=w([1,0],[(g.x-x.x)/d,(g.y-x.y)/c]),T=[(g.x-x.x)/d,(g.y-x.y)/c],C=[(-g.x-x.x)/d,(-g.y-x.y)/c],S=w(T,C);E(T,C)<=-1&&(S=Math.PI),E(T,C)>=1&&(S=0);var A=1-y?1:-1,P=k+A*(S/2),I=new u.Point(b.x+d*Math.cos(P),b.y+c*Math.sin(P));if(e.addMarkerAngle(I,P-A*Math.PI/2),e.addMarkerAngle(l,P-A*Math.PI),i.addPoint(l.x,l.y),null!=t&&!isNaN(k)&&!isNaN(S)){E=d>c?d:c;var z=d>c?1:d/c,D=d>c?c/d:1;t.translate(b.x,b.y),t.rotate(p),t.scale(z,D),t.arc(0,0,E,k,k+S,1-y),t.scale(1/z,1/D),t.rotate(-p),t.translate(-b.x,-b.y)}}break;case"Z":case"z":null!=t&&i.x1!==i.x2&&i.y1!==i.y2&&t.closePath(),e.current=e.start}return i},this.getMarkers=function(){for(var t=this.PathParser.getMarkerPoints(),e=this.PathParser.getMarkerAngles(),i=[],n=0;n<t.length;n++)i.push([t[n],e[n]]);return i}},u.Element.path.prototype=new u.Element.PathElementBase,u.Element.pattern=function(t){this.base=u.Element.ElementBase,this.base(t),this.createPattern=function(t){var e=this.attribute("width").toPixels("x",!0),i=this.attribute("height").toPixels("y",!0),n=new u.Element.svg;n.attributes.viewBox=new u.Property("viewBox",this.attribute("viewBox").value),n.attributes.width=new u.Property("width",e+"px"),n.attributes.height=new u.Property("height",i+"px"),n.attributes.transform=new u.Property("transform",this.attribute("patternTransform").value),n.children=this.children;var s=h(e,i),o=s.getContext("2d");this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&o.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(var r=-1;r<=1;r++)for(var a=-1;a<=1;a++)o.save(),n.attributes.x=new u.Property("x",r*s.width),n.attributes.y=new u.Property("y",a*s.height),n.render(o),o.restore();return t.createPattern(s,"repeat")}},u.Element.pattern.prototype=new u.Element.ElementBase,u.Element.marker=function(t){this.base=u.Element.ElementBase,this.base(t),this.baseRender=this.render,this.render=function(t,e,i){if(e){t.translate(e.x,e.y),"auto"==this.attribute("orient").valueOrDefault("auto")&&t.rotate(i),"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&t.scale(t.lineWidth,t.lineWidth),t.save();var n=new u.Element.svg;n.attributes.viewBox=new u.Property("viewBox",this.attribute("viewBox").value),n.attributes.refX=new u.Property("refX",this.attribute("refX").value),n.attributes.refY=new u.Property("refY",this.attribute("refY").value),n.attributes.width=new u.Property("width",this.attribute("markerWidth").value),n.attributes.height=new u.Property("height",this.attribute("markerHeight").value),n.attributes.fill=new u.Property("fill",this.attribute("fill").valueOrDefault("black")),n.attributes.stroke=new u.Property("stroke",this.attribute("stroke").valueOrDefault("none")),n.children=this.children,n.render(t),t.restore(),"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"==this.attribute("orient").valueOrDefault("auto")&&t.rotate(-i),t.translate(-e.x,-e.y)}}},u.Element.marker.prototype=new u.Element.ElementBase,u.Element.defs=function(t){this.base=u.Element.ElementBase,this.base(t),this.render=function(){}},u.Element.defs.prototype=new u.Element.ElementBase,u.Element.GradientBase=function(t){this.base=u.Element.ElementBase,this.base(t),this.stops=[];for(var e=0;e<this.children.length;e++){var i=this.children[e];"stop"==i.type&&this.stops.push(i)}this.getGradient=function(){},this.gradientUnits=function(){return this.attribute("gradientUnits").valueOrDefault("objectBoundingBox")},this.attributesToInherit=["gradientUnits"],this.inheritStopContainer=function(t){for(var e=0;e<this.attributesToInherit.length;e++){var i=this.attributesToInherit[e];!this.attribute(i).hasValue()&&t.attribute(i).hasValue()&&(this.attribute(i,!0).value=t.attribute(i).value)}},this.createGradient=function(t,e,i){var n=this;this.getHrefAttribute().hasValue()&&(n=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(n));var s=function(t){return i.hasValue()?new u.Property("color",t).addOpacity(i).value:t},o=this.getGradient(t,e);if(null==o)return s(n.stops[n.stops.length-1].color);for(var r=0;r<n.stops.length;r++)o.addColorStop(n.stops[r].offset,s(n.stops[r].color));if(this.attribute("gradientTransform").hasValue()){var a=u.ViewPort.viewPorts[0],l=new u.Element.rect;l.attributes.x=new u.Property("x",-u.MAX_VIRTUAL_PIXELS/3),l.attributes.y=new u.Property("y",-u.MAX_VIRTUAL_PIXELS/3),l.attributes.width=new u.Property("width",u.MAX_VIRTUAL_PIXELS),l.attributes.height=new u.Property("height",u.MAX_VIRTUAL_PIXELS);var d=new u.Element.g;d.attributes.transform=new u.Property("transform",this.attribute("gradientTransform").value),d.children=[l];var c=new u.Element.svg;c.attributes.x=new u.Property("x",0),c.attributes.y=new u.Property("y",0),c.attributes.width=new u.Property("width",a.width),c.attributes.height=new u.Property("height",a.height),c.children=[d];var p=h(a.width,a.height),f=p.getContext("2d");return f.fillStyle=o,c.render(f),f.createPattern(p,"no-repeat")}return o}},u.Element.GradientBase.prototype=new u.Element.ElementBase,u.Element.linearGradient=function(t){this.base=u.Element.GradientBase,this.base(t),this.attributesToInherit.push("x1"),this.attributesToInherit.push("y1"),this.attributesToInherit.push("x2"),this.attributesToInherit.push("y2"),this.getGradient=function(t,e){var i="objectBoundingBox"==this.gradientUnits()?e.getBoundingBox(t):null;this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0);var n="objectBoundingBox"==this.gradientUnits()?i.x()+i.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),s="objectBoundingBox"==this.gradientUnits()?i.y()+i.height()*this.attribute("y1").numValue():this.attribute("y1").toPixels("y"),o="objectBoundingBox"==this.gradientUnits()?i.x()+i.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),r="objectBoundingBox"==this.gradientUnits()?i.y()+i.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return n==o&&s==r?null:t.createLinearGradient(n,s,o,r)}},u.Element.linearGradient.prototype=new u.Element.GradientBase,u.Element.radialGradient=function(t){this.base=u.Element.GradientBase,this.base(t),this.attributesToInherit.push("cx"),this.attributesToInherit.push("cy"),this.attributesToInherit.push("r"),this.attributesToInherit.push("fx"),this.attributesToInherit.push("fy"),this.getGradient=function(t,e){var i=e.getBoundingBox(t);this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%"),this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%"),this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%");var n="objectBoundingBox"==this.gradientUnits()?i.x()+i.width()*this.attribute("cx").numValue():this.attribute("cx").toPixels("x"),s="objectBoundingBox"==this.gradientUnits()?i.y()+i.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),o=n,r=s;this.attribute("fx").hasValue()&&(o="objectBoundingBox"==this.gradientUnits()?i.x()+i.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x")),this.attribute("fy").hasValue()&&(r="objectBoundingBox"==this.gradientUnits()?i.y()+i.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));var a="objectBoundingBox"==this.gradientUnits()?(i.width()+i.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return t.createRadialGradient(o,r,0,n,s,a)}},u.Element.radialGradient.prototype=new u.Element.GradientBase,u.Element.stop=function(t){this.base=u.Element.ElementBase,this.base(t),this.offset=this.attribute("offset").numValue(),this.offset<0&&(this.offset=0),this.offset>1&&(this.offset=1);var e=this.style("stop-color",!0);""===e.value&&(e.value="#000"),this.style("stop-opacity").hasValue()&&(e=e.addOpacity(this.style("stop-opacity"))),this.color=e.value},u.Element.stop.prototype=new u.Element.ElementBase,u.Element.AnimateBase=function(t){this.base=u.Element.ElementBase,this.base(t),u.Animations.push(this),this.duration=0,this.begin=this.attribute("begin").toMilliseconds(),this.maxDuration=this.begin+this.attribute("dur").toMilliseconds(),this.getProperty=function(){var t=this.attribute("attributeType").value,e=this.attribute("attributeName").value;return"CSS"==t?this.parent.style(e,!0):this.parent.attribute(e,!0)},this.initialValue=null,this.initialUnits="",this.removed=!1,this.calcValue=function(){return""},this.update=function(t){if(null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits()),this.duration>this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"!=this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration=this.duration+t;var e=!1;if(this.begin<this.duration){var i=this.calcValue();this.attribute("type").hasValue()&&(i=this.attribute("type").value+"("+i+")"),this.getProperty().value=i,e=!0}return e},this.from=this.attribute("from"),this.to=this.attribute("to"),this.values=this.attribute("values"),this.values.hasValue()&&(this.values.value=this.values.value.split(";")),this.progress=function(){var t={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var e=t.progress*(this.values.value.length-1),i=Math.floor(e),n=Math.ceil(e);t.from=new u.Property("from",parseFloat(this.values.value[i])),t.to=new u.Property("to",parseFloat(this.values.value[n])),t.progress=(e-i)/(n-i)}else t.from=this.from,t.to=this.to;return t}},u.Element.AnimateBase.prototype=new u.Element.ElementBase,u.Element.animate=function(t){this.base=u.Element.AnimateBase,this.base(t),this.calcValue=function(){var t=this.progress();return t.from.numValue()+(t.to.numValue()-t.from.numValue())*t.progress+this.initialUnits}},u.Element.animate.prototype=new u.Element.AnimateBase,u.Element.animateColor=function(e){this.base=u.Element.AnimateBase,this.base(e),this.calcValue=function(){var e=this.progress(),i=new t(e.from.value),n=new t(e.to.value);if(i.ok&&n.ok){var s=i.r+(n.r-i.r)*e.progress,o=i.g+(n.g-i.g)*e.progress,r=i.b+(n.b-i.b)*e.progress;return"rgb("+parseInt(s,10)+","+parseInt(o,10)+","+parseInt(r,10)+")"}return this.attribute("from").value}},u.Element.animateColor.prototype=new u.Element.AnimateBase,u.Element.animateTransform=function(t){this.base=u.Element.AnimateBase,this.base(t),this.calcValue=function(){for(var t=this.progress(),e=u.ToNumberArray(t.from.value),i=u.ToNumberArray(t.to.value),n="",s=0;s<e.length;s++)n+=e[s]+(i[s]-e[s])*t.progress+" ";return n}},u.Element.animateTransform.prototype=new u.Element.animate,u.Element.font=function(t){this.base=u.Element.ElementBase,this.base(t),this.horizAdvX=this.attribute("horiz-adv-x").numValue(),this.isRTL=!1,this.isArabic=!1,this.fontFace=null,this.missingGlyph=null,this.glyphs=[];for(var e=0;e<this.children.length;e++){var i=this.children[e];"font-face"==i.type?(this.fontFace=i,i.style("font-family").hasValue()&&(u.Definitions[i.style("font-family").value]=this)):"missing-glyph"==i.type?this.missingGlyph=i:"glyph"==i.type&&(""!=i.arabicForm?(this.isRTL=!0,this.isArabic=!0,void 0===this.glyphs[i.unicode]&&(this.glyphs[i.unicode]=[]),this.glyphs[i.unicode][i.arabicForm]=i):this.glyphs[i.unicode]=i)}this.render=function(){}},u.Element.font.prototype=new u.Element.ElementBase,u.Element.fontface=function(t){this.base=u.Element.ElementBase,this.base(t),this.ascent=this.attribute("ascent").value,this.descent=this.attribute("descent").value,this.unitsPerEm=this.attribute("units-per-em").numValue()},u.Element.fontface.prototype=new u.Element.ElementBase,u.Element.missingglyph=function(t){this.base=u.Element.path,this.base(t),this.horizAdvX=0},u.Element.missingglyph.prototype=new u.Element.path,u.Element.glyph=function(t){this.base=u.Element.path,this.base(t),this.horizAdvX=this.attribute("horiz-adv-x").numValue(),this.unicode=this.attribute("unicode").value,this.arabicForm=this.attribute("arabic-form").value},u.Element.glyph.prototype=new u.Element.path,u.Element.text=function(t){this.captureTextNodes=!0,this.base=u.Element.RenderedElementBase,this.base(t),this.baseSetContext=this.setContext,this.setContext=function(t){this.baseSetContext(t);var e=this.style("dominant-baseline").toTextBaseline();null==e&&(e=this.style("alignment-baseline").toTextBaseline()),null!=e&&(t.textBaseline=e)},this.initializeCoordinates=function(t){this.x=this.attribute("x").toPixels("x"),this.y=this.attribute("y").toPixels("y"),this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x")),this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y")),this.x+=this.getAnchorDelta(t,this,0)},this.getBoundingBox=function(t){this.initializeCoordinates(t);for(var e=null,i=0;i<this.children.length;i++){var n=this.getChildBoundingBox(t,this,this,i);null==e?e=n:e.addBoundingBox(n)}return e},this.renderChildren=function(t){this.initializeCoordinates(t);for(var e=0;e<this.children.length;e++)this.renderChild(t,this,this,e)},this.getAnchorDelta=function(t,e,i){var n=this.style("text-anchor").valueOrDefault("start");if("start"!=n){for(var s=0,o=i;o<e.children.length;o++){var r=e.children[o];if(o>i&&r.attribute("x").hasValue())break;s+=r.measureTextRecursive(t)}return-1*("end"==n?s:s/2)}return 0},this.adjustChildCoordinates=function(t,e,i,n){var s=i.children[n];return s.attribute("x").hasValue()?(s.x=s.attribute("x").toPixels("x")+e.getAnchorDelta(t,i,n),s.attribute("dx").hasValue()&&(s.x+=s.attribute("dx").toPixels("x"))):(s.attribute("dx").hasValue()&&(e.x+=s.attribute("dx").toPixels("x")),s.x=e.x),e.x=s.x+s.measureText(t),s.attribute("y").hasValue()?(s.y=s.attribute("y").toPixels("y"),s.attribute("dy").hasValue()&&(s.y+=s.attribute("dy").toPixels("y"))):(s.attribute("dy").hasValue()&&(e.y+=s.attribute("dy").toPixels("y")),s.y=e.y),e.y=s.y,s},this.getChildBoundingBox=function(t,e,i,n){var s=this.adjustChildCoordinates(t,e,i,n),o=s.getBoundingBox(t);for(n=0;n<s.children.length;n++){var r=e.getChildBoundingBox(t,e,s,n);o.addBoundingBox(r)}return o},this.renderChild=function(t,e,i,n){var s=this.adjustChildCoordinates(t,e,i,n);for(s.render(t),n=0;n<s.children.length;n++)e.renderChild(t,e,s,n)}},u.Element.text.prototype=new u.Element.RenderedElementBase,u.Element.TextElementBase=function(t){this.base=u.Element.RenderedElementBase,this.base(t),this.getGlyph=function(t,e,i){var n=e[i],s=null;if(t.isArabic){var o="isolated";(0==i||" "==e[i-1])&&i<e.length-2&&" "!=e[i+1]&&(o="terminal"),i>0&&" "!=e[i-1]&&i<e.length-2&&" "!=e[i+1]&&(o="medial"),i>0&&" "!=e[i-1]&&(i==e.length-1||" "==e[i+1])&&(o="initial"),void 0!==t.glyphs[n]&&null==(s=t.glyphs[n][o])&&"glyph"==t.glyphs[n].type&&(s=t.glyphs[n])}else s=t.glyphs[n];return null==s&&(s=t.missingGlyph),s},this.renderChildren=function(t){var e=this.parent.style("font-family").getDefinition();if(null==e)"stroke"==t.paintOrder?(""!=t.strokeStyle&&t.strokeText(u.compressSpaces(this.getText()),this.x,this.y),""!=t.fillStyle&&t.fillText(u.compressSpaces(this.getText()),this.x,this.y)):(""!=t.fillStyle&&t.fillText(u.compressSpaces(this.getText()),this.x,this.y),""!=t.strokeStyle&&t.strokeText(u.compressSpaces(this.getText()),this.x,this.y));else{var i=this.parent.style("font-size").numValueOrDefault(u.Font.Parse(u.ctx.font).fontSize),n=this.parent.style("font-style").valueOrDefault(u.Font.Parse(u.ctx.font).fontStyle),s=this.getText();e.isRTL&&(s=s.split("").reverse().join(""));for(var o=u.ToNumberArray(this.parent.attribute("dx").value),r=0;r<s.length;r++){var a=this.getGlyph(e,s,r),h=i/e.fontFace.unitsPerEm;t.translate(this.x,this.y),t.scale(h,-h);var l=t.lineWidth;t.lineWidth=t.lineWidth*e.fontFace.unitsPerEm/i,"italic"==n&&t.transform(1,0,.4,1,0,0),a.render(t),"italic"==n&&t.transform(1,0,-.4,1,0,0),t.lineWidth=l,t.scale(1/h,-1/h),t.translate(-this.x,-this.y),this.x+=i*(a.horizAdvX||e.horizAdvX)/e.fontFace.unitsPerEm,void 0===o[r]||isNaN(o[r])||(this.x+=o[r])}}},this.getText=function(){},this.measureTextRecursive=function(t){for(var e=this.measureText(t),i=0;i<this.children.length;i++)e+=this.children[i].measureTextRecursive(t);return e},this.measureText=function(t){var e=this.parent.style("font-family").getDefinition();if(null!=e){var i=this.parent.style("font-size").numValueOrDefault(u.Font.Parse(u.ctx.font).fontSize),n=0,s=this.getText();e.isRTL&&(s=s.split("").reverse().join(""));for(var o=u.ToNumberArray(this.parent.attribute("dx").value),r=0;r<s.length;r++)n+=(this.getGlyph(e,s,r).horizAdvX||e.horizAdvX)*i/e.fontFace.unitsPerEm,void 0===o[r]||isNaN(o[r])||(n+=o[r]);return n}var a=u.compressSpaces(this.getText());if(!t.measureText)return 10*a.length;t.save(),this.setContext(t,!0);var h=t.measureText(a).width;return t.restore(),h},this.getBoundingBox=function(t){var e=this.parent.style("font-size").numValueOrDefault(u.Font.Parse(u.ctx.font).fontSize);return new u.BoundingBox(this.x,this.y-e,this.x+this.measureText(t),this.y)}},u.Element.TextElementBase.prototype=new u.Element.RenderedElementBase,u.Element.tspan=function(t){this.captureTextNodes=!0,this.base=u.Element.TextElementBase,this.base(t),this.text=u.compressSpaces(t.value||t.text||t.textContent||""),this.getText=function(){return this.children.length>0?"":this.text}},u.Element.tspan.prototype=new u.Element.TextElementBase,u.Element.tref=function(t){this.base=u.Element.TextElementBase,this.base(t),this.getText=function(){var t=this.getHrefAttribute().getDefinition();if(null!=t)return t.children[0].getText()}},u.Element.tref.prototype=new u.Element.TextElementBase,u.Element.a=function(t){this.base=u.Element.TextElementBase,this.base(t),this.hasText=t.childNodes.length>0;for(var e=0;e<t.childNodes.length;e++)3!=t.childNodes[e].nodeType&&(this.hasText=!1);this.text=this.hasText?t.childNodes[0].value||t.childNodes[0].data:"",this.getText=function(){return this.text},this.baseRenderChildren=this.renderChildren,this.renderChildren=function(t){if(this.hasText){this.baseRenderChildren(t);var e=new u.Property("fontSize",u.Font.Parse(u.ctx.font).fontSize);u.Mouse.checkBoundingBox(this,new u.BoundingBox(this.x,this.y-e.toPixels("y"),this.x+this.measureText(t),this.y))}else if(this.children.length>0){var i=new u.Element.g;i.children=this.children,i.parent=this,i.render(t)}},this.onclick=function(){n.open(this.getHrefAttribute().value)},this.onmousemove=function(){u.ctx.canvas.style.cursor="pointer"}},u.Element.a.prototype=new u.Element.TextElementBase,u.Element.image=function(t){this.base=u.Element.RenderedElementBase,this.base(t);var e=this.getHrefAttribute().value;if(""!=e){var i=e.match(/\.svg$/);if(u.Images.push(this),this.loaded=!1,i)this.img=u.ajax(e),this.loaded=!0;else{this.img=o.createElement("img"),1==u.opts.useCORS&&(this.img.crossOrigin="Anonymous");var n=this;this.img.onload=function(){n.loaded=!0},this.img.onerror=function(){u.log('ERROR: image "'+e+'" not found'),n.loaded=!0},this.img.src=e}this.renderChildren=function(t){var e=this.attribute("x").toPixels("x"),s=this.attribute("y").toPixels("y"),o=this.attribute("width").toPixels("x"),r=this.attribute("height").toPixels("y");0!=o&&0!=r&&(t.save(),i?t.drawSvg(this.img,e,s,o,r):(t.translate(e,s),u.AspectRatio(t,this.attribute("preserveAspectRatio").value,o,this.img.width,r,this.img.height,0,0),n.loaded&&(void 0===this.img.complete||this.img.complete)&&t.drawImage(this.img,0,0)),t.restore())},this.getBoundingBox=function(){var t=this.attribute("x").toPixels("x"),e=this.attribute("y").toPixels("y"),i=this.attribute("width").toPixels("x"),n=this.attribute("height").toPixels("y");return new u.BoundingBox(t,e,t+i,e+n)}}},u.Element.image.prototype=new u.Element.RenderedElementBase,u.Element.g=function(t){this.base=u.Element.RenderedElementBase,this.base(t),this.getBoundingBox=function(t){for(var e=new u.BoundingBox,i=0;i<this.children.length;i++)e.addBoundingBox(this.children[i].getBoundingBox(t));return e}},u.Element.g.prototype=new u.Element.RenderedElementBase,u.Element.symbol=function(t){this.base=u.Element.RenderedElementBase,this.base(t),this.render=function(){}},u.Element.symbol.prototype=new u.Element.RenderedElementBase,u.Element.style=function(t){this.base=u.Element.ElementBase,this.base(t);for(var e="",i=0;i<t.childNodes.length;i++)e+=t.childNodes[i].data;e=e.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"");var n=(e=u.compressSpaces(e)).split("}");for(i=0;i<n.length;i++)if(""!=u.trim(n[i]))for(var o=n[i].split("{"),r=o[0].split(","),a=o[1].split(";"),h=0;h<r.length;h++){var l=u.trim(r[h]);if(""!=l){for(var d=u.Styles[l]||{},c=0;c<a.length;c++){var p=a[c].indexOf(":"),f=a[c].substr(0,p),y=a[c].substr(p+1,a[c].length-p);null!=f&&null!=y&&(d[u.trim(f)]=new u.Property(u.trim(f),u.trim(y)))}if(u.Styles[l]=d,u.StylesSpecificity[l]=m(l),"@font-face"==l&&!s)for(var g=d["font-family"].value.replace(/"/g,""),v=d.src.value.split(","),x=0;x<v.length;x++)if(v[x].indexOf('format("svg")')>0)for(var b=v[x].indexOf("url"),M=v[x].indexOf(")",b),E=v[x].substr(b+5,M-b-6),w=u.parseXml(u.ajax(E)).getElementsByTagName("font"),k=0;k<w.length;k++){var T=u.CreateElement(w[k]);u.Definitions[g]=T}}}},u.Element.style.prototype=new u.Element.ElementBase,u.Element.use=function(t){this.base=u.Element.RenderedElementBase,this.base(t),this.baseSetContext=this.setContext,this.setContext=function(t){this.baseSetContext(t),this.attribute("x").hasValue()&&t.translate(this.attribute("x").toPixels("x"),0),this.attribute("y").hasValue()&&t.translate(0,this.attribute("y").toPixels("y"))};var e=this.getHrefAttribute().getDefinition();this.path=function(t){null!=e&&e.path(t)},this.elementTransform=function(){if(null!=e&&e.style("transform",!1,!0).hasValue())return new u.Transform(e.style("transform",!1,!0).value)},this.getBoundingBox=function(t){if(null!=e)return e.getBoundingBox(t)},this.renderChildren=function(t){if(null!=e){var i=e;"symbol"==e.type&&((i=new u.Element.svg).type="svg",i.attributes.viewBox=new u.Property("viewBox",e.attribute("viewBox").value),i.attributes.preserveAspectRatio=new u.Property("preserveAspectRatio",e.attribute("preserveAspectRatio").value),i.attributes.overflow=new u.Property("overflow",e.attribute("overflow").value),i.children=e.children),"svg"==i.type&&(this.attribute("width").hasValue()&&(i.attributes.width=new u.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&(i.attributes.height=new u.Property("height",this.attribute("height").value)));var n=i.parent;i.parent=null,i.render(t),i.parent=n}}},u.Element.use.prototype=new u.Element.RenderedElementBase,u.Element.mask=function(t){this.base=u.Element.ElementBase,this.base(t),this.apply=function(t,e){var i=this.attribute("x").toPixels("x"),n=this.attribute("y").toPixels("y"),s=this.attribute("width").toPixels("x"),o=this.attribute("height").toPixels("y");if(0==s&&0==o){for(var r=new u.BoundingBox,a=0;a<this.children.length;a++)r.addBoundingBox(this.children[a].getBoundingBox(t));i=Math.floor(r.x1),n=Math.floor(r.y1),s=Math.floor(r.width()),o=Math.floor(r.height())}var l=e.style("mask").value;e.style("mask").value="";var d=h(i+s,n+o),c=d.getContext("2d");this.renderChildren(c);var p=h(i+s,n+o),f=p.getContext("2d");e.render(f),f.globalCompositeOperation="destination-in",f.fillStyle=c.createPattern(d,"no-repeat"),f.fillRect(0,0,i+s,n+o),t.fillStyle=f.createPattern(p,"no-repeat"),t.fillRect(0,0,i+s,n+o),e.style("mask").value=l},this.render=function(){}},u.Element.mask.prototype=new u.Element.ElementBase,u.Element.clipPath=function(t){this.base=u.Element.ElementBase,this.base(t),this.apply=function(t){var e="undefined"!=typeof CanvasRenderingContext2D,i=t.beginPath,n=t.closePath;e&&(CanvasRenderingContext2D.prototype.beginPath=function(){},CanvasRenderingContext2D.prototype.closePath=function(){}),i.call(t);for(var s=0;s<this.children.length;s++){var o=this.children[s];if(void 0!==o.path){var r=void 0!==o.elementTransform&&o.elementTransform();!r&&o.style("transform",!1,!0).hasValue()&&(r=new u.Transform(o.style("transform",!1,!0).value)),r&&r.apply(t),o.path(t),e&&(CanvasRenderingContext2D.prototype.closePath=n),r&&r.unapply(t)}}n.call(t),t.clip(),e&&(CanvasRenderingContext2D.prototype.beginPath=i,CanvasRenderingContext2D.prototype.closePath=n)},this.render=function(){}},u.Element.clipPath.prototype=new u.Element.ElementBase,u.Element.filter=function(t){this.base=u.Element.ElementBase,this.base(t),this.apply=function(t,e){var i=e.getBoundingBox(t),n=Math.floor(i.x1),s=Math.floor(i.y1),o=Math.floor(i.width()),r=Math.floor(i.height()),a=e.style("filter").value;e.style("filter").value="";for(var l=0,u=0,d=0;d<this.children.length;d++){var c=this.children[d].extraFilterDistance||0;l=Math.max(l,c),u=Math.max(u,c)}var p=h(o+2*l,r+2*u),f=p.getContext("2d");for(f.translate(-n+l,-s+u),e.render(f),d=0;d<this.children.length;d++)"function"==typeof this.children[d].apply&&this.children[d].apply(f,0,0,o+2*l,r+2*u);t.drawImage(p,0,0,o+2*l,r+2*u,n-l,s-u,o+2*l,r+2*u),e.style("filter",!0).value=a},this.render=function(){}},u.Element.filter.prototype=new u.Element.ElementBase,u.Element.feDropShadow=function(t){this.base=u.Element.ElementBase,this.base(t),this.addStylesFromStyleDefinition(),this.apply=function(){}},u.Element.feDropShadow.prototype=new u.Element.ElementBase,u.Element.feMorphology=function(t){this.base=u.Element.ElementBase,this.base(t),this.apply=function(){}},u.Element.feMorphology.prototype=new u.Element.ElementBase,u.Element.feComposite=function(t){this.base=u.Element.ElementBase,this.base(t),this.apply=function(){}},u.Element.feComposite.prototype=new u.Element.ElementBase,u.Element.feColorMatrix=function(t){this.base=u.Element.ElementBase,this.base(t);var e=u.ToNumberArray(this.attribute("values").value);switch(this.attribute("type").valueOrDefault("matrix")){case"saturate":var i=e[0];e=[.213+.787*i,.715-.715*i,.072-.072*i,0,0,.213-.213*i,.715+.285*i,.072-.072*i,0,0,.213-.213*i,.715-.715*i,.072+.928*i,0,0,0,0,0,1,0,0,0,0,0,1];break;case"hueRotate":var n=e[0]*Math.PI/180,s=function(t,e,i){return t+Math.cos(n)*e+Math.sin(n)*i};e=[s(.213,.787,-.213),s(.715,-.715,-.715),s(.072,-.072,.928),0,0,s(.213,-.213,.143),s(.715,.285,.14),s(.072,-.072,-.283),0,0,s(.213,-.213,-.787),s(.715,-.715,.715),s(.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case"luminanceToAlpha":e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}function o(t,e,i,n,s,o){return t[i*n*4+4*e+o]}function r(t,e,i,n,s,o,r){t[i*n*4+4*e+o]=r}function a(t,i){var n=e[t];return n*(n<0?i-255:i)}this.apply=function(t,e,i,n,s){var h=t.getImageData(0,0,n,s);for(i=0;i<s;i++)for(e=0;e<n;e++){var l=o(h.data,e,i,n,0,0),u=o(h.data,e,i,n,0,1),d=o(h.data,e,i,n,0,2),c=o(h.data,e,i,n,0,3);r(h.data,e,i,n,0,0,a(0,l)+a(1,u)+a(2,d)+a(3,c)+a(4,1)),r(h.data,e,i,n,0,1,a(5,l)+a(6,u)+a(7,d)+a(8,c)+a(9,1)),r(h.data,e,i,n,0,2,a(10,l)+a(11,u)+a(12,d)+a(13,c)+a(14,1)),r(h.data,e,i,n,0,3,a(15,l)+a(16,u)+a(17,d)+a(18,c)+a(19,1))}t.clearRect(0,0,n,s),t.putImageData(h,0,0)}},u.Element.feColorMatrix.prototype=new u.Element.ElementBase,u.Element.feGaussianBlur=function(t){this.base=u.Element.ElementBase,this.base(t),this.blurRadius=Math.floor(this.attribute("stdDeviation").numValue()),this.extraFilterDistance=this.blurRadius,this.apply=function(t,i,n,s,r){e&&void 0!==e.canvasRGBA?(t.canvas.id=u.UniqueId(),t.canvas.style.display="none",o.body.appendChild(t.canvas),e.canvasRGBA(t.canvas,i,n,s,r,this.blurRadius),o.body.removeChild(t.canvas)):u.log("ERROR: StackBlur.js must be included for blur to work")}},u.Element.feGaussianBlur.prototype=new u.Element.ElementBase,u.Element.title=function(){},u.Element.title.prototype=new u.Element.ElementBase,u.Element.desc=function(){},u.Element.desc.prototype=new u.Element.ElementBase,u.Element.MISSING=function(t){u.log("ERROR: Element '"+t.nodeName+"' not yet implemented.")},u.Element.MISSING.prototype=new u.Element.ElementBase,u.CreateElement=function(t){var e=t.nodeName.replace(/^[^:]+:/,"");e=e.replace(/\-/g,"");var i=null;return(i=void 0!==u.Element[e]?new u.Element[e](t):new u.Element.MISSING(t)).type=t.nodeName,i},u.load=function(t,e){u.loadXml(t,u.ajax(e))},u.loadXml=function(t,e){u.loadXmlDoc(t,u.parseXml(e))},u.loadXmlDoc=function(t,e){u.init(t);var i=function(e){for(var i=t.canvas;i;)e.x-=i.offsetLeft,e.y-=i.offsetTop,i=i.offsetParent;return n.scrollX&&(e.x+=n.scrollX),n.scrollY&&(e.y+=n.scrollY),e};1!=u.opts.ignoreMouse&&(t.canvas.onclick=function(t){var e=i(new u.Point(null!=t?t.clientX:event.clientX,null!=t?t.clientY:event.clientY));u.Mouse.onclick(e.x,e.y)},t.canvas.onmousemove=function(t){var e=i(new u.Point(null!=t?t.clientX:event.clientX,null!=t?t.clientY:event.clientY));u.Mouse.onmousemove(e.x,e.y)});var s=u.CreateElement(e.documentElement);s.root=!0,s.addStylesFromStyleDefinition();var o=!0,h=function(){u.ViewPort.Clear(),t.canvas.parentNode?u.ViewPort.SetCurrent(t.canvas.parentNode.clientWidth,t.canvas.parentNode.clientHeight):u.ViewPort.SetCurrent(r,a),1!=u.opts.ignoreDimensions&&(s.style("width").hasValue()&&(t.canvas.width=s.style("width").toPixels("x"),t.canvas.style&&(t.canvas.style.width=t.canvas.width+"px")),s.style("height").hasValue()&&(t.canvas.height=s.style("height").toPixels("y"),t.canvas.style&&(t.canvas.style.height=t.canvas.height+"px")));var i=t.canvas.clientWidth||t.canvas.width,n=t.canvas.clientHeight||t.canvas.height;if(1==u.opts.ignoreDimensions&&s.style("width").hasValue()&&s.style("height").hasValue()&&(i=s.style("width").toPixels("x"),n=s.style("height").toPixels("y")),u.ViewPort.SetCurrent(i,n),null!=u.opts.offsetX&&(s.attribute("x",!0).value=u.opts.offsetX),null!=u.opts.offsetY&&(s.attribute("y",!0).value=u.opts.offsetY),null!=u.opts.scaleWidth||null!=u.opts.scaleHeight){var h=null,l=null,d=u.ToNumberArray(s.attribute("viewBox").value);null!=u.opts.scaleWidth&&(s.attribute("width").hasValue()?h=s.attribute("width").toPixels("x")/u.opts.scaleWidth:isNaN(d[2])||(h=d[2]/u.opts.scaleWidth)),null!=u.opts.scaleHeight&&(s.attribute("height").hasValue()?l=s.attribute("height").toPixels("y")/u.opts.scaleHeight:isNaN(d[3])||(l=d[3]/u.opts.scaleHeight)),null==h&&(h=l),null==l&&(l=h),s.attribute("width",!0).value=u.opts.scaleWidth,s.attribute("height",!0).value=u.opts.scaleHeight,s.style("transform",!0,!0).value+=" scale("+1/h+","+1/l+")"}1!=u.opts.ignoreClear&&t.clearRect(0,0,i,n),s.render(t),o&&(o=!1,"function"==typeof u.opts.renderCallback&&u.opts.renderCallback(e))},l=!0;u.ImagesLoaded()&&(l=!1,h()),u.intervalID=setInterval(function(){var t=!1;if(l&&u.ImagesLoaded()&&(l=!1,t=!0),1!=u.opts.ignoreMouse&&(t=t||u.Mouse.hasEvents()),1!=u.opts.ignoreAnimation)for(var e=0;e<u.Animations.length;e++){var i=u.Animations[e].update(1e3/u.FRAMERATE);t=t||i}"function"==typeof u.opts.forceRedraw&&1==u.opts.forceRedraw()&&(t=!0),t&&(h(),u.Mouse.runEvents())},1e3/u.FRAMERATE)},u.stop=function(){u.intervalID&&clearInterval(u.intervalID)},u.Mouse=new function(){this.events=[],this.hasEvents=function(){return 0!=this.events.length},this.onclick=function(t,e){this.events.push({type:"onclick",x:t,y:e,run:function(t){t.onclick&&t.onclick()}})},this.onmousemove=function(t,e){this.events.push({type:"onmousemove",x:t,y:e,run:function(t){t.onmousemove&&t.onmousemove()}})},this.eventElements=[],this.checkPath=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];e.isPointInPath&&e.isPointInPath(n.x,n.y)&&(this.eventElements[i]=t)}},this.checkBoundingBox=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];e.isPointInBox(n.x,n.y)&&(this.eventElements[i]=t)}},this.runEvents=function(){u.ctx.canvas.style.cursor="";for(var t=0;t<this.events.length;t++)for(var e=this.events[t],i=this.eventElements[t];i;)e.run(i),i=i.parent;this.events=[],this.eventElements=[]}},u}(c||{});"string"==typeof i&&(i=o.getElementById(i)),null!=i.svg&&i.svg.stop(),i.childNodes&&1==i.childNodes.length&&"OBJECT"==i.childNodes[0].nodeName||(i.svg=p);var f=i.getContext("2d");void 0!==d.documentElement?p.loadXmlDoc(f,d):"<"==d.substr(0,1)?p.loadXml(f,d):p.load(f,d)}else for(var y=o.querySelectorAll("svg"),g=0;g<y.length;g++){var v=y[g],x=o.createElement("canvas");if(void 0!==v.clientWidth&&void 0!==v.clientHeight)x.width=v.clientWidth,x.height=v.clientHeight;else{var b=v.getBoundingClientRect();x.width=b.width,x.height=b.height}v.parentNode.insertBefore(x,v),v.parentNode.removeChild(v);var M=o.createElement("div");M.appendChild(v),u(x,M.innerHTML)}};"undefined"==typeof Element||(void 0!==Element.prototype.matches?l=function(t,e){return t.matches(e)}:void 0!==Element.prototype.webkitMatchesSelector?l=function(t,e){return t.webkitMatchesSelector(e)}:void 0!==Element.prototype.mozMatchesSelector?l=function(t,e){return t.mozMatchesSelector(e)}:void 0!==Element.prototype.msMatchesSelector?l=function(t,e){return t.msMatchesSelector(e)}:void 0!==Element.prototype.oMatchesSelector?l=function(t,e){return t.oMatchesSelector(e)}:("function"!=typeof jQuery&&"function"!=typeof Zepto||(l=function(t,e){return $(t).is(e)}),void 0===l&&"undefined"!=typeof Sizzle&&(l=Sizzle.matchesSelector)));var d=/(\[[^\]]+\])/g,c=/(#[^\s\+>~\.\[:]+)/g,p=/(\.[^\s\+>~\.\[:]+)/g,f=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,y=/(:[\w-]+\([^\)]*\))/gi,g=/(:[^\s\+>~\.\[:]+)/g,v=/([^\s\+>~\.\[:]+)/g;function m(t){var e=[0,0,0],i=function(i,n){var s=t.match(i);null!=s&&(e[n]+=s.length,t=t.replace(i," "))};return t=(t=t.replace(/:not\(([^\)]*)\)/g,"     $1 ")).replace(/{[\s\S]*/gm," "),i(d,1),i(c,0),i(p,1),i(f,2),i(y,1),i(g,1),t=(t=t.replace(/[\*\s\+>~]/g," ")).replace(/[#\.]/g," "),i(v,2),e.join("")}"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(t,e,i,n,s,o){var r={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:e,offsetY:i,scaleWidth:n,scaleHeight:s};for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);u(this.canvas,t,r)}),i.exports=u}(n={exports:{}},n.exports),n.exports;var n}(i(9))},function(t,e,i){var n;
  /**
   * A class to parse color values
   * @author Stoyan Stefanov <sstoo@gmail.com>
   * @link   http://www.phpied.com/rgb-color-parser-in-javascript/
   * @license Use it if you like it
   */
  /**
   * A class to parse color values
   * @author Stoyan Stefanov <sstoo@gmail.com>
   * @link   http://www.phpied.com/rgb-color-parser-in-javascript/
   * @license Use it if you like it
   */
  !function(s){function o(t){this.ok=!1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t=(t=t.replace(/ /g,"")).toLowerCase();var e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var i in e)t==i&&(t=e[i]);for(var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],s=0;s<n.length;s++){var r=n[s].re,a=n[s].process,h=r.exec(t);h&&(channels=a(h),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),i=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==i.length&&(i="0"+i),"#"+t+e+i},this.getHelpXML=function(){for(var t=new Array,i=0;i<n.length;i++)for(var s=n[i].example,r=0;r<s.length;r++)t[t.length]=s[r];for(var a in e)t[t.length]=a;var h=document.createElement("ul");h.setAttribute("id","rgbcolor-examples");for(i=0;i<t.length;i++)try{var l=document.createElement("li"),u=new o(t[i]),d=document.createElement("div");d.style.cssText="margin: 3px; border: 1px solid black; background:"+u.toHex()+"; color:"+u.toHex(),d.appendChild(document.createTextNode("test"));var c=document.createTextNode(" "+t[i]+" -> "+u.toRGB()+" -> "+u.toHex());l.appendChild(d),l.appendChild(c),h.appendChild(l)}catch(t){}return h}}void 0===(n=function(){return o}.call(e,i,e,t))||(t.exports=n),s.RGBColor=o}("undefined"!=typeof window?window:this)},function(t,e){var i,n;i=this,n=function(){"use strict";var t=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var i=-1;return t.some(function(t,n){return t[0]===e&&(i=n,!0)}),i}return function(){function e(){this.__entries__=[]}var i={size:{configurable:!0}};return i.size.get=function(){return this.__entries__.length},e.prototype.get=function(e){var i=t(this.__entries__,e),n=this.__entries__[i];return n&&n[1]},e.prototype.set=function(e,i){var n=t(this.__entries__,e);~n?this.__entries__[n][1]=i:this.__entries__.push([e,i])},e.prototype.delete=function(e){var i=this.__entries__,n=t(i,e);~n&&i.splice(n,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var i=0,n=this.__entries__;i<n.length;i+=1){var s=n[i];t.call(e,s[1],s[0])}},Object.defineProperties(e.prototype,i),e}()}(),e="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,i="undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),n="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(i):function(t){return setTimeout(function(){return t(Date.now())},1e3/60)},s=2,o=["top","right","bottom","left","width","height","size","weight"],r="undefined"!=typeof MutationObserver,a=function(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t,e){var i=!1,o=!1,r=0;function a(){i&&(i=!1,t()),o&&l()}function h(){n(a)}function l(){var t=Date.now();if(i){if(t-r<s)return;o=!0}else i=!0,o=!1,setTimeout(h,e);r=t}return l}(this.refresh.bind(this),20)};a.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},a.prototype.removeObserver=function(t){var e=this.observers_,i=e.indexOf(t);~i&&e.splice(i,1),!e.length&&this.connected_&&this.disconnect_()},a.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},a.prototype.updateObservers_=function(){var t=this.observers_.filter(function(t){return t.gatherActive(),t.hasActive()});return t.forEach(function(t){return t.broadcastActive()}),t.length>0},a.prototype.connect_=function(){e&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),r?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){e&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(t){var e=t.propertyName;void 0===e&&(e=""),o.some(function(t){return!!~e.indexOf(t)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null;var h=function(t,e){for(var i=0,n=Object.keys(e);i<n.length;i+=1){var s=n[i];Object.defineProperty(t,s,{value:e[s],enumerable:!1,writable:!1,configurable:!0})}return t},l=function(t){return t&&t.ownerDocument&&t.ownerDocument.defaultView||i},u=y(0,0,0,0);function d(t){return parseFloat(t)||0}function c(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];return e.reduce(function(e,i){return e+d(t["border-"+i+"-width"])},0)}var p="undefined"!=typeof SVGGraphicsElement?function(t){return t instanceof l(t).SVGGraphicsElement}:function(t){return t instanceof l(t).SVGElement&&"function"==typeof t.getBBox};function f(t){return e?p(t)?y(0,0,(i=t.getBBox()).width,i.height):function(t){var e=t.clientWidth,i=t.clientHeight;if(!e&&!i)return u;var n,s=l(t).getComputedStyle(t),o=function(t){for(var e={},i=0,n=["top","right","bottom","left"];i<n.length;i+=1){var s=n[i],o=t["padding-"+s];e[s]=d(o)}return e}(s),r=o.left+o.right,a=o.top+o.bottom,h=d(s.width),p=d(s.height);if("border-box"===s.boxSizing&&(Math.round(h+r)!==e&&(h-=c(s,"left","right")+r),Math.round(p+a)!==i&&(p-=c(s,"top","bottom")+a)),(n=t)!==l(n).document.documentElement){var f=Math.round(h+r)-e,g=Math.round(p+a)-i;1!==Math.abs(f)&&(h-=f),1!==Math.abs(g)&&(p-=g)}return y(o.left,o.top,h,p)}(t):u;var i}function y(t,e,i,n){return{x:t,y:e,width:i,height:n}}var g=function(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=y(0,0,0,0),this.target=t};g.prototype.isActive=function(){var t=f(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},g.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t};var v=function(t,e){var i,n,s,o,r,a,l,u=(n=(i=e).x,s=i.y,o=i.width,r=i.height,a="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,l=Object.create(a.prototype),h(l,{x:n,y:s,width:o,height:r,top:s,right:n+o,bottom:r+s,left:n}),l);h(this,{target:t,contentRect:u})},m=function(e,i,n){if(this.activeObservations_=[],this.observations_=new t,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=i,this.callbackCtx_=n};m.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof l(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)||(e.set(t,new g(t)),this.controller_.addObserver(this),this.controller_.refresh())}},m.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof l(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)&&(e.delete(t),e.size||this.controller_.removeObserver(this))}},m.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},m.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(e){e.isActive()&&t.activeObservations_.push(e)})},m.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,e=this.activeObservations_.map(function(t){return new v(t.target,t.broadcastRect())});this.callback_.call(t,e,t),this.clearActive()}},m.prototype.clearActive=function(){this.activeObservations_.splice(0)},m.prototype.hasActive=function(){return this.activeObservations_.length>0};var x="undefined"!=typeof WeakMap?new WeakMap:new t,b=function(t){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var e=a.getInstance(),i=new m(t,e,this);x.set(this,i)};return["observe","unobserve","disconnect"].forEach(function(t){b.prototype[t]=function(){return(e=x.get(this))[t].apply(e,arguments);var e}}),void 0!==i.ResizeObserver?i.ResizeObserver:b},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):i.ResizeObserver=n()},function(t,e,i){var n=i(12);"string"==typeof n&&(n=[[t.i,n,""]]);var s={insert:"head",singleton:!1};i(1)(n,s);n.locals&&(t.exports=n.locals)},function(t,e,i){(t.exports=i(0)(!1)).push([t.i,'.adsk-viewing-viewer .autodesk-markups-extension-core-make-me-bigger:after {\n\tcontent: ""; \n\tposition: absolute; \n\ttop: -15px; \n\tbottom: -15px; \n\tleft: -15px; \n\tright: -15px;\n}\n\n.adsk-viewing-viewer .autodesk-markups-extension-core-make-me-bigger.rotation-bridge:after {\n\ttop: 0; \n\tbottom: 0px; \n}\n\n.adsk-viewing-viewer .selector-box {\n\tposition: absolute;\n    border: 1px dashed #0696D7;\n    background: rgba(6, 150, 215, 0.05);\n    z-index: 1;\n    cursor: move;\n    box-sizing: border-box;\n}\n\n.adsk-viewing-viewer .selector-drag-point,\n.adsk-viewing-viewer .selector-rotate-point {\n\tposition: absolute;\n\theight: 8px;\n\twidth: 8px;\n\tborder-radius: 8px;\t\t\t\t\t/*HANDLE_SIZE*/\n    background: #FFFFFF;\t\t\t\t/*HANDLE_BACKGROUND_COLOR*/\n    border-color: rgba(107,120,127,0.7); /* HANDLE_BORDER_COLOR; */\n    border-width: 1px; \t\t\t\t\t/* BORDER_WIDTH */\n    border-style: solid;\n}\n\n.adsk-viewing-viewer .selector-rotate-point {\n\ttop: calc(100% + 22px); /* 30 - 8 = 22 */\n\tleft: calc(50% + 1px);\n\ttransform: translate3d(-50%, 0px, 0px);\n}\n\n.adsk-viewing-viewer .selector-drag-point.selected,\n.adsk-viewing-viewer .selector-rotate-point.selected:not(.rotation-bridge) {\n\tbackground: #0696D7;\n\tborder-color: #0696D7;\n}\n\n.adsk-viewing-viewer .rotation-bridge {\n\tposition: absolute;\n\tbackground-color: rgba(0,0,0,0);\n\theight: 30px;\n\twidth: 0px;\n\ttop: 100%;\n\tleft: calc(50% + 1px);\n\tborder: unset;\n    border-left: 1px dashed #0696D7;\n}\n/*var placementOffset = -6;*/\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-n {\n\ttop: -6px;\n\tleft: calc(50% - 4px);\n\tposition: relative;\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-s {\n\ttop: calc(100% - 14px);\n    left: calc(50% - 4px);\n    position: relative;\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-w {\n\tleft: -6px;\n\ttop: 50%;\n\ttransform: translate3d(0, -50%, 0);\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-e {\n\tright: -6px;\n\ttop: 50%;\n    transform: translate3d(0, -50%, 0);\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-nw {\n\ttop: -6px;\n\tleft: -6px;\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-ne {\n\ttop: -6px;\n\tright: -6px;\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-sw {\n\tbottom: -6px;\n\tleft: -6px;\n}\n\n.adsk-viewing-viewer .selector-drag-point.sdp-handle-se {\n\tbottom: -6px;\n\tright: -6px;\n}',""])},function(t,e,i){var n=i(14);"string"==typeof n&&(n=[[t.i,n,""]]);var s={insert:"head",singleton:!1};i(1)(n,s);n.locals&&(t.exports=n.locals)},function(t,e,i){(t.exports=i(0)(!1)).push([t.i,'\n.adsk-icon-markup:before {\n  content: "a";\n}\n\n.lmv-markup-gui-toolbar {\n  position: absolute;\n  top: 0;\n  margin: 5px 5px;\n  color: #000000;\n}\n\n.lmv-markup-gui-toolbar-content > * {\n  margin: 0 2px;\n}\n\n.lmv-markup-gui-style-options {\n  display: inline-block;\n}',""])},function(t,e,i){"use strict";i.r(e);var n={};i.r(n),i.d(n,"MARKUP_TYPE_ARROW",function(){return a}),i.d(n,"MARKUP_TYPE_TEXT",function(){return h}),i.d(n,"MARKUP_TYPE_RECTANGLE",function(){return l}),i.d(n,"MARKUP_TYPE_CIRCLE",function(){return u}),i.d(n,"MARKUP_TYPE_CLOUD",function(){return d}),i.d(n,"MARKUP_TYPE_FREEHAND",function(){return c}),i.d(n,"MARKUP_TYPE_HIGHLIGHT",function(){return p}),i.d(n,"MARKUP_TYPE_POLYLINE",function(){return f}),i.d(n,"MARKUP_TYPE_POLYCLOUD",function(){return y}),i.d(n,"MARKUP_TYPE_CALLOUT",function(){return g}),i.d(n,"MARKUP_TYPE_DIMENSION",function(){return v});var s={};i.r(s),i.d(s,"createStyle",function(){return x}),i.d(s,"copyStyle",function(){return b}),i.d(s,"isStyleEqual",function(){return M}),i.d(s,"cloneStyle",function(){return E}),i.d(s,"getStyleDefaultValues",function(){return w});var o={};i.r(o),i.d(o,"EVENT_EDITMODE_CHANGED",function(){return k}),i.d(o,"EVENT_EDITMODE_ENTER",function(){return T}),i.d(o,"EVENT_EDITMODE_LEAVE",function(){return C}),i.d(o,"EVENT_MARKUP_SELECTED",function(){return S}),i.d(o,"EVENT_MARKUP_DRAGGING",function(){return A}),i.d(o,"EVENT_MARKUP_ENTER_EDITION",function(){return P}),i.d(o,"EVENT_MARKUP_CANCEL_EDITION",function(){return I}),i.d(o,"EVENT_MARKUP_DELETE_EDITION",function(){return z}),i.d(o,"EVENT_HISTORY_CHANGED",function(){return D}),i.d(o,"EVENT_EDITMODE_CREATION_BEGIN",function(){return R}),i.d(o,"EVENT_EDITMODE_CREATION_END",function(){return B}),i.d(o,"EVENT_MARKUP_DESELECT",function(){return N}),i.d(o,"EVENT_EDITFRAME_EDITION_START",function(){return V}),i.d(o,"EVENT_EDITFRAME_EDITION_END",function(){return L});var r={};i.r(r),i.d(r,"MARKUP_DEFAULT_STROKE_WIDTH_IN_PIXELS",function(){return Ii}),i.d(r,"MARKUP_DEFAULT_FONT_WIDTH_IN_PIXELS",function(){return zi}),i.d(r,"MARKUP_DEFAULT_HITAREAS_MARGIN_IN_PIXELS",function(){return Di}),i.d(r,"EDIT_FRAME_DEFAULT_MARGIN",function(){return Ri}),i.d(r,"isTouchDevice",function(){return Bi}),i.d(r,"createSvgElement",function(){return Ni}),i.d(r,"setSvgParentAttributes",function(){return Vi}),i.d(r,"createMarkupGroupSvg",function(){return Li}),i.d(r,"createMarkupPathSvg",function(){return Hi}),i.d(r,"setAttributeToMarkupSvg",function(){return _i}),i.d(r,"updateMarkupPathSvgHitarea",function(){return Oi}),i.d(r,"createMarkupTextSvg",function(){return Fi}),i.d(r,"setMarkupTextSvgTransform",function(){return Ui}),i.d(r,"updateMarkupTextSvgHitarea",function(){return ji}),i.d(r,"updateMarkupTextSvgBackground",function(){return Gi}),i.d(r,"updateMarkupTextSvgClipper",function(){return Wi}),i.d(r,"addSvgMetadata",function(){return Xi}),i.d(r,"addMarkupMetadata",function(){return Yi}),i.d(r,"removeAllMetadata",function(){return Ki}),i.d(r,"transferChildNodes",function(){return qi}),i.d(r,"getUniqueID",function(){return $i}),i.d(r,"svgNodeToString",function(){return Zi}),i.d(r,"stringToSvgNode",function(){return Ji}),i.d(r,"addTraitEventDispatcher",function(){return Qi}),i.d(r,"removeTraitEventDispatcher",function(){return tn}),i.d(r,"worldToClient",function(){return en}),i.d(r,"clientToWorld",function(){return nn}),i.d(r,"clientToViewport",function(){return sn}),i.d(r,"viewportToClient",function(){return on}),i.d(r,"worldToViewport",function(){return rn}),i.d(r,"metersToModel",function(){return an}),i.d(r,"radiansToDegrees",function(){return hn}),i.d(r,"degreesToRadians",function(){return ln}),i.d(r,"sign",function(){return un}),i.d(r,"areMarkupsPointsInClientRange",function(){return dn}),i.d(r,"hideLmvUi",function(){return cn}),i.d(r,"restoreLmvUi",function(){return pn}),i.d(r,"hideLmvPanels",function(){return fn}),i.d(r,"showLmvToolsAndPanels",function(){return yn}),i.d(r,"hideLmvToolsAndPanels",function(){return gn}),i.d(r,"dismissLmvHudMessage",function(){return vn}),i.d(r,"getStrokeWidth",function(){return mn}),i.d(r,"createMarkupFromSVG",function(){return xn}),i.d(r,"composeRGBAString",function(){return bn}),i.d(r,"checkLineSegment",function(){return Mn}),i.d(r,"checkPolygon",function(){return En}),i.d(r,"createStyleSheet",function(){return wn}),i.d(r,"addRuleToStyleSheet",function(){return kn}),i.d(r,"measureTextLines",function(){return Tn}),i.d(r,"createArcTo",function(){return Cn}),i.d(r,"createEllipsePath",function(){return Sn}),i.d(r,"createRectanglePath",function(){return An}),i.d(r,"renderToCanvas",function(){return Pn}),i.d(r,"simplify",function(){return In});const a="arrow",h="label",l="rectangle",u="ellipse",d="cloud",c="freehand",p="highlight",f="polyline",y="polycloud",g="callout",v="dimension";function m(t,e,i){this.type=e,this.editor=t,this.targetId=i,this.addToHistory=!0,this.selectOnExecution=!0}m.prototype.execute=function(){this.editor.actionManager.execute(this)},m.prototype.redo=function(){},m.prototype.undo=function(){},m.prototype.merge=function(t){return!1},m.prototype.isIdentity=function(){return!1};var x=function(t,e){for(var i={},n=0;n<t.length;++n)i[t[n]]=null;var s=w(i,e);for(n=0;n<t.length;++n){var o=t[n];i[o]=s[o].values[s[o].default].value}return i},b=function(t,e){for(var i in e)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},M=function(t,e){for(var i in e)if(t.hasOwnProperty(i)&&t[i]!==e[i])return!1;return!0},E=function(t){var e={};for(var i in t)e[i]=t[i];return e},w=function(t,e){function i(t){return{values:[{name:"Thin",value:t/2},{name:"Normal",value:t},{name:"Thick",value:4*t}],default:1}}function n(t){return{values:[{name:"100%",value:1},{name:"75%",value:.75},{name:"50%",value:.5},{name:"25%",value:.25},{name:"0%",value:0}],default:t?4:0}}var s,o=E(t),r=e.getStrokeWidth(),a=e.getFontWidth();for(var h in o)switch(h){case"stroke-width":o[h]={values:[{name:"Thin",value:(s=r)/3},{name:"Normal",value:s},{name:"Thick",value:3*s},{name:"Very Thick",value:9*s}],default:1};break;case"stroke-linejoin":o[h]={values:[{name:"Miter",value:"miter"},{name:"Round",value:"round"},{name:"Bevel",value:"bevel"}],default:0};break;case"font-size":o[h]=i(a);break;case"font-family":o[h]={values:[{name:"Arial",value:"Arial"},{name:"Arial Black",value:"Arial Black"},{name:"Arial Narrow",value:"Arial Narrow"},{name:"Century Gothic",value:"Century Gothic"},{name:"Courier New",value:"Courier New"},{name:"Georgia",value:"Georgia"},{name:"Impact",value:"Impact"},{name:"Lucida Console",value:"Lucida Console"},{name:"Tahoma",value:"Tahoma"},{name:"Verdana",value:"Verdana"}],default:0};break;case"font-style":o[h]={values:[{name:"Normal",value:"normal"},{name:"Italic",value:"italic"}],default:0};break;case"font-weight":o[h]={values:[{name:"Normal",value:"normal"},{name:"Bold",value:"bold"}],default:0};break;case"stroke-color":case"fill-color":o[h]={values:[{name:"red",value:"#ff0000"},{name:"green",value:"#00ff00"},{name:"blue",value:"#0000ff"},{name:"white",value:"#ffffff"},{name:"black",value:"#000000"},{name:"yellow",value:"#ffff00"}],default:0};break;case"stroke-opacity":var l=!1;o[h]=n(l);break;case"fill-opacity":l=!0;o[h]=n(l)}return o};const k="EVENT_EDITMODE_CHANGED",T="EVENT_EDITMODE_ENTER",C="EVENT_EDITMODE_LEAVE",S="EVENT_MARKUP_SELECTED",A="EVENT_MARKUP_DRAGGING",P="EVENT_MARKUP_ENTER_EDITION",I="EVENT_MARKUP_CANCEL_EDITION",z="EVENT_MARKUP_DELETE_EDITION",D="EVENT_HISTORY_CHANGED",R="EVENT_EDITMODE_CREATION_BEGIN",B="EVENT_EDITMODE_CREATION_END",N="EVENT_MARKUP_DESELECT",V="EVENT_EDITFRAME_EDITION_START",L="EVENT_EDITFRAME_EDITION_END";var H=Autodesk.Viewing;function _(t,e,i){this.id=t,this.type="",this.editor=e,this.viewer=e.viewer,this.setGlobalManager(this.viewer.globalManager),this.position={x:0,y:0},this.size={x:0,y:0},this.rotation=0,this.style=x(i,this.editor),this.style=b(e.getDefaultStyle(),this.style),this.highlightColor="#0696D7",this.constraintWidth=!1,this.constraintHeight=!1,this.constraintRotation=!1,this.minWidth=-1e4,this.minHeight=-1e4,this.highlighted=!1,this.selected=!1,this.checkLineSegment=Mn.bind(this),this.checkPolygon=En.bind(this),this.renderToCanvasX=Pn.bind(this),Qi(this)}H.GlobalManagerMixin.call(_.prototype);var O=_.prototype;function F(t,e,i){m.call(this,t,"SET-STYLE",e.id),this.newStyle=E(i),this.oldStyle=e.getStyle()}O.destroy=function(){this.unselect(),this.setParent(null)},O.setParent=function(t){var e=this.shape;e.parentNode&&e.parentNode.removeChild(e),t&&t.appendChild(e)},O.clone=function(){var t=Object.create(this.__proto__),e=this.getCloneOverrides();for(var i in this)if(this.hasOwnProperty(i)){var n=this[i];e.hasOwnProperty(i)?t[i]=e[i]:null!=n?n.clone instanceof Function?t[i]=n.clone():n instanceof Function?t[i]=n.bind(t):n.nodeType?t[i]=n.cloneNode(!0):n instanceof H.GlobalManager?(H.GlobalManagerMixin.call(t),t.setGlobalManager(n)):n instanceof Object?t[i]=JSON.parse(JSON.stringify(n)):t[i]=n:t[i]=n}return this.cloneShape(t),t},O.cloneShape=function(t){t.shape.markup=t.shape.childNodes.item(0),t.shape.hitarea=t.shape.childNodes.item(1),t.bindDomEvents()},O.getCloneOverrides=function(){return{viewer:this.viewer,editor:this.editor,hammer:null,listeners:{}}},O.select=function(){this.selected||(this.selected=!0,this.highlighted=!1,this.updateStyle(),this.dispatchEvent({type:S,markup:this}))},O.unselect=function(){this.selected=!1},O.highlight=function(t){this.interactionsDisabled||(this.highlighted=t,this.updateStyle())},O.getStyle=function(){return E(this.style)},O.setStyle=function(t){b(t,this.style),this.updateStyle()},O.updateStyle=function(){},O.edit=function(){this.dispatchEvent({type:P,markup:this})},O.cancel=function(){this.dispatchEvent({type:I,markup:this})},O.deleteMarkup=function(){this.dispatchEvent({type:z,markup:this})},O.getEditMode=function(){return console.warn("EditMode of markup type"+this.type+" not defined."),null},O.getClientPosition=function(){var t=this.position;return this.editor.positionFromMarkupsToClient(t.x,t.y)},O.getClientSize=function(){var t=this.size;return this.editor.sizeFromMarkupsToClient(t.x,t.y)},O.getBoundingRect=function(){var t=this.rotation;0!==t&&this.setRotation(0);var e=this.viewer.impl.getCanvasBoundingClientRect(),i=this.shape.markup.getBoundingClientRect(),n=i.top-e.top,s=this.style["stroke-width"]||0,o=this.editor.sizeFromMarkupsToClient(s,0).x;return 0!==t&&this.setRotation(t),{x:i.left-e.left-o,y:n-o,width:i.width+2*o,height:i.height+2*o}},O.setRotation=function(t){this.rotation=t,this.updateStyle()},O.getRotation=function(){return this.rotation},O.setPosition=function(t,e){this.position.x=t,this.position.y=e,this.updateStyle()},O.setSize=function(t,e,i){this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.size.y=i,this.updateStyle()},O.isWidthConstrained=function(){return this.constraintWidth},O.isHeightConstrained=function(){return this.constraintHeight},O.isRotationConstrained=function(){return this.constraintRotation},O.setMinWidth=function(t){this.minWidth=t},O.setMinHeight=function(t){this.minHeight=t},O.getMinWidth=function(){return this.minWidth},O.getMinHeight=function(){return this.minHeight},O.disableInteractions=function(t){this.interactionsDisabled=t},O.setStrokeWidth=function(t){},O.constrainsToBounds=function(t){},O.onMouseDown=function(t){this.interactionsDisabled||(this.select(),this.editor.editFrame.startDrag(t))},O.generatePoint3d=function(t){var e=this.viewer,i=this.generateBoundingPolygon(),n=this;function s(i,s){var o=n.checkLineSegment(i.x,i.y,s.x,s.y,t),r=o&&e.clientToWorld(o.x,o.y);return r&&r.point}var o=i.xVertices,r=i.yVertices,a=new THREE.Vector2(o[0]+o[1],r[0]+r[1]).multiplyScalar(.5),h=new THREE.Vector2(o[0]+o[3],r[0]+r[3]).multiplyScalar(.5),l=new THREE.Vector2(o[2]+o[1],r[2]+r[1]).multiplyScalar(.5),u=new THREE.Vector2(o[2]+o[3],r[2]+r[3]).multiplyScalar(.5),d=h.clone().add(l).multiplyScalar(.5);return s(d,l)||s(d,h)||s(d,a)||s(d,u)||function(i){var s=n.checkPolygon(i,t),o=s&&e.clientToWorld(s.x,s.y);return o&&o.point}(i)},O.generateBoundingBox=function(){for(var t={min:{x:0,y:0},max:{x:0,y:0}},e=this.generateBoundingPolygon(),i=e.vertexCount,n=e.xVertices,s=e.yVertices,o=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,l=0;l<i;++l){var u=n[l],d=s[l];o=Math.min(o,u),r=Math.min(r,d),a=Math.max(a,u),h=Math.max(h,d)}return t.min.x=o,t.min.y=r,t.max.x=a,t.max.y=h,t},O.generateBoundingPolygon=function(){var t=this.getClientPosition(),e=this.getClientSize();e.x*=.5,e.y*=.5;var i=new THREE.Vector3(-e.x,-e.y).add(t),n=new THREE.Vector3(e.x,-e.y).add(t),s=new THREE.Vector3(e.x,e.y).add(t),o=new THREE.Vector3(-e.x,e.y).add(t);if(0!==this.rotation){var r=(new THREE.Matrix4).makeTranslation(-t.x,-t.y,0),a=(new THREE.Matrix4).makeRotationZ(this.rotation),h=(new THREE.Matrix4).makeTranslation(t.x,t.y,0).multiply(a).multiply(r);i.applyMatrix4(h),n.applyMatrix4(h),s.applyMatrix4(h),o.applyMatrix4(h)}return{vertexCount:4,xVertices:new Float32Array([i.x,n.x,s.x,o.x]),yVertices:new Float32Array([i.y,n.y,s.y,o.y])}},O.setMetadata=function(){return null},O.setMouseDisabledWhenTouching=function(t){if(t.isFirst)this.shape.removeEventListener("mousedown",this.onMouseDownBinded);else if(t.isFinal){var e=this;setTimeout(function(){e.shape.addEventListener("mousedown",e.onMouseDownBinded)},10)}},O.bindDomEvents=function(){Bi()&&(this.hammer=new H.Hammer.Manager(this.shape,{recognizers:[H.GestureRecognizers.singletap],handlePointerEventMouse:!1,inputClass:H.isIE11?H.Hammer.PointerEventInput:H.Hammer.TouchInput}),this.onSingleTapBinded=function(t){this.onMouseDown(t)}.bind(this),this.onHammerInputBinded=function(t){this.setMouseDisabledWhenTouching(t)}.bind(this),this.hammer.on("singletap",this.onSingleTapBinded),this.hammer.on("hammer.input",this.onHammerInputBinded)),this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseOutBinded=function(){this.highlight(!1)}.bind(this),this.onMouseOverBinded=function(){this.highlight(!0)}.bind(this),this.shape.addEventListener("mousedown",this.onMouseDownBinded),this.shape.addEventListener("mouseout",this.onMouseOutBinded),this.shape.addEventListener("mouseover",this.onMouseOverBinded)},O.renderToCanvas=function(t,e,i,n,s){this.renderToCanvasX(this.shape,e,i,n,t,s)},O.getPath=function(){},O.getTransform=function(){return["translate(",this.position.x,",",this.position.y,")","rotate(",hn(-this.rotation),")"].join(" ")},F.prototype=Object.create(m.prototype),F.prototype.constructor=F;var U=F.prototype;function j(t,e,i){this.editor=t,this.viewer=t.viewer,this.setGlobalManager(this.viewer.globalManager),this.type=e,this.selectedMarkup=null,this.dragging=!1,this.draggingAnnotationIniPosition=null,this.draggingMouseIniPosition=new THREE.Vector2,this.initialX=0,this.initialY=0,this.minSize=9,this.creating=!1,this.size={x:0,y:0},this.style=x(i,this.editor),this.style=b(t.getDefaultStyle(),this.style),this.CREATION_METHOD_DRAG="CREATION_METHOD_DRAG",this.CREATION_METHOD_CLICK="CREATION_METHOD_CLICK",this.CREATION_METHOD_CLICKS="CREATION_METHOD_CLICKS",this.creationMethod=this.CREATION_METHOD_DRAG,Qi(this)}U.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setStyle(this.newStyle)},U.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setStyle(this.oldStyle)},Autodesk.Viewing.GlobalManagerMixin.call(j.prototype);var G=j.prototype;function W(t,e){m.call(this,t,"DELETE-ARROW",e.id),this.createArrow=new tt(t,e.id,e.tail,e.head,e.getStyle())}G.destroy=function(){this.unselect(),tn(this)},G.unselect=function(){var t=!1,e=this.selectedMarkup,i=null;e&&(i=e.id,e.unselect(),this.selectedMarkup=null,t=!0),this.editor.editFrame.setMarkup(null),t&&this.dispatchEvent({type:N,markupId:i})},G.creationBegin=function(){this.creating||(this.creating=!0,this.dispatchEvent({type:R}))},G.creationEnd=function(t){this.creating&&(this.creationMethod!==this.CREATION_METHOD_CLICK&&(this.selectedMarkup&&!this.isMinSizeValid()?(this.creationCancel(),t=!0):(this.creationMethod===this.CREATION_METHOD_DRAG&&this.finishDragging(),this.selectedMarkup&&(this.editor.closeActionGroup(),this.selectedMarkup=null))),this.creating=!1,this.dispatchEvent({type:B,creationCancelled:!!t}))},G.creationCancel=function(){this.editor.cancelActionGroup(),this.creationEnd(!0),this.selectedMarkup=null},G.setStyle=function(t){this.style=t;var e=this.selectedMarkup;e&&new F(this.editor,e,t).execute()},G.getStyle=function(){return this.style},G.setSelection=function(t){this.selectedMarkup!==t&&(this.unselect(),t&&t.select()),this.selectedMarkup=t;var e=this.editor;t&&e.bringToFront(t),this.isTextInputHelperActive()&&e.editFrame.markup?this.textInputHelper.setEditFrame():this.creating||e.editFrame.setMarkup(t)},G.getSelection=function(){return this.selectedMarkup},G.deleteMarkup=function(t,e){return!1},G.isMinSizeValid=function(){if(0!==this.minSize){var t=this.editor.sizeFromMarkupsToClient(this.size.x,this.size.y);return t.x*t.x+t.y*t.y>=this.minSize*this.minSize}return!0},G.startDragging=function(){var t=this.selectedMarkup,e=this.editor.getMousePosition();t&&(this.dragging=!0,this.draggingAnnotationIniPosition=t.getClientPosition(),this.draggingMouseIniPosition.set(e.x,e.y))},G.finishDragging=function(){var t=this.dragging,e=this.selectedMarkup;this.dragging=!1,e&&t&&e.finishDragging()},G.getFinalMouseDraggingPosition=function(){var t=this.editor,e=t.getBounds(),i=t.getMousePosition(),n=this.initialX,s=this.initialY,o=Math.min(Math.max(e.x,i.x),e.x+e.width),r=Math.min(Math.max(e.y,i.y),e.y+e.height);if(o==n&&r==s&&(o++,r++),t.input.makeSameXY){var a=Math.abs(o-n),h=Math.abs(r-s),l=Math.max(a,h);o=n+l*un(o-n),r=s+l*un(r-s)}return{x:o,y:r}},G.notifyAllowNavigation=function(t){},G.onMouseMove=function(t){},G.onMouseDown=function(){},G.onMouseUp=function(t){this.creationMethod===this.CREATION_METHOD_DRAG&&this.creationEnd()},G.onMouseDoubleClick=function(t){this.creationMethod===this.CREATION_METHOD_CLICKS&&this.creationEnd()},G.onSave=function(){this.creating&&this.creationCancel()},G.getDraggingPosition=function(){var t=this.editor.getMousePosition(),e=t.x-this.draggingMouseIniPosition.x,i=t.y-this.draggingMouseIniPosition.y;return{x:this.draggingAnnotationIniPosition.x+e,y:this.draggingAnnotationIniPosition.y+i}},G.isInsideBounds=function(t,e,i){return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},G.useWithSnapping=function(){return this.viewer.model.is2d()},G.isTextInputHelperActive=function(){return this.textInputHelper&&this.textInputHelper.isActive()},W.prototype=Object.create(m.prototype),W.prototype.constructor=W;var X=W.prototype;function Y(t,e,i,n){m.call(this,t,"SET-ARROW",e.id),this.newHead={x:i.x,y:i.y},this.newTail={x:n.x,y:n.y},this.oldHead={x:e.head.x,y:e.head.y},this.oldTail={x:e.tail.x,y:e.tail.y}}X.redo=function(){this.createArrow.undo()},X.undo=function(){this.createArrow.redo()},Y.prototype=Object.create(m.prototype),Y.prototype.constructor=Y;var K=Y.prototype;K.redo=function(){this.applyState(this.targetId,this.newHead,this.newTail)},K.undo=function(){this.applyState(this.targetId,this.oldHead,this.oldTail)},K.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newHead=t.newHead,this.newTail=t.newTail,!0)},K.applyState=function(t,e,i){var n=this.editor.getMarkup(t);if(n){(Math.abs(n.head.x-e.x)>=1e-4||Math.abs(n.head.y-e.y)>=1e-4||Math.abs(n.tail.x-i.x)>=1e-4||Math.abs(n.tail.y-i.y)>=1e-4)&&n.set(e.x,e.y,i.x,i.y)}},K.isIdentity=function(){return this.newHead.x===this.oldHead.x&&this.newHead.y===this.oldHead.y&&this.newTail.x===this.oldTail.x&&this.newTail.y===this.oldTail.y};var q=Autodesk.Viewing.MeasureCommon;function $(t){j.call(this,t,a,["stroke-width","stroke-color","stroke-opacity"])}$.prototype=Object.create(j.prototype),$.prototype.constructor=$;var Z=$.prototype;function J(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.checkLineSegment=Mn.bind(this),this.type=a,this.constraintHeight=!0,this.head=new THREE.Vector3,this.tail=new THREE.Vector3,this.size.y=3*this.style["stroke-width"],this.shape=Hi(),this.bindDomEvents()}Z.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=new W(this.editor,t);return i.addToHistory=!e,i.execute(),!0}return!1},Z.onMouseDown=function(){if(j.prototype.onMouseDown.call(this),!this.selectedMarkup){var t=this.editor,e=t.getMousePosition();if(this.initialX=e.x,this.initialY=e.y,this.size.x=0,this.size.y=0,this.lineSnapped=null,t.snapper){var i=t.snapper.getGeometryType();i!==q.SnapType.SNAP_VERTEX&&i!==q.SnapType.SNAP_EDGE&&i!==q.SnapType.SNAP_MIDPOINT&&i!==q.SnapType.SNAP_CIRCLE_CENTER||(this.lineSnapped=t.snapper.getEdge())}var n=3.5*this.style["stroke-width"],s=this.head=t.positionFromClientToMarkups(this.initialX,this.initialY),o={x:s.x+Math.cos(.25*Math.PI)*n,y:s.y+Math.sin(.25*-Math.PI)*n};(function(t,e,i,n){this.isInsideBounds(e.x,e.y,n)||(e.y=t.y+Math.sin(.25*Math.PI)*i,this.isInsideBounds(e.x,e.y,n)||(e.x=t.x+Math.cos(.25*-Math.PI)*i,this.isInsideBounds(e.x,e.y,n)||(e.y=t.y+Math.sin(.25*-Math.PI)*i)))}).bind(this)(s,o,n,t.getBounds()),t.beginActionGroup();var r=new THREE.Vector2(o.x-s.x,o.y-s.y);r.lengthSq()<n*n&&(r=r.normalize().multiplyScalar(n),o.x=s.x+r.x,o.y=s.y+r.y);var a=t.getId();new tt(t,a,s,o,this.style).execute(),this.selectedMarkup=t.getMarkup(a),this.creationBegin()}},Z.onMouseMove=function(t){j.prototype.onMouseMove.call(this,t);var e=this.selectedMarkup;if(e&&this.creating){var i=this.editor,n=this.getFinalMouseDraggingPosition(),s=this.initialX,o=this.initialY;if(i.snapper&&!i.snapper.isSnapped()&&this.lineSnapped){var r=i.project(this.lineSnapped.vertices[0]),a=i.project(this.lineSnapped.vertices[1]),h=new THREE.Vector3(n.x,n.y,r.z),l=q.nearestPointInPointToLine(h,r,a),u=-(r.x-a.x)/(r.y-a.y),d=s+1,c=u*d+(o-u*s),p=new THREE.Vector3(d,c,r.z),f=new THREE.Vector3(s,o,r.z),y=q.nearestPointInPointToLine(h,f,p);l.distanceTo(h)<=20?(n.x=l.x,n.y=l.y):y.distanceTo(h)<=20&&(n.x=y.x,n.y=y.y)}var g=this.head,v=i.positionFromClientToMarkups(n.x,n.y),m=new THREE.Vector2(v.x-g.x,v.y-g.y),x=3.5*e.style["stroke-width"];m.lengthSq()<x*x&&(m=m.normalize().multiplyScalar(x),v.x=g.x+m.x,v.y=g.y+m.y),this.size=i.sizeFromClientToMarkups(n.x-s,n.y-o),new Y(i,e,g,v).execute()}},J.prototype=Object.create(_.prototype),J.prototype.constructor=J;var Q=J.prototype;function tt(t,e,i,n,s){m.call(this,t,"CREATE-ARROW",e),this.selectOnExecution=!1,this.tail=n,this.head=i,this.style=E(s)}Q.getEditMode=function(){return new $(this.editor)},Q.set=function(t,e,i,n){var s=new THREE.Vector2(t,e),o=new THREE.Vector2(i,n),r=o.clone().sub(s).normalize();this.size.x=s.distanceTo(o),this.rotation=Math.acos(r.dot(new THREE.Vector2(1,0))),this.rotation=n>e?2*Math.PI-this.rotation:this.rotation;var a=this.head,h=this.tail;a.set(i,n,0),h.set(t,e,0),this.position.x=h.x+.5*(a.x-h.x),this.position.y=h.y+.5*(a.y-h.y),this.updateStyle()},Q.setRotation=function(t){this.rotation=t;var e=Math.cos(-t),i=Math.sin(-t),n=new THREE.Vector2(e,i);n.multiplyScalar(.5*this.size.x);var s=new THREE.Vector2(this.position.x,this.position.y),o=s.clone().sub(n),r=s.clone().add(n);this.head.set(r.x,r.y,0),this.tail.set(o.x,o.y,0),this.updateStyle()},Q.setSize=function(t,e,i){var n=Math.cos(-this.rotation),s=Math.sin(-this.rotation),o=new THREE.Vector2(n,s);o.multiplyScalar(.5*e);var r=new THREE.Vector2(t.x,t.y),a=r.clone().sub(o),h=r.clone().add(o);this.head.set(h.x,h.y,0),this.tail.set(a.x,a.y,0),this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.updateStyle()},Q.updateStyle=function(){var t=this.style,e=this.shape,i=t["stroke-width"],n=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),s=this.getTransform();this.size.y=3*i,this.style["fill-color"]=t["stroke-color"],this.style["fill-opacity"]=t["stroke-opacity"],_i(e,"d",this.getPath().join(" ")),_i(e,"stroke-width",i),_i(e,"stroke",n),_i(e,"fill",n),_i(e,"transform",s),Oi(e,this.editor)},Q.setPosition=function(t,e){var i=this.head,n=this.tail,s=i.x-n.x,o=i.y-n.y,r=t+.5*s,a=e+.5*o;i.x=r,i.y=a,n.x=r-s,n.y=a-o,this.position.x=n.x+.5*(i.x-n.x),this.position.y=n.y+.5*(i.y-n.y),this.updateStyle()},Q.generatePoint3d=function(t){var e=this.editor.positionFromMarkupsToClient(this.head.x,this.head.y),i=this.editor.positionFromMarkupsToClient(this.tail.x,this.tail.y),n=e.clone().sub(i).normalize(),s=this.checkLineSegment(e.x,e.y,e.x+200*n.x,e.y+200*n.y,t),o=s&&this.viewer.clientToWorld(s.x,s.y);return o&&o.point},Q.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.head=[this.head.x,this.head.y].join(" "),t.tail=[this.tail.x,this.tail.y].join(" "),t.rotation=String(this.rotation),this.addMarkupMetadata(this.shape,t)},Q.getPath=function(){var t=this.size.x,e=this.size.y,i=e/3,n=this.style["stroke-width"],s=t-3*n,o=t-s,r=.3*n;return["M",.5*-t,.5*-e+i,"l",s,0,"l",-r,-i,"l",o+r,1.5*i,"l",-o-r,1.5*i,"l",r,-i,"l",-s,0,"z"]},tt.prototype=Object.create(m.prototype),tt.prototype.constructor=tt;var et=tt.prototype;et.redo=function(){var t=this.editor,e=new J(this.targetId,t);t.addMarkup(e),e.set(this.head.x,this.head.y,this.tail.x,this.tail.y),e.setStyle(this.style)},et.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)};var it=function(t,e){m.call(this,t,"DELETE-RECTANGLE",e.id),this.createRectangle=new dt(t,e.id,e.position,e.size,e.rotation,e.getStyle())};(it.prototype=Object.create(m.prototype)).constructor=it;var nt=it.prototype;function st(t,e,i,n){m.call(this,t,"SET-RECTANGLE",e.id),this.newPosition={x:i.x,y:i.y},this.newSize={x:n.x,y:n.y},this.oldPosition={x:e.position.x,y:e.position.y},this.oldSize={x:e.size.x,y:e.size.y}}nt.redo=function(){this.createRectangle.undo()},nt.undo=function(){this.createRectangle.redo()},st.prototype=Object.create(m.prototype),st.prototype.constructor=st;var ot=st.prototype;ot.redo=function(){this.applyState(this.targetId,this.newPosition,this.newSize)},ot.undo=function(){this.applyState(this.targetId,this.oldPosition,this.oldSize)},ot.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newPosition=t.newPosition,this.newSize=t.newSize,!0)},ot.applyState=function(t,e,i){var n=this.editor.getMarkup(t);if(n){(Math.abs(n.position.x-e.x)>1e-4||Math.abs(n.size.y-i.y)>1e-4||Math.abs(n.position.y-e.y)>1e-4||Math.abs(n.size.y-i.y)>1e-4)&&n.set(e,i)}},ot.isIdentity=function(){return this.newPosition.x===this.oldPosition.x&&this.newPosition.y===this.oldPosition.y&&this.newSize.x===this.oldSize.x&&this.newSize.y===this.oldSize.y};var rt=Autodesk.Viewing.MeasureCommon;function at(t){j.call(this,t,l,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"])}at.prototype=Object.create(j.prototype),at.prototype.constructor=at;var ht=at.prototype;function lt(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.type=l,this.shape=Hi(),this.bindDomEvents()}ht.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=new it(this.editor,t);return i.addToHistory=!e,i.execute(),!0}return!1},ht.onMouseMove=function(t){j.prototype.onMouseMove.call(this,t);var e=this.selectedMarkup;if(e&&this.creating){var i,n,s=this.editor,o=this.getFinalMouseDraggingPosition(),r=s.clientToMarkups(o.x,o.y),a={x:(this.firstCorner.x+r.x)/2,y:(this.firstCorner.y+r.y)/2};if(s.snapper&&this.lineSnapped){var h=s.project(this.lineSnapped.vertices[0]),l=s.project(this.lineSnapped.vertices[1]),u=h.z;h=s.clientToMarkups(h.x,h.y),l=s.clientToMarkups(l.x,l.y),h=new THREE.Vector3(h.x,h.y,u),l=new THREE.Vector3(l.x,l.y,u);var d=new THREE.Vector3(r.x,r.y,u),c=rt.nearestPointInPointToLine(d,h,l);n=d.distanceTo(c);var p=-(h.x-l.x)/(h.y-l.y),f=this.firstCorner.y-p*this.firstCorner.x,y=this.firstCorner.x+1,g=p*y+f,v=new THREE.Vector3(y,g,u),m=new THREE.Vector3(this.firstCorner.x,this.firstCorner.y,u),x=rt.nearestPointInPointToLine(d,m,v);i=d.distanceTo(x)}else i=r.x-this.firstCorner.x,n=r.y-this.firstCorner.y;new st(s,e,a,this.size={x:Math.abs(i),y:Math.abs(n)}).execute()}},ht.onMouseDown=function(){if(j.prototype.onMouseDown.call(this),!this.selectedMarkup){var t=this.editor,e=t.getMousePosition();this.initialX=e.x,this.initialY=e.y;var i=this.firstCorner=t.clientToMarkups(this.initialX,this.initialY),n=this.size=t.sizeFromClientToMarkups(1,1),s=0;if(this.lineSnapped=null,t.snapper)if(t.snapper.getGeometryType()===rt.SnapType.SNAP_EDGE){this.lineSnapped=t.snapper.getEdge();var o=t.project(this.lineSnapped.vertices[0]),r=t.project(this.lineSnapped.vertices[1]),a=r.x-o.x,h=r.y-o.y;s=this.rotation=Math.atan2(h,a)}t.beginActionGroup();var l=t.getId();new dt(t,l,i,n,s,this.style).execute(),this.selectedMarkup=t.getMarkup(l),this.creationBegin()}},lt.prototype=Object.create(_.prototype),lt.prototype.constructor=lt;var ut=lt.prototype;function dt(t,e,i,n,s,o){m.call(this,t,"CREATE-RECTANGLE",e),this.selectOnExecution=!1,this.position={x:i.x,y:i.y},this.size={x:n.x,y:n.y},this.rotation=s,this.style=E(o)}ut.getEditMode=function(){return new at(this.editor)},ut.set=function(t,e){this.position.x=t.x,this.position.y=t.y,this.size.x=e.x,this.size.y=e.y,this.updateStyle()},ut.updateStyle=function(){var t=this.style,e=this.shape,i=this.getPath().join(" "),n=this.style["stroke-width"],s=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),o=bn(t["fill-color"],t["fill-opacity"]),r=this.getTransform();_i(e,"d",i),_i(e,"stroke-width",n),_i(e,"stroke",s),_i(e,"fill",o),_i(e,"transform",r),Oi(e,this.editor)},ut.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.rotation=String(this.rotation),this.addMarkupMetadata(this.shape,t)},ut.getPath=function(){var t=this.style["stroke-width"],e=this.size.x-t,i=this.size.y-t,n=[];return An(.5*-e,.5*-i,e,i,!1,n),n},dt.prototype=Object.create(m.prototype),dt.prototype.constructor=dt;var ct=dt.prototype;function pt(t,e){m.call(this,t,"DELETE-TEXT",e.id);var i={x:e.position.x,y:e.position.y},n={x:e.size.x,y:e.size.y};this.createText=new te(t,e.id,i,n,e.getText(),e.getStyle())}ct.redo=function(){var t=this.editor,e=new lt(this.targetId,t);t.addMarkup(e),e.set(this.position,this.size),e.setRotation(this.rotation),e.setStyle(this.style)},ct.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},pt.prototype=Object.create(m.prototype),pt.prototype.constructor=pt;var ft=pt.prototype;function yt(t,e,i,n,s,o){m.call(this,t,"SET-CALLOUT",e.id),this.newPosition={x:i.x,y:i.y},this.oldPosition={x:e.position.x,y:e.position.y},this.newSize={x:n.x,y:n.y},this.oldSize={x:e.size.x,y:e.size.y},this.newText=s,this.oldText=e.getText(),this.newIsFrameUsed=o,this.oldIsFrameUsed=e.isFrameUsed}ft.redo=function(){this.createText.undo()},ft.undo=function(){this.createText.redo()},yt.prototype=Object.create(m.prototype),yt.prototype.constructor=yt;var gt=yt.prototype;function vt(t,e,i,n,s){m.call(this,t,"SET-SIZE",e.id),this.newPosition={x:i.x,y:i.y},this.oldPosition={x:e.position.x,y:e.position.y},this.newWidth=n,this.oldWidth=e.size.x,this.newHeight=s,this.oldHeight=e.size.y}gt.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.newPosition,this.newSize,this.newText,this.newIsFrameUsed)},gt.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.oldPosition,this.oldSize,this.oldText,this.oldIsFrameUsed)},vt.prototype=Object.create(m.prototype),vt.prototype.constructor=vt;var mt=vt.prototype;mt.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setSize(this.newPosition,this.newWidth,this.newHeight)},mt.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setSize(this.oldPosition,this.oldWidth,this.oldHeight)},mt.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newPosition=t.newPosition,this.newWidth=t.newWidth,this.newHeight=t.newHeight,!0)},mt.isIdentity=function(){return this.newPosition.x===this.oldPosition.x&&this.newPosition.y===this.oldPosition.y&&this.newWidth===this.oldWidth&&this.newHeight===this.oldHeight};
  /*!
      Based on Autosize 4.0.0
      license: MIT
      http://www.jacklmoore.com/autosize
  */
  var xt,bt,Mt="function"==typeof Map?new Map:(xt=[],bt=[],{has:function(t){return xt.indexOf(t)>-1},get:function(t){return bt[xt.indexOf(t)]},set:function(t,e){-1===xt.indexOf(t)&&(xt.push(t),bt.push(e))},delete:function(t){var e=xt.indexOf(t);e>-1&&(xt.splice(e,1),bt.splice(e,1))}}),Et=function(t){return new Event(t,{bubbles:!0})};try{new Event("test")}catch(t){Et=function(t){var e=Autodesk.Viewing.getGlobal().document.createEvent("Event");return e.initEvent(t,!0,!1),e}}function wt(t){if(!t||!t.nodeName||"TEXTAREA"!==t.nodeName||Mt.has(t))return;var e=null,i=t.clientWidth,n=null;const s=this;function o(e){var i=t.style.width;t.style.width="0px",t.offsetWidth,t.style.width=i,t.style.overflow=e}function r(){var n=t.style.height,o=function(t){for(var e=[];t&&t.parentNode&&t.parentNode instanceof Element;)t.parentNode.scrollTop&&e.push({node:t.parentNode,scrollTop:t.parentNode.scrollTop}),t=t.parentNode;return e}(t);const r=s.getDocument();var a=r.documentElement&&r.documentElement.scrollTop;t.style.height="";var h=t.scrollHeight+e;0!==t.scrollHeight?(t.style.height=h+"px",i=t.clientWidth,o.forEach(function(t){t.node.scrollTop!==t.scrollTop&&(t.node.scrollTop=t.scrollTop)}),a&&(r.documentElement.scrollTop=a)):t.style.height=n}function a(){r();const e=s.getWindow();var i=Math.round(parseFloat(t.style.height)),a=e.getComputedStyle(t,null),h="content-box"===a.boxSizing?Math.round(parseFloat(a.height)):t.offsetHeight;if(h!==i?"hidden"===a.overflow&&(o("scroll"),r(),h="content-box"===a.boxSizing?Math.round(parseFloat(window.getComputedStyle(t,null).height)):t.offsetHeight):"hidden"!==a.overflow&&(o("hidden"),r(),h="content-box"===a.boxSizing?Math.round(parseFloat(window.getComputedStyle(t,null).height)):t.offsetHeight),n!==h){n=h;var l=Et("autosize:resized");try{t.dispatchEvent(l)}catch(t){}}}var h,l=function(){t.clientWidth!==i&&a()},u=function(e){s.removeWindowEventListener("resize",l,!1),t.removeEventListener("input",a,!1),t.removeEventListener("keyup",a,!1),t.removeEventListener("autosize:destroy",u,!1),t.removeEventListener("autosize:update",a,!1),Object.keys(e).forEach(function(i){t.style[i]=e[i]}),Mt.delete(t)}.bind(t,{height:t.style.height,resize:t.style.resize,overflow:t.style.overflow,overflowX:t.style.overflowX,wordWrap:t.style.wordWrap});t.addEventListener("autosize:destroy",u,!1),"onpropertychange"in t&&"oninput"in t&&t.addEventListener("keyup",a,!1),s.addWindowEventListener("resize",l,!1),t.addEventListener("input",a,!1),t.addEventListener("autosize:update",a,!1),t.style.overflowX="hidden",t.style.wordWrap="break-word",Mt.set(t,{destroy:u,update:a}),"vertical"===(h=s.getWindow().getComputedStyle(t,null)).resize?t.style.resize="none":"both"===h.resize&&(t.style.resize="horizontal"),e="content-box"===h.boxSizing?-(parseFloat(h.paddingTop)+parseFloat(h.paddingBottom)):parseFloat(h.borderTopWidth)+parseFloat(h.borderBottomWidth),isNaN(e)&&(e=0),a()}function kt(t){var e=Mt.get(t);e&&e.destroy()}function Tt(t){var e=Mt.get(t);e&&e.update()}const Ct=(Autodesk.Viewing.getGlobal(),"undefined"!=typeof window&&"function"==typeof window.getComputedStyle);var St=function(t,e){const i=this;return Ct&&t&&Array.prototype.forEach.call(t.length?t:[t],function(t){return wt.bind(i)(t,e)}),t};function At(){this.reset()}St.destroy=function(t){return Ct&&t&&Array.prototype.forEach.call(t.length?t:[t],kt),t},St.update=function(t){return Ct&&t&&Array.prototype.forEach.call(t.length?t:[t],Tt),t};var Pt=["-ms-","-webkit-","-moz-","-o-"],It=At.prototype;It.reset=function(){return this.attributes={},this.dirty=!1,this.styleString="",this},It.setAttribute=function(t,e,i){if(this.attributes[t]=e,i&&i.allBrowsers){var n=this;Pt.forEach(function(i){n.attributes[i+t]=e})}return this.dirty=!0,this},It.removeAttribute=function(t){Array.isArray(t)||(t=[t]);var e=this;return t.forEach(function(t){t in e.attributes&&(delete e.attributes[t],e.dirty=!0)}),this},It.getStyleString=function(){return this.dirty&&(this.styleString=function(t){var e=[];for(var i in t){var n=t[i];e.push(i),e.push(":"),e.push(n),e.push("; ")}return e.join("")}(this.attributes),this.dirty=!1),this.styleString},It.clone=function(){var t=new At,e=this.attributes;for(var i in e)t.setAttribute(i,e[i]);return t};const zt=i(10);function Dt(t,e,i,n,s){this.parentDiv=t,this.editor=e,this.setGlobalManager(e.viewer.globalManager),this.EVENT_TEXT_CHANGE="EVENT_CO2_TEXT_CHANGE",this.EVENT_TEXT_SET_ACTIVE="EVENT_CO2_TEXT_SET_ACTIVE",this.EVENT_TEXT_SET_INACTIVE="EVENT_CO2_TEXT_SET_INACTIVE";const o=this.getDocument();i?(this.textArea=o.createElement("input"),this.textArea.setAttribute("type","text")):(this.textArea=o.createElement("textarea"),this.textArea.rows="1",Autodesk.Viewing.isIE11||(this.textArea.dir="auto")),this.firstEdit=!0,this.defaultText=n,this.textArea.setAttribute("maxlength",s),this.textArea.setAttribute("data-i18n",n),this.startingHeight=0,St.bind(this)(this.textArea),new zt(function(t,e){this.setEditFrame()}.bind(this)).observe(this.textArea),this.styleTextArea=new At,this.styleTextArea.setAttribute("position","absolute").setAttribute("resize","none").setAttribute("box-sizing","border-box").setAttribute("-moz-box-sizing","border-box").setAttribute("-webkit-box-sizing","border-box").setAttribute("overflow","hidden").setAttribute("outline","none").setAttribute("border","none").setAttribute("z-index","1").setAttribute("padding","10px"),this.measureDiv=o.createElement("div"),Qi(this)}Autodesk.Viewing.GlobalManagerMixin.call(Dt.prototype);var Rt=Dt.prototype;function Bt(t){if(0===t.length)return"";for(var e=t.length-1,i=e;i>=0;--i)if(" "!==t.charAt(i)){e=i;break}return t.substr(0,e+1)}function Nt(t){if(0===t.length)return"";for(var e=0,i=0;i<t.length;++i)if(" "!==t.charAt(i)){e=i;break}return t.substr(e)}Rt.destroy=function(){this.setInactive()},Rt.setActive=function(t,e){if(this.textMarkup!==t){var i=Autodesk.Viewing.i18n.translate(this.defaultText);if(this.textArea.setAttribute("placeholder",i),this.setInactive(),this.parentDiv.appendChild(this.textArea),this.textMarkup=t,this.firstEdit=e||!1,this.constrainToCanvas=e,this.initFromMarkup(),this.constrainToCanvas=!1,!Autodesk.Viewing.isIOSDevice()){var n=this.textArea;this.getWindow().requestAnimationFrame(function(){n.focus()})}var s={markup:this.textMarkup,firstEdit:this.firstEdit,isActive:!0};this.dispatchEvent({type:this.EVENT_TEXT_SET_ACTIVE,data:s})}},Rt.setInactive=function(){var t={markup:this.textMarkup,isActive:!1};Autodesk.Viewing.isIOSDevice()&&this.textArea.blur(),this.removeWindowEventListener("resize",this.onResizeBinded),this.textMarkup&&(this.textMarkup=null,this.parentDiv.removeChild(this.textArea)),this.style=null,this.dispatchEvent({type:this.EVENT_TEXT_SET_INACTIVE,data:t})},Rt.isActive=function(){return!!this.textMarkup},Rt.setEditFrame=function(){if(this.editor.editFrame.markup&&this.textMarkup&&this.editor.editFrame.markup===this.textMarkup){var t=parseFloat(this.textArea.style.width),e=parseFloat(this.textArea.style.height),i=this.textMarkup.getClientPosition(),n=this.textMarkup.getRotation(),s=i.x-t/2,o=i.y-this.startingHeight/2;this.editor.editFrame.setSelection(s,o,t,e,n)}},Rt.initFromMarkup=function(t){var e=this.textMarkup,i=e.getClientPosition(),n=e.getClientSize(),s=e.getClientFontSize()/2;this.startingHeight=n.y;var o=i.x-.5*n.x,r=i.y-.5*n.y,a=e.lineHeight+"%";this.styleTextArea.setAttribute("line-height",a),this.styleTextArea.setAttribute("padding",s+"px"),this.setPosAndSize(o,r,n.x,n.y),t?(this.setStyle(e.getStyle()),this.textArea.value=e.getText()):(this.textArea.value=e.getText(),this.setStyle(e.getStyle()))},Rt.setPosAndSize=function(t,e,i,n){this.constrainToCanvas&&(t+i>=this.editor.viewer.container.clientWidth&&(t=this.editor.viewer.container.clientWidth-(i+10)),e+n>=this.editor.viewer.container.clientHeight&&(e=this.editor.viewer.container.clientHeight-(n+10)),t<5&&(t=5,i=this.editor.viewer.container.clientWidth-10)),this.styleTextArea.setAttribute("left",t+"px").setAttribute("top",e+"px").setAttribute("width",i+"px").setAttribute("height",n+"px")},Rt.setStyle=function(t){if(this.style){var e={};this.injectSizeValues(e),this.setPosAndSize(e.newPos.x-.5*e.width,e.newPos.y-.5*e.height,e.width,e.height)}var i=this.editor.sizeFromMarkupsToClient(0,t["font-size"]).y,n=this.editor.sizeFromMarkupsToClient(0,t["stroke-width"]).y,s=this.styleTextArea.setAttribute("color",t["stroke-color"]).setAttribute("outline",n+"px solid "+t["stroke-color"]).setAttribute("font-family",t["font-family"]).setAttribute("font-size",i+"px").setAttribute("font-weight",t["font-weight"]).setAttribute("font-style",t["font-style"]).getStyleString();this.textArea.setAttribute("style",s),this.style=E(t),St.update(this.textArea)},Rt.getTextValuesForMarkup=function(t,e){var i=this.isActive(),n=this.textMarkup,s=this.firstEdit;this.setActive(t,!1);var o={markup:t,textValues:this.getTextValues()};return i?this.setActive(n,s):(e&&this.injectSizeValues(o),this.setInactive()),o},Rt.getTextValues=function(){var t=this.textArea.value;return t===this.defaultText&&(t=""),{text:t,lines:this.generateLines()}},Rt.acceptAndExit=function(){var t=this.getTextValues(),e=this.textMarkup,i={markup:this.textMarkup,style:this.style,firstEdit:this.firstEdit,newText:t.text,newLines:t.lines};this.injectSizeValues(i),this.dispatchEvent({type:this.EVENT_TEXT_CHANGE,data:i}),this.setInactive(),e.updateStyle(!0)},Rt.injectSizeValues=function(t){var e=parseFloat(this.textArea.style.width),i=parseFloat(this.textArea.style.height),n=parseFloat(this.textArea.style.left),s=parseFloat(this.textArea.style.top);t.width=e,t.height=i,t.newPos={x:n+.5*e,y:s+.5*i}},Rt.onCameraChanged=function(t){var e=this.textArea.value;this.textMarkup.style=E(this.style),this.style=null,this.initFromMarkup(!0),this.textArea.value=e,this.setEditFrame()},Rt.generateLines=function(){var t=this.textArea.value.split(/\r*\n/),e=this.styleTextArea.clone().removeAttribute(["top","left","width","height"]).setAttribute("position","absolute").setAttribute("white-space","nowrap").setAttribute("float","left").setAttribute("visibility","hidden").getStyleString();this.measureDiv.setAttribute("style",e),this.parentDiv.appendChild(this.measureDiv);for(var i=this.textArea.clientWidth-2*parseFloat(this.textArea.style.padding),n=[],s=0,o=t.length;s<o;++s){var r=Bt(t[s]);r=""===r?" ":r,this.splitLine(r,i,n)}return this.parentDiv.removeChild(this.measureDiv),n},Rt.splitLine=function(t,e,i){if(""!==t)for(var n="",s=!1;!s;){if(this.measureDiv.innerText=t,this.measureDiv.clientWidth-2*parseFloat(this.measureDiv.style.padding)<=e)i.push(t),this.splitLine(Nt(n),e,i),s=!0;else{var o=this.getShorterLine(t);1===o.length?(this.splitWord(t,n,e,i),s=!0):(t=o[0],n=o[1]+n)}}},Rt.getShorterLine=function(t){var e=t.lastIndexOf(" ");if(-1===e)return[t];for(;" "===t.charAt(e-1);)e--;var i=t.substr(e);return[t.substr(0,e),i]},Rt.splitWord=function(t,e,i,n){for(var s=1;;){var o=t.substr(0,s);if(this.measureDiv.innerText=o,this.measureDiv.clientWidth-2*parseFloat(this.measureDiv.style.padding)>i){if(1===s)return n.push(o),void this.splitWord(t.substr(1),e,i,n);var r=t.substr(0,s-1);n.push(r);var a=t.substr(s-1);return void this.splitLine(a+e,i,n)}if(++s>t.length)return void n.push(t)}};function Vt(t){j.call(this,t,g,["font-size","stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity","font-family","font-style","font-weight"]),this.style["fill-opacity"]=1,this.style["fill-color"]="#ffffff";var e=new Dt(this.viewer.container,this.editor,!1,"Text",360);e.addEventListener(e.EVENT_TEXT_CHANGE,this.onHelperTextChange.bind(this),!1),e.addEventListener(e.EVENT_TEXT_SET_ACTIVE,this.onHelperSetActive.bind(this),!1),e.addEventListener(e.EVENT_TEXT_SET_INACTIVE,this.onHelperSetActive.bind(this),!1),this.textInputHelper=e,this.onHistoryChangeBinded=this.onHistoryChange.bind(this),this.minSize=0,this.creationMethod=this.CREATION_METHOD_CLICK}Vt.prototype=Object.create(j.prototype),Vt.prototype.constructor=Vt;var Lt=Vt.prototype;Lt.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type===this.type){var i=new Gt(this.editor,t);return i.addToHistory=!e,i.execute(),!0}return!1},Lt.setStyle=function(t){this.textInputHelper&&this.textInputHelper.isActive()?this.textInputHelper.setStyle(t):j.prototype.setStyle.call(this,t)},Lt.notifyAllowNavigation=function(t){t&&this.textInputHelper&&this.textInputHelper.isActive()&&this.textInputHelper.acceptAndExit()},Lt.destroy=function(){this.textInputHelper&&(this.textInputHelper.isActive()&&this.textInputHelper.acceptAndExit(),this.textInputHelper.destroy(),this.textInputHelper=null),j.prototype.destroy.call(this)},Lt.onMouseDown=function(){if(this.textInputHelper&&this.textInputHelper.isActive())this.textInputHelper.acceptAndExit();else if(!this.selectedMarkup){var t=this.editor,e=t.getMousePosition(),i=t.sizeFromMarkupsToClient(0,this.style["font-size"]).y,n=6*i,s=1*i,o=this.size=t.sizeFromClientToMarkups(n,s),r=t.positionFromClientToMarkups(e.x+.5*n,e.y+.5*s);this.creationBegin(),t.beginActionGroup();var a=new Ut(t,t.getId(),r,o,"",this.style,!0);a.execute(),this.creationEnd(),this.selectedMarkup=t.getMarkup(a.targetId),this.textInputHelper&&this.textInputHelper.setActive(this.selectedMarkup,!0),this.editor.actionManager.addEventListener(D,this.onHistoryChangeBinded)}},Lt.onMouseUp=function(t){},Lt.onMouseDoubleClick=function(t){t===this.selectedMarkup&&(this.editor.selectMarkup(t),this.editor.editFrame.setMarkup(t),this.textInputHelper&&this.textInputHelper.setActive(t,!1))},Lt.onHelperSetActive=function(t){var e=t.data,i=e.markup;i&&(i.setIsHelperTextActive(e.isActive),i.setIsShapeVisible(!e.isActive))},Lt.onHelperTextChange=function(t){var e=t.data,i=e.markup,n=e.style,s=this.selectedMarkup;if(this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),""===e.newText)return this.editor.cancelActionGroup(),new Gt(this.editor,i).execute(),void(i!==s&&this.editor.selectMarkup(s));e.firstEdit||this.editor.beginActionGroup();var o=this.editor.positionFromClientToMarkups(e.newPos.x,e.newPos.y),r=this.editor.sizeFromClientToMarkups(e.width,e.height);new vt(this.editor,i,o,r.x,r.y).execute(),new yt(this.editor,i,i.position,i.size,e.newText,i.isFrameUsed).execute(),new F(this.editor,i,n).execute(),this.editor.closeActionGroup(),this.editor.selectMarkup(s)},Lt.onHistoryChange=function(t){this.textInputHelper&&this.textInputHelper.isActive()&&(this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.setInactive())},Lt.onSave=function(){if(j.prototype.onSave.call(this),this.textInputHelper&&this.textInputHelper.isActive()){var t=this.textInputHelper.firstEdit;this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.setInactive(),t&&this.editor.cancelActionGroup(),this.editor.selectMarkup(null),this.selectedMarkup=null}},Lt.updateTextBoxStyle=function(){this.isTextInputHelperActive()&&this.textInputHelper.onCameraChanged()};var Ht=100,_t=6;function Ot(t,e,i){_.call(this,t,e,["font-size","stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity","font-family","font-style","font-weight"]),this.addMarkupMetadata=Yi.bind(this),this.createSvgElement=Ni.bind(this),this.type=g,this.textShape=Fi(),this.rectShape=Hi(),this.shape=Li([this.rectShape,this.textShape]),this.isFrameUsed=!0,this.constraintRotation=!0,this.constraintHeight=!0,this.constraintWidth=!1,this.size.x=i.x,this.size.y=i.y,this.currentText="",this.currentTextLines=[""],this.prevHighlight=!1,this.isHelperTextActive=!1,this.lineHeight=130,this.minWidth=this.getClientFontSize()*_t,this.bindDomEvents()}Ot.prototype=Object.create(_.prototype),Ot.prototype.constructor=Ot;var Ft=Ot.prototype;function Ut(t,e,i,n,s,o,r){m.call(this,t,"CREATE-CALLOUT",e),this.text=s,this.position={x:i.x,y:i.y},this.size={x:n.x,y:n.y},this.style=E(o),this.isFrameUsed=r}Ft.getEditMode=function(){return new Vt(this.editor)},Ft.set=function(t,e,i,n){this.position.x=t.x,this.position.y=t.y,this.size.x=e.x,this.size.y=e.y,this.setIsFilledFrameUsed(n),this.setText(i)},Ft.setSize=function(t,e,i){this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.size.y=i;this.isHelperTextActive?this.updateTextBoxStyle():this.updateStyle(!0)},Ft.setPosition=function(t,e){this.position.x=t,this.position.y=e,this.isHelperTextActive?this.updateTextBoxStyle():this.updateStyle()},Ft.setStyle=function(t){var e=M(t,this.style);e||b(t,this.style),this.updateStyle(!e)},Ft.setText=function(t){this.currentText=t},Ft.getText=function(){return this.currentText},Ft.getTextLines=function(){return this.currentTextLines.concat()},Ft.highlightChanged=function(){if(this.highlighted&&this.highlighted!==this.prevHighlight){var t=this.rectShape,e=this.textShape,i=this.highlighted?this.highlightColor:bn(style["stroke-color"],style["stroke-opacity"]);return _i(e,"fill",i),this.isFrameUsed&&_i(t,"stroke",i),this.prevHighlight=!0,!1}return!0},Ft.updateTextBoxStyle=function(){var t=this.editor.duringEditMode&&this.editor.editMode;t&&t.type===this.type||(t=this.getEditMode()),t.updateTextBoxStyle()},Ft.setIsHelperTextActive=function(t){this.isHelperTextActive=t},Ft.updateStyle=function(t){if(this.highlightChanged()){this.prevHighlight=!1;var e=this.style,i=this.rectShape,n=this.textShape,s=this.style["font-size"],o=this.style["font-family"],r=this.style["font-weight"],a=this.style["font-style"],h=this.highlighted?this.highlightColor:bn(e["stroke-color"],e["stroke-opacity"]),l=this.style["stroke-width"];Ht=s>1?1:100,this.rebuildTextSvg(t);var u=this.editor,d=this.getTextContainerTransform(),c=this.getTextTransform();_i(n,"font-family",o),_i(n,"font-size",s*Ht),_i(n,"fill",h),_i(n,"font-weight",r),_i(n,"font-style",a),Ui(n,d,c),Wi(n,this.size.x,this.size.y),ji(n,this.size.x,this.size.y,u);var p=this.getPath().join(" "),f=this.getTransform(),y=bn(e["fill-color"],e["fill-opacity"]);_i(i,"d",p),_i(i,"stroke-width",l),_i(i,"stroke",h),_i(i,"transform",f),_i(i,"fill",y),Oi(i,u)}},Ft.rebuildTextSvg=function(t){var e=this.editor.duringEditMode&&this.editor.editMode;if(e&&e.type===this.type||((e=this.getEditMode()).textInputHelper.textArea.value=this.currentText,e.textInputHelper.setStyle(this.style)),!e.textInputHelper.textMarkup||e.textInputHelper.textMarkup===this){var i=E(e.textInputHelper.style),n=e.textInputHelper.textArea.value,s=e.textInputHelper.getTextValuesForMarkup(this,t);if(this.currentTextLines=s.textValues.lines,s.newPos){var o=this.editor.positionFromClientToMarkups(s.newPos.x,s.newPos.y),r=this.editor.sizeFromClientToMarkups(s.width,s.height);this.position.x=o.x,this.position.y=o.y,this.size.x=r.x,this.size.y=r.y}e.selectedMarkup===this||e.textInputHelper.firstEdit||(e.textInputHelper.textArea.value=n,e.textInputHelper.setStyle(i));var a=this.createSvgElement("text");a.setAttribute("id","markup"),a.setAttribute("alignment-baseline","middle"),this.textShape.childNodes[0].removeChild(this.textShape.markup),this.textShape.childNodes[0].appendChild(a),this.textShape.markup=a;var h=this.getLineHeight()*Ht*(this.lineHeight/100),l=this.getLineHeight()*Ht/2,u=l,d=l;this.currentTextLines.forEach(function(t){var e=this.createSvgElement("tspan");e.setAttribute("x",u),e.setAttribute("y",d),e.textContent=t,a.appendChild(e),d+=h}.bind(this))}},Ft.setIsFilledFrameUsed=function(t){this.isFrameUsed=t;var e=this.rectShape.parentNode===this.shape;t&&!e?this.shape.insertBefore(this.rectShape,this.shape.firstChild):!t&&e&&this.shape.removeChild(this.rectShape)},Ft.setIsFilledFrameVisible=function(t){this.rectShape.markup.style.display=t&&this.isFrameUsed?"block":"none"},Ft.setIsShapeVisible=function(t){this.shape.style.display=t?"block":"none"},Ft.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.text=String(this.currentText),t.isframeused=this.isFrameUsed?1:0,this.addMarkupMetadata(this.shape,t)},Ft.getClientFontSize=function(){return this.editor.sizeFromMarkupsToClient(0,this.style["font-size"]).y},Ft.getLineHeight=function(){return this.style["font-size"]},Ft.getTextContainerTransform=function(){return["translate(",this.position.x-.5*this.size.x,",",this.position.y+.5*this.size.y,")","rotate(",hn(-this.rotation),")","scale(1,-1)"].join(" ")},Ft.getTextTransform=function(){var t=this.getLineHeight();return["translate(",this.position.x-.5*this.size.x,",",this.position.y+.5*this.size.y-t,")","rotate(",hn(-this.rotation),")","scale("+1/Ht+","+-1/Ht+")"].join(" ")},Ft.cloneShape=function(t){t.textShape=Fi(),t.rectShape=Hi(),t.shape=Li([t.rectShape,t.textShape]),t.bindDomEvents()},Ft.getPath=function(){var t=this.style["stroke-width"],e=this.size.x+t,i=this.size.y+t,n=[];return An(.5*-e,.5*-i,e,i,!1,n),n},Ft.getBoundingRect=function(){var t=this.getClientPosition(),e=this.getClientSize(),i=this.style["stroke-width"],n=this.editor.sizeFromMarkupsToClient(i,0).x+Ri;return{x:t.x-e.x/2,y:t.y-e.y/2,width:e.x,height:e.y,margin:n}},Ut.prototype=Object.create(m.prototype),Ut.prototype.constructor=Ut;var jt=Ut.prototype;function Gt(t,e){m.call(this,t,"DELETE-CALLOUT",e.id);var i={x:e.position.x,y:e.position.y},n={x:e.size.x,y:e.size.y};this.createCallout=new Ut(t,e.id,i,n,e.getText(),e.getStyle(),e.isFrameUsed)}jt.redo=function(){var t=this.editor,e=this.position,i=this.size,n=new Ot(this.targetId,t,i);t.addMarkup(n),n.setIsFilledFrameUsed(this.isFrameUsed),n.setText(this.text),n.setSize(e,i.x,i.y),n.setStyle(this.style)},jt.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&(this.editor.removeMarkup(t),t.destroy())},Gt.prototype=Object.create(m.prototype),Gt.prototype.constructor=Gt;var Wt=Gt.prototype;function Xt(t,e,i,n,s){m.call(this,t,"SET-TEXT",e.id),this.newPosition={x:i.x,y:i.y},this.oldPosition={x:e.position.x,y:e.position.y},this.newSize={x:n.x,y:n.y},this.oldSize={x:e.size.x,y:e.size.y},this.newText=s,this.oldText=e.getText()}Wt.redo=function(){this.createCallout.undo()},Wt.undo=function(){this.createCallout.redo()},Xt.prototype=Object.create(m.prototype),Xt.prototype.constructor=Xt;var Yt=Xt.prototype;function Kt(t){j.call(this,t,h,["font-size","stroke-color","stroke-opacity","fill-color","fill-opacity","font-family","font-style","font-weight"]);var e=new Dt(this.viewer.container,this.editor,!1,"Text",260);e.addEventListener(e.EVENT_TEXT_CHANGE,this.onHelperTextChange.bind(this),!1),e.addEventListener(e.EVENT_TEXT_SET_ACTIVE,this.onHelperSetActive.bind(this),!1),e.addEventListener(e.EVENT_TEXT_SET_INACTIVE,this.onHelperSetActive.bind(this),!1),this.textInputHelper=e,this.onHistoryChangeBinded=this.onHistoryChange.bind(this),this.minSize=0,this.creationMethod=this.CREATION_METHOD_CLICK}Yt.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.newPosition,this.newSize,this.newText)},Yt.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.oldPosition,this.oldSize,this.oldText)},Kt.prototype=Object.create(j.prototype),Kt.prototype.constructor=Kt;var qt=Kt.prototype;qt.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=new pt(this.editor,t);return i.addToHistory=!e,i.execute(),!0}return!1},qt.setStyle=function(t){this.textInputHelper&&this.textInputHelper.isActive()?this.textInputHelper.setStyle(t):j.prototype.setStyle.call(this,t)},qt.notifyAllowNavigation=function(t){t&&this.textInputHelper&&this.textInputHelper.isActive()&&this.textInputHelper.acceptAndExit()},qt.destroy=function(){this.textInputHelper&&(this.textInputHelper.isActive()&&this.textInputHelper.acceptAndExit(),this.textInputHelper.destroy(),this.textInputHelper=null),j.prototype.destroy.call(this)},qt.onMouseDown=function(){if(this.textInputHelper&&this.textInputHelper.isActive())this.textInputHelper.acceptAndExit();else if(!this.selectedMarkup){var t=this.editor,e=t.getMousePosition(),i=t.sizeFromMarkupsToClient(0,this.style["font-size"]).y,n=15*i,s=1*i,o=this.size=t.sizeFromClientToMarkups(n,s),r=t.positionFromClientToMarkups(e.x+.5*n,e.y+.5*s);this.creationBegin(),t.beginActionGroup();var a=new te(t,t.getId(),r,o,"",this.style);a.execute(),this.creationEnd(),this.selectedMarkup=t.getMarkup(a.targetId),this.textInputHelper&&this.textInputHelper.setActive(this.selectedMarkup,!0),this.editor.actionManager.addEventListener(D,this.onHistoryChangeBinded)}},qt.updateTextBoxStyle=function(){this.isTextInputHelperActive()&&this.textInputHelper.onCameraChanged()},qt.onMouseUp=function(t){},qt.onMouseDoubleClick=function(t){t===this.selectedMarkup&&(this.editor.selectMarkup(t),this.editor.editFrame.setMarkup(t),this.textInputHelper&&this.textInputHelper.setActive(t,!1))},qt.onHelperSetActive=function(t){var e=t.data,i=e.markup;i&&(i.setIsHelperTextActive(e.isActive),i.setIsShapeVisible(!e.isActive))},qt.onHelperTextChange=function(t){var e=t.data,i=e.markup,n=e.style,s=this.selectedMarkup;if(this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),""===e.newText)return this.editor.cancelActionGroup(),new Gt(this.editor,i).execute(),void(i!==s&&this.editor.selectMarkup(s));e.firstEdit||this.editor.beginActionGroup();var o=this.editor.positionFromClientToMarkups(e.newPos.x,e.newPos.y),r=this.editor.sizeFromClientToMarkups(e.width,e.height);new vt(this.editor,i,o,r.x,r.y).execute(),new Xt(this.editor,i,i.position,i.size,e.newText).execute(),new F(this.editor,i,n).execute(),this.editor.closeActionGroup(),this.editor.selectMarkup(s)},qt.onHistoryChange=function(t){this.textInputHelper&&this.textInputHelper.isActive()&&(this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.setInactive())},qt.onSave=function(){if(j.prototype.onSave.call(this),this.textInputHelper&&this.textInputHelper.isActive()){var t=this.textInputHelper.firstEdit;this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.setInactive(),t&&this.editor.cancelActionGroup(),this.editor.selectMarkup(null),this.selectedMarkup=null}},qt.updateTextBoxStyle=function(){this.isTextInputHelperActive()&&this.textInputHelper.onCameraChanged()};var $t=100,Zt=6;function Jt(t,e,i){_.call(this,t,e,["font-size","stroke-color","stroke-opacity","fill-color","fill-opacity","font-family","font-style","font-weight"]),this.createSvgElement=Ni.bind(this),this.addMarkupMetadata=Yi.bind(this),this.type=h,this.shape=Fi(),this.constraintRotation=!0,this.constraintHeight=!0,this.constraintWidth=!1,this.size.x=i.x,this.size.y=i.y,this.currentText="",this.currentTextLines=[""],this.textDirty=!0,this.textSize={x:0,y:0},this.prevHighlight=!1,this.isHelperTextActive=!1,this.lineHeight=130,this.minWidth=this.getClientFontSize()*Zt,this.bindDomEvents()}Jt.prototype=Object.create(_.prototype),Jt.prototype.constructor=Jt;var Qt=Jt.prototype;function te(t,e,i,n,s,o){m.call(this,t,"CREATE-TEXT",e),this.text=s,this.position={x:i.x,y:i.y},this.size={x:n.x,y:n.y},this.style=E(o)}Qt.getEditMode=function(){return new Kt(this.editor)},Qt.set=function(t,e,i){this.position.x=t.x,this.position.y=t.y,this.size.x=e.x,this.size.y=e.y,this.setText(i)},Qt.setSize=function(t,e,i){this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.size.y=i;this.isHelperTextActive?this.updateTextBoxStyle():this.updateStyle(!0)},Qt.setPosition=function(t,e){this.position.x=t,this.position.y=e,this.isHelperTextActive?this.updateTextBoxStyle():this.updateStyle()},Qt.setStyle=function(t){var e=M(t,this.style);e||b(t,this.style),this.updateStyle(!e)},Qt.setText=function(t){this.currentText=t},Qt.getText=function(){return this.currentText},Qt.getTextLines=function(){return this.currentTextLines.concat()},Qt.highlightChanged=function(){if(this.highlighted&&this.highlighted!==this.prevHighlight){var t=this.shape,e=this.highlighted?this.highlightColor:bn(style["stroke-color"],style["stroke-opacity"]);return _i(t,"fill",e),this.prevHighlight=!0,!1}return!0},Qt.updateTextBoxStyle=function(){var t=this.editor.duringEditMode&&this.editor.editMode;t&&t.type===this.type||(t=this.getEditMode()),t.updateTextBoxStyle()},Qt.setIsHelperTextActive=function(t){this.isHelperTextActive=t},Qt.updateStyle=function(t){if(this.highlightChanged()){this.prevHighlight=!1;var e=this.style,i=this.shape,n=this.style["font-size"],s=this.style["font-family"],o=this.style["font-weight"],r=this.style["font-style"],a=this.highlighted?this.highlightColor:bn(e["stroke-color"],e["stroke-opacity"]),h=bn(e["fill-color"],e["fill-opacity"]);$t=n>1?1:100,this.rebuildTextSvg(t),_i(i,"font-family",s),_i(i,"font-size",n*$t),_i(i,"fill",a),_i(i,"font-weight",o),_i(i,"font-style",r);var l=this.editor,u=this.getTransform(),d=this.getTextTransform();Ui(i,u,d),Gi(i,this.size.x,this.size.y,h),Wi(i,this.size.x,this.size.y),ji(i,this.size.x,this.size.y,l)}},Qt.rebuildTextSvg=function(t){var e=this.editor.duringEditMode&&this.editor.editMode;if(e&&e.type===this.type||((e=this.getEditMode()).textInputHelper.textArea.value=this.currentText,e.textInputHelper.setStyle(this.style)),!e.textInputHelper.textMarkup||e.textInputHelper.textMarkup===this){var i=E(e.textInputHelper.style),n=e.textInputHelper.textArea.value,s=e.textInputHelper.getTextValuesForMarkup(this,t);if(this.currentTextLines=s.textValues.lines,s.newPos){var o=this.editor.positionFromClientToMarkups(s.newPos.x,s.newPos.y),r=this.editor.sizeFromClientToMarkups(s.width,s.height);this.position.x=o.x,this.position.y=o.y,this.size.x=r.x,this.size.y=r.y}e.selectedMarkup===this||e.textInputHelper.firstEdit||(e.textInputHelper.textArea.value=n,e.textInputHelper.setStyle(i));var a=this.createSvgElement("text");a.setAttribute("id","markup"),a.setAttribute("alignment-baseline","middle"),this.shape.childNodes[0].removeChild(this.shape.markup),this.shape.childNodes[0].appendChild(a),this.shape.markup=a;var h=this.getLineHeight()*$t*(this.lineHeight/100),l=this.getLineHeight()*$t/2,u=l,d=l;this.currentTextLines.forEach(function(t){var e=this.createSvgElement("tspan");e.setAttribute("x",u),e.setAttribute("y",d),e.textContent=t,a.appendChild(e),d+=h}.bind(this))}},Qt.setIsShapeVisible=function(t){this.shape.style.display=t?"block":"none"},Qt.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.text=String(this.currentText),this.addMarkupMetadata(this.shape,t)},Qt.getClientFontSize=function(){return this.editor.sizeFromMarkupsToClient(0,this.style["font-size"]).y},Qt.getLineHeight=function(){return this.style["font-size"]},Qt.getTransform=function(){return["translate(",this.position.x-.5*this.size.x,",",this.position.y+.5*this.size.y,")","rotate(",hn(-this.rotation),")","scale(1,-1)"].join(" ")},Qt.getTextTransform=function(){var t=this.getLineHeight();return["translate(",this.position.x-.5*this.size.x,",",this.position.y+.5*this.size.y-t,")","rotate(",hn(-this.rotation),")","scale("+1/$t+","+-1/$t+")"].join(" ")},Qt.cloneShape=function(t){t.shape=Fi(),t.bindDomEvents()},Qt.getBoundingRect=function(){var t=this.getClientPosition(),e=this.getClientSize();return{x:t.x-e.x/2,y:t.y-e.y/2,width:e.x,height:e.y}},te.prototype=Object.create(m.prototype),te.prototype.constructor=te;var ee=te.prototype;function ie(t,e){m.call(this,t,"DELETE-CIRCLE",e.id),this.createCircle=new ue(t,e.id,e.position,e.size,e.rotation,e.getStyle())}ee.redo=function(){var t=this.editor,e=this.position,i=this.size,n=new Jt(this.targetId,t,i);t.addMarkup(n),n.set(e,i,this.text),n.setStyle(this.style)},ee.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&(this.editor.removeMarkup(t),t.destroy())},ie.prototype=Object.create(m.prototype),ie.prototype.constructor=ie;var ne=ie.prototype;function se(t,e,i,n){m.call(this,t,"SET-CIRCLE",e.id),this.newPosition={x:i.x,y:i.y},this.newSize={x:n.x,y:n.y},this.oldPosition={x:e.position.x,y:e.position.y},this.oldSize={x:e.size.x,y:e.size.y}}ne.redo=function(){this.createCircle.undo()},ne.undo=function(){this.createCircle.redo()},se.prototype=Object.create(m.prototype),se.prototype.constructor=se;var oe=se.prototype;function re(t){j.call(this,t,u,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"])}oe.redo=function(){this.applyState(this.targetId,this.newPosition,this.newSize)},oe.undo=function(){this.applyState(this.targetId,this.oldPosition,this.oldSize)},oe.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newPosition=t.newPosition,this.newSize=t.newSize,!0)},oe.applyState=function(t,e,i){var n=this.editor.getMarkup(t);if(n){(Math.abs(n.position.x-e.x)>1e-4||Math.abs(n.size.y-i.y)>1e-4||Math.abs(n.position.y-e.y)>1e-4||Math.abs(n.size.y-i.y)>1e-4)&&n.set(e,i)}},oe.isIdentity=function(){return this.newPosition.x===this.oldPosition.x&&this.newPosition.y===this.oldPosition.y&&this.newSize.x===this.oldSize.x&&this.newSize.y===this.oldSize.y},re.prototype=Object.create(j.prototype),re.prototype.constructor=re;var ae=re.prototype;function he(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.type=u,this.shape=Hi(),this.bindDomEvents()}ae.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=new ie(this.editor,t);return i.addToHistory=!e,i.execute(),!0}return!1},ae.onMouseMove=function(t){j.prototype.onMouseMove.call(this,t);var e=this.selectedMarkup;if(e&&this.creating){var i=this.editor,n=this.getFinalMouseDraggingPosition();n=i.clientToMarkups(n.x,n.y);var s=Math.abs(this.firstPosition.x-n.x),o=Math.abs(this.firstPosition.y-n.y);new se(i,e,{x:.5*(this.firstPosition.x+n.x),y:.5*(this.firstPosition.y+n.y)},this.size={x:s,y:o}).execute()}},ae.onMouseDown=function(){if(j.prototype.onMouseDown.call(this),!this.selectedMarkup){var t=this.editor,e=t.getMousePosition();this.initialX=e.x,this.initialY=e.y;var i=this.firstPosition=t.clientToMarkups(this.initialX,this.initialY),n=this.size=t.sizeFromClientToMarkups(1,1);t.beginActionGroup();var s=t.getId();new ue(t,s,i,n,0,this.style).execute(),this.selectedMarkup=t.getMarkup(s),this.creationBegin()}},he.prototype=Object.create(_.prototype),he.prototype.constructor=he;var le=he.prototype;function ue(t,e,i,n,s,o){m.call(this,t,"CREATE-CIRCLE",e),this.selectOnExecution=!1,this.position={x:i.x,y:i.y},this.size={x:n.x,y:n.y},this.rotation=s,this.style=E(o)}le.getEditMode=function(){return new re(this.editor)},le.set=function(t,e){this.setSize(t,e.x,e.y)},le.updateStyle=function(){var t=this.style,e=this.shape,i=this.getPath().join(" "),n=this.style["stroke-width"],s=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),o=bn(t["fill-color"],t["fill-opacity"]),r=this.getTransform();_i(e,"d",i),_i(e,"stroke-width",n),_i(e,"stroke",s),_i(e,"fill",o),_i(e,"transform",r),Oi(e,this.editor)},le.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.rotation=String(this.rotation),this.addMarkupMetadata(this.shape,t)},le.getPath=function(){var t=this.size;if(1===t.x||1===t.y)return[""];var e=this.style["stroke-width"],i=t.x-e,n=t.y-e,s=[];return Sn(-.5*i,0,i,n,!1,s),s},ue.prototype=Object.create(m.prototype),ue.prototype.constructor=ue;var de=ue.prototype;function ce(t,e){m.call(this,t,"DELETE-CLOUD",e.id),this.createCloud=new be(t,e.id,e.position,e.size,e.rotation,e.getStyle())}de.redo=function(){var t=this.editor,e=new he(this.targetId,t);t.addMarkup(e),e.setSize(this.position,this.size.x,this.size.y),e.setRotation(this.rotation),e.setStyle(this.style)},de.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},ce.prototype=Object.create(m.prototype),ce.prototype.constructor=ce;var pe=ce.prototype;function fe(t,e,i,n){m.call(this,t,"SET-CLOUD",e.id),this.newPosition={x:i.x,y:i.y},this.newSize={x:n.x,y:n.y},this.oldPosition={x:e.position.x,y:e.position.y},this.oldSize={x:e.size.x,y:e.size.y}}pe.redo=function(){this.createCloud.undo()},pe.undo=function(){this.createCloud.redo()},fe.prototype=Object.create(m.prototype),fe.prototype.constructor=fe;var ye=fe.prototype;function ge(t){j.call(this,t,d,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"])}ye.redo=function(){this.applyState(this.targetId,this.newPosition,this.newSize,this.newStrokeWidth,this.newColor)},ye.undo=function(){this.applyState(this.targetId,this.oldPosition,this.oldSize,this.oldStrokeWidth,this.oldColor)},ye.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newPosition=t.newPosition,this.newSize=t.newSize,!0)},ye.applyState=function(t,e,i){var n=this.editor.getMarkup(t);if(n){(Math.abs(n.position.x-e.x)>1e-4||Math.abs(n.size.y-i.y)>1e-4||Math.abs(n.position.y-e.y)>1e-4||Math.abs(n.size.y-i.y)>1e-4)&&n.set(e,i)}},ye.isIdentity=function(){return this.newPosition.x===this.oldPosition.x&&this.newPosition.y===this.oldPosition.y&&this.newSize.x===this.oldSize.x&&this.newSize.y===this.oldSize.y},ge.prototype=Object.create(j.prototype),ge.prototype.constructor=ge;var ve=ge.prototype;function me(t,e){_.call(this,t,e,["stroke-width","stroke-linejoin","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.type=d,this.shape=Hi(),this.bindDomEvents()}ve.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=new ce(this.editor,t);return i.addToHistory=!e,i.execute(),!0}return!1},ve.onMouseMove=function(t){j.prototype.onMouseMove.call(this,t);var e=this.selectedMarkup;if(e&&this.creating){var i=this.editor,n=this.getFinalMouseDraggingPosition(),s=i.clientToMarkups(n.x,n.y);new fe(i,e,{x:(this.firstPosition.x+s.x)/2,y:(this.firstPosition.y+s.y)/2},this.size={x:Math.abs(s.x-this.firstPosition.x),y:Math.abs(s.y-this.firstPosition.y)}).execute()}},ve.onMouseDown=function(){if(j.prototype.onMouseDown.call(this),!this.selectedMarkup){var t=this.editor,e=t.getMousePosition();this.initialX=e.x,this.initialY=e.y;var i=this.firstPosition=t.clientToMarkups(this.initialX,this.initialY),n=this.size=t.sizeFromClientToMarkups(1,1);t.beginActionGroup();var s=t.getId();new be(t,s,i,n,0,this.style).execute(),this.selectedMarkup=t.getMarkup(s),this.creationBegin()}},me.prototype=Object.create(_.prototype),me.prototype.constructor=me;var xe=me.prototype;function be(t,e,i,n,s,o){m.call(this,t,"CREATE-CLOUD",e),this.selectOnExecution=!1,this.position={x:i.x,y:i.y},this.size={x:n.x,y:n.y},this.rotation=s,this.style=E(o)}xe.getEditMode=function(){return new ge(this.editor)},xe.set=function(t,e){this.setSize(t,e.x,e.y)},xe.updateStyle=function(){var t=this.style,e=this.shape,i=this.getPath().join(" "),n=this.style["stroke-width"],s=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),o=bn(t["fill-color"],t["fill-opacity"]),r=this.getTransform();_i(e,"d",i),_i(e,"stroke-width",n),_i(e,"stroke",s),_i(e,"fill",o),_i(e,"transform",r),Oi(e,this.editor)},xe.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.rotation=String(this.rotation),this.addMarkupMetadata(this.shape,t)},xe.getPath=function(){var t=this.position,e=this.size,i=this.style["stroke-width"],n=2*i;function s(t,e,i,n,s){return s.push("a"),s.push(i),s.push(n),s.push(0),s.push(1),s.push(1),s.push(t),s.push(e),s}function o(t,e,i,n,o){switch(t){case"LT":return s(e,-i,e,i,o);case"RT":return s(e,i,e,i,o);case"RB":return s(-e,i,e,i,o);case"LB":return s(-e,-i,e,i,o)}}function r(t,e,i,n){var s=2*i,o=Math.abs(e-t-n),r=Math.round(o/s),a=.05*(s+=(o-s*r)/r),h=3.5*(i=.5*s)/3;return{count:r,radius:i,diameter:s,p1:{x:a,y:-h},p2:{x:s-a,y:-h},p3:{x:s,y:0}}}var a=t.x,h=t.y,l=t.x+e.x,u=t.y+e.y,d=5*n,c=[];if(e.x<d||e.y<d){var p=e.x-i,f=e.y-i;Sn(E=.5*-p,w=0,p,f,!1,c)}else{var y=r(a,l,n,i),g=r(h,u,n,i),v=y.diameter,m=g.diameter,x=y.radius,b=g.radius;y=r(a+v,l-v,n,i),g=r(h+m,u-m,n,i);var M=.5*i,E=.5*-e.x+M+x,w=.5*-e.y+M+2*b;c.push("M"),c.push(E),c.push(w),o("LT",x,b,0,c),function(t,e){for(var i=t,n=0;n<i.count;++n)e.push("c"),e.push(i.p1.x),e.push(i.p1.y),e.push(i.p2.x),e.push(i.p2.y),e.push(i.p3.x),e.push(i.p3.y)}(y,c),o("RT",x,b,0,c),function(t,e){for(var i=t,n=0;n<i.count;++n)e.push("c"),e.push(-i.p1.y),e.push(i.p1.x),e.push(-i.p2.y),e.push(i.p2.x),e.push(-i.p3.y),e.push(i.p3.x)}(g,c),o("RB",x,b,0,c),function(t,e){for(var i=t,n=0;n<i.count;++n)e.push("c"),e.push(-i.p1.x),e.push(-i.p1.y),e.push(-i.p2.x),e.push(-i.p2.y),e.push(-i.p3.x),e.push(-i.p3.y)}(y,c),o("LB",x,b,0,c),function(t,e){for(var i=t,n=0;n<i.count;++n)e.push("c"),e.push(i.p1.y),e.push(-i.p1.x),e.push(i.p2.y),e.push(-i.p2.x),e.push(i.p3.y),e.push(-i.p3.x)}(g,c)}return c.push("z"),c},be.prototype=Object.create(m.prototype),be.prototype.constructor=be;var Me=be.prototype;function Ee(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.shape=Hi(),this.bindDomEvents()}Me.redo=function(){var t=this.editor,e=new me(this.targetId,t);t.addMarkup(e),e.set(this.position,this.size),e.setRotation(this.rotation),e.setStyle(this.style)},Me.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},Ee.prototype=Object.create(_.prototype),Ee.prototype.constructor=Ee;var we=Ee.prototype;function ke(t,e,i){j.call(this,t,e,i),this.smoothen=!0,this.bufferSize=8}we.set=function(t,e,i,n){this.rotation=0,this.isAbsoluteCoords=n,this.isAbsoluteCoords?this.updatePath(i):(this.locations=i.slice(0),this.size.x=0===e.x?1:e.x,this.size.y=0===e.y?1:e.y,this.setSize(t,e.x,e.y),this.updateStyle())},we.setPosition=function(t,e){this.position.x=t,this.position.y=e;var i=this.shape,n=this.getTransform();_i(i,"transform",n),Oi(i,this.editor)},we.updateStyle=function(){var t=this.style,e=this.shape,i=this.getPath().join(" "),n=this.style["stroke-width"],s=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]);_i(e,"stroke-width",n),_i(e,"stroke-linejoin","round"),_i(e,"stroke-linecap","round"),_i(e,"stroke",s),_i(e,"fill","none"),this.updatePath(i),Oi(e,this.editor)},we.updatePath=function(t){var e=this.shape,i=this.isAbsoluteCoords?"scale(1)":this.getTransform();_i(e,"transform",i),_i(e,"d",t)},we.setSize=function(t,e,i){e=0===e?1:e,i=0===i?1:i;for(var n=this.locations,s=n.length,o=e/this.size.x,r=i/this.size.y,a=0;a<s;++a){var h=n[a];h.x*=o,h.y*=r}this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.size.y=i,this.updateStyle()},we.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.rotation=String(this.rotation),t.locations=this.locations.map(function(t){return[t.x,t.y].join(" ")}).join(" "),this.addMarkupMetadata(this.shape,t)},we.getPath=function(){var t=[],e=this.locations,i=e.length;if(i>1){t.push("M"),t.push(+e[0].x.toFixed(6)),t.push(+e[0].y.toFixed(6));for(var n=1;n<i;++n){var s=e[n-1],o=e[n];t.push("l"),t.push(+(o.x-s.x).toFixed(6)),t.push(+(o.y-s.y).toFixed(6))}}return t},ke.prototype=Object.create(j.prototype);var Te=ke.prototype;function Ce(t,e){m.call(this,t,"DELETE-FREEHAND",e.id),this.createFreehand=new Re(t,e.id,e.position,e.size,e.rotation,e.locations,e.getStyle())}Te.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type===this.type){var i=this.deletePen(t);return i.addToHistory=!e,i.execute(),!0}return!1},Te.onMouseMove=function(t){if(j.prototype.onMouseMove.call(this,t),this.selectedMarkup&&this.creating){var e=this.editor,i=e.getMousePosition(),n=this.movements,s=e.clientToMarkups(i.x,i.y);if(this.smoothen)this.appendToBuffer(s),this.amendPath();else{var o=this.lastX-i.x,r=this.lastY-i.y;n.length>1&&o*o+r*r<25?(n[n.length-1]=s,this.removeFromAbsolutePath(1)):(n.push(s),this.lastX=i.x,this.lastY=i.y),this.addToAbsolutePath([s])}this.setPen(this.position,this.size,this.absolutePath,!0).execute()}},Te.onMouseDown=function(){if(j.prototype.onMouseDown.call(this),!this.selectedMarkup){var t=this.editor;t.snapper&&t.snapper.clearSnapped();var e=t.getMousePosition();this.lastX=this.initialX=e.x,this.lastY=this.initialY=e.y;var i=this.position=t.clientToMarkups(this.initialX,this.initialY);this.movements=[i],this.smoothen&&(this.buffer=[],this.movementsLastIndex=null,this.appendToBuffer(i));var n=this.size=t.sizeFromClientToMarkups(1,1);t.beginActionGroup();var s=t.getId();this.createPen(s,i,n,0,[{x:0,y:0}]).execute(),this.createAbsolutePath(i),this.selectedMarkup=t.getMarkup(s),this.creationBegin()}},Te.onMouseUp=function(){if(this.creating){var t=this.movements,e=this.viewer.impl.camera.right-this.viewer.impl.camera.left,i=this.viewer.impl.camera.top-this.viewer.impl.camera.bottom,n=(t=In(t,1e-8*(e*e+i*i),!0)).map(function(t){return t.x}),s=t.map(function(t){return t.y}),o=Math.min.apply(null,n),r=Math.min.apply(null,s),a=Math.max.apply(null,n)-o,h=Math.max.apply(null,s)-r,l={x:o+.5*a,y:r+.5*h},u=this.size={x:a,y:h},d=t.map(function(t){return{x:t.x-l.x,y:t.y-l.y}});this.setPen(l,u,d,!1).execute(),j.prototype.onMouseUp.call(this)}else j.prototype.onMouseUp.call(this)},Te.createPen=function(){console.error("createPen not implemented")},Te.deletePen=function(){console.error("deletePen not implemented")},Te.setPen=function(){console.error("setPen not implemented")},Te.useWithSnapping=function(){return!1},Te.createAbsolutePath=function(t){this.absolutePath="M"+ +t.x.toFixed(6)+" "+ +t.y.toFixed(6),this.absolutePathIndexes=[0]},Te.removeFromAbsolutePath=function(t){(t=Math.min(t,this.absolutePathIndexes.length))>0&&(this.absolutePath=this.absolutePath.slice(0,this.absolutePathIndexes[this.absolutePathIndexes.length-t]),this.absolutePathIndexes.splice(this.absolutePathIndexes.length-t))},Te.addToAbsolutePath=function(t){for(var e=0;e<t.length;e++)this.absolutePathIndexes.push(this.absolutePath.length),this.absolutePath+=" L"+ +t[e].x.toFixed(6)+" "+ +t[e].y.toFixed(6)},Te.appendToBuffer=function(t){for(this.buffer.push(t);this.buffer.length>this.bufferSize;)this.buffer.shift()},Te.amendPath=function(){var t=this.getAveragePoint(0);if(t){this.movementsLastIndex&&(this.removeFromAbsolutePath(this.movements.length-this.movementsLastIndex),this.movements.splice(this.movementsLastIndex));var e=[t];this.movementsLastIndex=this.movements.length+1;for(var i=2;i<this.buffer.length;i+=2){var n=this.getAveragePoint(i);e.push(n)}this.addToAbsolutePath(e),this.movements.push.apply(this.movements,e)}},Te.getAveragePoint=function(t){var e=this.buffer.length;if(e%2==1||e>=this.bufferSize){for(var i,n=0,s=0,o=0,r=t;r<e;r++)o++,n+=(i=this.buffer[r]).x,s+=i.y;return{x:n/o,y:s/o}}return null},Ce.prototype=Object.create(m.prototype),Ce.prototype.constructor=Ce;var Se=Ce.prototype;function Ae(t,e,i,n,s,o){m.call(this,t,"SET-FREEHAND",e.id),this.position=i,this.size=n,this.locations=o?s:s.slice(0),this.isAbsoluteCoords=o}Se.redo=function(){this.createFreehand.undo()},Se.undo=function(){this.createFreehand.redo()},Ae.prototype=Object.create(m.prototype),Ae.prototype.constructor=Ae;var Pe=Ae.prototype;function Ie(t){ke.call(this,t,c,["stroke-width","stroke-color","stroke-opacity"])}Pe.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.position,this.size,this.locations,this.isAbsoluteCoords)},Pe.undo=function(){},Pe.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.locations=t.isAbsoluteCoords?t.locations:t.locations.slice(0),this.position=t.position,this.size=t.size,this.isAbsoluteCoords=t.isAbsoluteCoords,!0)},Pe.isIdentity=function(){return!1},Ie.prototype=Object.create(ke.prototype),Ie.prototype.constructor=Ie;var ze=Ie.prototype;function De(t,e){Ee.call(this,t,e),this.type=c}function Re(t,e,i,n,s,o,r){m.call(this,t,"CREATE-FREEHAND",e),this.selectOnExecution=!1,this.position=i,this.size=n,this.rotation=s,this.movements=o.slice(0),this.style=E(r)}ze.createPen=function(t,e,i,n,s){return new Re(this.editor,t,e,i,n,s,this.style)},ze.deletePen=function(t){return new Ce(this.editor,t)},ze.setPen=function(t,e,i,n){return new Ae(this.editor,this.selectedMarkup,t,e,i,n)},De.prototype=Object.create(Ee.prototype),De.prototype.constructor=De,De.prototype.getEditMode=function(){return new Ie(this.editor)},Re.prototype=Object.create(m.prototype),Re.prototype.constructor=Re;var Be=Re.prototype;function Ne(t,e){m.call(this,t,"DELETE-POLYLINE",e.id),this.createPolyline=new Ge(t,e.id,e.position,e.size,e.rotation,e.locations,e.getStyle(),e.closed)}Be.redo=function(){var t=this.editor,e=new De(this.targetId,t);t.addMarkup(e),e.set(this.position,this.size,this.movements,!1),e.setRotation(this.rotation),e.setStyle(this.style)},Be.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},Ne.prototype=Object.create(m.prototype),Ne.prototype.constructor=Ne;var Ve=Ne.prototype;function Le(t,e,i,n,s,o){m.call(this,t,"SET-POLYLINE",e.id),this.position=i,this.size=n,this.locations=s.concat(),this.closed=o}Ve.redo=function(){this.createPolyline.undo()},Ve.undo=function(){this.createPolyline.redo()},Le.prototype=Object.create(m.prototype),Le.prototype.constructor=Le;var He=Le.prototype;He.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.position,this.size,this.locations,this.closed)},He.undo=function(){},He.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.locations=t.locations.concat(),this.position=t.position,this.size=t.size,this.closed=t.closed,!0)},He.isIdentity=function(){return!1};function _e(t){j.call(this,t,f,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.creationMethod=this.CREATION_METHOD_CLICKS,this.movements=[]}_e.prototype=Object.create(j.prototype),_e.prototype.constructor=_e;var Oe=_e.prototype;function Fe(t,e){var i=function(t,e){var i=t.map(function(t){return t[e]});return Math.min.apply(null,i)},n=function(t,e){var i=t.map(function(t){return t[e]});return Math.max.apply(null,i)},s=i(t,"x"),o=i(t,"y"),r=n(t,"x")-s,a=n(t,"y")-o;e.size={x:r,y:a},e.position={x:s+.5*r,y:o+.5*a};var h=e.position;return t.map(function(t){return{x:t.x-h.x,y:t.y-h.y}})}function Ue(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.type=f,this.shape=Hi("path"),this.bindDomEvents()}Oe.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=this.movements;if(!(this.creating&&i.length>=2)){var n=new Ne(this.editor,t);return n.addToHistory=!e,n.execute(),this.creationEnd(),!0}i.pop(),i.pop();var s=i.length-1;if(s>=0){var o=i[s];i.push(o);var r=Fe(i,this);new Le(this.editor,t,this.position,this.size,r).execute()}}return!1},Oe.onMouseMove=function(t){j.prototype.onMouseMove.call(this,t);var e=this.editor,i=this.selectedMarkup;if(i&&this.creating){this.dragging=!0;var n=this.movements;n.splice(n.length-1,1);var s=e.getMousePosition();s=e.clientToMarkups(s.x,s.y),n.length>=2&&dn(n[0],s,25,this.editor)&&(s=n[0]),n.push(s);var o=Fe(n,this);new Le(e,i,this.position,this.size,o).execute()}},Oe.onMouseDown=function(t){if(j.prototype.onMouseDown.call(this),(!this.selectedMarkup||this.creating)&&!this.creating){var e=this.editor,i=e.getMousePosition();i=e.clientToMarkups(i.x,i.y);var n=this.size=e.sizeFromClientToMarkups(1,1);this.movements=[i,i],e.beginActionGroup();var s=e.getId();new Ge(e,s,i,n,0,[{x:0,y:0}],this.style).execute(),this.selectedMarkup=e.getMarkup(s),this.creationBegin()}},Oe.onMouseUp=function(){if(j.prototype.onMouseUp.call(this),this.creating){this.dragging=!1;var t=this.editor,e=t.getMousePosition(),i=this.movements,n=!1;if(e=t.clientToMarkups(e.x,e.y),!(i.length>1&&dn(i[i.length-2],e,25,this.editor))){i.length>2&&dn(i[0],e,25,this.editor)&&(e=i[0],n=!0),i.splice(i.length-1,1),n||(i.push(e),i.push(e));var s=this.selectedMarkup,o=Fe(i,s);new Le(t,s,s.position,s.size,o,n).execute(),n&&this.creationEnd()}}},Oe.destroy=function(){this.onMouseDoubleClick(),j.prototype.creationEnd.call(this),j.prototype.destroy.call(this)},Oe.creationEnd=function(){this.selectedMarkup&&(this.size.x=this.selectedMarkup.size.x,this.size.y=this.selectedMarkup.size.y),j.prototype.creationEnd.call(this),this.closed=!1,this.movements=[],this.dragging=!1,this.creating=!1},Oe.creationCancel=function(){j.prototype.creationCancel.call(this),this.closed=!1,this.movements=[],this.dragging=!1,this.creating=!1},Oe.onMouseDoubleClick=function(t){if(this.creating){var e=this.movements;if(e.splice(Math.max(0,e.length-1)),e.length<2)this.creationCancel();else{var i=this.selectedMarkup,n=Fe(e,i);new Le(this.editor,i,i.position,i.size,n,this.closed).execute(),this.creationEnd()}}},Ue.prototype=Object.create(_.prototype),Ue.prototype.constructor=Ue;var je=Ue.prototype;function Ge(t,e,i,n,s,o,r,a){m.call(this,t,"CREATE-POLYLINE",e),this.selectOnExecution=!1,this.position=i,this.size=n,this.rotation=s,this.movements=o.concat(),this.closed=a,this.style=E(r)}je.getEditMode=function(){return new _e(this.editor)},je.set=function(t,e,i,n){this.rotation=0,this.locations=i.concat(),this.size.x=0===e.x?1:e.x,this.size.y=0===e.y?1:e.y,this.closed=n,this.setSize(t,e.x,e.y),this.updateStyle()},je.updateStyle=function(){var t=this.style,e=this.shape,i=this.style["stroke-width"],n=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),s=this.closed?bn(t["fill-color"],t["fill-opacity"]):"none",o=this.getTransform();_i(e,"d",this.getPath().join(" ")),_i(e,"stroke-width",i),_i(e,"stroke",n),_i(e,"fill",s),_i(e,"transform",o),Oi(e,this.editor)},je.setSize=function(t,e,i){e=0===e?1:e,i=0===i?1:i;for(var n=this.locations,s=n.length,o=e/this.size.x,r=i/this.size.y,a=0;a<s;++a){var h=n[a];h.x*=o,h.y*=r}this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.size.y=i,this.updateStyle()},je.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.rotation=String(this.rotation),t.locations=this.locations.map(function(t){return[t.x,t.y].join(" ")}).join(" "),this.addMarkupMetadata(this.shape,t)},je.getPath=function(){var t=[],e=this.locations,i=e.length;if(0===i)return" ";t.push("M"),t.push(e[0].x),t.push(e[0].y);for(var n=1;n<i;++n){var s=e[n-1],o=e[n];t.push("l"),t.push(o.x-s.x),t.push(o.y-s.y)}return this.closed&&t.push("z"),t},Ge.prototype=Object.create(m.prototype),Ge.prototype.constructor=Ge;var We=Ge.prototype;function Xe(t,e){m.call(this,t,"DELETE-POLYCLOUD",e.id),this.createPolycloud=new ei(t,e.id,e.position,e.size,e.rotation,e.locations,e.getStyle(),e.closed)}We.redo=function(){var t=this.editor,e=new Ue(this.targetId,t);t.addMarkup(e),e.set(this.position,this.size,this.movements,this.closed),e.setRotation(this.rotation),e.setStyle(this.style)},We.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},Xe.prototype=Object.create(m.prototype),Xe.prototype.constructor=Xe;var Ye=Xe.prototype;function Ke(t,e,i,n,s,o){m.call(this,t,"SET-POLYCLOUD",e.id),this.position=i,this.size=n,this.locations=s.concat(),this.closed=o}Ye.redo=function(){this.createPolycloud.undo()},Ye.undo=function(){this.createPolycloud.redo()},Ke.prototype=Object.create(m.prototype),Ke.prototype.constructor=Ke;var qe=Ke.prototype;qe.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.position,this.size,this.locations,this.closed)},qe.undo=function(){},qe.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.locations=t.locations.concat(),this.position=t.position,this.size=t.size,this.closed=t.closed,!0)},qe.isIdentity=function(){return!1};function $e(t){j.call(this,t,y,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.creationMethod=this.CREATION_METHOD_CLICKS,this.movements=[]}$e.prototype=Object.create(j.prototype),$e.prototype.constructor=$e;var Ze=$e.prototype;function Je(t,e){var i=function(t,e){var i=t.map(function(t){return t[e]});return Math.min.apply(null,i)},n=function(t,e){var i=t.map(function(t){return t[e]});return Math.max.apply(null,i)},s=e.style["stroke-width"],o=2*s+.5*s,r=i(t,"x")-o,a=i(t,"y")-o,h=n(t,"x")+o-r,l=n(t,"y")+o-a;e.size={x:h,y:l},e.position={x:r+.5*h,y:a+.5*l};var u=e.position;return t.map(function(t){return{x:t.x-u.x,y:t.y-u.y}})}function Qe(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity"]),this.addMarkupMetadata=Yi.bind(this),this.type=y,this.locations=[],this.shape=Hi(),this.bindDomEvents()}Ze.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=this.movements;if(!(this.creating&&i.length>=2)){var n=new Xe(this.editor,t);return n.addToHistory=!e,n.execute(),this.creationEnd(),!0}i.pop(),i.pop();var s=i.length-1;if(s>=0){var o=i[s];i.push(o);var r=Je(i,this);new Ke(this.editor,t,this.position,this.size,r).execute()}}return!1},Ze.onMouseMove=function(t){j.prototype.onMouseMove.call(this,t);var e=this.editor,i=this.selectedMarkup;if(i&&this.creating){this.dragging=!0;var n=this.movements;n.splice(n.length-1,1);var s=e.getMousePosition();s=e.clientToMarkups(s.x,s.y),n.length>=2&&dn(n[0],s,25,this.editor)&&(s=n[0]),n.push(s);var o=Je(n,this);new Ke(e,i,this.position,this.size,o).execute()}},Ze.onMouseDown=function(){if(j.prototype.onMouseDown.call(this),(!this.selectedMarkup||this.creating)&&!this.creating){var t=this.editor,e=t.getMousePosition();e=t.clientToMarkups(e.x,e.y);var i=this.size=t.sizeFromClientToMarkups(1,1);this.movements=[e,e],t.beginActionGroup();var n=t.getId();new ei(t,n,e,i,0,[{x:0,y:0}],this.style).execute(),this.selectedMarkup=t.getMarkup(n),this.creationBegin()}},Ze.onMouseUp=function(t){if(j.prototype.onMouseUp.call(this),this.creating){this.dragging=!1;var e=this.editor,i=e.getMousePosition(),n=this.movements,s=!1;if(i=e.clientToMarkups(i.x,i.y),!(n.length>1&&dn(n[n.length-2],i,25,this.editor))){n.length>2&&dn(n[0],i,25,this.editor)&&(i=n[0],s=!0),n.splice(n.length-1,1),s||(n.push(i),n.push(i));var o=this.selectedMarkup,r=Je(n,o);new Ke(e,o,o.position,o.size,r,s).execute(),s&&this.creationEnd()}}},Ze.onMouseDoubleClick=function(t){if(this.creating){var e=this.movements;if(e.splice(Math.max(0,e.length-1)),e.length<2)this.creationCancel();else{var i=this.selectedMarkup,n=Je(e,i);new Ke(this.editor,i,i.position,i.size,n,!0).execute(),this.creationEnd()}}},Ze.destroy=function(){this.onMouseDoubleClick(),j.prototype.creationEnd.call(this),j.prototype.destroy.call(this)},Ze.creationEnd=function(){this.selectedMarkup&&(this.size.x=this.selectedMarkup.size.x,this.size.y=this.selectedMarkup.size.y),j.prototype.creationEnd.call(this),this.closed=!1,this.movements=[],this.dragging=!1,this.creating=!1},Ze.creationCancel=function(){j.prototype.creationCancel.call(this),this.closed=!1,this.movements=[],this.dragging=!1,this.creating=!1},Qe.prototype=Object.create(_.prototype),Qe.prototype.constructor=Qe;var ti=Qe.prototype;function ei(t,e,i,n,s,o,r,a){m.call(this,t,"CREATE-POLYCLOUD",e),this.selectOnExecution=!1,this.position=i,this.size=n,this.rotation=s,this.movements=o.concat(),this.style=E(r),this.closed=a}ti.getEditMode=function(){return new $e(this.editor)},ti.set=function(t,e,i,n){this.rotation=0,this.locations=i.concat(),this.size.x=0===e.x?1:e.x,this.size.y=0===e.y?1:e.y,this.closed=n,this.setSize(t,e.x,e.y),this.updateStyle()},ti.updateStyle=function(){var t=this.style,e=this.shape,i=this.getPath().join(" "),n=this.style["stroke-width"],s=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),o=this.closed?bn(t["fill-color"],t["fill-opacity"]):"none",r=this.getTransform();_i(e,"d",i),_i(e,"stroke-width",n),_i(e,"stroke",s),_i(e,"fill",o),_i(e,"transform",r),Oi(e,this.editor)},ti.setSize=function(t,e,i){e=0===e?1:e,i=0===i?1:i;for(var n=this.locations,s=n.length,o=e/this.size.x,r=i/this.size.y,a=0;a<s;++a){var h=n[a];h.x*=o,h.y*=r}this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.size.y=i,this.updateStyle()},ti.setMetadata=function(){var t=E(this.style);return t.type=this.type,t.position=[this.position.x,this.position.y].join(" "),t.size=[this.size.x,this.size.y].join(" "),t.rotation=String(this.rotation),t.locations=this.locations.map(function(t){return[t.x,t.y].join(" ")}).join(" "),this.addMarkupMetadata(this.shape,t)},ti.getPath=function(){function t(t,e,i,n){var s=e.radius,o=i.radius,r=t.length;if(s>0&&o>0&&s+o>r&&Math.abs(s-o)<r){var a=t.pointA.x,h=t.pointA.y,l=t.pointB.x,u=t.pointB.y,d=.25*Math.sqrt((r+s+o)*(r+s-o)*(r-s+o)*(-r+s+o)),c=(a+l)/2+(l-a)*(s*s-o*o)/(2*r*r),p=2*(h-u)/(r*r)*d,f=(h+u)/2+(u-h)*(s*s-o*o)/(2*r*r),y=2*(a-l)/(r*r)*d,g=c+p,v=c-p,m=f-y,x=f+y;if(Math.abs((g-a)*(g-a)+(m-h)*(m-h)-s*s)>1e-7){var b=m;m=x,x=b}var M=new THREE.Vector3(g,m,0);return Math.sign(M.clone().sub(t.pointA).cross(t.vecAB).z)!==n&&M.set(v,x,0),e.pointB=M.clone(),i.pointA=M.clone(),!0}return!1}function e(t,e,i){var n=t.bodyCount;if(0!==n){var s=t.bodyRadius,o=t.bodyDiameter,r=.05*o,a=3.5*s/3,h=new THREE.Vector3(r,e*-a),l=new THREE.Vector3(o-r,e*-a),u=new THREE.Vector3(o,0),d=Math.acos(t.vecAB.x)*(t.vecAB.y<0?-1:1),c=(new THREE.Matrix4).makeRotationZ(d);h.applyMatrix4(c),l.applyMatrix4(c),u.applyMatrix4(c);for(var p=0;p<n;++p)i.push("c"),i.push(h.x),i.push(h.y),i.push(l.x),i.push(l.y),i.push(u.x),i.push(u.y)}}function i(t,e,i,n){e&&(n.push("M"),n.push(t.pointA.x),n.push(t.pointA.y));var s=1===i?t.large:!t.large;return 0!==t.radius&&(n.push("a"),n.push(t.radius),n.push(t.radius),n.push(0),n.push(s?1:0),n.push(1===i?1:0),n.push(t.pointB.x-t.pointA.x),n.push(t.pointB.y-t.pointA.y)),n}var n=2*this.style["stroke-width"],s=function(t){switch(t.length){case 0:case 1:return 1;case 2:var e=t[0],i=t[1];return e.y>i.y?1:-1;default:var n=t[0],s=t[1],o=t[2];return(s.x-n.x)*(s.y+n.y)+(o.x-s.x)*(o.y+s.y)<0?1:-1}}(this.locations),o=this.closed,r=[],a=function(t,e){for(var i=t.length,n=[],s=i-(e?0:1),o=0;o<s;++o){var r=t[o],a=t[(o+1)%i],h=a.x-r.x,l=a.y-r.y,u=Math.sqrt(h*h+l*l);n.push({index:o,pointA:new THREE.Vector3(r.x,r.y,0),pointB:new THREE.Vector3(a.x,a.y,0),vecAB:new THREE.Vector3(h/u,l/u,0),vecBA:new THREE.Vector3(-h/u,-l/u,0),length:u})}return n}(this.locations,o),h=function(t,e,i){for(var n=[],s=t.length,o=0;o<s;++o){var r=t[0!==o?o-1:s-1],a=t[o],h=r.vecBA.clone().cross(a.vecAB).z<0;r.length<e||a.length<e||0===o&&!i?n.push({pointA:a.pointA.clone(),pointB:a.pointA.clone(),radius:0,large:!1}):n.push({pointA:a.pointA.clone().add(r.vecBA.clone().multiplyScalar(e)),pointB:a.pointA.clone().add(a.vecAB.clone().multiplyScalar(e)),radius:e,large:h})}return n}(a,n,o),l=h.length;!function(e,i,n,s){for(var o=2*n,r=e.length,a=0;a<r;++a){var h=e[a],l=i[a],u=i[(a+1)%r];h.bodyA=h.vecAB.clone().multiplyScalar(l.radius).add(h.pointA),h.bodyB=h.vecBA.clone().multiplyScalar(u.radius).add(h.pointB),t(h,l,u,s)?(h.body=0,h.bodyDiameter=h.bodyCount=0):(h.body=h.bodyB.clone().sub(h.bodyA).length(),h.bodyCount=Math.round(h.body/o),0===h.bodyCount&&h.body>.5*n&&(h.bodyCount=1),h.bodyDiameter=o+(h.body-o*h.bodyCount)/h.bodyCount),h.bodyRadius=.5*h.bodyDiameter}}(a,h,n,s);for(var u=0;u<l;++u)i(h[u],0===u,s,r),e(a[u],s,r);return o&&r.push("z"),r},ei.prototype=Object.create(m.prototype),ei.prototype.constructor=ei;var ii=ei.prototype;function ni(t,e){m.call(this,t,"DELETE-HIGHLIGHT",e.id),this.createHighlight=new ui(t,e.id,e.position,e.size,e.rotation,e.locations,e.getStyle())}ii.redo=function(){var t=this.editor,e=new Qe(this.targetId,t);t.addMarkup(e),e.set(this.position,this.size,this.movements,this.closed),e.setRotation(this.rotation),e.setStyle(this.style)},ii.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},ni.prototype=Object.create(m.prototype),ni.prototype.constructor=ni;var si=ni.prototype;function oi(t,e,i,n,s,o){m.call(this,t,"SET-HIGHLIGHT",e.id),this.position=i,this.size=n,this.locations=o?s:s.slice(0),this.isAbsoluteCoords=o}si.redo=function(){this.createHighlight.undo()},si.undo=function(){this.createHighlight.redo()},oi.prototype=Object.create(m.prototype),oi.prototype.constructor=oi;var ri=oi.prototype;function ai(t){ke.call(this,t,p,["stroke-width","stroke-color","stroke-opacity"]);var e=t.getStrokeWidth();this.style["stroke-opacity"]=.5,this.style["stroke-color"]="#ffff00",this.style["stroke-width"]=4*e}ri.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.set(this.position,this.size,this.locations,this.isAbsoluteCoords)},ri.undo=function(){},ri.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.locations=t.isAbsoluteCoords?t.locations:t.locations.slice(0),this.position=t.position,this.size=t.size,this.isAbsoluteCoords=t.isAbsoluteCoords,!0)},ri.isIdentity=function(){return!1},ai.prototype=Object.create(ke.prototype),ai.prototype.constructor=ai;var hi=ai.prototype;function li(t,e){Ee.call(this,t,e),this.type=p}function ui(t,e,i,n,s,o,r){m.call(this,t,"CREATE-HIGHLIGHT",e),this.selectOnExecution=!1,this.position=i,this.size=n,this.rotation=s,this.movements=o.slice(0),this.style=E(r)}hi.createPen=function(t,e,i,n,s){return new ui(this.editor,t,e,i,n,s,this.style)},hi.deletePen=function(t){return new ni(this.editor,t)},hi.setPen=function(t,e,i,n){return new oi(this.editor,this.selectedMarkup,t,e,i,n)},li.prototype=Object.create(Ee.prototype),li.prototype.constructor=li,li.prototype.getEditMode=function(){return new ai(this.editor)},ui.prototype=Object.create(m.prototype),ui.prototype.constructor=ui;var di=ui.prototype;function ci(t,e){m.call(this,t,"DELETE-DIMENSION",e.id),this.createDimension=new wi(t,e.id,e.secondAnchor,e.firstAnchor,e.currentText,e.getStyle())}di.redo=function(){var t=this.editor,e=new li(this.targetId,t);t.addMarkup(e),e.set(this.position,this.size,this.movements,!1),e.setRotation(this.rotation),e.setStyle(this.style)},di.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)},ci.prototype=Object.create(m.prototype),ci.prototype.constructor=ci;var pi=ci.prototype;function fi(t,e,i,n,s){m.call(this,t,"SET-DIMENSION",e.id),this.newFirstAnchor={x:i.x,y:i.y},this.newSecondAnchor={x:n.x,y:n.y},this.oldFirstAnchor={x:e.firstAnchor.x,y:e.firstAnchor.y},this.oldSecondAnchor={x:e.secondAnchor.x,y:e.secondAnchor.y},this.newText=s,this.oldText=e.currentText}pi.redo=function(){this.createDimension.undo()},pi.undo=function(){this.createDimension.redo()},fi.prototype=Object.create(m.prototype),fi.prototype.constructor=fi;var yi=fi.prototype;yi.redo=function(){this.applyState(this.newFirstAnchor,this.newSecondAnchor,this.newText)},yi.undo=function(){this.applyState(this.oldFirstAnchor,this.oldSecondAnchor,this.oldText)},yi.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newFirstAnchor=t.newFirstAnchor,this.newSecondAnchor=t.newSecondAnchor,this.newText=t.newText,!0)},yi.applyState=function(t,e,i){var n=this.editor.getMarkup(this.targetId);n&&n.set(t.x,t.y,e.x,e.y,i)},yi.isIdentity=function(){return this.newText===this.oldText&&(!this.newFirstAnchor||!this.newSecondAnchor||this.newFirstAnchor.x===this.oldFirstAnchor.x&&this.newFirstAnchor.y===this.oldFirstAnchor.y&&this.newSecondAnchor.x===this.oldSecondAnchor.x&&this.newSecondAnchor.y===this.oldSecondAnchor.y)};var gi,vi=Autodesk.Viewing.MeasureCommon;function mi(t){var e=this;j.call(this,t,v,["stroke-width","stroke-color","stroke-opacity","font-size","font-family","font-style","font-weight"]),this.onHistoryChangeBinded=this.onHistoryChange.bind(this),this.measurement=new vi.Measurement(vi.MeasurementTypes.MEASUREMENT_DISTANCE);var i=this.viewer,n=i.getExtension("Autodesk.Measure");function s(){e.cancelEditModeChange=!0,t.enterEditMode()}n||(console.error("Demension markup cant work without measure extension. Please load measure extension first"),s()),this.sharedMeasureConfig=n.sharedMeasureConfig,(n.forceCalibrate||i.model.getData().isLeaflet||i.model.getData().isPdf)&&!n.calibrationTool.isCalibrated()&&(n.openCalibrationRequiredDialog("dimension"),s())}mi.prototype=Object.create(j.prototype),mi.prototype.constructor=mi;var xi=mi.prototype;xi.deleteMarkup=function(t,e){if((t=t||this.selectedMarkup)&&t.type==this.type){var i=new ci(this.editor,t);return i.addToHistory=!e,i.execute(),this.creating=!1,this.dragging=!1,!0}return!1},xi.updateTextBoxStyle=function(t){this.isTextInputHelperActive()&&(t||(t=this.textInputHelper.textMarkup.getStyle()),this.textInputHelper.setStyle(t),this.updateTextBox(this.textInputHelper.textMarkup))},xi.setStyle=function(t){j.prototype.setStyle.call(this,t),this.updateTextBoxStyle(t)},xi.notifyAllowNavigation=function(t){t&&this.isTextInputHelperActive()&&this.textInputHelper.acceptAndExit()},xi.creationBegin=function(){j.prototype.creationBegin.call(this)},xi.creationEnd=function(){this.dragging=!1,j.prototype.creationEnd.call(this)},xi.isMinSizeValid=function(){if(0!==this.minSize){var t=this.editor.sizeFromMarkupsToClient(this.selectedMarkup.size.x,this.selectedMarkup.size.y);return t.x*t.x>=this.minSize*this.minSize}return!0},xi.creationCancel=function(){j.prototype.creationCancel.call(this),this.creating=!1,this.dragging=!1},xi.destroy=function(){this.textInputHelper&&(this.textInputHelper.isActive()&&this.textInputHelper.acceptAndExit(),this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.destroy(),this.textInputHelper=null),this.updateViewportId(),j.prototype.destroy.call(this)},xi.getDistance=function(){if(this.measurement.computeResult(this.measurement.picks,this.viewer),this.viewer.model&&this.measurement.distanceXYZ){var t=Autodesk.Viewing.Private.convertUnits(this.viewer.model.getUnitString(),this.sharedMeasureConfig.units,this.sharedMeasureConfig.calibrationFactor,this.measurement.distanceXYZ);return Autodesk.Viewing.Private.formatValueWithUnits(t,this.sharedMeasureConfig.units,3,this.sharedMeasureConfig.precision)}return null},xi.updateMeasurement=function(t){var e=this.editor,i=this.measurement.getPick(t);return gi?(i.geomType=vi.SnapType.SNAP_VERTEX,i.geomVertex=gi,i.intersectPoint=gi):e.snapper.copyResults(i),i},xi.updateViewportId=function(t){this.viewer.model&&this.viewer.model.is2d()&&(t?(this.viewer.impl.updateViewportId(t),this.editor.snapper.setViewportId(t)):(this.viewer.impl.updateViewportId(0),this.editor.snapper.setViewportId(null)))},xi.pickFirstAnchor=function(){var t=this.editor;this.measurement.clearAllPicks();var e=t.getMousePosition();this.initialX=e.x,this.initialY=e.y,this.firstAnchor=t.positionFromClientToMarkups(this.initialX,this.initialY),t.beginActionGroup();var i=t.getId();new wi(t,i,this.firstAnchor,null,this.currentText,this.style).execute(),this.selectedMarkup=t.getMarkup(i),this.creationBegin();var n=this.updateMeasurement(1);this.updateViewportId(n.viewportIndex2d)},xi.pickSecondAnchor=function(t){var e=this.editor,i=this.selectedMarkup;if(this.secondAnchor=this.getFinalMouseDraggingPosition(),this.updateMeasurement(2),vi.correctPerpendicularPicks(this.measurement.getPick(1),this.measurement.getPick(2),this.viewer,e.snapper)){var n=vi.getSnapResultPosition(this.measurement.getPick(2),this.viewer);this.secondAnchor=e.project(n),e.snapper.indicator.render()}var s=e.positionFromClientToMarkups(this.secondAnchor.x,this.secondAnchor.y);this.size.x=i.size.x,this.size.y=i.size.y,i.currentText=this.getDistance(),new fi(e,i,this.firstAnchor,s,i.currentText).execute(),new F(e,i,this.style).execute(),t&&!i.currentText&&this.isMinSizeValid()&&(i.currentText="",this.editor.selectMarkup(null),this.updateTextBox(i))},xi.onMouseDown=function(t){if(!Autodesk.Viewing.Private.isRightClick(t,this.viewer.navigation))if(gi=null,this.isTextInputHelperActive())this.textInputHelper.acceptAndExit();else if(j.prototype.onMouseDown.call(this),!this.selectedMarkup||this.creating){var e=this.editor.snapper.isSnapped();this.selectedMarkup||this.creating||!e?this.selectedMarkup&&this.creating&&(e?this.pickSecondAnchor(!0):(this.deleteMarkup(this.selectedMarkup,!0),this.creating=!0),this.updateViewportId(),this.creationEnd()):this.pickFirstAnchor()}},xi.onMouseUp=function(t){this.dragging&&(this.onMouseDown(t),this.dragging=!1)},xi.onMouseMove=function(t){gi=null,this.selectedMarkup&&this.creating&&(this.dragging=!0,this.pickSecondAnchor(!1))},xi.getFinalMouseDraggingPosition=function(){var t=this.editor,e=t.getBounds(),i=t.getMousePosition();t.snapper.isSnapped()||t.viewer.model&&t.viewer.model.is2d()&&(gi=vi.inverseProject(i,t.viewer));var n=this.initialX,s=this.initialY,o=Math.min(Math.max(e.x,i.x),e.x+e.width),r=Math.min(Math.max(e.y,i.y),e.y+e.height);(o==n&&r==s&&(o++,r++),t.input.constrainAxis&&t.viewer.model.is2d())&&(Math.abs(o-n)>Math.abs(r-s)?r=s:o=n,t.snapper.onMouseMove({x:o,y:r}),t.snapper.isSnapped()?(t.snapper.copyResults(this.measurement.getPick(2)),gi=null):gi=vi.inverseProject({x:o,y:r},t.viewer));return{x:o,y:r}},xi.isVisibleChar=function(t){return t>47&&t<58||32==t||t>64&&t<91||t>95&&t<112||t>185&&t<193||t>218&&t<223},xi.measureTextLine=function(t,e,i){return t=0===(t=t.replace(new RegExp(" ","g")," ")).length?e.initialText:t,Tn([t+"|"],this.style,i)[0]},xi.handleKeyDown=function(t){var e=this.textInputHelper;if(t.keyCode!==Autodesk.Viewing.KeyCode.ENTER){var i=e.textMarkup,n=e.textArea.value;t.keyCode===Autodesk.Viewing.KeyCode.BACKSPACE&&(n=n.substring(0,n.length-1)),n.length<15&&this.isVisibleChar(t.keyCode)&&(n+=t.key);var s=this.measureTextLine(n,i,this.editor);this.updateTextBox(i,s)}},xi.updateTextBox=function(t,e){this.textInputHelper||(this.textInputHelper=new Dt(this.viewer.container,this.editor,!0,t.initialText,15),this.textInputHelper.addEventListener(this.textInputHelper.EVENT_TEXT_CHANGE,this.onHelperTextChange.bind(this),!1),this.handleKeyDownBinded=this.handleKeyDown.bind(this)),t.text.style.display="none",e||(e=this.measureTextLine(this.textInputHelper.textArea.value,t,this.editor));var i=this.getTextAreaTransform(t,e);this.textInputHelper.styleTextArea.setAttribute("text-align","center"),this.textInputHelper.setActive(t,!1),this.textInputHelper.textArea.style.position="static",this.textInputHelper.textArea.style.padding="0",this.textInputHelper.textArea.style.width=e.width+"px",this.textInputHelper.textArea.style.height=e.height+"px",this.textInputHelper.textArea.style.transform=i,this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.editor.actionManager.addEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.textArea.removeEventListener("keydown",this.handleKeyDownBinded),this.textInputHelper.textArea.addEventListener("keydown",this.handleKeyDownBinded)},xi.getTextAreaTransform=function(t,e){var i=t.getClientPosition(),n=hn(t.rotation)%360;return n>90&&n<=270&&t.shouldFlip()&&(n=180+n),["translate(",i.x-e.width/2+"px,",i.y-this.viewer.container.clientHeight-e.height+"px)","rotate(",n+"deg)","translate(0px,",e.height+"px)"].join(" ")},xi.onMouseDoubleClick=function(t){t===this.selectedMarkup&&(this.editor.selectMarkup(null),this.updateTextBox(t))},xi.onHelperTextChange=function(t){var e=t.data,i=e.markup,n=e.style,s=this.editor;i.text.style.display="block",""===e.newText&&(e.newText=i.initialText),e.firstEdit||s.beginActionGroup(),new F(s,i,n).execute(),new fi(s,i,i.firstAnchor,i.secondAnchor,e.newText).execute(),s.closeActionGroup(),s.selectMarkup(null)},xi.onHistoryChange=function(t){this.isTextInputHelperActive()&&(this.textInputHelper.textMarkup.text.style.display="block",this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded),this.textInputHelper.setInactive())},xi.onSave=function(){if(j.prototype.onSave.call(this),this.isTextInputHelperActive()){this.editor.actionManager.removeEventListener(D,this.onHistoryChangeBinded);var t=this.textInputHelper.textMarkup;this.textInputHelper.acceptAndExit(),t.text.style.display="block"}},xi.useWithSnapping=function(){return!0};var bi="Add Length";function Mi(t,e){_.call(this,t,e,["stroke-width","stroke-color","stroke-opacity","font-size","font-family","font-style","font-weight"]),this.type=v,this.constraintHeight=!0,this.constraintWidth=!0,this.addMarkupMetadata=Yi.bind(this),this.createSvgElement=Ni.bind(this),this.checkLineSegment=Mn.bind(this),this.measureTextLines=Tn.bind(this),this.firstAnchor=new THREE.Vector3,this.secondAnchor=new THREE.Vector3,this.shape=Hi(),this.text=Fi(),this.shape.appendChild(this.text),this.textSize={x:0,y:0},this.initialText=bi,this.currentText=" ",this.viewer.model.is2d()||(this.preventReposition=!0,this.constraintRotation=!0),this.bindDomEvents()}Mi.prototype=Object.create(_.prototype),Mi.prototype.constructor=Mi;var Ei=Mi.prototype;function wi(t,e,i,n,s,o){m.call(this,t,"CREATE-DIMENSION",e),this.selectOnExecution=!1,this.secondAnchor=n,this.firstAnchor=i,this.text=s,this.style=E(o)}Ei.getEditMode=function(){return new mi(this.editor)},Ei.set=function(t,e,i,n,s){var o=new THREE.Vector2(t,e),r=new THREE.Vector2(i,n),a=r.clone().sub(o).normalize();this.size.x=o.distanceTo(r),this.rotation=Math.acos(a.dot(new THREE.Vector2(1,0))),this.rotation=n>e?2*Math.PI-this.rotation:this.rotation;var h=this.firstAnchor,l=this.secondAnchor;h.set(i,n,0),l.set(t,e,0),this.position.x=l.x+.5*(h.x-l.x),this.position.y=l.y+.5*(h.y-l.y),this.currentText=s,this.updateStyle()},Ei.setRotation=function(t){90===hn(t)&&(t=ln(-90)),this.rotation=t;var e=Math.cos(-t),i=Math.sin(-t),n=new THREE.Vector2(e,i);n.multiplyScalar(.5*this.size.x);var s=new THREE.Vector2(this.position.x,this.position.y),o=s.clone().sub(n),r=s.clone().add(n);this.firstAnchor.set(r.x,r.y,0),this.secondAnchor.set(o.x,o.y,0),this.updateStyle()},Ei.setSize=function(t,e,i){var n=Math.cos(-this.rotation),s=Math.sin(-this.rotation),o=new THREE.Vector2(n,s);o.multiplyScalar(.5*e);var r=new THREE.Vector2(t.x,t.y),a=r.clone().sub(o),h=r.clone().add(o);this.firstAnchor.set(h.x,h.y,0),this.secondAnchor.set(a.x,a.y,0),this.position.x=t.x,this.position.y=t.y,this.size.x=e,this.updateStyle()},Ei.getClientFontSize=function(){return this.editor.sizeFromMarkupsToClient(0,this.style["font-size"]).y},Ei.updateStyle=function(){var t=this.style,e=this.shape,i=t["stroke-width"],n=this.highlighted?this.highlightColor:bn(t["stroke-color"],t["stroke-opacity"]),s=this.getTransform();this.rebuildTextSvg(this.currentText),_i(e,"d",this.getPath().join(" ")),_i(e,"stroke-width",i/2),_i(e,"stroke",n),_i(e,"fill",n),_i(e,"transform",s),Oi(e,this.editor)},Ei.rebuildTextSvg=function(t){var e=this.style,i=this.highlighted?this.highlightColor:bn(e["stroke-color"],e["stroke-opacity"]),n=e["stroke-width"],s=this.createSvgElement("text");s.setAttribute("id","markup"),s.setAttribute("alignment-baseline","middle");var o=this.text,r=this.editor;o.childNodes[0].removeChild(o.markup),o.childNodes[0].appendChild(s),o.markup=s;var a=this.createSvgElement("tspan");a.textContent=t,s.appendChild(a);var h=this.measureTextLines([t],e,r)[0],l=this.textSize=r.sizeFromClientToMarkups(h.width,h.height),u=10*n/2,d=2*n/2,c=l.x+2*n>=this.size.x?d+u/2:d;this.size.y=u+l.y+c;var p=this.getTextTransform(.8*l.y+c,!0),f=this.getTextTransform(l.y+c,!1);_i(o,"font-family",e["font-family"]),_i(o,"font-size",e["font-size"]),_i(o,"font-weight",e["font-weight"]),_i(o,"font-style",e["font-style"]),_i(o,"text-rendering","auto"),_i(o,"fill",i),Ui(o,f,p),Gi(o,l.x,l.y,"none"),Wi(o,l.x,l.y),ji(o,l.x,l.y,r)},Ei.shouldFlip=function(){return this.firstAnchor.x<this.secondAnchor.x},Ei.getTextTransform=function(t,e){var i=this.shouldFlip()?-1:1;return e=e?-1:1,90===hn(this.rotation)&&(this.rotation=ln(-90)),["translate(",this.position.x,",",this.position.y,")","rotate(",hn(-this.rotation),")","translate(",-i*this.textSize.x/2,",",-i*t,")","scale("+i+","+i*e+")"].join(" ")},Ei.setPosition=function(t,e){var i=this.firstAnchor,n=this.secondAnchor,s=i.x-n.x,o=i.y-n.y,r=t+.5*s,a=e+.5*o;i.x=r,i.y=a,n.x=r-s,n.y=a-o,this.position.x=n.x+.5*(i.x-n.x),this.position.y=n.y+.5*(i.y-n.y),this.updateStyle()},Ei.generatePoint3d=function(t){var e=this.editor.positionFromMarkupsToClient(this.firstAnchor.x,this.firstAnchor.y),i=this.editor.positionFromMarkupsToClient(this.secondAnchor.x,this.secondAnchor.y),n=e.clone().sub(i).normalize(),s=this.checkLineSegment(e.x,e.y,e.x+200*n.x,e.y+200*n.y,t),o=s&&this.viewer.clientToWorld(s.x,s.y);return o&&o.point},Ei.setMetadata=function(){this.text.setAttribute("pointer-events","none");var t=E(this.style);return t.type=this.type,t.firstAnchor=[this.firstAnchor.x,this.firstAnchor.y].join(" "),t.secondAnchor=[this.secondAnchor.x,this.secondAnchor.y].join(" "),t.text=String(this.currentText),this.addMarkupMetadata(this.shape,t)},Ei.getText=function(){return this.currentText===this.initialText?"":this.currentText},Ei.getPath=function(){var t=this.style["stroke-width"],e=this.size.x-t/2,i=10*t/2;return["M",.5*-e,0,"l",0,i/2,"l",0,-i/2,"l",e,0,"l",0,i/2,"l",0,-i,"l",0,i/2,"l",-e,0,"l",0,-i/2,"z"]},Ei.cloneShape=function(t){t.shape=Hi(),t.text=Fi(),t.shape.appendChild(t.text),t.bindDomEvents()},Ei.getBoundingRect=function(){var t=this.getClientPosition(),e=this.getClientSize();return{x:t.x-e.x/2,y:t.y-e.y/2,width:e.x,height:e.y}},wi.prototype=Object.create(m.prototype),wi.prototype.constructor=wi;var ki=wi.prototype;ki.redo=function(){var t=this.editor,e=new Mi(this.targetId,t);t.addMarkup(e),this.secondAnchor&&(e.set(this.firstAnchor.x,this.firstAnchor.y,this.secondAnchor.x,this.secondAnchor.y,this.text),e.setStyle(this.style))},ki.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)};const Ti=i(8);var Ci=Autodesk.Viewing,Si=Autodesk.Viewing.Private;const Ai=Ci.getGlobal(),Pi=Ai.document;var Ii=1,zi=10,Di=15,Ri=7,Bi=function(){return!(!Ci.isTouchDevice||"function"!=typeof Hammer)&&Ci.isTouchDevice()},Ni=function(t){return(this&&this.getDocument&&this.getDocument()||Pi).createElementNS("http://www.w3.org/2000/svg",t)},Vi=function(t){return t.setAttribute("version","1.1"),t.setAttribute("baseProfile","full"),t.setAttribute("layer-order-id","markups-svg"),t},Li=function(t){t=t||[];var e=Ni("g");e.setAttribute("cursor","default"),e.setAttribute("pointer-events","none");for(var i=0;i<t.length;i++)e.appendChild(t[i]);return e},Hi=function(){var t=Ni("g");t.setAttribute("cursor","inherit"),t.setAttribute("pointer-events","none");var e=Ni("path");e.setAttribute("id","markup");var i=Ni("path");return i.setAttribute("id","hitarea"),i.setAttribute("fill","transparent"),i.setAttribute("stroke","transparent"),t.markup=e,t.hitarea=i,t.appendChild(e),t.appendChild(i),t},_i=function(t,e,i){t.markup.setAttribute(e,i)},Oi=function(t,e){var i=t.markup,n=t.hitarea,s=e.sizeFromClientToMarkups(0,Di).y;s+=parseFloat(i.getAttribute("stroke-width"))+s;var o=i.getAttribute("fill"),r=i.getAttribute("stroke"),a=""!==r&&"none"!==r,h=""!==o&&"none"!==o;if(n.setAttribute("d",i.getAttribute("d")),n.setAttribute("stroke-width",s),n.setAttribute("transform",i.getAttribute("transform")),e.duringEditMode&&!e.navigating){if(a&&h)return void t.setAttribute("pointer-events","painted");if(a)return void t.setAttribute("pointer-events","stroke");if(h)return void t.setAttribute("pointer-events","fill")}t.setAttribute("pointer-events","none")},Fi=function(){var t=Ni("g");t.setAttribute("cursor","default");var e="markup-clipper-"+$i(),i="url(#"+e+")",n=Ni("clipPath");n.setAttribute("id",e),n.removeAttribute("pointer-events"),n.rect=Ni("rect"),n.appendChild(n.rect);var s=Ni("rect");s.setAttribute("id","markup-background"),s.removeAttribute("pointer-events");var o=Ni("text");o.setAttribute("id","markup");var r=Ni("rect");r.setAttribute("id","hitarea"),r.setAttribute("fill","transparent"),r.setAttribute("stroke","none"),r.setAttribute("stroke-width","0");var a=Ni("g");return a.setAttribute("clip-path",i),a.appendChild(n),a.appendChild(s),a.appendChild(o),t.appendChild(a),t.appendChild(r),t.clipper=n,t.background=s,t.markup=o,t.hitarea=r,t},Ui=function(t,e,i){t.clipper.rect.setAttribute("transform",e),t.background.setAttribute("transform",e),t.markup.setAttribute("transform",i),t.hitarea.setAttribute("transform",e)},ji=function(t,e,i,n){var s=t.hitarea,o=n.sizeFromClientToMarkups(0,Di).y;s.setAttribute("x",-o),s.setAttribute("y",-o),s.setAttribute("width",e+2*o),s.setAttribute("height",i+2*o),t.setAttribute("pointer-events",n.navigating?"none":"painted")},Gi=function(t,e,i,n){var s=t.background;s.setAttribute("x",0),s.setAttribute("y",0),s.setAttribute("width",e),s.setAttribute("height",i),s.setAttribute("fill",n)},Wi=function(t,e,i){var n=t.clipper;n.rect.setAttribute("x",0),n.rect.setAttribute("y",0),n.rect.setAttribute("width",e),n.rect.setAttribute("height",i)},Xi=function(t,e){const i=this&&this.getDocument&&this.getDocument()||Pi;var n=i.createElementNS("http://www.w3.org/2000/svg","metadata"),s=i.createElement("markup_document");return n.appendChild(s),s.setAttribute("data-model-version",e["data-model-version"]),t.insertBefore(n,t.firstChild),n},Yi=function(t,e){const i=this&&this.getDocument&&this.getDocument()||Pi;var n=i.createElementNS("http://www.w3.org/2000/svg","metadata"),s=i.createElement("markup_element");for(var o in n.appendChild(s),e)e.hasOwnProperty(o)&&s.setAttribute(o,e[o]);return t.insertBefore(n,t.firstChild),n},Ki=function(t){if(t.getElementsByTagName)for(var e=t.getElementsByTagName("metadata"),i=0;i<e.length;++i){var n=e[i];n.parentNode&&n.parentNode.removeChild(n)}var s=t.children||t.childNodes;if(s)for(i=0;i<s.length;++i)Ki(s[i])},qi=function(t,e){for(var i=t.children||t.childNodes,n=[],s=0;s<i.length;++s)n.push(i[s]);n.forEach(function(t){e.appendChild(t)})},$i=function(){return THREE.Math.generateUUID()},Zi=function(t){var e;try{var i=[];!function t(e,i){var n=e.hitarea,s=n&&n.parentNode;s&&(i.push({hitarea:n,parent:s}),s.removeChild(n));for(var o=e.childNodes,r=o.length,a=0;a<r;++a)t(o.item(a),i)}(t,i),e=(new XMLSerializer).serializeToString(t),function(t){for(var e=t.length,i=0;i<e;++i){var n=t[i];n.parent.appendChild(n.hitarea)}}(i)}catch(t){e="",console.warn("svgNodeToString failed to generate string representation of domNode.")}return e},Ji=function(t){var e=null;try{e=(new DOMParser).parseFromString(t,"text/xml").firstChild}catch(t){e=null,console.warn("stringToSvgNode failed to generate an HTMLElement from its string representation.")}return e},Qi=function(t){t.listeners={},t.addEventListener=function(t,e){void 0===this.listeners[t]&&(this.listeners[t]=[]),this.listeners[t].push(e)},t.hasEventListener=function(t,e){if(void 0===this.listeners)return!1;var i=this.listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},t.removeEventListener=function(t,e){if(this.listeners[t]instanceof Array)for(var i=this.listeners[t],n=0,s=i.length;n<s;n++)if(i[n]===e){i.splice(n,1);break}},t.dispatchEvent=function(t){if("string"==typeof t&&(t={type:t}),t.target||(t.target=this),!t.type)throw new Error("event type unknown.");if(this.listeners[t.type]instanceof Array)for(var e=this.listeners[t.type].slice(),i=0;i<e.length;i++)e[i].call(this,t)}},tn=function(t){try{delete t.listeners,delete t.addEventListener,delete t.hasEventListener,delete t.removeEventListener,delete t.dispatchEvent}catch(t){}},en=function(t,e,i){var n=rn(t,e),s=on(n.x,n.y,e);return s.z=0,i&&(s.x=Math.floor(s.x)+.5,s.y=Math.floor(s.y)+.5),s},nn=function(t,e,i,n){var s=sn(t,e,n);return s.z=i,s.unproject(n.impl.camera),s},sn=function(t,e,i){return i.impl.clientToViewport(t,e)},on=function(t,e,i){return i.impl.viewportToClient(t,e)},rn=function(t,e){var i=new THREE.Vector3;return i.x=t.x,i.y=t.y,i.z=t.z,i.project(e.impl.camera),i},an=function(t,e){return 1/e.model.getUnitScale()*t},hn=function(t){return t*(180/Math.PI)},ln=function(t){return t*(Math.PI/180)},un=function(t){return t>=0?1:-1},dn=function(t,e,i,n){i=n.sizeFromClientToMarkups(0,i).y;var s=t.x-e.x,o=t.y-e.y;return i*i>=s*s+o*o},cn=function(t){t.toolbar&&(t.setActiveNavigationTool(),vn(),fn(!0,t),gn(t))},pn=function(t){t.toolbar&&(vn(),fn(!1,t),yn(t))},fn=function(t,e){var i=e.dockingPanels;if(i)for(var n=0;n<i.length;++n){var s=i[n],o=s.container;o.classList.contains("dockingPanelVisible")&&(o.style.display=t?"none":"block",s.visibilityChanged())}},yn=function(t){t&&t.model&&!t.model.is2d()&&t.getExtension("Autodesk.ViewCubeUi",function(t){t.displayViewCube(!0,!1),t.displayHomeButton(!0)});var e=t.getDocument().getElementsByClassName("toolbar-animation-subtoolbar");if(e.length>0&&(e[0].style.display=""),t.toolbar)for(var i=t.toolbar.container,n=i.children.length,s=0;s<n;++s)i.children[s].style.display=""},gn=function(t){t&&t.model&&!t.model.is2d()&&t.getExtension("Autodesk.ViewCubeUi",function(t){t.displayViewCube(!1,!1),t.displayHomeButton(!1)});var e=t.getDocument().getElementsByClassName("toolbar-animation-subtoolbar");if(e.length>0){e[0].style.display="none";var i=t.impl.keyFrameAnimator;if(i&&!i.isPaused){i.pauseCameraAnimations(),i.pause();var n=t.modelTools.getControl("toolbar-animationPlay");n&&(n.setIcon("toolbar-animation-pause-icon"),n.setToolTip("Pause"))}}if(t.toolbar)for(var s=t.toolbar.container,o=s.children.length,r=0;r<o;++r)s.children[r].style.display="none"},vn=function(){try{for(var t=!0;t;)t=Autodesk.Viewing.Private.HudMessage.dismiss()}catch(t){console.warn("[CO2]Failed to dismiss LMV HudMessage")}},mn=function(t,e){return e.sizeFromClientToMarkups(0,t).y},xn=function(t,e){if(!t.childNodes[0])return null;var i=t.childNodes[0].childNodes[0]||"",n=function(){var e=t.childNodes[1]||"",i=!1;if("string"!=typeof e){var n=e.getAttribute("d").split(" ");"z"===n[n.length-1].toLowerCase()&&(i=!0)}return i},s=function(){for(var t=[],e=i.getAttribute("locations").split(" ")||"",n=0;n<e.length;n+=2){var s={x:parseFloat(e[n]),y:parseFloat(e[n+1])};t.push(s)}return t},o=function(t){var e=new THREE.Vector3,n=(i.getAttribute(t)||i.getAttribute(t.toLowerCase())).split(" ");return e.x=parseFloat(n[0]),e.y=parseFloat(n[1]),e},r=function(){return o("position")},m=function(){return o("size")},x=function(){var t=i.getAttribute("rotation")||"";return parseFloat(t)},b=function(){return i.getAttribute("text")||""};if("string"!=typeof i){var M,E=e.getId(),w=function(t,e){for(var i=["stroke-width","stroke-color","stroke-opacity","fill-color","fill-opacity","font-family","font-size","font-style","font-weight","stroke-linejoin"],n={},s=0;s<i.length;s++){var o=e.getAttribute(i[s]);if(null!=o)switch(i[s]){case"font-size":case"stroke-width":case"stroke-opacity":case"fill-opacity":n[i[s]]=parseFloat(o);break;case"stroke-linejoin":break;case"font-family":case"font-style":case"font-weight":case"stroke-color":case"fill-color":n[i[s]]=o;break;default:Si.logger.warn("Style not recognized.")}}return n}(0,i);switch(i.getAttribute("type")||""){case a:M=new tt(e,E,o("tail"),o("head"),w);break;case l:M=new dt(e,E,r(),m(),x(),w);break;case h:M=new te(e,E,r(),m(),b(),w);break;case g:M=new Ut(e,E,r(),m(),b(),w,!!parseInt(i.getAttribute("isframeused")));break;case u:M=new ue(e,E,r(),m(),x(),w);break;case d:M=new be(e,E,r(),m(),x(),w);break;case c:M=new Re(e,E,r(),m(),x(),s(),w);break;case f:M=new Ge(e,E,r(),m(),x(),s(),w,n());break;case y:M=new ei(e,E,r(),m(),x(),s(),w,n());break;case p:M=new ui(e,E,r(),m(),x(),s(),w);break;case v:M=new wi(e,E,o("firstAnchor"),o("secondAnchor"),b(),w);break;default:M=null}if(M){M.addToHistory=!1,M.execute();for(var k=e.svgLayersMap[e.activeLayer].markups,T=0;T<k.length;++T)if(k[T].id===E)return k[T]}return null}},bn=function(t,e){return!t||!e||e<=0?"none":["rgba("+parseInt("0x"+t.substr(1,2)),",",parseInt("0x"+t.substr(3,2)),",",parseInt("0x"+t.substr(5,2)),",",e,")"].join("")},Mn=function(t,e,i,n,s){var o=(this&&this.getWindow&&this.getWindow()||Ai).devicePixelRatio||1;t*=o,e*=o,i*=o,n*=o;var r=s.width,a=s.height,h=s.buffer;function l(t,e){t=Math.round(t),e=Math.round(e);for(var i=0,n=0,s=-o;s<=o;s+=2*o)n+=u(t,e+s)?s:0;for(var r=-o;r<=o;r+=2*o)i+=u(t+r,e)?r:0;return{x:Math.round(t/o+i),y:Math.round((a-e)/o-n)}}function u(t,e){if(t<0||t>=r||e<0||e>=a)return!1;var i=4*(e*r+t);return 255!==h[i]||255!==h[i+1]||255!==h[i+2]}t=Math.round(t),i=Math.round(i),e=Math.round(a-e),n=Math.round(a-n);var d=i-t,c=0!==d?(n-e)/d:1,p=t,f=e;if(0!==d&&Math.abs(c)<=1){if(t<=i){for(;p<=i;++p,f+=c)if(u(p,Math.round(f)))return l(p,f)}else for(;p>=i;--p,f-=c)if(u(p,Math.round(f)))return l(p,f)}else if(c=0!==d?1/c:0,e<=n){for(;f<=n;++f,p+=c)if(u(Math.round(p),f))return l(p,f)}else for(;f>=n;--f,p-=c)if(u(Math.round(p),f))return l(p,f)},En=function(t,e){if(!t||t.verxtexCount<3||!e)return null;var i=(this&&this.getWindow&&this.getWindow()||Ai).devicePixelRatio||1,n=e.width,s=e.height,o=e.buffer,r=t.vertexCount,a=Float32Array.from(t.xVertices),h=Float32Array.from(t.yVertices);function l(t,e){for(var n=0,o=0,r=-i;r<=i;r+=2*i)o+=u(t,e+r)?r:0;for(var a=-i;a<=i;a+=2*i)n+=u(t+a,e)?a:0;return{x:Math.round(t/i)+n,y:Math.round((s-e)/i-o)}}function u(e,i){if(e<0||e>=n||i<0||i>=s)return!1;var r=4*(i*n+e);return(255!==o[r]||255!==o[r+1]||255!==o[r+2])&&function(e,i){for(var n=!1,s=t.vertexCount,o=0,r=s-1;o<s;r=o++)h[o]>i!=h[r]>i&&e<(a[r]-a[o])*(i-h[o])/(h[r]-h[o])+a[o]&&(n=!n);return n}(e,i)}for(var d=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,f=Number.NEGATIVE_INFINITY,y=0;y<r;++y){var g=a[y]=a[y]*i,v=h[y]=s-h[y]*i;d=Math.min(d,g),c=Math.min(c,v),p=Math.max(p,g),f=Math.max(f,v)}if(p<0||d>n||f<0||c>s)return null;var m=Math.round(p-d),x=Math.round(f-c),b=Math.round(.5*(d+p)),M=Math.round(.5*(c+f)),E=1,w=1;do{for(var k=b+E,T=M+w;b<k;++b)if(u(b,M))return l(b,M);for(;M<T;++M)if(u(b,M))return l(b,M);for(E<m?(k=b-++E,++E):k=b-E,w<x?(T=M-++w,++w):T=M-w;b>k;--b)if(u(b,M))return l(b,M);for(;M>T;--M)if(u(b,M))return l(b,M)}while(E<m||w<x)},wn=function(){const t=this&&this.getDocument&&this.getDocument()||Pi;var e=t.createElement("style");return e.appendChild(t.createTextNode("")),t.head.appendChild(e),e.sheet},kn=function(t,e,i,n){"insertRule"in t?t.insertRule(e+"{"+i+"}",n):"addRule"in t&&t.addRule(e,i,n)},Tn=function(t,e,i){var n=i.sizeFromMarkupsToClient(0,e["font-size"]).y,s=(new At).setAttribute("font-family",e["font-family"]).setAttribute("font-size",n+"px").setAttribute("font-weight",e["font-weight"]?"bold":"").setAttribute("font-style",e["font-style"]?"italic":"").removeAttribute(["top","left","width","height","overflow-y"]).setAttribute("position","absolute").setAttribute("white-space","nowrap").setAttribute("float","left").setAttribute("visibility","hidden").getStyleString();var o=(this&&this.getDocument&&this.getDocument()||Pi).createElement("div");o.setAttribute("style",s),i.viewer.container.appendChild(o);for(var r=[],a=t.length,h=0;h<a;++h)o.innerText=t[h],r.push({line:t[h],width:o.clientWidth,height:o.clientHeight});return i.viewer.container.removeChild(o),r},Cn=function(t,e,i,n,s,o){return o.push(s?"a":"A"),o.push(i),o.push(n),o.push(0),o.push(1),o.push(1),o.push(t),o.push(e),o},Sn=function(t,e,i,n,s,o){var r=.5*i,a=.5*n;o.push(s?"m":"M"),o.push(t),o.push(e),Cn(i,0,r,a,!0,o),Cn(-i,0,r,a,!0,o),o.push("z")},An=function(t,e,i,n,s,o){o.push(s?"m":"M"),o.push(t),o.push(e),o.push("l"),o.push(i),o.push(0),o.push("l"),o.push(0),o.push(n),o.push("l"),o.push(-i),o.push(0),o.push("z")},Pn=function(t,e,i,n,s,o){var r=Ni("svg");Ci.isIE11||r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width",i),r.setAttribute("height",n),r.setAttribute("viewBox",e),r.setAttribute("transform","scale(1,-1)");var a=t.parentNode.cloneNode(!0);r.appendChild(a);const h=this&&this.getWindow&&this.getWindow()||Ai;var l=(this&&this.getDocument&&this.getDocument()||Pi).createElement("div"),u=r.cloneNode(!0);l.appendChild(u);var d=l.innerHTML;r=l=u=null;var c=function(){Ti(s.canvas,d,{ignoreMouse:!0,ignoreDimensions:!0,ignoreClear:!0,renderCallback:o})};if(Ci.isIE11)c();else{var p=new Image;p.onload=function(){s.drawImage(p,0,0),o()},p.onerror=function(){c()},p.src="data:image/svg+xml;base64,"+h.btoa(unescape(encodeURIComponent(d)))}},In=function(t,e,i){if(t.length<=2)return t;function n(t,e,i){var n=e.x,s=e.y,o=i.x-n,r=i.y-s;if(0!==o||0!==r){var a=((t.x-n)*o+(t.y-s)*r)/(o*o+r*r);a>1?(n=i.x,s=i.y):a>0&&(n+=o*a,s+=r*a)}return(o=t.x-n)*o+(r=t.y-s)*r}var s=void 0!==e?e*e:1;return t=function(t,e){var i=t.length-1,s=[t[0]];return function t(e,i,s,o,r){for(var a,h=o,l=i+1;l<s;l++){var u=n(e[l],e[i],e[s]);u>h&&(a=l,h=u)}h>o&&(a-i>1&&t(e,i,a,o,r),r.push(e[a]),s-a>1&&t(e,a,s,o,r))}(t,0,i,e,s),s.push(t[i]),s}(t=i?t:function(t,e){for(var i,n,s,o,r,a=t[0],h=[a],l=1,u=t.length;l<u;l++)i=t[l],s=a,o=void 0,r=void 0,o=(n=i).x-s.x,r=n.y-s.y,o*o+r*r>e&&(h.push(i),a=i);return a!==i&&h.push(i),h}(t,s),s)};function zn(){this.actions=[],this.closed=!0}var Dn=zn.prototype;function Rn(t){this.historySize=t,this.undoStack=[],this.redoStack=[],Qi(this)}Dn.open=function(){return!!this.closed&&(this.closed=!1,!0)},Dn.close=function(){return!this.closed&&(this.closed=!0,!0)},Dn.undo=function(){for(var t=this.actions,e=-1,i=t.length-1;i>=0;--i){var n=t[i];n.undo(),-1!==n.targetId&&(e=n.targetId)}return e},Dn.redo=function(){for(var t=this.actions,e=t.length,i=-1,n=0;n<e;++n){var s=t[n];s.redo(),-1!==s.targetId&&(i=s.targetId)}return i},Dn.isOpen=function(){return!this.closed},Dn.isClosed=function(){return this.closed},Dn.isEmpty=function(){return 0===this.actions.length},Dn.addAction=function(t){return!this.closed&&(this.actions.push(t),this.compact(),!0)},Dn.compact=function(){for(var t=this.actions,e=t.length,i=0;i<e;++i){var n=t[i];if(n.isIdentity())t.splice(i,1),--e,--i;else for(var s=i+1;s<e;++s){var o=t[s];if(n.type===o.type&&n.merge(o)){t.splice(s,1),--e,--i;break}}}},Dn.getTargetId=function(){for(var t=this.actions,e=t.length,i=-1,n=0;n<e;++n){var s=t[n];-1!==s.targetId&&(i=s.targetId)}return i};var Bn=Rn.prototype;function Nn(t,e,i,n){m.call(this,t,"CLONE-MARKUP",e),this.clone=i.clone(),this.clone.id=e,this.position={x:n.x,y:n.y}}Bn.execute=function(t){var e=this.redoStack,i=this.undoStack;e.splice(0,e.length),t.redo();var n=this.getEditActionGroup();n.isOpen()?n.addAction(t):(n.open(),n.addAction(t),n.close()),i.length>this.historySize&&i.splice(0,1);var s=t.selectOnExecution?t.targetId:-1;this.dispatchEvent({type:D,data:{action:"execute",targetId:s}})},Bn.beginActionGroup=function(){var t=this.undoStack,e=t.length;0===e||t[e-1].isClosed()?this.getEditActionGroup().open():console.warn("Markups - Undo/Redo - Action edit group already open.")},Bn.closeActionGroup=function(){var t=this.undoStack,e=t.length;if(0!==e){var i=t[e-1];i.close()||console.warn("Markups - Undo/Redo - Action edit group already closed."),i.isEmpty()&&t.pop()}else console.warn("Markups - Undo/Redo - There is no action edit group to close.")},Bn.cancelActionGroup=function(){var t=this.undoStack,e=t.length;if(0!==e){var i=t[e-1];i.close()?(i.undo(),t.pop(),this.dispatchEvent({type:D,data:{action:"cancel",targetId:-1}})):console.warn("Markups - Undo/Redo - Action edit group already closed.")}else console.warn("Markups - Undo/Redo - There is no action edit group to close.")},Bn.undo=function(){var t=this.undoStack,e=this.redoStack;if(0!==t.length){var i=t.pop(),n=i.undo();e.push(i),this.dispatchEvent({type:D,data:{action:"undo",targetId:n}})}},Bn.redo=function(){var t=this.undoStack,e=this.redoStack;if(0!==e.length){var i=e.pop(),n=i.redo();t.push(i),this.dispatchEvent({type:D,data:{action:"redo",targetId:n}})}},Bn.clear=function(){this.undoStack.splice(0,this.undoStack.length),this.redoStack.splice(0,this.redoStack.length),this.dispatchEvent({type:D,data:{action:"clear",targetId:-1}})},Bn.isUndoStackEmpty=function(){return 0===this.undoStack.length},Bn.isRedoStackEmpty=function(){return 0===this.redoStack.length},Bn.getLastElementInUndoStack=function(){var t=this.undoStack;return t[t.length-1]},Bn.getEditActionGroup=function(){var t=this.undoStack,e=this.undoStack.length,i=null;return 0===e||t[e-1].isClosed()?(i=new zn,t.push(i)):i=t[e-1],i},Nn.prototype=Object.create(m.prototype),Nn.prototype.constructor=Nn;var Vn=Nn.prototype;function Ln(t){this.editor=t,this.content=null,this.pastePosition={x:0,y:0},Qi(this)}Vn.redo=function(){var t=this.editor,e=this.clone,i=this.position;if(!t.getMarkup(this.targetId)){var n=e.clone();n.setPosition(i.x,i.y),t.addMarkup(n)}},Vn.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&this.editor.removeMarkup(t)};var Hn=Ln.prototype;Hn.copy=function(){var t=this.editor.getSelection();t&&(this.content=t.clone(),this.pastePosition.x=t.position.x,this.pastePosition.y=t.position.y)},Hn.cut=function(){var t=this.editor.getSelection();t&&(this.copy(),this.editor.deleteMarkup(t))},Hn.paste=function(){var t=this.content;if(t){var e=this.editor,i=this.pastePosition,n=e.sizeFromClientToMarkups(20,20);i.x+=n.x,i.y-=n.y,new Nn(e,e.getId(),t,i).execute()}};var _n=Autodesk.Viewing,On=_n.Private,Fn=!1,Un=!1,jn=!1;function Gn(){this.editor=null,this.mousePosition={x:0,y:0},this.makeSameXY=!1,this.snapRotations=!1,this.keepAspectRatio=!1,this.constrainAxis=!1,this.duringEditMode=!1,this.onWheelBinded=this.onWheel.bind(this),this.onTouchDragBinded=this.onTouchDrag.bind(this),this.onTouchPanBinded=this.onTouchPan.bind(this),this.onTouchPinchBinded=this.onTouchPinch.bind(this),this.onSingleTapBinded=this.onSingleTap.bind(this),this.onDoubleTapBinded=this.onDoubleTap.bind(this),this.onMouseMoveBinded=this.onMouseMove.bind(this),this.onMouseUpBinded=this.onMouseUp.bind(this),this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseDoubleClickBinded=this.onMouseDoubleClick.bind(this),this.onHammerInputBinded=this.onHammerInput.bind(this),this.isMouseDown=!1}_n.GlobalManagerMixin.call(Gn.prototype);var Wn=Gn.prototype;function Xn(t,e){var i=t.editor.svg.getBoundingClientRect();t.makeSameXY=e.shiftKey,t.snapRotations=e.shiftKey,t.keepAspectRatio=e.shiftKey,t.constrainAxis=e.shiftKey,t.mousePosition.x=e.clientX-i.left,t.mousePosition.y=e.clientY-i.top}function Yn(t){t.shiftKey=!1,t.clientX=t.pointers[0].clientX,t.clientY=t.pointers[0].clientY}function Kn(t,e,i){m.call(this,t,"SET-POSITION",e.id),this.newPosition={x:i.x,y:i.y},this.oldPosition={x:e.position.x,y:e.position.y}}Wn.attachTo=function(t){this.editor&&this.detachFrom(this.editor),this.editor=t,Bi()&&(this.hammer=new _n.Hammer.Manager(t.svg,{recognizers:[_n.GestureRecognizers.drag,_n.GestureRecognizers.doubletap,_n.GestureRecognizers.doubletap2,_n.GestureRecognizers.singletap,_n.GestureRecognizers.singletap2,_n.GestureRecognizers.press,_n.GestureRecognizers.pan,_n.GestureRecognizers.pinch],handlePointerEventMouse:!1,inputClass:_n.isIE11?_n.Hammer.PointerEventInput:_n.Hammer.TouchInput}),this.hammer.get("doubletap2").recognizeWith("doubletap"),this.hammer.get("singletap2").recognizeWith("singletap"),this.hammer.get("singletap").requireFailure("doubletap"))},Wn.onHammerInput=function(t){this.setMouseDisabledWhenTouching(t)},Wn.setMouseDisabledWhenTouching=function(t){if(t.isFirst&&!jn)this.enableMouseButtons(!1),jn=!0;else if(t.isFinal){var e=this;setTimeout(function(){e.enableMouseButtons(Un),jn=!1},10)}},Wn.enableMouseButtons=function(t){t&&!Fn?(this.editor.svg.addEventListener("mousedown",this.onMouseDownBinded),this.editor.svg.addEventListener("dblclick",this.onMouseDoubleClickBinded),this.editor.svg.addEventListener("wheel",this.onWheelBinded),this.editor.svg.addEventListener("DOMMouseScroll",this.onWheelBinded),this.addDocumentEventListener("mousemove",this.onMouseMoveBinded),this.addDocumentEventListener("mouseup",this.onMouseUpBinded)):!t&&Fn&&(this.editor.svg.removeEventListener("mousedown",this.onMouseDownBinded),this.editor.svg.removeEventListener("dblclick",this.onMouseDoubleClickBinded),this.editor.svg.removeEventListener("wheel",this.onWheelBinded),this.editor.svg.removeEventListener("DOMMouseScroll",this.onWheelBinded),this.removeDocumentEventListener("mousemove",this.onMouseMoveBinded),this.removeDocumentEventListener("mouseup",this.onMouseUpBinded)),Un=Fn,Fn=t},Wn.detachFrom=function(t){this.hammer&&this.hammer.destroy(),this.removeDocumentEventListener("mousemove",this.onMouseMoveBinded),this.removeDocumentEventListener("mouseup",this.onMouseUpBinded),this.editor&&(this.editor.svg.removeEventListener("mousedown",this.onMouseDownBinded),this.editor.svg.removeEventListener("dblclick",this.onMouseDoubleClickBinded)),this.editor=t},Wn.enterEditMode=function(){this.duringEditMode||(this.hammer&&(this.hammer.on("dragstart dragmove dragend",this.onTouchDragBinded),this.hammer.on("panstart panmove panend",this.onTouchPanBinded),this.hammer.on("pinchstart pinchmove pinchend",this.onTouchPinchBinded),this.hammer.on("singletap",this.onSingleTapBinded),this.hammer.on("singletap2",this.onSingleTapBinded),this.hammer.on("doubletap",this.onDoubleTapBinded),this.hammer.on("doubletap2",this.onDoubleTapBinded),this.hammer.on("hammer.input",this.onHammerInputBinded),this.hammer.get("drag").requireFailure("pinch"),this.hammer.get("drag").requireFailure("pan")),_n.isMobileDevice()||this.enableMouseButtons(!0),this.duringEditMode=!0)},Wn.leaveEditMode=function(){this.duringEditMode&&(this.hammer&&(this.hammer.off("dragstart dragmove dragend",this.onTouchDragBinded),this.hammer.off("panstart panmove panend",this.onTouchPanBinded),this.hammer.off("pinchstart pinchmove pinchend",this.onTouchPinchBinded),this.hammer.off("singletap",this.onSingleTapBinded),this.hammer.off("singletap2",this.onSingleTapBinded),this.hammer.off("doubletap",this.onDoubleTapBinded),this.hammer.off("doubletap2",this.onDoubleTapBinded),this.hammer.off("hammer.input",this.onHammerInputBinded)),_n.isMobileDevice()||this.enableMouseButtons(!1),this.duringEditMode=!1)},Wn.enterViewMode=function(){},Wn.leaveViewMode=function(){},Wn.getMousePosition=function(){return{x:this.mousePosition.x,y:this.mousePosition.y}},Wn.onWheel=function(t){_n.isMobileDevice()||this.editor.viewer.toolController.mousewheel(t),t.preventDefault()},Wn.onMouseMove=function(t){Xn(this,t),_n.isMobileDevice()||this.editor.viewer.toolController.mousemove(t),this.editor.onMouseMove(t),t.preventDefault()},Wn.onMouseDownRightClick=function(t){const e=this.getDocument();_n.isIE11&&_n.inFullscreen()||e.activeElement&&e.activeElement.blur&&e.activeElement.blur(),this.editor.viewer.toolController.__clientToCanvasCoords(t),this.editor.markupTool.handleButtonDown(t,2)},Wn.onMouseUpRightClick=function(t){this.editor.viewer.toolController.__clientToCanvasCoords(t),this.editor.markupTool.handleButtonUp(t,2)},Wn.onMouseDown=function(t){Xn(this,t),_n.isMobileDevice()||!On.isRightClick(t,this.editor.viewer.navigation)&&!On.isMiddleClick(t)?(this.isMouseDown=!0,this.editor.onMouseDown(t),t.preventDefault()):this.onMouseDownRightClick(t)},Wn.onMouseUp=function(t){Xn(this,t),_n.isMobileDevice()||!On.isRightClick(t,this.editor.viewer.navigation)&&!On.isMiddleClick(t)?(this.isMouseDown=!1,this.editor.onMouseUp(t),t.preventDefault()):this.onMouseUpRightClick(t)},Wn.onMouseDoubleClick=function(t){Xn(this,t),this.editor.onMouseDoubleClick(t),t.preventDefault()},Wn.onTouchDrag=function(t){switch(Yn(t),t.type){case"dragstart":this.onMouseDown(t);break;case"dragmove":this.onMouseMove(t);break;case"dragend":this.onMouseUp(t)}t.preventDefault()},Wn.onTouchPan=function(t){this.editor.viewer.toolController.getTool("gestures").distributeGesture(t),t.preventDefault()},Wn.onTouchPinch=function(t){Xn(this,t),this.editor.viewer.toolController.getTool("gestures").distributeGesture(t),this.mousePosition.x=this.mousePosition.y=null,this.editor.callSnapperMouseMove(),t.preventDefault()},Wn.onSingleTap=function(t){Yn(t),this.onMouseDown(t),this.onMouseUp(t),t.preventDefault()},Wn.onDoubleTap=function(t){Yn(t),this.onMouseDoubleClick(t),t.preventDefault()},Kn.prototype=Object.create(m.prototype),Kn.prototype.constructor=Kn;var qn=Kn.prototype;function $n(t,e,i){m.call(this,t,"SET-ROTATION",e.id);var n=e.getRotation();this.newRotation={angle:i},this.oldRotation={angle:n}}qn.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setPosition(this.newPosition.x,this.newPosition.y)},qn.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setPosition(this.oldPosition.x,this.oldPosition.y)},qn.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newPosition=t.newPosition,!0)},qn.isIdentity=function(){var t=this.newPosition,e=this.oldPosition;return t.x===e.x&&t.y===e.y},$n.prototype=Object.create(m.prototype),$n.prototype.constructor=$n;var Zn=$n.prototype;Zn.redo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setRotation(this.newRotation.angle)},Zn.undo=function(){var t=this.editor.getMarkup(this.targetId);t&&t.setRotation(this.oldRotation.angle)},Zn.merge=function(t){return this.targetId===t.targetId&&this.type===t.type&&(this.newRotation=t.newRotation,!0)},Zn.isIdentity=function(){return this.newRotation.angle===this.oldRotation.angle};var Jn=Autodesk.Viewing,Qn=Autodesk.Viewing.Private;function ts(t,e){this.containingDiv=t,this.editor=e,this.setGlobalManager(this.editor.viewer.globalManager),this.selectionLayer=function(){var t=this.getDocument().createElement("div");return t.style.position="absolute",t.style.top=0,t.style.bottom=0,t.style.left=0,t.style.right=0,t.style.overflow="hidden",t.style.visibility="hidden",cs(t,!1),t}.bind(this)(),this.frameMargin=Ri,this.selection={x:0,y:0,width:0,height:0,rotation:0,element:null,active:!1,dragging:!1,resizing:!1,handle:{}},function(){var t=this.getDocument().createElement("div");cs(t,!0),t.classList.add("selector-box"),this.selection.rotationBridge=function(){var t=this.getDocument().createElement("div");return t.classList.add("adsk-viewing-viewer"),t.classList.add("selector-rotate-point"),t.classList.add("autodesk-markups-extension-core-make-me-bigger"),t.classList.add("rotation-bridge"),ns(t,"w"),t}.bind(this)(),t.appendChild(this.selection.rotationBridge),this.selection.rotationHandle=function(){var t=this.getDocument().createElement("div");return t.classList.add("adsk-viewing-viewer"),t.classList.add("selector-rotate-point"),t.classList.add("autodesk-markups-extension-core-make-me-bigger"),ns(t,"w"),t}.bind(this)(),t.appendChild(this.selection.rotationHandle),function(t){["n","s","w","e","nw","ne","sw","se"].forEach(function(e){this.selection.handle[e]=function(t){var e=this.getDocument().createElement("div");return ns(e,t),e.className="selector-drag-point autodesk-markups-extension-core-make-me-bigger sdp-handle-"+t,e.classList.add("adsk-viewing-viewer"),e.setAttribute("data-sdp-handle",t),e}.call(this,e),t.appendChild(this.selection.handle[e])}.bind(this))}.bind(this)(t),this.selection.element=t,Jn.isMobileDevice()||(this.onWheelBinded=this.onWheel.bind(this),this.selection.element.addEventListener("wheel",this.onWheelBinded),this.selection.element.addEventListener("DOMMouseScroll",this.onWheelBinded));return this.selectionLayer.appendChild(this.selection.element),rs.bind(this)(!1),t}.bind(this)(),Bi()&&(this.hammer=new Jn.Hammer.Manager(this.selectionLayer,{recognizers:[Jn.GestureRecognizers.drag,Jn.GestureRecognizers.doubletap,Jn.GestureRecognizers.doubletap2,Jn.GestureRecognizers.pan,Jn.GestureRecognizers.pinch],handlePointerEventMouse:!1,inputClass:Jn.isIE11?Jn.Hammer.PointerEventInput:Jn.Hammer.TouchInput}),this.onHammerDragBinded=this.onHammerDrag.bind(this),this.onHammerDoubleTapBinded=this.onHammerDoubleTap.bind(this),this.onTouchPanBinded=this.onTouchPan.bind(this),this.onTouchPinchBinded=this.onTouchPinch.bind(this),this.hammer.on("dragstart dragmove dragend",this.onHammerDragBinded),this.hammer.on("doubletap",this.onHammerDoubleTapBinded),this.hammer.on("doubletap2",this.onHammerDoubleTapBinded),this.hammer.on("panstart panmove panend",this.onTouchPanBinded),this.hammer.on("pinchstart pinchmove pinchend",this.onTouchPinchBinded),this.hammer.get("drag").requireFailure("pinch"),this.hammer.get("drag").requireFailure("pan")),function(){this.selection.element.addEventListener("mousedown",this._onRepositionMouseDown.bind(this))}.bind(this)(),function(){this.selectionLayer.addEventListener("mousedown",this._onResizeMouseDown.bind(this))}.bind(this)(),function(){var t=function(t){if(!t.defaultPrevented){this.selection.dragging=!1;var e=this.editor.editMode;e&&e.onMouseDoubleClick(this.markup)}}.bind(this);this.selectionLayer.addEventListener("dblclick",t)}.bind(this)(),function(){this.selection.element.addEventListener("mousedown",this._onRotationMouseDown.bind(this))}.bind(this)(),this.containingDiv.appendChild(this.selectionLayer),Qi(this)}Jn.GlobalManagerMixin.call(ts.prototype);var es=ts.prototype;function is(t){t.pageX=t.pointers[0].clientX,t.pageY=t.pointers[0].clientY}function ns(t,e){var i;switch(e){case"n":case"s":i="ns-resize";break;case"w":case"e":i="ew-resize";break;case"ne":case"sw":i="nesw-resize";break;case"nw":case"se":i="nwse-resize"}t.style.cursor=i}function ss(t){return fs(t,".selector-drag-point")}function os(t){return fs(t,".selector-rotate-point")}function rs(t){this.selection.active=t,this.selection.element.style.display=t?"block":"none"}function as(t,e,i){this.selection.x=t,this.selection.y=e,this.selection.rotation=i;var n=this.markup.getBoundingRect();n.width+=2*this.frameMargin,n.height+=2*this.frameMargin;var s=function(t,e){return"translate3d("+t+"px,"+e+"px,0)"}(t,e)+" rotate("+i+"rad)",o=n.width/2+"px "+n.height/2+"px";this.selection.element.style.msTransform=this.selection.element.style.webkitTransform=this.selection.element.style.transform=s,this.selection.element.style.msTransformOrigin=this.selection.element.style.webkitTransformOrigin=this.selection.element.style.transformOrigin=o}es.unload=function(){this.containingDiv.removeChild(this.selectionLayer),this.selectionLayer=null},es.setSelection=function(t,e,i,n,s){var o=this.frameMargin,r=2*o;(function(t,e){this.selection.width=t,this.selection.height=e,this.selection.element.style.width=t+"px",this.selection.element.style.height=e+"px"}).bind(this)(i+r,n+r),as.bind(this)(t-o,e-o,s),rs.bind(this)(!0),this.selectionLayer.style.visibility="visible"},es.setMarkup=function(t){if(this.hammer&&this.hammer.set({enable:null!==t}),this.markup=t,rs.bind(this)(!1),t){var e=t.getBoundingRect(),i=t.getRotation();this.frameMargin=void 0!==e.margin?e.margin:Ri,this.setSelection(e.x,e.y,e.width,e.height,i),this.enableResizeHandles(),this.enableRotationHandle(),t.preventReposition?this.selectionLayer.firstChild.style.cursor="":this.selectionLayer.firstChild.style.cursor="move"}},es.startDrag=function(t){this.markup&&this.markup.preventReposition||(this.onMouseMove=this._onRepositionMouseMove.bind(this),this.onMouseUp=this._onRepositionMouseUp.bind(this),this._onRepositionMouseDown(t,this.editor.getMousePosition()))},es.isActive=function(){return this.selection.active},es.isDragging=function(){return this.selection.dragging},es.isResizing=function(){return this.selection.resizing},es.isRotating=function(){return this.selection.rotating},es.onMouseMove=function(t){},es.onMouseUp=function(t){},es.onWheel=function(t){this.editor.viewer.toolController.mousewheel(t)},es.onTouchPan=function(t){this.editor.viewer.toolController.getTool("gestures").distributeGesture(t),t.preventDefault()},es.onTouchPinch=function(t){this.editor.viewer.toolController.getTool("gestures").distributeGesture(t),t.preventDefault()},es.onHammerDrag=function(t){function e(t,e,i){var n=e.getBoundingClientRect();t.mousePosition.x=i.pageX-n.left,t.mousePosition.y=i.pageY-n.top}switch(is(t),t.type){case"dragstart":e(this.editor.input,this.editor.svg,t),this.editor.callSnapperMouseDown(),os(t.target)?this._onRotationMouseDown(t):ss(t.target)?this._onResizeMouseDown(t):this.startDrag(t),t.preventDefault();break;case"dragmove":e(this.editor.input,this.editor.svg,t),this.editor.callSnapperMouseMove(),this.onMouseMove(t),t.preventDefault();break;case"dragend":e(this.editor.input,this.editor.svg,t),this.onMouseUp(t),t.preventDefault()}},es.onHammerDoubleTap=function(t){is(t),function(t,e,i){var n=e.getBoundingClientRect();t.mousePosition.x=i.pageX-n.left,t.mousePosition.y=i.pageY-n.top}(this.editor.input,this.editor.svg,t),this.selection.dragging=!1,this.editor.editMode&&this.editor.editMode.onMouseDoubleClick(this.markup)},es.enableResizeHandles=function(){var t,e=this.markup;if(e.isHeightConstrained()||e.isWidthConstrained()){for(var i in this.selection.handle)(t=this.selection.handle[i])&&(t.style.display="none");e.isHeightConstrained()||(this.selection.handle.n.style.display="block",this.selection.handle.s.style.display="block"),e.isWidthConstrained()||(this.selection.handle.w.style.display="block",this.selection.handle.e.style.display="block")}else for(var i in this.selection.handle)(t=this.selection.handle[i])&&(t.style.display="block")},es.enableRotationHandle=function(){var t=this.markup.isRotationConstrained()?"none":"block";this.selection.rotationHandle.style.display=t,this.selection.rotationBridge.style.display=t},es._handleRightClickDown=function(t){return!(Jn.isMobileDevice()||!Qn.isRightClick(t,this.editor.viewer.navigation)&&!Qn.isMiddleClick(t))&&(this.editor.input.onMouseDownRightClick(t),!0)};var hs,ls,us=!1;function ds(t,e){e?t.classList.add("selected"):t.classList.remove("selected")}function cs(t,e){t.style.pointerEvents=e?"auto":"none"}function ps(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}function fs(t,e){return t.matches?t.matches(e):t.msMatchesSelector?t.msMatchesSelector(e):t.mozMatchesSelector?t.mozMatchesSelector(e):!!t.webkitMatchesSelector&&t.webkitMatchesSelector(e)}es._onRepositionMouseDown=function(t,e){if(this._handleRightClickDown(t))return;if(this.markup&&this.markup.preventReposition)return;us=!Jn.isMobileDevice()&&Jn.isTouchDevice();var i=!(t instanceof this.getWindow().MouseEvent);if((i||!ss(t.target)&&!os(t.target))&&(e=i?e:this.editor.getMousePosition(),this.initialCursor=e,this.initialPosition=this.markup.getClientPosition(),this.areAxisConstrained=!1,this.axisConstrains=new THREE.Vector2(1,1),this.onMouseMove=this._onRepositionMouseMove.bind(this),this.onMouseUp=this._onRepositionMouseUp.bind(this),!this.selection.dragging)){if(this.selection.dragging=!0,this.editor.beginActionGroup(),t&&t.altKey){var n=this.editor;new Nn(n,n.getId(),this.markup,this.markup.position).execute()}this.dispatchEvent({type:V})}},es._onRepositionMouseMove=function(t){if(us)us=!1;else if(this.selection.dragging&&this.markup&&!this.markup.preventReposition){var e=this.editor.getMousePosition(),i=this.editor.input.constrainAxis;this.areAxisConstrained!==i&&(this.areAxisConstrained=i,this.axisConstrains=i?new THREE.Vector2(0,0):new THREE.Vector2(1,1),this.initialPosition.x+=e.x-this.initialCursor.x,this.initialPosition.y+=e.y-this.initialCursor.y,this.initialCursor.x=e.x,this.initialCursor.y=e.y);var n={x:e.x-this.initialCursor.x,y:e.y-this.initialCursor.y};0===this.axisConstrains.x&&0===this.axisConstrains.y&&(Math.abs(n.x)>15?(this.axisConstrains.x=1,n.x+=n.x<0?15:-15):Math.abs(n.y)>15&&(this.axisConstrains.y=1,n.y+=n.y<0?15:-15));var s=this.initialPosition.x+n.x*this.axisConstrains.x,o=this.initialPosition.y+n.y*this.axisConstrains.y;as.bind(this)(s,o,this.selection.rotation);var r=this.editor.positionFromClientToMarkups(s,o);new Kn(this.editor,this.markup,r).execute()}},es._onRepositionMouseUp=function(){this.markup&&this.markup.preventReposition||(this.last=null,this.onMouseMove=function(){},this.onMouseUp=function(){},this.selection.dragging&&(this.editor.closeActionGroup(),this.selection.dragging=!1,this.dispatchEvent({type:L})))},es._onResizeMouseDown=function(t){if(!this._handleRightClickDown(t)){var e=t.target;if(ss(e)){this.selection.handle.resizing=e;var i=this.selection.handle.resizing.getAttribute("data-sdp-handle");this.containingDiv.style.cursor=i+"-resize";var n=this.editor.getMousePosition(),s=this.markup.getClientPosition(),o=this.markup.getBoundingRect();this.initial={x:s.x,y:s.y,width:o.width,height:o.height,mouseX:n.x,mouseY:n.y},this.onMouseMove=this._onResizeMouseMove.bind(this),this.onMouseUp=this._onResizeMouseUp.bind(this),this.selection.resizing||(this.selection.resizing=!0,this.editor.beginActionGroup(),ds(t.target,!0),this.dispatchEvent({type:V}))}}},es._onResizeMouseMove=function(t){if(this.selection.resizing){var e=this.editor.getMousePosition(),i=this.initial,n={x:e.x-i.mouseX,y:e.y-i.mouseY},s=new THREE.Vector3(n.x,n.y,0),o=(new THREE.Matrix4).makeRotationZ(-this.selection.rotation);n=s.applyMatrix4(o);var r=i.x,a=i.y,h=i.width,l=i.height,u=new THREE.Vector3,d=this.selection.handle.resizing.getAttribute("data-sdp-handle");if(this.editor.input.keepAspectRatio&&-1!==["nw","ne","sw","se"].indexOf(d)){var c=new THREE.Vector3(n.x,n.y,0);switch(d){case"nw":n.set(-i.width,-i.height,0);break;case"ne":case"sw":n.set(i.width,-i.height,0);break;case"se":n.set(i.width,i.height,0)}n.normalize(),n=c.projectOnVector(n)}if({n:function(){l-=n.y,u.y=n.y},s:function(){l+=n.y,u.y=n.y},w:function(){h-=n.x,u.x=n.x},e:function(){h+=n.x,u.x=n.x},nw:function(){this.n(),this.w()},ne:function(){this.n(),this.e()},sw:function(){this.s(),this.w()},se:function(){this.s(),this.e()}}[d](),!(h<=this.markup.getMinWidth()||l<=this.markup.getMinHeight())){var p=(new THREE.Matrix4).makeRotationZ(this.selection.rotation),f=u.applyMatrix4(p),y=this.editor.positionFromClientToMarkups(r+.5*f.x,a+.5*f.y),g=this.editor.sizeFromClientToMarkups(h,l);new vt(this.editor,this.markup,y,g.x,g.y).execute()}}},es._onResizeMouseUp=function(t){for(var e in this.selection.resizing=!1,this.selection.handle.resizing=null,this.containingDiv.style.cursor="",this.selection.handle)this.selection.handle[e]&&ds(this.selection.handle[e],!1);this.editor.closeActionGroup(),this.dispatchEvent({type:L}),this.onMouseMove=function(){},this.onMouseUp=function(){}},es._onRotationMouseDown=function(t){this._handleRightClickDown(t)||os(t.target)&&(this.editor.beginActionGroup(),this.selection.rotating=!0,ls=this.editor.getMousePosition(),hs=this.selection.rotation||0,this.onMouseMove=this._onRotationMouseMove.bind(this),this.onMouseUp=this._onRotationMouseUp.bind(this),ds(t.target,!0),this.dispatchEvent({type:V}))},es._onRotationMouseMove=function(t){if(this.selection.rotating){var e=this.editor.getMousePosition(),i=this.markup.getClientPosition(),n=ps(i,e)-ps(i,ls)+hs;if(this.editor.input.snapRotations){var s=ln(22.5);n=Math.ceil(n/s)*s}as.bind(this)(this.selection.x,this.selection.y,n),new $n(this.editor,this.markup,n).execute()}},es._onRotationMouseUp=function(t){this.selection.rotating=!1,hs=null,ls=null,ds(this.selection.rotationHandle,!1),this.editor.closeActionGroup(),this.dispatchEvent({type:L})};var ys=Autodesk.Viewing.Private;function gs(){Autodesk.Viewing.ToolInterface.call(this),this.names=["markups.core"],this.panTool=null,this.allowNav=!1,this.is2d=!1,this.coreExt=null,this.hotkeysEnabled=!0;var t=!1,e=!1;this.allowNavigation=function(t){this.allowNav=t},this.setCoreExtension=function(t){this.coreExt=t},this.setHotkeysEnabled=function(t){this.hotkeysEnabled=t},this.activate=function(t,e){this.panTool=e.toolController.getTool("pan"),this.panTool&&this.panTool.activate("pan"),this.is2d=e.model.is2d(),this.viewer=e},this.deactivate=function(t){this.panTool&&this.panTool.deactivate("pan")},this.handleKeyDown=function(i,n){if(!this.coreExt.editMode)return!1;if(!this.hotkeysEnabled)return!0;switch(n){case Autodesk.Viewing.KeyCode.CONTROL:t=!0;break;case Autodesk.Viewing.KeyCode.SHIFT:e=!0;break;case Autodesk.Viewing.KeyCode.x:t&&!this.allowNav&&this.coreExt.cut();break;case Autodesk.Viewing.KeyCode.c:t&&!this.allowNav&&this.coreExt.copy();break;case Autodesk.Viewing.KeyCode.v:t&&!this.allowNav&&this.coreExt.paste();break;case Autodesk.Viewing.KeyCode.d:t&&!this.allowNav&&(this.coreExt.copy(),this.coreExt.paste());break;case Autodesk.Viewing.KeyCode.z:!t||e||this.allowNav?t&&e&&!this.allowNav&&this.coreExt.redo():this.coreExt.undo();break;case Autodesk.Viewing.KeyCode.y:t&&!this.allowNav&&this.coreExt.redo();break;case Autodesk.Viewing.KeyCode.ESCAPE:this.coreExt.onUserCancel();break;case Autodesk.Viewing.KeyCode.BACKSPACE:case Autodesk.Viewing.KeyCode.DELETE:var s=this.coreExt.getSelection();s&&this.coreExt.deleteMarkup(s);break;case Autodesk.Viewing.KeyCode.F12:return!1}return!0},this.handleKeyUp=function(i,n){if(!this.coreExt.editMode)return!1;if(!this.hotkeysEnabled)return!0;switch(n){case Autodesk.Viewing.KeyCode.CONTROL:t=!1;break;case Autodesk.Viewing.KeyCode.SHIFT:e=!1}return!0},this.update=function(){return!!(this.allowNav&&this.panTool&&this.panTool.update)&&this.panTool.update()},this.handleSingleClick=function(t,e){return!this.allowNav||!(!this.panTool||!this.panTool.handleSingleClick)&&this.panTool.handleSingleClick(t,e)},this.handleDoubleClick=function(t,e){return!this.allowNav||!(!this.panTool||!this.panTool.handleDoubleClick)&&this.panTool.handleDoubleClick(t,e)},this.handleSingleTap=function(t){return!this.allowNav||!(!this.panTool||!this.panTool.handleSingleTap)&&this.panTool.handleSingleTap(t)},this.handleDoubleTap=function(t){return!this.allowNav||!(!this.panTool||!this.panTool.handleDoubleTap)&&this.panTool.handleDoubleTap(t)},this.handleWheelInput=function(t,e){return!this.allowNav&&!this.is2d||!(!this.panTool||!this.panTool.handleWheelInput)&&(this.coreExt.callSnapperMouseMove(),this.panTool.handleWheelInput(t,e))},this.handleButtonDown=function(t,e){return!(this.allowNav||this.is2d&&(ys.isRightClick(t,this.viewer.navigation)||ys.isMiddleClick(t)))||!(!this.panTool||!this.panTool.handleButtonDown)&&this.panTool.handleButtonDown(t,e)},this.handleButtonUp=function(t,e){return!(this.allowNav||this.is2d&&(ys.isRightClick(t,this.viewer.navigation)||ys.isMiddleClick(t)))||!(!this.panTool||!this.panTool.handleButtonUp)&&this.panTool.handleButtonUp(t,e)},this.handleMouseMove=function(t){return!this.allowNav&&!this.is2d||!(!this.panTool||!this.panTool.handleMouseMove)&&this.panTool.handleMouseMove(t)},this.handleGesture=function(t){return!this.allowNav&&!this.is2d||!(!this.panTool||!this.panTool.handleGesture)&&this.panTool.handleGesture(t)},this.handleBlur=function(t){return!this.allowNav||!(!this.panTool||!this.panTool.handleBlur)&&this.panTool.handleBlur(t)}}var vs={};var ms=new class{constructor(){}register(t,e){if(t in vs)throw new Error(`EditMode with id (${t}) already registered.`);vs[t]=e}unregister(t){t in vs&&delete vs[t]}getClass(t){return vs[t]||null}getRegistered(){var t={};for(var e in vs)vs.hasOwnProperty(e)&&(t[e]=vs[e]);return t}};ms.register(a,$),ms.register(h,Kt),ms.register(l,at),ms.register(u,re),ms.register(d,ge),ms.register(c,Ie),ms.register(p,ai),ms.register(f,_e),ms.register(y,$e),ms.register(g,Vt),ms.register(v,mi);i(11);var xs=Autodesk.Viewing.MeasureCommon;function bs(t,e){Autodesk.Viewing.Extension.call(this,t,e),this.options=this.options||{},this.markups=[],this.styles={},this.activeLayer="",this.duringViewMode=!1,this.duringEditMode=!1,this.svgLayersMap={},this.actionManager=new Rn(50),this.actionManager.addEventListener(D,this.onEditActionHistoryChanged.bind(this)),this.nextId=0,this.clipboard=new Ln(this),this.input=new Gn,this.input.setGlobalManager(this.globalManager),this.createSvgElement=Ni.bind(this),this.addSvgMetadata=Xi.bind(this),this.checkPolygon=En.bind(this),Qi(this),t.addEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT,function(){this.getStrokeWidth(),this.getFontWidth()}.bind(this),{once:!0}),this.onCameraChangeBinded=this.onCameraChange.bind(this),this.onViewerResizeBinded=function(t){var e=this;e.onViewerResize(t),requestAnimationFrame(function(){e.duringViewMode&&e.onViewerResize(t)})}.bind(this),this.onMarkupSelectedBinded=this.onMarkupSelected.bind(this),this.onMarkupEnterEditionBinded=this.onMarkupEnterEdition.bind(this),this.onMarkupCancelEditionBinded=this.onMarkupCancelEdition.bind(this),this.onMarkupDeleteEditionBinded=this.onMarkupDeleteEdition.bind(this),this.onToolChangeBinded=this.onToolChange.bind(this),this.onUnitsCalibrationStartsBinded=this.onUnitsCalibrationStarts.bind(this),t.addEventListener(xs.Events.UNITS_CALIBRATION_STARTS_EVENT,this.onUnitsCalibrationStartsBinded)}bs.prototype=Object.create(Autodesk.Viewing.Extension.prototype),bs.prototype.constructor=bs;var Ms=bs.prototype;Ms.load=async function(){var t=this.svg=this.createSvgElement("svg");Vi(t);var e=new At;e.setAttribute("position","absolute"),e.setAttribute("left","0"),e.setAttribute("top","0"),e.setAttribute("transform","scale(1,-1)",{allBrowsers:!0}),e.setAttribute("transformOrigin","0, 0",{allBrowsers:!0}),t.setAttribute("style",e.getStyleString()),this.bounds={x:0,y:0,width:0,height:0},this.input.attachTo(this),this.editFrame=new ts(this.viewer.container,this),this.editFrame.addEventListener(V,function(){this.disableMarkupInteractions(!0)}.bind(this)),this.editFrame.addEventListener(L,function(){this.disableMarkupInteractions(!1)}.bind(this));var i=this.options.markupToolClass||gs;return this.changeMarkupTool(i,!this.options.markupDisableHotkeys),await this.viewer.loadExtension("Autodesk.Snapping"),this.snapper=new Autodesk.Viewing.Extensions.Snapping.Snapper(this.viewer,{markupMode:!0}),this.viewer.toolController.registerTool(this.snapper),!0},Ms.changeMarkupTool=function(t,e){this.markupTool&&(this.viewer.toolController.deregisterTool(this.markupTool),this.markupTool=null),this.markupTool=new t,this.markupTool.setCoreExtension(this),this.markupTool.setHotkeysEnabled(e),this.viewer.toolController.registerTool(this.markupTool)},Ms.unload=function(){this.hide(),this.input.detachFrom(this),this.editFrame.unload(),this.markupTool&&(this.viewer.toolController.deregisterTool(this.markupTool),this.markupTool=null),this.snapper&&(this.viewer.toolController.deregisterTool(this.snapper),this.snapper=null);var t=this.svg;return t&&this.onMouseDownBinded&&(t.removeEventListener("mousedown",this.onMouseDownBinded),this.onMouseDownBinded=null),t.parentNode&&t.parentNode.removeChild(t),this.editModeSvgLayerNode=null,this.svg=null,!0},bs.prototype.getStrokeWidth=function(){return(!this.initialStrokeWidth||this.viewer.model&&!this.viewer.model.is2d())&&(this.initialStrokeWidth=this.sizeFromClientToMarkups(0,Ii).y),this.initialStrokeWidth},bs.prototype.getFontWidth=function(){return(!this.initialFontWidth||this.viewer.model&&!this.viewer.model.is2d())&&(this.initialFontWidth=this.sizeFromClientToMarkups(0,zi).y),this.initialFontWidth},bs.prototype.toggleEditMode=function(){this.duringEditMode?this.leaveEditMode():this.enterEditMode()},bs.prototype.enterEditMode=function(t){function e(t,e){if(t)for(var i=t.markups,n=0;n<i.length;n++){i[n].disableInteractions(e)}}if(t&&!this.svgLayersMap[t])return console.warn("No such layer exists."),!1;if(!this.duringViewMode&&!this.show())return!1;if(!this.editModeSvgLayerNode){var i=this.createSvgElement("g");this.editModeSvgLayerNode={markups:[],svg:i},this.editModeSvgLayerNode.svg.setAttribute("cursor","default")}if(this.editModeSvgLayerNode.svg.parentNode==this.svg&&t||this.svg.appendChild(this.editModeSvgLayerNode.svg),this.svg.setAttribute("cursor","crosshair"),t){var n=this.svgLayersMap[t];if(n){var s=this.editModeSvgLayerNode.svg.parentNode;for(var o in s&&s.removeChild(this.editModeSvgLayerNode.svg),e(this.editModeSvgLayerNode,!0),this.svgLayersMap)for(var r=this.svgLayersMap[o].markups,a=0;a<r.length;a++){var h=r[a];o!==t.toString()?h.disableInteractions(!0):h.disableInteractions(!1)}this.activeLayer=t,this.editingLayer=t;var l=n.svg;l.parentNode&&this.svg.removeChild(l),this.markups=n.markups.slice(),this.svg.appendChild(l)}}else{if(this.editingLayer){for(var u=0;u<this.markups.length;u++){this.markups[u].disableInteractions(!0)}e(this.editModeSvgLayerNode,!1)}this.editingLayer="",this.editModeSvgLayerNode?this.markups=this.editModeSvgLayerNode.markups.slice():this.markups=[],this.activeLayer=""}return this.input.enterEditMode(),this.activateTool(!0),this.styles={},this.defaultStyle=null,this.duringEditMode=!0,this.changeEditMode(new $(this)),this.actionManager.clear(),this.dispatchEvent({type:T}),this.allowNavigation(!1),!0},bs.prototype.leaveEditMode=function(){return!this.duringEditMode||!this.duringViewMode||!!this.viewer&&(this.editMode.destroy(),this.editMode=null,this.duringEditMode=!1,this.snapper&&(this.snapper.indicator.clearOverlays(),this.snapper.clearSnapped()),this.editModeSvgLayerNode&&this.editModeSvgLayerNode.svg.parentNode&&this.svg.removeChild(this.editModeSvgLayerNode.svg),this.svg.setAttribute("cursor","default"),this.input.leaveEditMode(),this.editFrame.setMarkup(null),this.activateTool(!0),this.allowNavigation(!0),this.dispatchEvent({type:C}),!0)},bs.prototype.toggle=function(){this.duringViewMode?this.hide():this.show()},bs.prototype.show=function(){var t=this.viewer;if(!t||!t.model||!this.svg)return!1;if(this.duringViewMode||this.duringEditMode)return!0;t.addEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT,this.onCameraChangeBinded),t.addEventListener(Autodesk.Viewing.VIEWER_RESIZE_EVENT,this.onViewerResizeBinded),t.container.appendChild(this.svg),t.reorderElements(this.svg),this.input.enterViewMode(),cn(t),this.onViewerRolloverObject=t.impl.rolloverObject,t.impl.rolloverObject=function(){},this.activateTool(!0);var e=t.impl.camera;return this.onViewerResize({width:e.clientWidth,height:e.clientHeight}),this.svgLayersMap={},this.duringViewMode=!0,this.allowNavigation(!0),!0},bs.prototype.hide=function(){var t=this.viewer;if(!t||!this.duringViewMode)return!0;if(this.duringEditMode&&!this.leaveEditMode())return!1;t.removeEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT,this.onCameraChangeBinded),t.removeEventListener(Autodesk.Viewing.VIEWER_RESIZE_EVENT,this.onViewerResizeBinded);var e=this.svg;return e.parentNode&&e.parentNode.removeChild(e),this.unloadMarkupsAllLayers(),Ki(e),this.input.leaveViewMode(),pn(t),this.viewer.impl.rolloverObject=this.onViewerRolloverObject,this.activateTool(!1),this.duringViewMode=!1,!0},bs.prototype.clear=function(){if(this.duringEditMode){var t=this.editingLayer?this.svgLayersMap[this.editingLayer]:this.editModeSvgLayerNode;if(t){var e=t.markups,i=t.svg;if(i&&i.childNodes.length>0)for(;i.childNodes.length;)i.removeChild(i.childNodes[0]);for(;e.length>0;){var n=e[0];this.removeMarkup(n),n.destroy()}}}else console.warn("Clear only removes markups when in Edit Mode.")},bs.prototype.generateData=function(){var t=this.editModeSvgLayerNode.svg;this.editMode&&this.editMode.onSave(),Ki(this.svg),this.activeLayer&&(t=this.svgLayersMap[this.activeLayer].svg);var e=this.createSvgElement("svg");qi(this.svg,e),qi(t,this.svg);var i=[this.addSvgMetadata(this.svg,{"data-model-version":"4"})];this.markups.forEach(function(t){var e=t.setMetadata();e&&i.push(e)});var n=Zi(this.svg);return i.forEach(function(t){t.parentNode.removeChild(t)}),qi(this.svg,t),qi(e,this.svg),e=null,n},bs.prototype.generatePoints3d=function(){var t={markups:[],main:null},e=this.markups,i=e.length;if(0===i)return t;for(var n=this.viewer.impl.renderer().readbackTargetId(),s=0;s<i;++s){var o=e[s],r=o.generatePoint3d(n)||null;t.markups.push({id:o.id,type:o.type,point:r||null})}if(1===i){var h=t.markups[0].point;return t.main=h&&h.clone(),t}for(s=0;s<i;++s){var l=t.markups[s];if(l.type===a&&null!==l.point)return t.main=l.point.clone(),t}var u=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,p=Number.NEGATIVE_INFINITY;for(s=0;s<i;++s){var f=e[s].generateBoundingBox();u=Math.min(u,f.min.x),d=Math.min(d,f.min.y),c=Math.max(c,f.max.x),p=Math.max(p,f.max.y)}var y={vertexCount:4};y.xVertices=new Float32Array([u,c,c,u]),y.yVertices=new Float32Array([d,d,p,p]);var g=this.checkPolygon(y,n),v=g&&this.viewer.clientToWorld(g.x,g.y);return t.main=v&&v.point,t},bs.prototype.renderToCanvas=function(t,e,i){var n,s=this.bounds.width,o=this.bounds.height,r=this.getSvgViewBox(s,o),a=0,h=[],l=function(){e&&++a===h.length&&e()}.bind(this);if(i)for(var u=Object.keys(this.svg.childNodes),d=Object.keys(this.svgLayersMap),c=0;c<u.length;c++)for(var p=0;p<d.length;p++)n=this.svgLayersMap[d[p]],this.svg.childNodes[u[c]]===n.svg&&(h=h.concat(n.markups));else n=this.svgLayersMap[this.activeLayer]||this.editModeSvgLayerNode,h=n.markups;0===h.length?e():h.forEach(function(e){e.renderToCanvas(t,r,s,o,l)})},bs.prototype.changeEditMode=function(t){var e=this.editMode;e&&e.destroy(),t.addEventListener(R,function(){this.disableMarkupInteractions(!0)}.bind(this)),t.addEventListener(B,function(){this.disableMarkupInteractions(!1)}.bind(this)),t.addEventListener(N,function(t){this.dispatchEvent(t)}.bind(this)),this.editMode=t,this.styles[t.type]=E(t.getStyle()),this.dispatchEvent({type:k,target:t})},bs.prototype.isNavigationAllowed=function(){return!this.viewer.impl.camera.isPerspective},bs.prototype.allowNavigation=function(t){var e=this.editMode;this.navigating=t,t?(this.svg.setAttribute("pointer-events","none"),e&&this.selectMarkup(null)):this.svg.setAttribute("pointer-events","painted");for(var i=this.markups,n=i.length,s=0;s<n;++s)i[s].updateStyle();if(e&&e.notifyAllowNavigation(t),t&&(this.duringEditMode||this.duringViewMode)&&!this.isNavigationAllowed())return!1;t&&this.snapper&&(this.snapper.indicator.clearOverlays(),this.snapper.clearSnapped()),this.markupTool.allowNavigation(t)},bs.prototype.disableMarkupInteractions=function(t){this.editModeSvgLayerNode&&this.editModeSvgLayerNode.svg.setAttribute("cursor",t?"inherit":"default"),this.markups.forEach(function(e){e.disableInteractions(t)})},bs.prototype.activateTool=function(t){if(t)this.cachedNavigationTool||(this.cachedNavigationTool=this.viewer.getActiveNavigationTool(),this.viewer.addEventListener(Autodesk.Viewing.TOOL_CHANGE_EVENT,this.onToolChangeBinded)),this.viewer.setActiveNavigationTool(this.markupTool.getName());else{if(this.cachedNavigationTool)this.viewer.setActiveNavigationTool(this.cachedNavigationTool),this.cachedNavigationTool=null;else{var e=this.viewer.getDefaultNavigationToolName();this.viewer.setActiveNavigationTool(e)}this.viewer.removeEventListener(Autodesk.Viewing.TOOL_CHANGE_EVENT,this.onToolChangeBinded)}},bs.prototype.onToolChange=function(t){if(t.toolName===this.markupTool.getName()){if(t.active){var e=this.isNavigationAllowed();this.viewer.setNavigationLockSettings({pan:e,zoom:e,orbit:!1,roll:!1,fov:!1,walk:!1,gotoview:!1})}this.viewer.setNavigationLock(t.active)}},bs.prototype.onUnitsCalibrationStarts=function(t){this.duringEditMode&&this.hide()},Ms.changeInputHandler=function(t){this.input.detachFrom(this),t.attachTo(this),this.input=t,this.duringEditMode&&t.enterEditMode(),this.duringViewMode&&t.enterViewMode()},bs.prototype.copy=function(){this.clipboard.copy()},bs.prototype.cut=function(){this.clipboard.cut()},bs.prototype.paste=function(){this.clipboard.paste()},bs.prototype.undo=function(){this.actionManager.undo()},bs.prototype.redo=function(){this.actionManager.redo()},bs.prototype.isUndoStackEmpty=function(){return this.actionManager.isUndoStackEmpty()},bs.prototype.isRedoStackEmpty=function(){return this.actionManager.isRedoStackEmpty()},Ms.beginActionGroup=function(){this.actionManager.beginActionGroup()},Ms.closeActionGroup=function(){this.actionManager.closeActionGroup()},Ms.cancelActionGroup=function(){this.actionManager.cancelActionGroup()},Ms.getId=function(){return++this.nextId},Ms.onEditActionHistoryChanged=function(t){var e=t.data;if("undo"!==e.action&&-1!==e.targetId){var i=this.getMarkup(e.targetId);this.selectMarkup(i)}if("undo"===e.action&&!this.isUndoStackEmpty()){i=this.getMarkup(this.actionManager.getLastElementInUndoStack().getTargetId());this.selectMarkup(i)}this.dispatchEvent(t)},bs.prototype.getMarkup=function(t){for(var e=this.markups,i=e.length,n=0;n<i;++n)if(e[n].id==t)return e[n];return null},bs.prototype.selectMarkup=function(t){if(t)if(this.editMode.type===t.type)this.editMode.setSelection(t);else{var e=t.getEditMode();e.setSelection(null),this.changeEditMode(e),this.setStyle(t.getStyle()),this.editMode.setSelection(t)}else this.editMode&&this.editMode.setSelection(null)},bs.prototype.getSelection=function(){return this.editMode.getSelection()},bs.prototype.deleteMarkup=function(t,e){(!this.editMode||this.editMode&&this.editMode.selectedMarkup.id!==t.id)&&(this.editMode=t.getEditMode()),this.editMode.deleteMarkup(t,e)},Ms.addMarkup=function(t){var e,i=this.activeLayer,n=this.svgLayersMap[i]||"";if(n){var s=n.svg;t.setParent(s),n.markups.push(t),e=n.markups.slice()}else t.setParent(this.editModeSvgLayerNode.svg),this.editModeSvgLayerNode.markups.push(t),e=this.editModeSvgLayerNode.markups.slice();t.addEventListener(S,this.onMarkupSelectedBinded),t.addEventListener(P,this.onMarkupEnterEditionBinded),t.addEventListener(I,this.onMarkupCancelEditionBinded),t.addEventListener(z,this.onMarkupDeleteEditionBinded),this.duringEditMode&&(this.markups=e)},Ms.removeMarkup=function(t){if(!t)return!1;var e=this;if(-1===function(t){var i,n=-1;if(e.editModeSvgLayerNode){var s=e.editModeSvgLayerNode.markups;if(-1!==(i=s.indexOf(t)))return s.splice(i,1),n=s.slice(),""===e.activeLayer&&(e.markups=n),n}if(e.svgLayersMap)for(var o in e.svgLayersMap){var r=e.svgLayersMap[o].markups;if(-1!==(i=r.indexOf(t)))return r.splice(i,1),n=r.slice(),e.activeLayer===o&&(e.markups=n),n}return n}(t))return!1;t.setParent(null),t.removeEventListener(S,this.onMarkupSelectedBinded),t.removeEventListener(P,this.onMarkupEnterEditionBinded),t.removeEventListener(I,this.onMarkupCancelEditionBinded),t.removeEventListener(z,this.onMarkupDeleteEditionBinded);var i=this.editMode;i&&(i.getSelection()===t&&this.selectMarkup(null))},bs.prototype.setStyle=function(t){var e=this.styles,i=this.editMode;b(t,e[i.type]),i.setStyle(e[i.type])},bs.prototype.getStyle=function(){return E(this.styles[this.editMode.type])},bs.prototype.getDefaultStyle=function(){return this.defaultStyle=this.defaultStyle||x(["stroke-width","font-size","font-family","font-style","font-weight","stroke-color","stroke-opacity","fill-color","fill-opacity"],this),this.defaultStyle},Ms.bringToFront=function(t){this.sendMarkupTo(t,this.markups.length-1)},Ms.sendToBack=function(t){this.sendMarkupTo(t,0)},Ms.bringForward=function(t){var e=this.markups.indexOf(t);this.sendMarkupTo(t,e+1)},Ms.bringBackward=function(t){var e=this.markups.indexOf(t);this.sendMarkupTo(t,e-1)},Ms.sendMarkupTo=function(t,e){var i=this.markups,n=i.indexOf(t);if(!(-1===n||e<0||e>=i.length))if(i.splice(n,1),e=n>e?e-1:e,i.splice(e,0,t),t.setParent(null),this.activeLayer){var s=this.svgLayersMap[this.activeLayer].svg;t.setParent(s)}else t.setParent(this.editModeSvgLayerNode.svg)},bs.prototype.loadMarkups=function(t,e){if(this.duringEditMode)return console.warn("Markups will not be loaded during the edit mode"),!1;if(!this.duringViewMode)return!1;if(!e)return console.warn("loadMarkups failed; missing 2nd argument 'layerId'"),!1;var i=Ji(t);if(!i)return!1;if(e in this.svgLayersMap&&this.svg.childNodes.length>0)return console.warn("This layer is already loaded, will not load again."),!1;this.activeLayer=e;var n=this.svgLayersMap[e];n&&delete this.svgLayersMap[e],n={markups:[],svgString:t,svg:this.createLayerNode()},this.svgLayersMap[e]=n;for(var s=i.childNodes,o=0;o<s.length;o++){var r=s[o],a=xn(r,this);a&&this.duringEditMode&&this.editingLayer!==this.activeLayer&&a.disableInteractions(!0),a||"metadata"===r.localName||(n.svg.appendChild(r),o--,"function"==typeof r.setAttribute&&r.setAttribute("pointer-events","none"))}var h=this.svgLayersMap[this.activeLayer].svg;return this.svg.appendChild(h),this.duringEditMode&&this.editingLayer!==this.activeLayer&&(this.activeLayer=this.editingLayer,this.editingLayer&&(this.markups=this.svgLayersMap[this.activeLayer].markups.slice())),!0},Ms.createLayerNode=function(){var t=this.createSvgElement("g");return t.setAttribute("cursor","default"),t},bs.prototype.revertLayer=function(t){if(!t)return console.warn("revertLayer failed because no layerId was supplied."),!1;var e=this.svgLayersMap[t];if(!e)return console.warn("The supplied layer does not exist."),!1;this.duringEditMode&&this.leaveEditMode();var i=this.markups.slice();this.markups=e.markups;var n=e.svgString;if(this.unloadMarkups(t),this.loadMarkups(n,t),this.editingLayer){if(this.editingLayer!==t){this.markups=i;var s=this.svgLayersMap[this.editingLayer];s&&(s.markups=i)}}else this.editModeSvgLayerNode&&(this.editModeSvgLayerNode.markups=i);if(this.editingLayer||0===this.editingLayer.length){var o=0===this.editingLayer.length?this.editModeSvgLayerNode.svg:this.svgLayersMap[this.editingLayer].svg;o.parentNode==this.svg&&(this.svg.removeChild(o),this.svg.appendChild(o))}return!0},bs.prototype.unloadMarkups=function(t){if(!t)return console.warn("unloadMarkups failed; No layerId provided."),!1;var e=this.svgLayersMap[t];if(!e)return console.warn("No such layer exists to unload."),!1;for(var i=e.markups.slice(),n=i.length,s=0;s<n;s++){var o=i[s];this.removeMarkup(o),o.destroy()}return e.svg.parentNode===this.svg&&this.svg.removeChild(e.svg),delete this.svgLayersMap[t],this.activeLayer.toString()===t.toString()&&(this.activeLayer=""),this.editingLayer&&this.editingLayer.toString()===t.toString()&&(this.editingLayer="",this.duringEditMode&&this.leaveEditMode()),!0},bs.prototype.unloadMarkupsAllLayers=function(){this.activeLayer="";var t,e=this;for(t in function(){if(e.editModeSvgLayerNode)for(var t=e.editModeSvgLayerNode.markups.slice(),i=t.length,n=0;n<i;n++){var s=t[n];e.removeMarkup(s),s.destroy()}}(),this.svgLayersMap)this.unloadMarkups(t)},bs.prototype.hideMarkups=function(t){if(!t)return console.warn("hideMarkups failed; No layerId provided."),!1;var e=this.svgLayersMap[t];if(!e)return!1;var i=e.svg;return i.parentNode!=this.svg?(console.warn("Layer is already hidden."),!1):(this.svg.removeChild(i),!0)},bs.prototype.showMarkups=function(t){if(!t)return console.warn("showMarkups failed; No layerId provided."),!1;var e=this.svgLayersMap[t];if(!e)return!1;var i=e.svg;this.svg.appendChild(i)},Ms.positionFromClientToMarkups=function(t,e){return this.clientToMarkups(t,e)},Ms.positionFromMarkupsToClient=function(t,e){return this.markupsToClient(t,e)},Ms.vectorFromClientToMarkups=function(t,e){var i=this.clientToMarkups(0,0),n=this.clientToMarkups(t,e);return{x:n.x-i.x,y:n.y-i.y}},Ms.vectorFromMarkupsToClient=function(t,e){var i=this.markupsToClient(0,0),n=this.markupsToClient(t,e);return{x:n.x-i.x,y:n.y-i.y}},Ms.sizeFromClientToMarkups=function(t,e){var i=this.clientToMarkups(0,0),n=this.clientToMarkups(t,e);return{x:Math.abs(n.x-i.x),y:Math.abs(n.y-i.y)}},Ms.sizeFromMarkupsToClient=function(t,e){var i=this.markupsToClient(0,0),n=this.markupsToClient(t,e);return{x:Math.abs(n.x-i.x),y:Math.abs(n.y-i.y)}},Ms.markupsToClient=function(t,e){var i=this.viewer.impl.camera,n=new THREE.Vector3(t,e,0);if(i.isPerspective){var s=this.viewer.impl.getCanvasBoundingClientRect();n.x=n.x/1e3*(.5*s.height)+.5*s.width,n.y=-n.y/1e3*(.5*s.height)+.5*s.height}else{n.applyMatrix4(i.matrixWorld),n.sub(i.position);var o=this.viewer.model&&this.viewer.model.getData().globalOffset;o&&n.sub(o),(n=en(n,this.viewer,!1)).z=0}return n},Ms.clientToMarkups=function(t,e){var i=this.viewer.impl.camera,n=new THREE.Vector3(t,e,0);if(i.isPerspective){var s=this.viewer.impl.getCanvasBoundingClientRect();n.x=(n.x-.5*s.width)/(.5*s.height)*1e3,n.y=-(n.y-.5*s.height)/(.5*s.height)*1e3}else{n=nn(n.x,n.y,0,this.viewer);var o=this.viewer.model&&this.viewer.model.getData().globalOffset;o&&n.add(o),n.add(i.position),n.applyMatrix4(i.matrixWorldInverse),n.z=0}return n},Ms.getSvgViewBox=function(t,e){var i=this.clientToMarkups(0,0),n=this.clientToMarkups(t,e),s=Math.min(i.x,n.x),o=Math.min(i.y,n.y);return[s,o,Math.max(i.x,n.x)-s,Math.max(i.y,n.y)-o].join(" ")},Ms.getBounds=function(){return this.bounds},Ms.getMousePosition=function(){return this.editMode.useWithSnapping()&&this.snapper&&this.snapper.isSnapped()?this.getSnapPosition():this.input.getMousePosition()},Ms.getSnapPosition=function(){var t=xs.getSnapResultPosition(this.snapper.getSnapResult(),this.viewer),e=this.project(t);return{x:e.x,y:e.y}},Ms.project=function(t){var e=this.viewer.navigation.getCamera(),i=this.viewer.navigation.getScreenViewport(),n=(new THREE.Vector3).copy(t);return n.project(e),new THREE.Vector3(Math.round((n.x+1)/2*i.width),Math.round((1-n.y)/2*i.height),n.z)},Ms.onCameraChange=function(t){var e=this.getSvgViewBox(this.bounds.width,this.bounds.height);if("NaN NaN NaN NaN"!==e){this.svg&&this.svg.setAttribute("viewBox",e);var i=this.editMode;if(i){if(this.editFrame.isActive()){var n=i.getSelection();this.editFrame.setMarkup(n)}i.updateTextBoxStyle&&i.updateTextBoxStyle(),this.snapper&&i.useWithSnapping()&&this.snapper.indicator.render()}}},Ms.onViewerResize=function(t){this.bounds.x=0,this.bounds.y=0,this.bounds.width=t.width,this.bounds.height=t.height,this.svg&&(this.svg.setAttribute("width",this.bounds.width),this.svg.setAttribute("height",this.bounds.height)),this.onCameraChange()},Ms.callSnapperMouseDown=function(){if(this.editMode&&this.editMode.useWithSnapping()){var t=this.input.getMousePosition();this.snapper&&(this.snapper.onMouseDown(t),this.snapper.indicator.render())}else this.snapper&&(this.snapper.clearSnapped(),this.snapper.indicator.clearOverlays())},Ms.callSnapperMouseMove=function(){if(this.editMode&&this.editMode.useWithSnapping()){var t=this.input.getMousePosition();this.snapper&&(this.snapper.onMouseMove(t),this.snapper.indicator.render())}},Ms.onMouseMove=function(t){this.navigating||(this.editFrame.isActive()&&"mousemove"===t.type&&this.editFrame.onMouseMove(t),this.callSnapperMouseMove(),this.editMode&&this.editMode.onMouseMove(t))},Ms.onMouseDown=function(t){vn(),this.callSnapperMouseDown();var e=this.getBounds(),i=this.getMousePosition();i.x>=e.x&&i.x<=e.x+e.width&&i.y>=e.y&&i.y<=e.y+e.height&&this.editMode.onMouseDown(t),this.editMode.creating||t.target!==this.svg||this.selectMarkup(null),this.ignoreNextMouseUp=!1},Ms.onMouseUp=function(t){this.navigating||(this.editFrame.isActive()?this.editFrame.onMouseUp(t):this.ignoreNextMouseUp||this.editMode.onMouseUp(t))},Ms.onMouseDoubleClick=function(t){this.navigating||this.editFrame.isActive()||this.editMode.onMouseDoubleClick(t)},Ms.onUserCancel=function(){this.editMode&&(this.editMode.creating?this.editMode.creationCancel():this.editMode.unselect())},Ms.onMarkupSelected=function(t){this.selectMarkup(t.markup),this.dispatchEvent(t)},Ms.onMarkupEnterEdition=function(t){},Ms.onMarkupCancelEdition=function(t){this.onUserCancel()},Ms.onMarkupDeleteEdition=function(t){this.removeMarkup(t.markup),this.editMode.deleteMarkup()},Autodesk.Viewing.theExtensionManager.registerExtension("Autodesk.Viewing.MarkupsCore",bs);i(13);function Es(t,e){Autodesk.Viewing.Extension.call(this,t,e),this.domEvents=[],this.name="markup",this.onEditModeEnter=this.onEditModeEnter.bind(this),this.onEditModeLeave=this.onEditModeLeave.bind(this),this.onEditModeChange=this.onEditModeChange.bind(this),this.onMarkupSelected=this.onMarkupSelected.bind(this)}Es.prototype=Object.create(Autodesk.Viewing.Extension.prototype),Es.prototype.constructor=Es;var ws=Es.prototype,ks=Autodesk.Viewing.Private;ws.load=function(){return this.viewer.loadExtension("Autodesk.Viewing.MarkupsCore").then(t=>{this.core=t,this.core.addEventListener(T,this.onEditModeEnter),this.core.addEventListener(C,this.onEditModeLeave),this.core.addEventListener(k,this.onEditModeChange),this.core.addEventListener(S,this.onMarkupSelected)}),!0},ws.unload=function(){return this.deactivate(),this.unhookAllEvents(),this.core.removeEventListener(T,this.onEditModeEnter),this.core.removeEventListener(C,this.onEditModeLeave),this.core.removeEventListener(k,this.onEditModeChange),this.core.removeEventListener(S,this.onMarkupSelected),this.destroyToolUi(),this.destroyToolbarUI(),this.core=null,!0},ws.onToolbarCreated=function(t){var e=this;this.viewer;this.markupToolButton=new Autodesk.Viewing.UI.Button("toolbar-markupTool"),this.markupToolButton.setToolTip("Markup"),this.markupToolButton.setIcon("adsk-icon-markup"),this.markupToolButton.onClick=function(){e.activate()};var i=t.getControl(Autodesk.Viewing.TOOLBAR.MODELTOOLSID);i&&i.addControl(this.markupToolButton,{index:0})},ws.destroyToolbarUI=function(){this.markupToolButton&&(this.viewer.getToolbar()&&this.markupToolButton.removeFromParent(),this.markupToolButton=null)},ws.onEditModeEnter=function(){ks.logger.log("ENTER edit mode"),this.showToolsUi()},ws.onEditModeLeave=function(){ks.logger.log("LEAVE edit mode"),this.hideToolsUi()},ws.onEditModeChange=function(t){if(this.domToolSelect&&!this.ignoreChangeEvent)for(var e=this.core.editMode,i=this.domToolSelect.options,n=0,s=i.length;n<s;n++){if(i[n].value===e.type){this.domToolSelect.selectedIndex=n;break}}},ws.onMarkupSelected=function(t){var e=t.markup,i=this.core.editMode;this.setStylesUi(i,e)},ws.showToolsUi=function(){this.createToolsUi();var t=this.core.isNavigationAllowed();this.setControlVisibility(".lmv-markup-gui-enterNavMode",t,"inline-block"),this.exitNavigationMode(),this.domContent.style.display="block",this.viewer.container.appendChild(this.domRoot)},ws.hideToolsUi=function(){this.domRoot&&this.domRoot.parentNode&&this.domRoot.parentNode.removeChild(this.domRoot)},ws.createToolsUi=function(){if(this.domRoot)return;function t(t,e){return['<option value="',e,'">',t,"</option>"].join("")}var e=['<div class="lmv-markup-gui-toolbar-content">','<button class="lmv-markup-gui-collapse-btn">&lt;-&gt;</button>','<button class="lmv-markup-editmode-done">Exit</button>','<div class="lmv-markup-gui-collapse-content">','<div class="lmv-markup-gui-editMode">','<button class="lmv-markup-gui-enterNavMode">Navigate</button>','<button class="lmv-markup-gui-undo">&#8617;</button>','<button class="lmv-markup-gui-redo">&#8618;</button>',"<br>",'<button class="lmv-markup-gui-delete">Delete</button>','<button class="lmv-markup-gui-duplicate">Duplicate</button>',"<br>",'<button class="lmv-markup-gui-cut">Cut</button>','<button class="lmv-markup-gui-copy">Copy</button>','<button class="lmv-markup-gui-paste">Paste</button>',"<br>","<span>Markup:</span>",'<select class="lmv-markup-tool-select">',t("Arrow",a),t("Rectangle",l),t("Circle",u),t("Text",h),t("Callout",g),t("Cloud",d),t("PolyLine",f),t("Polycloud",y),t("Freehand",c),t("Highlight",p),t("Dimension",v),"</select>","<br>",'<div class="lmv-markup-gui-style-options"></div>',"</div>",'<div class="lmv-markup-gui-navMode" style="display:none;">','<button class="lmv-markup-gui-exitNavMode">Back to Markup</button>',"</div>","</div>","</div>"].join("");const i=this.getDocument();this.domRoot=i.createElement("div"),this.domRoot.className="lmv-markup-gui-toolbar",this.domRoot.innerHTML=e,this.domContent=this.domRoot.querySelector(".lmv-markup-gui-collapse-content"),this.domToolSelect=this.domRoot.querySelector(".lmv-markup-tool-select"),this.domStylesRoot=this.domRoot.querySelector(".lmv-markup-gui-style-options"),this.hookEvent("click",".lmv-markup-gui-collapse-btn",this.onToggleCollapse.bind(this)),this.hookEvent("click",".lmv-markup-editmode-done",this.onEditModeDone.bind(this)),this.hookEvent("click",".lmv-markup-gui-enterNavMode",this.enterNavigationMode.bind(this)),this.hookEvent("click",".lmv-markup-gui-exitNavMode",this.exitNavigationMode.bind(this)),this.hookEvent("click",".lmv-markup-gui-undo",this.onUndoClick.bind(this)),this.hookEvent("click",".lmv-markup-gui-redo",this.onRedoClick.bind(this)),this.hookEvent("click",".lmv-markup-gui-delete",this.onDeleteClick.bind(this)),this.hookEvent("click",".lmv-markup-gui-cut",this.onCutClick.bind(this)),this.hookEvent("click",".lmv-markup-gui-copy",this.onCopyClick.bind(this)),this.hookEvent("click",".lmv-markup-gui-paste",this.onPasteClick.bind(this)),this.hookEvent("click",".lmv-markup-gui-duplicate",this.onDuplicateClick.bind(this)),this.hookEvent("change",".lmv-markup-tool-select",this.onSelectEditMode.bind(this)),this.hookEvent("change",".lmv-markup-gui-style-select",this.onStyleChange.bind(this)),this.setStylesUi(this.core.editMode)},ws.destroyToolUi=function(){this.domRoot&&(this.hideToolsUi(),this.domRoot=null)},ws.getEditMode=function(t){var e=ms.getClass(t);return e?new e(this.core):null},ws.onToggleCollapse=function(){var t=this.domContent.style.display;this.domContent.style.display="none"===t?"block":"none"},ws.onEditModeDone=function(){this.deactivate()},ws.enterNavigationMode=function(){this.core.allowNavigation(!0),this.setControlVisibility(".lmv-markup-gui-editMode",!1),this.setControlVisibility(".lmv-markup-gui-navMode",!0)},ws.exitNavigationMode=function(){this.core.allowNavigation(!1),this.setControlVisibility(".lmv-markup-gui-editMode",!0),this.setControlVisibility(".lmv-markup-gui-navMode",!1)},ws.onUndoClick=function(){this.core.undo()},ws.onRedoClick=function(){this.core.redo()},ws.onDeleteClick=function(){var t=this.core.getSelection();t&&this.core.deleteMarkup(t)},ws.onCutClick=function(){this.core.cut()},ws.onCopyClick=function(){this.core.copy()},ws.onPasteClick=function(){this.core.paste()},ws.onDuplicateClick=function(){this.core.getSelection()&&(this.core.copy(),this.core.paste())},ws.onSelectEditMode=function(t){var e=t.target.value,i=this.getEditMode(e);i?i.cancelEditModeChange?ks.logger.warn("There was a problem selecting current editMode"):(this.ignoreChangeEvent=!0,this.core.changeEditMode(i),this.ignoreChangeEvent=!1,this.setStylesUi(i),this.domToolSelect.blur()):ks.logger.error("Markup editMode not found for type: "+e)},ws.onStyleChange=function(t){var e=t.target,i=e.options[e.selectedIndex],n=e.getAttribute("style-key"),s=e.getAttribute("value-type");e.blur();var o,r,a=this.core.getSelection(),h=a?a.getStyle():this.core.getStyle();h[n]=(o=i.value,"number"===(r=s)?Number(o):"boolean"===r?"true"===o:o),this.core.setStyle(h)},ws.setStylesUi=function(t,e){ks.logger.log("set ui for "+t.type);var i=e?e.style:t.style,n=w(i,this.core);for(var s in this.domStylesRoot.innerHTML="",n){var o=this.getUiForStyleKey(s,n[s],i[s]);this.domStylesRoot.appendChild(o)}},ws.getUiForStyleKey=function(t,e,i){for(var n=e.default,s=[],o=e.values,r=0,a=o.length;r<a;++r){var h=['<option value="',o[r].value,'">',o[r].name,"</option>"].join("");s.push(h),this.valueEquals(o[r].value,i)&&(n=r)}var l=typeof o[0].value;var u=this.getDocument().createElement("div"),d=["<span>",t,"</span>",'<select class="lmv-markup-gui-style-select" style-key="',t,'" value-type="',l,'">',s.join(""),"</select>"].join("");return u.innerHTML=d,u.querySelector("select").selectedIndex=n,u},ws.valueEquals=function(t,e){return t===e},ws.setControlVisibility=function(t,e,i){i||(i="block"),this.domRoot.querySelector(t).style.display=e?i:"none"},ws.hookEvent=function(t,e,i){var n=function(t){this.matchesSelector(t.target,e)&&i(t)}.bind(this);this.domRoot.addEventListener(t,n),this.domEvents.push({str:t,handler:n})},ws.unhookAllEvents=function(){var t=this.domRoot;this.domEvents.forEach(function(e){t.removeEventListener(e.str,e.handler)}),this.domEvents=[]},ws.matchesSelector=function(t,e){return t.matches?t.matches(e):t.msMatchesSelector?t.msMatchesSelector(e):t.mozMatchesSelector?t.mozMatchesSelector(e):!!t.webkitMatchesSelector&&t.webkitMatchesSelector(e)},ws.getStyleOptions=function(t){var e=t.getStyle();return w(e,this.core)},ws.activate=function(){return this.activeStatus||(this.core.enterEditMode(),this.activeStatus=!0),!0},ws.deactivate=function(){return this.activeStatus&&(this.core.hide(),this.activeStatus=!1),!0},Autodesk.Viewing.theExtensionManager.registerExtension("Autodesk.Viewing.MarkupsGui",Es),i.d(e,"Core",function(){return Ts}),i.d(e,"Gui",function(){return Ps});const Ts={Clipboard:Ln,CloneMarkup:Nn,CreateArrow:tt,CreateCallout:Ut,CreateCircle:ue,CreateCloud:be,CreateDimension:wi,CreateFreehand:Re,CreateHighlight:ui,CreatePolycloud:ei,CreatePolyline:Ge,CreateRectangle:dt,CreateText:te,DeleteArrow:W,DeleteCallout:Gt,DeleteCircle:ie,DeleteCloud:ce,DeleteDimension:ci,DeleteFreehand:Ce,DeleteHighlight:ni,DeletePolycloud:Xe,DeletePolyline:Ne,DeleteRectangle:it,DeleteText:pt,EditAction:m,EditActionGroup:zn,EditActionManager:Rn,EditFrame:ts,EditMode:j,EditModeArrow:$,EditModeCallout:Vt,EditModeCircle:re,EditModeCloud:ge,EditModeDimension:mi,EditModeFreehand:Ie,EditModeHighlight:ai,EditModePen:ke,EditModePolycloud:$e,EditModePolyline:_e,EditModeRectangle:at,EditModeText:Kt,EditorTextInput:Dt,Markup:_,MarkupArrow:J,MarkupCallout:Ot,MarkupCircle:he,MarkupCloud:me,MarkupDimension:Mi,MarkupFreehand:De,MarkupHighlight:li,MarkupPen:Ee,MarkupPolycloud:Qe,MarkupPolyline:Ue,MarkupRectangle:lt,MarkupText:Jt,MarkupTool:gs,MarkupsCore:bs,SetArrow:Y,SetCallout:yt,SetCircle:se,SetCloud:fe,SetDimension:fi,SetFreehand:Ae,SetHighlight:oi,SetPolycloud:Ke,SetPolyline:Le,SetPosition:Kn,SetRectangle:st,SetRotation:$n,SetSize:vt,SetStyle:F,SetText:Xt,MarkupEvents:o,MarkupTypes:n,theEditModeManager:ms,Utils:r};for(var Cs in n)Ts[Cs]=n[Cs];for(var Ss in o)Ts[Ss]=o[Ss];for(var As in s){if(As in Ts.Utils)throw new Error(`Property ${As} from StyleUtils already present in MarkupsCoreUtils.`);Ts.Utils[As]=s[As]}const Ps={MarkupsGui:Es};Autodesk.Viewing.Extensions.Markups={Core:Ts}}]);
  //# sourceMappingURL=Markup.min.js.map