diff --git a/dist/g.js b/dist/g.js index 08c2d96..beafbed 100644 --- a/dist/g.js +++ b/dist/g.js @@ -960,67 +960,7 @@ }()); }).call(this,require('_process')) -},{"_process":2}],2:[function(require,module,exports){ -// shim for using process in browser - -var process = module.exports = {}; -var queue = []; -var draining = false; - -function drainQueue() { - if (draining) { - return; - } - draining = true; - var currentQueue; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - var i = -1; - while (++i < len) { - currentQueue[i](); - } - len = queue.length; - } - draining = false; -} -process.nextTick = function (fun) { - queue.push(fun); - if (!draining) { - setTimeout(drainQueue, 0); - } -}; - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],3:[function(require,module,exports){ +},{"_process":4}],2:[function(require,module,exports){ // rev 452 /******************************************************************************** * * @@ -8007,7 +7947,7 @@ ClipperLib.JS.PolyTreeToExPolygons = function (polytree) module.exports = ClipperLib; -},{}],4:[function(require,module,exports){ +},{}],3:[function(require,module,exports){ (function (global){ /** * @license @@ -20362,6 +20302,66 @@ module.exports = ClipperLib; }.call(this)); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],4:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; +var queue = []; +var draining = false; + +function drainQueue() { + if (draining) { + return; + } + draining = true; + var currentQueue; + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + var i = -1; + while (++i < len) { + currentQueue[i](); + } + len = queue.length; + } + draining = false; +} +process.nextTick = function (fun) { + queue.push(fun); + if (!draining) { + setTimeout(drainQueue, 0); + } +}; + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + },{}],5:[function(require,module,exports){ /* @@ -20691,7 +20691,7 @@ function DOMParser(options){ this.options = options ||{locator:{}}; } -DOMParser.prototype.parseFromString = function(source,mimeType){ +DOMParser.prototype.parseFromString = function(source,mimeType){ var options = this.options; var sax = new XMLReader(); var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler @@ -20710,12 +20710,13 @@ DOMParser.prototype.parseFromString = function(source,mimeType){ entityMap.copy = '\xa9'; defaultNSMap['']= 'http://www.w3.org/1999/xhtml'; } + defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace'; if(source){ sax.parse(source,defaultNSMap,entityMap); }else{ - sax.errorHandler.error("invalid document source"); + sax.errorHandler.error("invalid doc source"); } - return domBuilder.document; + return domBuilder.doc; } function buildErrorHandler(errorImpl,domBuilder,locator){ if(!errorImpl){ @@ -20729,27 +20730,20 @@ function buildErrorHandler(errorImpl,domBuilder,locator){ locator = locator||{} function build(key){ var fn = errorImpl[key]; - if(!fn){ - if(isCallback){ - fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl; - }else{ - var i=arguments.length; - while(--i){ - if(fn = errorImpl[arguments[i]]){ - break; - } - } - } + if(!fn && isCallback){ + fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl; } errorHandler[key] = fn && function(msg){ - fn(msg+_locator(locator)); + fn('[xmldom '+key+']\t'+msg+_locator(locator)); }||function(){}; } - build('warning','warn'); - build('error','warn','warning'); - build('fatalError','warn','warning','error'); + build('warning'); + build('error'); + build('fatalError'); return errorHandler; } + +//console.log('#\n\n\n\n\n\n\n####') /** * +ContentHandler+ErrorHandler * +LexicalHandler+EntityResolver2 @@ -20772,13 +20766,13 @@ function position(locator,node){ */ DOMHandler.prototype = { startDocument : function() { - this.document = new DOMImplementation().createDocument(null, null, null); + this.doc = new DOMImplementation().createDocument(null, null, null); if (this.locator) { - this.document.documentURI = this.locator.systemId; + this.doc.documentURI = this.locator.systemId; } }, startElement:function(namespaceURI, localName, qName, attrs) { - var doc = this.document; + var doc = this.doc; var el = doc.createElementNS(namespaceURI, qName||localName); var len = attrs.length; appendElement(this, el); @@ -20790,24 +20784,22 @@ DOMHandler.prototype = { var value = attrs.getValue(i); var qName = attrs.getQName(i); var attr = doc.createAttributeNS(namespaceURI, qName); - if( attr.getOffset){ - position(attr.getOffset(1),attr) - } + this.locator &&position(attrs.getLocator(i),attr); attr.value = attr.nodeValue = value; el.setAttributeNode(attr) } }, endElement:function(namespaceURI, localName, qName) { var current = this.currentElement - var tagName = current.tagName; - this.currentElement = current.parentNode; + var tagName = current.tagName; + this.currentElement = current.parentNode; }, startPrefixMapping:function(prefix, uri) { }, endPrefixMapping:function(prefix) { }, processingInstruction:function(target, data) { - var ins = this.document.createProcessingInstruction(target, data); + var ins = this.doc.createProcessingInstruction(target, data); this.locator && position(this.locator,ins) appendElement(this, ins); }, @@ -20816,13 +20808,17 @@ DOMHandler.prototype = { characters:function(chars, start, length) { chars = _toString.apply(this,arguments) //console.log(chars) - if(this.currentElement && chars){ + if(chars){ if (this.cdata) { - var charNode = this.document.createCDATASection(chars); - this.currentElement.appendChild(charNode); + var charNode = this.doc.createCDATASection(chars); } else { - var charNode = this.document.createTextNode(chars); + var charNode = this.doc.createTextNode(chars); + } + if(this.currentElement){ this.currentElement.appendChild(charNode); + }else if(/^\s*$/.test(chars)){ + this.doc.appendChild(charNode); + //process xml } this.locator && position(this.locator,charNode) } @@ -20830,7 +20826,7 @@ DOMHandler.prototype = { skippedEntity:function(name) { }, endDocument:function() { - this.document.normalize(); + this.doc.normalize(); }, setDocumentLocator:function (locator) { if(this.locator = locator){// && !('lineNumber' in locator)){ @@ -20840,7 +20836,7 @@ DOMHandler.prototype = { //LexicalHandler comment:function(chars, start, length) { chars = _toString.apply(this,arguments) - var comm = this.document.createComment(chars); + var comm = this.doc.createComment(chars); this.locator && position(this.locator,comm) appendElement(this, comm); }, @@ -20854,7 +20850,7 @@ DOMHandler.prototype = { }, startDTD:function(name, publicId, systemId) { - var impl = this.document.implementation; + var impl = this.doc.implementation; if (impl && impl.createDocumentType) { var dt = impl.createDocumentType(name, publicId, systemId); this.locator && position(this.locator,dt) @@ -20866,13 +20862,13 @@ DOMHandler.prototype = { * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html */ warning:function(error) { - console.warn(error,_locator(this.locator)); + console.warn('[xmldom warning]\t'+error,_locator(this.locator)); }, error:function(error) { - console.error(error,_locator(this.locator)); + console.error('[xmldom error]\t'+error,_locator(this.locator)); }, fatalError:function(error) { - console.error(error,_locator(this.locator)); + console.error('[xmldom fatalError]\t'+error,_locator(this.locator)); throw error; } } @@ -20930,18 +20926,18 @@ function _toString(chars,start,length){ /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ function appendElement (hander,node) { if (!hander.currentElement) { - hander.document.appendChild(node); + hander.doc.appendChild(node); } else { hander.currentElement.appendChild(node); } }//appendChild and setAttributeNS are preformance key -if(typeof require == 'function'){ +//if(typeof require == 'function'){ var XMLReader = require('./sax').XMLReader; var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation; exports.XMLSerializer = require('./dom').XMLSerializer ; exports.DOMParser = DOMParser; -} +//} },{"./dom":7,"./sax":8}],7:[function(require,module,exports){ /* @@ -21055,6 +21051,12 @@ NodeList.prototype = { */ item: function(index) { return this[index] || null; + }, + toString:function(isHTML,nodeFilter){ + for(var buf = [], i = 0;i=0){ var lastIndex = list.length-1 @@ -21125,7 +21128,7 @@ function _removeNamedNode(el,list,attr){ } } }else{ - throw DOMException(NOT_FOUND_ERR,new Error()) + throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr)) } } NamedNodeMap.prototype = { @@ -21135,9 +21138,11 @@ NamedNodeMap.prototype = { // if(key.indexOf(':')>0 || key == 'xmlns'){ // return null; // } + //console.log() var i = this.length; while(i--){ var attr = this[i]; + //console.log(attr.nodeName,key) if(attr.nodeName == key){ return attr; } @@ -21213,12 +21218,12 @@ DOMImplementation.prototype = { // Introduced in DOM Level 2: createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR var doc = new Document(); + doc.implementation = this; + doc.childNodes = new NodeList(); doc.doctype = doctype; if(doctype){ doc.appendChild(doctype); } - doc.implementation = this; - doc.childNodes = new NodeList(); if(qualifiedName){ var root = doc.createElementNS(namespaceURI,qualifiedName); doc.appendChild(root); @@ -21319,7 +21324,7 @@ Node.prototype = { } } } - el = el.nodeType == 2?el.ownerDocument : el.parentNode; + el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; } return null; }, @@ -21334,7 +21339,7 @@ Node.prototype = { return map[prefix] ; } } - el = el.nodeType == 2?el.ownerDocument : el.parentNode; + el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; } return null; }, @@ -21519,7 +21524,7 @@ Document.prototype = { } return newChild; } - if(this.documentElement == null && newChild.nodeType == 1){ + if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){ this.documentElement = newChild; } @@ -21539,7 +21544,7 @@ Document.prototype = { getElementById : function(id){ var rtv = null; _visitNode(this.documentElement,function(node){ - if(node.nodeType == 1){ + if(node.nodeType == ELEMENT_NODE){ if(node.getAttribute('id') == id){ rtv = node; return true; @@ -21688,6 +21693,7 @@ Element.prototype = { return this.attributes.setNamedItemNS(newAttr); }, removeAttributeNode : function(oldAttr){ + //console.log(this == oldAttr.ownerElement) return this.attributes.removeNamedItem(oldAttr.nodeName); }, //get real attribute name,and remove it by removeAttributeNode @@ -21705,7 +21711,7 @@ Element.prototype = { }, setAttributeNS : function(namespaceURI, qualifiedName, value){ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); - attr.value = attr.nodeValue = value; + attr.value = attr.nodeValue = "" + value; this.setAttributeNode(attr) }, getAttributeNodeNS : function(namespaceURI, localName){ @@ -21727,11 +21733,12 @@ Element.prototype = { return new LiveNodeList(this,function(base){ var ls = []; _visitNode(base,function(node){ - if(node !== base && node.nodeType === ELEMENT_NODE && node.namespaceURI === namespaceURI && (localName === '*' || node.localName == localName)){ + if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){ ls.push(node); } }); return ls; + }); } }; @@ -21763,10 +21770,7 @@ CharacterData.prototype = { }, appendChild:function(newChild){ - //if(!(newChild instanceof CharacterData)){ - throw new Error(ExceptionMessage[3]) - //} - return Node.prototype.appendChild.apply(this,arguments) + throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]) }, deleteData: function(offset, count) { this.replaceData(offset,count,""); @@ -21848,36 +21852,132 @@ function ProcessingInstruction() { ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; _extends(ProcessingInstruction,Node); function XMLSerializer(){} -XMLSerializer.prototype.serializeToString = function(node){ +XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){ + return nodeSerializeToString.call(node,isHtml,nodeFilter); +} +Node.prototype.toString = nodeSerializeToString; +function nodeSerializeToString(isHtml,nodeFilter){ var buf = []; - serializeToString(node,buf); + var refNode = this.nodeType == 9?this.documentElement:this; + var prefix = refNode.prefix; + var uri = refNode.namespaceURI; + + if(uri && prefix == null){ + //console.log(prefix) + var prefix = refNode.lookupPrefix(uri); + if(prefix == null){ + //isHTML = true; + var visibleNamespaces=[ + {namespace:uri,prefix:null} + //{namespace:uri,prefix:''} + ] + } + } + serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces); + //console.log('###',this.nodeType,uri,prefix,buf.join('')) return buf.join(''); } -Node.prototype.toString =function(){ - return XMLSerializer.prototype.serializeToString(this); +function needNamespaceDefine(node,isHTML, visibleNamespaces) { + var prefix = node.prefix||''; + var uri = node.namespaceURI; + if (!prefix && !uri){ + return false; + } + if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace" + || uri == 'http://www.w3.org/2000/xmlns/'){ + return false; + } + + var i = visibleNamespaces.length + //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces) + while (i--) { + var ns = visibleNamespaces[i]; + // get namespace prefix + //console.log(node.nodeType,node.tagName,ns.prefix,prefix) + if (ns.prefix == prefix){ + return ns.namespace != uri; + } + } + //console.log(isHTML,uri,prefix=='') + //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){ + // return false; + //} + //node.flag = '11111' + //console.error(3,true,node.flag,node.prefix,node.namespaceURI) + return true; } -function serializeToString(node,buf){ +function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){ + if(nodeFilter){ + node = nodeFilter(node); + if(node){ + if(typeof node == 'string'){ + buf.push(node); + return; + } + }else{ + return; + } + //buf.sort.apply(attrs, attributeSorter); + } switch(node.nodeType){ case ELEMENT_NODE: + if (!visibleNamespaces) visibleNamespaces = []; + var startVisibleNamespaces = visibleNamespaces.length; var attrs = node.attributes; var len = attrs.length; var child = node.firstChild; var nodeName = node.tagName; - var isHTML = htmlns === node.namespaceURI + + isHTML = (htmlns === node.namespaceURI) ||isHTML buf.push('<',nodeName); + + + for(var i=0;i'); //if is cdata child node if(isHTML && /^script$/i.test(nodeName)){ - if(child){ - buf.push(child.data); + while(child){ + if(child.data){ + buf.push(child.data); + }else{ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + } + child = child.nextSibling; } - }else{ + }else + { while(child){ - serializeToString(child,buf); + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); child = child.nextSibling; } } @@ -21885,12 +21985,14 @@ function serializeToString(node,buf){ }else{ buf.push('/>'); } + // remove added visible namespaces + //visibleNamespaces.length = startVisibleNamespaces; return; case DOCUMENT_NODE: case DOCUMENT_FRAGMENT_NODE: var child = node.firstChild; while(child){ - serializeToString(child,buf); + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); child = child.nextSibling; } return; @@ -22035,8 +22137,8 @@ try{ }, set:function(data){ switch(this.nodeType){ - case 1: - case 11: + case ELEMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: while(this.firstChild){ this.removeChild(this.firstChild); } @@ -22047,7 +22149,7 @@ try{ default: //TODO: this.data = data; - this.value = value; + this.value = data; this.nodeValue = data; } } @@ -22055,8 +22157,8 @@ try{ function getTextContent(node){ switch(node.nodeType){ - case 1: - case 11: + case ELEMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: var buf = []; node = node.firstChild; while(node){ @@ -22078,31 +22180,31 @@ try{ }catch(e){//ie8 } -if(typeof require == 'function'){ +//if(typeof require == 'function'){ exports.DOMImplementation = DOMImplementation; exports.XMLSerializer = XMLSerializer; -} +//} },{}],8:[function(require,module,exports){ //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] //[5] Name ::= NameStartChar (NameChar)* var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF -var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\u00B7\u0300-\u036F\\ux203F-\u2040]"); +var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"); var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$'); //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/ //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',') -//S_TAG, S_ATTR, S_EQ, S_V -//S_ATTR_S, S_E, S_S, S_C +//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE +//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE var S_TAG = 0;//tag name offerring var S_ATTR = 1;//attr name offerring -var S_ATTR_S=2;//attr name end and space offer +var S_ATTR_SPACE=2;//attr name end and space offer var S_EQ = 3;//=space? -var S_V = 4;//attr value(no quot value only) -var S_E = 5;//attr value end and no space(quot end) -var S_S = 6;//(attr value end || tag end ) && (space offer) -var S_C = 7;//closed el +var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only) +var S_ATTR_END = 5;//attr value end and no space(quot end) +var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer) +var S_TAG_CLOSE = 7;//closed el function XMLReader(){ @@ -22119,7 +22221,7 @@ XMLReader.prototype = { } } function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ - function fixedFromCharCode(code) { + function fixedFromCharCode(code) { // String.prototype.fromCharCode does not supports // > 2 bytes unicode chars directly if (code > 0xffff) { @@ -22144,95 +22246,126 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ } } function appendText(end){//has some bugs - var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer); - locator&&position(start); - domBuilder.characters(xt,0,end-start); - start = end + if(end>start){ + var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer); + locator&&position(start); + domBuilder.characters(xt,0,end-start); + start = end + } } - function position(start,m){ - while(start>=endPos && (m = linePattern.exec(source))){ - startPos = m.index; - endPos = startPos + m[0].length; + function position(p,m){ + while(p>=lineEnd && (m = linePattern.exec(source))){ + lineStart = m.index; + lineEnd = lineStart + m[0].length; locator.lineNumber++; //console.log('line++:',locator,startPos,endPos) } - locator.columnNumber = start-startPos+1; + locator.columnNumber = p-lineStart+1; } - var startPos = 0; - var endPos = 0; - var linePattern = /.+(?:\r\n?|\n)|.*$/g + var lineStart = 0; + var lineEnd = 0; + var linePattern = /.*(?:\r\n?|\n)|.*$/g var locator = domBuilder.locator; var parseStack = [{currentNSMap:defaultNSMapCopy}] var closeMap = {}; var start = 0; while(true){ - var i = source.indexOf('<',start); - if(i<0){ - if(!source.substr(start).match(/^\s*$/)){ - var doc = domBuilder.document; - var text = doc.createTextNode(source.substr(start)); - doc.appendChild(text); - domBuilder.currentElement = text; - } - return; - } - if(i>start){ - appendText(i); - } - switch(source.charAt(i+1)){ - case '/': - var end = source.indexOf('>',i+3); - var tagName = source.substring(i+2,end); - var config = parseStack.pop(); - var localNSMap = config.localNSMap; - - if(config.tagName != tagName){ - errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); - } - domBuilder.endElement(config.uri,config.localName,tagName); - if(localNSMap){ - for(var prefix in localNSMap){ - domBuilder.endPrefixMapping(prefix) ; + try{ + var tagStart = source.indexOf('<',start); + if(tagStart<0){ + if(!source.substr(start).match(/^\s*$/)){ + var doc = domBuilder.doc; + var text = doc.createTextNode(source.substr(start)); + doc.appendChild(text); + domBuilder.currentElement = text; } + return; } - end++; - break; - // end elment - case '?':// - locator&&position(i); - end = parseInstruction(source,i,domBuilder); - break; - case '!':// start){ + appendText(tagStart); + } + switch(source.charAt(tagStart+1)){ + case '/': + var end = source.indexOf('>',tagStart+3); + var tagName = source.substring(tagStart+2,end); + var config = parseStack.pop(); + if(end<0){ + + tagName = source.substring(tagStart+2).replace(/[\s<].*/,''); + //console.error('#@@@@@@'+tagName) + errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName); + end = tagStart+1+tagName.length; + }else if(tagName.match(/\s + locator&&position(tagStart); + end = parseInstruction(source,tagStart,domBuilder); + break; + case '!':// start){ start = end; + }else{ + //TODO: 这里有可能sax回退,有位置错误风险 + appendText(Math.max(tagStart,start)+1); } } } @@ -22258,14 +22392,13 @@ function copyLocator(f,t){ t.lineNumber = f.lineNumber; t.columnNumber = f.columnNumber; return t; - } /** * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack); * @return end of the elementStartPart(end of elementEndPart for selfClosed el) */ -function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ +function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){ var attrName; var value; var p = ++start; @@ -22277,7 +22410,7 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ if(s === S_ATTR){//attrName attrName = source.slice(start,p); s = S_EQ; - }else if(s === S_ATTR_S){ + }else if(s === S_ATTR_SPACE){ s = S_EQ; }else{ //fatalError: equal must after attrName or space after attrName @@ -22286,25 +22419,30 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ break; case '\'': case '"': - if(s === S_EQ){//equal + if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE + ){//equal + if(s === S_ATTR){ + errorHandler.warning('attribute value must after "="') + attrName = source.slice(start,p) + } start = p+1; p = source.indexOf(c,start) if(p>0){ value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); el.add(attrName,value,start-1); - s = S_E; + s = S_ATTR_END; }else{ //fatalError: no end quot match throw new Error('attribute value no end \''+c+'\' match'); } - }else if(s == S_V){ + }else if(s == S_ATTR_NOQUOT_VALUE){ value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); //console.log(attrName,value,start,p) el.add(attrName,value,start); //console.dir(el) errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!'); start = p+1; - s = S_E + s = S_ATTR_END }else{ //fatalError: no equal before throw new Error('attribute value must after "="'); @@ -22314,14 +22452,14 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ switch(s){ case S_TAG: el.setTagName(source.slice(start,p)); - case S_E: - case S_S: - case S_C: - s = S_C; + case S_ATTR_END: + case S_TAG_SPACE: + case S_TAG_CLOSE: + s =S_TAG_CLOSE; el.closed = true; - case S_V: + case S_ATTR_NOQUOT_VALUE: case S_ATTR: - case S_ATTR_S: + case S_ATTR_SPACE: break; //case S_EQ: default: @@ -22331,30 +22469,36 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ case ''://end document //throw new Error('unexpected end of input') errorHandler.error('unexpected end of input'); + if(s == S_TAG){ + el.setTagName(source.slice(start,p)); + } + return p; case '>': switch(s){ case S_TAG: el.setTagName(source.slice(start,p)); - case S_E: - case S_S: - case S_C: + case S_ATTR_END: + case S_TAG_SPACE: + case S_TAG_CLOSE: break;//normal - case S_V://Compatible state + case S_ATTR_NOQUOT_VALUE://Compatible state case S_ATTR: value = source.slice(start,p); if(value.slice(-1) === '/'){ el.closed = true; value = value.slice(0,-1) } - case S_ATTR_S: - if(s === S_ATTR_S){ + case S_ATTR_SPACE: + if(s === S_ATTR_SPACE){ value = attrName; } - if(s == S_V){ + if(s == S_ATTR_NOQUOT_VALUE){ errorHandler.warning('attribute "'+value+'" missed quot(")!!'); el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start) }else{ - errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!') + if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){ + errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!') + } el.add(value,value,start) } break; @@ -22371,64 +22515,68 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ switch(s){ case S_TAG: el.setTagName(source.slice(start,p));//tagName - s = S_S; + s = S_TAG_SPACE; break; case S_ATTR: attrName = source.slice(start,p) - s = S_ATTR_S; + s = S_ATTR_SPACE; break; - case S_V: + case S_ATTR_NOQUOT_VALUE: var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); errorHandler.warning('attribute "'+value+'" missed quot(")!!'); el.add(attrName,value,start) - case S_E: - s = S_S; + case S_ATTR_END: + s = S_TAG_SPACE; break; - //case S_S: + //case S_TAG_SPACE: //case S_EQ: - //case S_ATTR_S: + //case S_ATTR_SPACE: // void();break; - //case S_C: + //case S_TAG_CLOSE: //ignore warning } }else{//not space -//S_TAG, S_ATTR, S_EQ, S_V -//S_ATTR_S, S_E, S_S, S_C +//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE +//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE switch(s){ //case S_TAG:void();break; //case S_ATTR:void();break; - //case S_V:void();break; - case S_ATTR_S: - errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!') + //case S_ATTR_NOQUOT_VALUE:void();break; + case S_ATTR_SPACE: + var tagName = el.tagName; + if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){ + errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!') + } el.add(attrName,attrName,start); start = p; s = S_ATTR; break; - case S_E: + case S_ATTR_END: errorHandler.warning('attribute space is required"'+attrName+'"!!') - case S_S: + case S_TAG_SPACE: s = S_ATTR; start = p; break; case S_EQ: - s = S_V; + s = S_ATTR_NOQUOT_VALUE; start = p; break; - case S_C: + case S_TAG_CLOSE: throw new Error("elements closed character '/' and '>' must be connected to"); } } - } + }//end outer switch + //console.log('p++',p) p++; } } /** - * @return end of the elementStartPart(end of elementEndPart for selfClosed el) + * @return true if has new namespace define */ -function appendElement(el,domBuilder,parseStack){ +function appendElement(el,domBuilder,currentNSMap){ var tagName = el.tagName; var localNSMap = null; - var currentNSMap = parseStack[parseStack.length-1].currentNSMap; + //var currentNSMap = parseStack[parseStack.length-1].currentNSMap; var i = el.length; while(i--){ var a = el[i]; @@ -22467,7 +22615,7 @@ function appendElement(el,domBuilder,parseStack){ if(prefix === 'xml'){ a.uri = 'http://www.w3.org/XML/1998/namespace'; }if(prefix !== 'xmlns'){ - a.uri = currentNSMap[prefix] + a.uri = currentNSMap[prefix || ''] //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} } @@ -22496,7 +22644,8 @@ function appendElement(el,domBuilder,parseStack){ }else{ el.currentNSMap = currentNSMap; el.localNSMap = localNSMap; - parseStack.push(el); + //parseStack.push(el); + return true; } } function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){ @@ -22526,7 +22675,11 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){ var pos = closeMap[tagName]; if(pos == null){ //console.log(tagName) - pos = closeMap[tagName] = source.lastIndexOf('') + pos = source.lastIndexOf('') + if(pos 0) { var o = objects[0]; - if (o && (o.commands || o.shapes)) { + if (o && (o.commands || o.shapes || o.fontFamily)) { return vg.merge(objects); } else if (o instanceof img.Img) { return img.merge(objects); @@ -22806,7 +22957,7 @@ g.mix = function (a, b, t) { module.exports = g; -},{"./libraries/data":10,"./libraries/easing":12,"./libraries/graphics":13,"./libraries/image":14,"./libraries/img/img":18,"./libraries/list":21,"./libraries/math":22,"./libraries/string":23,"./libraries/vg/vg":45,"lodash":4}],10:[function(require,module,exports){ +},{"./libraries/data":10,"./libraries/easing":12,"./libraries/graphics":13,"./libraries/image":14,"./libraries/img/img":18,"./libraries/list":21,"./libraries/math":22,"./libraries/string":23,"./libraries/vg/vg":45,"lodash":3}],10:[function(require,module,exports){ 'use strict'; var _ = require('lodash'); @@ -22839,26 +22990,61 @@ g.convert = function (v, inMin, inMax, outMin, outMax) { }; g.filterData = function (data, key, op, value) { + var i, l, row, obj; if (value === null || value === undefined) { return data; } var results = []; - for (var i = 0; i < data.length; i += 1) { - var row = data[i]; - var obj = row[key]; - if (op === '==' && obj == value) { // jshint ignore:line - results.push(row); - } else if (op === '!=' && obj != value) { // jshint ignore:line - results.push(row); - } else if (op === '>' && obj > value) { - results.push(row); - } else if (op === '>=' && obj >= value) { - results.push(row); - } else if (op === '<' && obj < value) { - results.push(row); - } else if (op === '<=' && obj <= value) { - results.push(row); + if (op === '==') { + for (i = 0, l = data.length; i < l; i++) { + row = data[i]; + obj = row[key]; + if (obj == value) { // jshint ignore:line + results.push(row); + } } + } else if (op === '!=') { + for (i = 0, l = data.length; i < l; i++) { + row = data[i]; + obj = row[key]; + if (obj != value) { // jshint ignore:line + results.push(row); + } + } + } else if (op === '>') { + for (i = 0, l = data.length; i < l; i++) { + row = data[i]; + obj = row[key]; + if (obj > value) { + results.push(row); + } + } + } else if (op === '>=') { + for (i = 0, l = data.length; i < l; i++) { + row = data[i]; + obj = row[key]; + if (obj >= value) { + results.push(row); + } + } + } else if (op === '<') { + for (i = 0, l = data.length; i < l; i++) { + row = data[i]; + obj = row[key]; + if (obj < value) { + results.push(row); + } + } + } else if (op === '<=') { + for (i = 0, l = data.length; i < l; i++) { + row = data[i]; + obj = row[key]; + if (obj <= value) { + results.push(row); + } + } + } else { + throw new Error('Invalid op ' + op); } return results; }; @@ -22957,7 +23143,7 @@ g.ticks = function (min, max, n) { module.exports = g; -},{"./list":21,"lodash":4}],11:[function(require,module,exports){ +},{"./list":21,"lodash":3}],11:[function(require,module,exports){ /* jshint eqeqeq:false */ 'use strict'; @@ -23710,8 +23896,9 @@ g.stack = function (shapes, direction, margin) { var tx, ty, t, bounds, firstBounds = shapes[0].bounds(), newShapes = []; + if (direction === 'e') { - tx = -(firstBounds.width / 2); + tx = firstBounds.x; _.each(shapes, function (shape) { bounds = shape.bounds(); t = new vg.Transform().translate(tx - bounds.x, 0); @@ -23719,23 +23906,23 @@ g.stack = function (shapes, direction, margin) { tx += bounds.width + margin; }); } else if (direction === 'w') { - tx = firstBounds.width / 2; + tx = firstBounds.x + firstBounds.width; _.each(shapes, function (shape) { bounds = shape.bounds(); - t = new vg.Transform().translate(tx + bounds.x, 0); + t = new vg.Transform().translate(tx - (bounds.x + bounds.width), 0); newShapes.push(transform(shape, t)); tx -= bounds.width + margin; }); } else if (direction === 'n') { - ty = firstBounds.height / 2; + ty = firstBounds.y + firstBounds.height; _.each(shapes, function (shape) { bounds = shape.bounds(); - t = new vg.Transform().translate(0, ty + bounds.y); + t = new vg.Transform().translate(0, ty - (bounds.y + bounds.height)); newShapes.push(transform(shape, t)); ty -= bounds.height + margin; }); } else if (direction === 's') { - ty = -(firstBounds.height / 2); + ty = firstBounds.y; _.each(shapes, function (shape) { bounds = shape.bounds(); t = new vg.Transform().translate(0, ty - bounds.y); @@ -23830,7 +24017,7 @@ g.invert = function (shape) { module.exports = g; -},{"./img/img":18,"./math":22,"./vg/vg":45,"lodash":4}],14:[function(require,module,exports){ +},{"./img/img":18,"./math":22,"./vg/vg":45,"lodash":3}],14:[function(require,module,exports){ 'use strict'; var vg = require('./vg/vg'); @@ -24349,6 +24536,8 @@ function getNativeModes() { var dCanvas = document.createElement('canvas'); var ctx = dCanvas.getContext('2d'); + if (!ctx) { return {}; } + var native = ['source-over', 'source-in', 'source-out', 'source-atop', 'destination-over', 'destination-in', 'destination-out', 'destination-atop', 'lighter', 'darker', 'copy', 'xor']; @@ -28159,6 +28348,16 @@ g.contains = function (l, value) { return false; }; +g.cycle = function (l, length) { + if (!l || length <= 0) { return []; } + var newList = []; + var ll = l.length; + for (var i = 0; i < length; i += 1) { + newList.push(l[i % ll]); + } + return newList; +}; + g.equals = function (o1, o2) { return deepEqual.deepEqual(o1, o2); }; @@ -28261,6 +28460,9 @@ g.randomSample = function (l, amount, seed) { g.repeat = function (l, amount, perItem) { if (!l) { return []; } + if (!Array.isArray(l)) { + l = [l]; + } if (amount <= 0) { return []; } var i, j, v, newList = []; @@ -28310,6 +28512,7 @@ g.shuffle = function (l, seed) { seed = Math.random(); } r = util.randomGenerator(seed || 0); + l = l.slice(); for (i = l.length - 1; i > 0; i--) { j = Math.floor(r(0, i + 1)); tmp = l[i]; @@ -28810,15 +29013,17 @@ g.xor = function (bool1, bool2) { module.exports = g; -},{"./util":24,"./vg/vg":45,"lodash":4}],23:[function(require,module,exports){ +},{"./util":24,"./vg/vg":45,"lodash":3}],23:[function(require,module,exports){ 'use strict'; var g = {}; g.characterAt = function (s, index) { - if (!s || s.length === 0) { return null; } + if (!s || s.length === 0) { return ''; } s = String(s); - index = index % s.length; + if (index < 0) { + index = s.length + index; + } return s.charAt(index); }; @@ -28896,15 +29101,18 @@ g.stringTrim = function (s) { }; g.substring = function (s, start, end, endOffset) { - if (!s) { return null; } + if (!s) { return ''; } + if (end < start) { return ''; } s = String(s); - start = start % s.length; + + if (start < 0 && end < 0) { + start = s.length + start; + end = s.length + end; + } if (end !== undefined) { if (endOffset) { - end = (end % s.length) + 1; - } else { - end = end % (s.length + 1); + end += 1; } } return s.substring(start, end); @@ -29397,7 +29605,9 @@ vg.mirror = function (shape, angle, origin, keepOriginal) { return new Point(pt.x, pt.y); }; - var mirrorPath = function (path) { + var mirrorPath, mirrorPoints, mirrorGroup, mirror; + + mirrorPath = function (path) { var pt, ctrl1, ctrl2; var p = new Path([], path.fill, path.stroke, path.strokeWidth); for (var i = 0; i < path.commands.length; i += 1) { @@ -29422,20 +29632,20 @@ vg.mirror = function (shape, angle, origin, keepOriginal) { return p; }; - var mirrorPoints = function (points) { + mirrorPoints = function (points) { return _.map(points, function (point) { return f(point.x, point.y); }); }; - var mirrorGroup = function (group) { + mirrorGroup = function (group) { var shapes = _.map(group.shapes, function (shape) { return mirror(shape); }); return new Group(shapes); }; - var mirror = function (shape) { + mirror = function (shape) { if (Array.isArray(shape) && shape.length > 0 && shape[0].x !== undefined && shape[0].y !== undefined) { return mirrorPoints(shape); } @@ -29998,53 +30208,6 @@ vg.link = function (shape1, shape2, orientation) { return p; }; -vg.stack = function (shapes, direction, margin) { - if (!shapes) { - return []; - } - if (shapes.length <= 1) { - return shapes; - } - var tx, ty, t, bounds, - firstBounds = shapes[0].bounds(), - newShapes = []; - margin = margin || 0; - if (direction === vg.EAST) { - tx = -(firstBounds.width / 2); - _.each(shapes, function (shape) { - bounds = shape.bounds(); - t = new Transform().translate(tx - bounds.x, 0); - newShapes.push(t.transformShape(shape)); - tx += bounds.width + margin; - }); - } else if (direction === vg.WEST) { - tx = firstBounds.width / 2; - _.each(shapes, function (shape) { - bounds = shape.bounds(); - t = new Transform().translate(tx + bounds.x, 0); - newShapes.push(t.transformShape(shape)); - tx -= bounds.width + margin; - }); - } else if (direction === vg.NORTH) { - ty = firstBounds.height / 2; - _.each(shapes, function (shape) { - bounds = shape.bounds(); - t = new Transform().translate(0, ty + bounds.y); - newShapes.push(t.transformShape(shape)); - ty -= bounds.height + margin; - }); - } else if (direction === vg.SOUTH) { - ty = -(firstBounds.height / 2); - _.each(shapes, function (shape) { - bounds = shape.bounds(); - t = new Transform().translate(0, ty - bounds.y); - newShapes.push(t.transformShape(shape)); - ty += bounds.height + margin; - }); - } - return newShapes; -}; - vg.compound = function (shape1, shape2, method) { var methods = { 'union': ClipperLib.ClipType.ctUnion, @@ -30109,7 +30272,7 @@ vg.compound = function (shape1, shape2, method) { module.exports = vg; -},{"../objects/color":28,"../objects/group":29,"../objects/path":31,"../objects/point":32,"../objects/rect":33,"../objects/transform":35,"../objects/transformable":36,"../util/bezier":38,"../util/geo":40,"../util/math":42,"../util/random":43,"js-clipper":3,"lodash":4}],27:[function(require,module,exports){ +},{"../objects/color":28,"../objects/group":29,"../objects/path":31,"../objects/point":32,"../objects/rect":33,"../objects/transform":35,"../objects/transformable":36,"../util/bezier":38,"../util/geo":40,"../util/math":42,"../util/random":43,"js-clipper":2,"lodash":3}],27:[function(require,module,exports){ // Basic shapes 'use strict'; @@ -30420,7 +30583,7 @@ vg.demoEllipse = function () { module.exports = vg; -},{"../objects/color":28,"../objects/path":31,"../objects/point":32,"../objects/text":34,"../util/geo":40,"lodash":4}],28:[function(require,module,exports){ +},{"../objects/color":28,"../objects/path":31,"../objects/point":32,"../objects/text":34,"../util/geo":40,"lodash":3}],28:[function(require,module,exports){ // Color object 'use strict'; @@ -30888,7 +31051,7 @@ Group.prototype.draw = function (ctx) { module.exports = Group; -},{"../objects/color":28,"../objects/path":31,"../objects/rect":33,"lodash":4}],30:[function(require,module,exports){ +},{"../objects/color":28,"../objects/path":31,"../objects/rect":33,"lodash":3}],30:[function(require,module,exports){ // 3-dimensional matrix 'use strict'; @@ -31649,7 +31812,7 @@ Path.combine = function () { module.exports = Path; -},{"../objects/color":28,"../objects/rect":33,"../util/bezier":38,"../util/geo":40,"../util/math":42,"lodash":4}],32:[function(require,module,exports){ +},{"../objects/color":28,"../objects/rect":33,"../util/bezier":38,"../util/geo":40,"../util/math":42,"lodash":3}],32:[function(require,module,exports){ // 2-dimensional point object. 'use strict'; @@ -31852,7 +32015,7 @@ module.exports = Rect; },{"../objects/point":32}],34:[function(require,module,exports){ // Text object -// Internally the object is called "gText" to avoid conflicts with the DOM Text object. +// Internally the object is called "GText" to avoid conflicts with the DOM Text object. // Externally it is exposed as g.Text. 'use strict'; @@ -31873,7 +32036,7 @@ var _dummyContext = null; // new g.Text('Hello', [0, 0], {fontFamily: 'Helvetica', fontSize: 12, textAlign: 'center'}); // new g.Text('Hello', 0, 0, {fontFamily: 'Helvetica', fontSize: 12}); // align: center is the default. // new g.Text('Hello', {fontFamily: 'Helvetica', fontSize: 12}); // the position defaults to 0,0. -var gText = function (text) { +var GText = function (text) { var args = Array.prototype.slice.call(arguments, 1), secondArg = arguments[1], thirdArg = arguments[2], @@ -31938,8 +32101,8 @@ var gText = function (text) { this.transform = new Transform(); }; -gText.prototype.clone = function () { - var t = new gText(); +GText.prototype.clone = function () { + var t = new GText(); t.text = this.text; t.x = this.x; t.y = this.y; @@ -31953,7 +32116,7 @@ gText.prototype.clone = function () { // The `measureWidth` function requires a canvas, so we set up a dummy one // that we re-use for the duration of the page. -gText._getDummyContext = function () { +GText._getDummyContext = function () { if (!_dummyContext) { if (typeof document !== 'undefined') { _dummyContext = document.createElement('canvas').getContext('2d'); @@ -31972,17 +32135,17 @@ gText._getDummyContext = function () { return _dummyContext; }; -gText.prototype._getFont = function () { +GText.prototype._getFont = function () { return this.fontSize + 'px ' + this.fontFamily; }; -gText.prototype.colorize = function (fill) { +GText.prototype.colorize = function (fill) { var t = this.clone(); t.fill = Color.clone(fill); return t; }; -gText.prototype.draw = function (ctx) { +GText.prototype.draw = function (ctx) { ctx.save(); ctx.font = this._getFont(); ctx.textAlign = this.textAlign; @@ -31993,8 +32156,8 @@ gText.prototype.draw = function (ctx) { ctx.restore(); }; -gText.prototype.bounds = function () { - var ctx = gText._getDummyContext(), +GText.prototype.bounds = function () { + var ctx = GText._getDummyContext(), metrics, x = this.x; ctx.font = this._getFont(); @@ -32008,7 +32171,7 @@ gText.prototype.bounds = function () { return new Rect(x, this.y - this.fontSize, metrics.width, this.fontSize * 1.2); }; -gText.prototype.toSVG = function () { +GText.prototype.toSVG = function () { var svg = '=t.length&&r(null))}))})},r.forEach=r.each,r.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)return e();var r=0,u=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e(null):u())})};u()},r.forEachSeries=r.eachSeries,r.eachLimit=function(n,t,e,r){var u=a(t);u.apply(null,[n,e,r])},r.forEachLimit=r.eachLimit;var a=function(n){return function(t,e,r){if(r=r||function(){},!t.length||0>=n)return r();var u=0,i=0,c=0;!function o(){if(u>=t.length)return r();for(;n>c&&i=t.length?r():o())})}()}},l=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.each].concat(t))}},f=function(n,t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a(n)].concat(e))}},s=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.eachSeries].concat(t))}},p=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e,r){u[n.index]=r,t(e)})},function(n){r(n,u)})};r.map=l(p),r.mapSeries=s(p),r.mapLimit=function(n,t,e,r){return m(t)(n,e,r)};var m=function(n){return f(n,p)};r.reduce=function(n,t,e,u){r.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){u(n,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(n,t,e,u){var c=i(n,function(n){return n}).reverse();r.reduce(c,t,e,u)},r.foldr=r.reduceRight;var y=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.filter=l(y),r.filterSeries=s(y),r.select=r.filter,r.selectSeries=r.filterSeries;var v=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.reject=l(v),r.rejectSeries=s(v);var h=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(n){r()})};r.detect=l(h),r.detectSeries=s(h),r.some=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(n){e(!1)})},r.any=r.some,r.every=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(n){e(!0)})},r.all=r.every,r.sortBy=function(n,t,e){r.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);var r=function(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0};e(null,i(t.sort(r),function(n){return n.value}))})},r.auto=function(n,t){t=t||function(){};var e=o(n);if(!e.length)return t(null);var i={},a=[],l=function(n){a.unshift(n)},f=function(n){for(var t=0;tt;t++)n[t].apply(null,arguments)}])))};return u.memo=e,u.unmemoized=n,u},r.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},r.times=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.map(u,t,e)},r.timesSeries=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.mapSeries(u,t,e)},r.compose=function(){var n=Array.prototype.reverse.call(arguments);return function(){var t=this,e=Array.prototype.slice.call(arguments),u=e.pop();r.reduce(n,e,function(n,e,r){e.apply(t,n.concat([function(){var n=arguments[0],t=Array.prototype.slice.call(arguments,1);r(n,t)}]))},function(n,e){u.apply(t,[n].concat(e))})}};var A=function(n,t){var e=function(){var e=this,r=Array.prototype.slice.call(arguments),u=r.pop();return n(t,function(n,t){n.apply(e,r.concat([t]))},u)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};r.applyEach=l(A),r.applyEachSeries=s(A),r.forever=function(n,t){function e(r){if(r){if(t)return t(r);throw r}n(e)}e()},"undefined"!=typeof define&&define.amd?define([],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:t.async=r}(); +!function(){function n(n){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,n.apply(t,arguments)}}var t,e,r={};t=this,null!=t&&(e=t.async),r.noConflict=function(){return t.async=e,r};var u=function(n,t){if(n.forEach)return n.forEach(t);for(var e=0;e=t.length&&r(null))}))})},r.forEach=r.each,r.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)return e();var r=0,u=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e(null):u())})};u()},r.forEachSeries=r.eachSeries,r.eachLimit=function(n,t,e,r){var u=a(t);u.apply(null,[n,e,r])},r.forEachLimit=r.eachLimit;var a=function(n){return function(t,e,r){if(r=r||function(){},!t.length||n<=0)return r();var u=0,i=0,c=0;!function o(){if(u>=t.length)return r();for(;c=t.length?r():o())})}()}},l=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.each].concat(t))}},f=function(n,t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a(n)].concat(e))}},s=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.eachSeries].concat(t))}},p=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e,r){u[n.index]=r,t(e)})},function(n){r(n,u)})};r.map=l(p),r.mapSeries=s(p),r.mapLimit=function(n,t,e,r){return y(t)(n,e,r)};var y=function(n){return f(n,p)};r.reduce=function(n,t,e,u){r.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){u(n,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(n,t,e,u){var c=i(n,function(n){return n}).reverse();r.reduce(c,t,e,u)},r.foldr=r.reduceRight;var v=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.filter=l(v),r.filterSeries=s(v),r.select=r.filter,r.selectSeries=r.filterSeries;var h=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.reject=l(h),r.rejectSeries=s(h);var d=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(n){r()})};r.detect=l(d),r.detectSeries=s(d),r.some=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(n){e(!1)})},r.any=r.some,r.every=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(n){e(!0)})},r.all=r.every,r.sortBy=function(n,t,e){r.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);var r=function(n,t){var e=n.criteria,r=t.criteria;return er?1:0};e(null,i(t.sort(r),function(n){return n.value}))})},r.auto=function(n,t){t=t||function(){};var e=o(n);if(!e.length)return t(null);var i={},a=[],l=function(n){a.unshift(n)},f=function(n){for(var t=0;t2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};r.applyEach=l(A),r.applyEachSeries=s(A),r.forever=function(n,t){function e(r){if(r){if(t)return t(r);throw r}n(e)}e()},"undefined"!=typeof define&&define.amd?define([],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:t.async=r}(); }).call(this,require('_process')) -},{"_process":2}],2:[function(require,module,exports){ -function drainQueue(){if(!draining){draining=!0;for(var e,o=queue.length;o;){e=queue,queue=[];for(var r=-1;++r=0;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n}function am2(t,e,i,r,n,p){for(var o=32767&e,l=e>>15;--p>=0;){var s=32767&this[t],h=this[t++]>>15,u=l*s+h*o;s=o*s+((32767&u)<<15)+i[r]+(1073741823&n),n=(s>>>30)+(u>>>15)+l*h+(n>>>30),i[r++]=1073741823&s}return n}function am3(t,e,i,r,n,p){for(var o=16383&e,l=e>>14;--p>=0;){var s=16383&this[t],h=this[t++]>>14,u=l*s+h*o;s=o*s+((16383&u)<<14)+i[r]+n,n=(s>>28)+(u>>14)+l*h,i[r++]=268435455&s}return n}function int2char(t){return BI_RM.charAt(t)}function intAt(t,e){var i=BI_RC[t.charCodeAt(e)];return null==i?-1:i}function bnpCopyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function bnpFromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}function nbv(t){var e=nbi();return e.fromInt(t),e}function bnpFromString(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var r=t.length,n=!1,p=0;--r>=0;){var o=8==i?255&t[r]:intAt(t,r);o<0?"-"==t.charAt(r)&&(n=!0):(n=!1,0==p?this[this.t++]=o:p+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-p):this[this.t-1]|=o<=this.DB&&(p-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,p>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function bnToString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<0)for(l>l)>0&&(n=!0,p=int2char(i));o>=0;)l>(l+=this.DB-e)):(i=this[o]>>(l-=e)&r,l<=0&&(l+=this.DB,--o)),i>0&&(n=!0),n&&(p+=int2char(i));return n?p:"0"}function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function nbits(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function bnpDRShiftTo(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>n|l,l=(this[i]&p)<=0;--i)e[i]=0;e[o]=l,e.t=this.t+o+1,e.s=this.s,e.clamp()}function bnpRShiftTo(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,n=this.DB-r,p=(1<>r;for(var o=i+1;o>r;r>0&&(e[this.t-i-1]|=(this.s&p)<>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function bnpMultiplyTo(t,e){var i=this.abs(),r=t.abs(),n=i.t;for(e.t=n+r.t;--n>=0;)e[n]=0;for(n=0;n=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function bnpDivRemTo(t,e,i){var r=t.abs();if(!(r.t<=0)){var n=this.abs();if(n.t0?(r.lShiftTo(s,p),n.lShiftTo(s,i)):(r.copyTo(p),n.copyTo(i));var h=p.t,u=p[h-1];if(0!=u){var a=u*(1<1?p[h-2]>>this.F2:0),C=this.FV/a,f=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),BigInteger.ONE.dlShiftTo(h,b),b.subTo(p,p);p.t=0;){var m=i[--L]==u?this.DM:Math.floor(i[L]*C+(i[L-1]+d)*f);if((i[L]+=p.am(0,m,i,P,0,h))0&&i.rShiftTo(s,i),o<0&&BigInteger.ZERO.subTo(i,i)}}}function bnMod(t){var e=nbi();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e}function Classic(t){this.m=t}function cConvert(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function cRevert(t){return t}function cReduce(t){t.divRemTo(this.m,null,t)}function cMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function cSqrTo(t,e){t.squareTo(e),this.reduce(e)}function bnpInvDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(e,e),e}function montRevert(t){var e=nbi();return t.copyTo(e),this.reduce(e),e}function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function montSqrTo(t,e){t.squareTo(e),this.reduce(e)}function montMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var i=nbi(),r=nbi(),n=e.convert(this),p=nbits(t)-1;for(n.copyTo(i);--p>=0;)if(e.sqrTo(i,r),(t&1<0)e.mulTo(r,n,i);else{var o=i;i=r,r=o}return e.revert(i)}function bnModPowInt(t,e){var i;return i=t<256||e.isEven()?new Classic(e):new Montgomery(e),this.exp(t,i)}function bnClone(){var t=nbi();return this.copyTo(t),t}function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=nbv(i),n=nbi(),p=nbi(),o="";for(this.divRemTo(r,n,p);n.signum()>0;)o=(i+p.intValue()).toString(t).substr(1)+o,n.divRemTo(r,n,p);return p.intValue().toString(t)+o}function bnpFromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),n=!1,p=0,o=0,l=0;l=i&&(this.dMultiply(r),this.dAddOffset(o,0),p=0,o=0))}p>0&&(this.dMultiply(Math.pow(e,p)),this.dAddOffset(o,0)),n&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var r=new Array,n=7&t;r.length=(t>>3)+1,e.nextBytes(r),n>0?r[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<=0;)r<8?(i=(this[t]&(1<>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=i);return e}function bnEquals(t){return 0==this.compareTo(t)}function bnMin(t){return this.compareTo(t)<0?this:t}function bnMax(t){return this.compareTo(t)>0?this:t}function bnpBitwiseTo(t,e,i){var r,n,p=Math.min(t.t,this.t);for(r=0;r>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function bnGetLowestSetBit(){for(var t=0;t=this.t?0!=this.s:0!=(this[e]&1<>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function bnAdd(t){var e=nbi();return this.addTo(t,e),e}function bnSubtract(t){var e=nbi();return this.subTo(t,e),e}function bnMultiply(t){var e=nbi();return this.multiplyTo(t,e),e}function bnSquare(){var t=nbi();return this.squareTo(t),t}function bnDivide(t){var e=nbi();return this.divRemTo(t,e,null),e}function bnRemainder(t){var e=nbi();return this.divRemTo(t,null,e),e}function bnDivideAndRemainder(t){var e=nbi(),i=nbi();return this.divRemTo(t,e,i),new Array(e,i)}function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function NullExp(){}function nNop(t){return t}function nMulTo(t,e,i){t.multiplyTo(e,i)}function nSqrTo(t,e){t.squareTo(e)}function bnPow(t){return this.exp(t,new NullExp)}function bnpMultiplyLowerTo(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var n;for(n=i.t-this.t;r=0;)i[r]=0;for(r=Math.max(e-this.t,0);r2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=nbi();return t.copyTo(e),this.reduce(e),e}function barrettRevert(t){return t}function barrettReduce(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function barrettSqrTo(t,e){t.squareTo(e),this.reduce(e)}function barrettMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function bnModPow(t,e){var i,r,n=t.bitLength(),p=nbv(1);if(n<=0)return p;i=n<18?1:n<48?3:n<144?4:n<768?5:6,r=n<8?new Classic(e):e.isEven()?new Barrett(e):new Montgomery(e);var o=new Array,l=3,s=i-1,h=(1<1){var u=nbi();for(r.sqrTo(o[1],u);l<=h;)o[l]=nbi(),r.mulTo(u,o[l-2],o[l]),l+=2}var a,C,f=t.t-1,d=!0,L=nbi();for(n=nbits(t[f])-1;f>=0;){for(n>=s?a=t[f]>>n-s&h:(a=(t[f]&(1<0&&(a|=t[f-1]>>this.DB+n-s)),l=i;0==(1&a);)a>>=1,--l;if((n-=l)<0&&(n+=this.DB,--f),d)o[a].copyTo(p),d=!1;else{for(;l>1;)r.sqrTo(p,L),r.sqrTo(L,p),l-=2;l>0?r.sqrTo(p,L):(C=p,p=L,L=C),r.mulTo(L,o[a],p)}for(;f>=0&&0==(t[f]&1<0&&(e.rShiftTo(p,e),i.rShiftTo(p,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return p>0&&i.lShiftTo(p,i),i}function bnpModInt(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function bnModInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return BigInteger.ZERO;for(var i=t.clone(),r=this.clone(),n=nbv(1),p=nbv(0),o=nbv(0),l=nbv(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(n.isEven()&&p.isEven()||(n.addTo(this,n),p.subTo(t,p)),n.rShiftTo(1,n)):p.isEven()||p.subTo(t,p),p.rShiftTo(1,p);for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&l.isEven()||(o.addTo(this,o),l.subTo(t,l)),o.rShiftTo(1,o)):l.isEven()||l.subTo(t,l),l.rShiftTo(1,l);i.compareTo(r)>=0?(i.subTo(r,i),e&&n.subTo(o,n),p.subTo(l,p)):(r.subTo(i,r),e&&o.subTo(n,o),l.subTo(p,l))}return 0!=r.compareTo(BigInteger.ONE)?BigInteger.ZERO:l.compareTo(t)>=0?l.subtract(t):l.signum()<0?(l.addTo(t,l),l.signum()<0?l.add(t):l):l}function bnIsProbablePrime(t){var e,i=this.abs();if(1==i.t&&i[0]<=lowprimes[lowprimes.length-1]){for(e=0;e>1,t>lowprimes.length&&(t=lowprimes.length);for(var n=nbi(),p=0;p0},Int128.op_LessThan=function(t,e){return t.compareTo(e)<0},Int128.op_Addition=function(t,e){return new Int128(t).add(new Int128(e))},Int128.op_Subtraction=function(t,e){return new Int128(t).subtract(new Int128(e))},Int128.Int128Mul=function(t,e){return new Int128(t).multiply(new Int128(e))},Int128.op_Division=function(t,e){return t.divide(e)},Int128.prototype.ToDouble=function(){return parseFloat(this.toString())},"undefined"==typeof Inherit)var Inherit=function(t,e){var i;if("undefined"==typeof Object.getOwnPropertyNames){for(i in e.prototype)"undefined"!=typeof t.prototype[i]&&t.prototype[i]!=Object.prototype[i]||(t.prototype[i]=e.prototype[i]);for(i in e)"undefined"==typeof t[i]&&(t[i]=e[i]);t.$baseCtor=e}else{for(var r=Object.getOwnPropertyNames(e.prototype),n=0;n0?this.m_Childs[0]:this.GetNextSiblingUp()},ClipperLib.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index==this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},ClipperLib.PolyNode.prototype.Childs=function(){return this.m_Childs},ClipperLib.PolyNode.prototype.Parent=function(){return this.m_Parent},ClipperLib.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},ClipperLib.PolyTree=function(){this.m_AllPolys=[],ClipperLib.PolyNode.call(this)},ClipperLib.PolyTree.prototype.Clear=function(){for(var t=0,e=this.m_AllPolys.length;t0?this.m_Childs[0]:null},ClipperLib.PolyTree.prototype.Total=function(){return this.m_AllPolys.length},Inherit(ClipperLib.PolyTree,ClipperLib.PolyNode),ClipperLib.Math_Abs_Int64=ClipperLib.Math_Abs_Int32=ClipperLib.Math_Abs_Double=function(t){return Math.abs(t)},ClipperLib.Math_Max_Int32_Int32=function(t,e){return Math.max(t,e)},browser.msie||browser.opera||browser.safari?ClipperLib.Cast_Int32=function(t){return 0|t}:ClipperLib.Cast_Int32=function(t){return~~t},browser.chrome?ClipperLib.Cast_Int64=function(t){return t<-2147483648||t>2147483647?t<0?Math.ceil(t):Math.floor(t):~~t}:browser.firefox&&"function"==typeof Number.toInteger?ClipperLib.Cast_Int64=function(t){return Number.toInteger(t)}:browser.msie7||browser.msie8?ClipperLib.Cast_Int64=function(t){return parseInt(t,10)}:browser.msie?ClipperLib.Cast_Int64=function(t){return t<-2147483648||t>2147483647?t<0?Math.ceil(t):Math.floor(t):0|t}:ClipperLib.Cast_Int64=function(t){return t<0?Math.ceil(t):Math.floor(t)},ClipperLib.Clear=function(t){t.length=0},ClipperLib.PI=3.141592653589793,ClipperLib.PI2=6.283185307179586,ClipperLib.IntPoint=function(){var t=arguments,e=t.length;if(this.X=0,this.Y=0,use_xyz)if(this.Z=0,3==e)this.X=t[0],this.Y=t[1],this.Z=t[2];else if(2==e)this.X=t[0],this.Y=t[1],this.Z=0;else if(1==e)if(t[0]instanceof ClipperLib.DoublePoint){var i=t[0];this.X=ClipperLib.Clipper.Round(i.X),this.Y=ClipperLib.Clipper.Round(i.Y),this.Z=0}else{var r=t[0];"undefined"==typeof r.Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z}else this.X=0,this.Y=0,this.Z=0;else if(2==e)this.X=t[0],this.Y=t[1];else if(1==e)if(t[0]instanceof ClipperLib.DoublePoint){var i=t[0];this.X=ClipperLib.Clipper.Round(i.X),this.Y=ClipperLib.Clipper.Round(i.Y)}else{var r=t[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},ClipperLib.IntPoint.op_Equality=function(t,e){return t.X==e.X&&t.Y==e.Y},ClipperLib.IntPoint.op_Inequality=function(t,e){return t.X!=e.X||t.Y!=e.Y},use_xyz?(ClipperLib.IntPoint0=function(){this.X=0,this.Y=0,this.Z=0},ClipperLib.IntPoint1=function(t){this.X=t.X,this.Y=t.Y,this.Z=t.Z},ClipperLib.IntPoint1dp=function(t){this.X=ClipperLib.Clipper.Round(t.X),this.Y=ClipperLib.Clipper.Round(t.Y),this.Z=0},ClipperLib.IntPoint2=function(t,e){this.X=t,this.Y=e,this.Z=0},ClipperLib.IntPoint3=function(t,e,i){this.X=t,this.Y=e,this.Z=i}):(ClipperLib.IntPoint0=function(){this.X=0,this.Y=0},ClipperLib.IntPoint1=function(t){this.X=t.X,this.Y=t.Y},ClipperLib.IntPoint1dp=function(t){this.X=ClipperLib.Clipper.Round(t.X),this.Y=ClipperLib.Clipper.Round(t.Y)},ClipperLib.IntPoint2=function(t,e){this.X=t,this.Y=e}),ClipperLib.IntRect=function(){var t=arguments,e=t.length;4==e?(this.left=t[0],this.top=t[1],this.right=t[2],this.bottom=t[3]):1==e?(this.left=ir.left,this.top=ir.top,this.right=ir.right,this.bottom=ir.bottom):(this.left=0,this.top=0,this.right=0,this.bottom=0)},ClipperLib.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},ClipperLib.IntRect1=function(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom},ClipperLib.IntRect4=function(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r},ClipperLib.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},ClipperLib.PolyType={ptSubject:0,ptClip:1},ClipperLib.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},ClipperLib.JoinType={jtSquare:0,jtRound:1,jtMiter:2},ClipperLib.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},use_deprecated&&(ClipperLib.EndType_={etSquare:0,etRound:1,etButt:2,etClosed:3}),ClipperLib.EdgeSide={esLeft:0,esRight:1},ClipperLib.Direction={dRightToLeft:0,dLeftToRight:1},ClipperLib.TEdge=function(){this.Bot=new ClipperLib.IntPoint,this.Curr=new ClipperLib.IntPoint,this.Top=new ClipperLib.IntPoint,this.Delta=new ClipperLib.IntPoint,this.Dx=0,this.PolyTyp=ClipperLib.PolyType.ptSubject,this.Side=ClipperLib.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},ClipperLib.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new ClipperLib.IntPoint},ClipperLib.MyIntersectNodeSort=function(){},ClipperLib.MyIntersectNodeSort.Compare=function(t,e){return e.Pt.Y-t.Pt.Y},ClipperLib.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},ClipperLib.Scanbeam=function(){this.Y=0,this.Next=null},ClipperLib.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},ClipperLib.OutPt=function(){this.Idx=0,this.Pt=new ClipperLib.IntPoint,this.Next=null,this.Prev=null},ClipperLib.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new ClipperLib.IntPoint},ClipperLib.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_MinimaList=null,this.m_CurrentLM=null,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},ClipperLib.ClipperBase.horizontal=-9007199254740992,ClipperLib.ClipperBase.Skip=-2,ClipperLib.ClipperBase.Unassigned=-1,ClipperLib.ClipperBase.tolerance=1e-20,use_int32?(ClipperLib.ClipperBase.loRange=46340,ClipperLib.ClipperBase.hiRange=46340):(ClipperLib.ClipperBase.loRange=47453132,ClipperLib.ClipperBase.hiRange=0xfffffffffffff),ClipperLib.ClipperBase.near_zero=function(t){return t>-ClipperLib.ClipperBase.tolerance&&te.X==t.Xe.Y==t.Ye.X==t.Xe.Y==t.YClipperLib.ClipperBase.hiRange||t.Y>ClipperLib.ClipperBase.hiRange||-t.X>ClipperLib.ClipperBase.hiRange||-t.Y>ClipperLib.ClipperBase.hiRange)&&ClipperLib.Error("Coordinate outside allowed range in RangeTest()."):(t.X>ClipperLib.ClipperBase.loRange||t.Y>ClipperLib.ClipperBase.loRange||-t.X>ClipperLib.ClipperBase.loRange||-t.Y>ClipperLib.ClipperBase.loRange)&&(e.Value=!0,this.RangeTest(t,e))},ClipperLib.ClipperBase.prototype.InitEdge=function(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,t.OutIdx=-1},ClipperLib.ClipperBase.prototype.InitEdge2=function(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y),this.SetDx(t),t.PolyTyp=e},ClipperLib.ClipperBase.prototype.FindNextLocMin=function(t){for(var e;;){for(;ClipperLib.IntPoint.op_Inequality(t.Bot,t.Prev.Bot)||ClipperLib.IntPoint.op_Equality(t.Curr,t.Top);)t=t.Next;if(t.Dx!=ClipperLib.ClipperBase.horizontal&&t.Prev.Dx!=ClipperLib.ClipperBase.horizontal)break;for(;t.Prev.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Prev;for(e=t;t.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Next;if(t.Top.Y!=t.Prev.Bot.Y){e.Prev.Bot.Xp.Next.Top.X&&(p=i.Prev)}for(;t!=p;)t.NextInLML=t.Next,t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Prev.Top.X&&this.ReverseHorizontal(t),t=t.Next;t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Prev.Top.X&&this.ReverseHorizontal(t),p=p.Next}else{for(;p.Top.Y==p.Prev.Bot.Y&&p.Prev.OutIdx!=ClipperLib.ClipperBase.Skip;)p=p.Prev;if(p.Dx==ClipperLib.ClipperBase.horizontal&&p.Prev.OutIdx!=ClipperLib.ClipperBase.Skip){for(i=p;i.Next.Dx==ClipperLib.ClipperBase.horizontal;)i=i.Next;i.Next.Top.X==p.Prev.Top.X?e||(p=i.Next):i.Next.Top.X>p.Prev.Top.X&&(p=i.Next)}for(;t!=p;)t.NextInLML=t.Prev,t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Next.Top.X&&this.ReverseHorizontal(t),t=t.Prev;t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Next.Top.X&&this.ReverseHorizontal(t),p=p.Prev}if(p.OutIdx==ClipperLib.ClipperBase.Skip){if(t=p,e){for(;t.Top.Y==t.Next.Bot.Y;)t=t.Next;for(;t!=p&&t.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Prev}else{for(;t.Top.Y==t.Prev.Bot.Y;)t=t.Prev;for(;t!=p&&t.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Next}if(t==p)p=e?t.Next:t.Prev;else{t=e?p.Next:p.Prev;var o=new ClipperLib.LocalMinima;o.Next=null,o.Y=t.Bot.Y,o.LeftBound=null,o.RightBound=t,o.RightBound.WindDelta=0,p=this.ProcessBound(o.RightBound,e),this.InsertLocalMinima(o)}}return p},ClipperLib.ClipperBase.prototype.AddPath=function(t,e,i){use_lines?i||e!=ClipperLib.PolyType.ptClip||ClipperLib.Error("AddPath: Open paths must be subject."):i||ClipperLib.Error("AddPath: Open paths have been disabled.");var r=t.length-1;if(i)for(;r>0&&ClipperLib.IntPoint.op_Equality(t[r],t[0]);)--r;for(;r>0&&ClipperLib.IntPoint.op_Equality(t[r],t[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var n=new Array,p=0;p<=r;p++)n.push(new ClipperLib.TEdge);var o=!0;n[1].Curr.X=t[1].X,n[1].Curr.Y=t[1].Y;var l={Value:this.m_UseFullRange};this.RangeTest(t[0],l),this.m_UseFullRange=l.Value,l.Value=this.m_UseFullRange,this.RangeTest(t[r],l),this.m_UseFullRange=l.Value,this.InitEdge(n[0],n[1],n[r],t[0]),this.InitEdge(n[r],n[0],n[r-1],t[r]);for(var p=r-1;p>=1;--p)l.Value=this.m_UseFullRange,this.RangeTest(t[p],l),this.m_UseFullRange=l.Value,this.InitEdge(n[p],n[p+1],n[p-1],t[p]);for(var s=n[0],h=s,u=s;;)if(ClipperLib.IntPoint.op_Equality(h.Curr,h.Next.Curr)){if(h==h.Next)break;h==s&&(s=h.Next),h=this.RemoveEdge(h),u=h}else{if(h.Prev==h.Next)break;if(!i||!ClipperLib.ClipperBase.SlopesEqual(h.Prev.Curr,h.Curr,h.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(h.Prev.Curr,h.Curr,h.Next.Curr)){if(h=h.Next,h==u)break}else h==s&&(s=h.Next),h=this.RemoveEdge(h),h=h.Prev,u=h}if(!i&&h==h.Next||i&&h.Prev==h.Next)return!1;i||(this.m_HasOpenPaths=!0,s.Prev.OutIdx=ClipperLib.ClipperBase.Skip);h=s;do this.InitEdge2(h,e),h=h.Next,o&&h.Curr.Y!=s.Curr.Y&&(o=!1);while(h!=s);if(o){if(i)return!1;h.Prev.OutIdx=ClipperLib.ClipperBase.Skip,h.Prev.Bot.Xt.X==e.Xt.Y==e.Y=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;null!==e.Next&&t.Ythis.m_Scanbeam.Y){var e=new ClipperLib.Scanbeam;e.Y=t,e.Next=this.m_Scanbeam,this.m_Scanbeam=e}else{for(var i=this.m_Scanbeam;null!==i.Next&&t<=i.Next.Y;)i=i.Next;if(t==i.Y)return;var e=new ClipperLib.Scanbeam;e.Y=t,e.Next=i.Next,i.Next=e}},ClipperLib.Clipper.prototype.Execute=function(){var t=arguments,e=t.length,i=t[1]instanceof ClipperLib.PolyTree;if(4==e&&!i){var r=t[0],n=t[1],p=t[2],o=t[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&ClipperLib.Error("Error: PolyTree struct is need for open path clipping."),this.m_ExecuteLocked=!0,ClipperLib.Clear(n),this.m_SubjFillType=p,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{var l=this.ExecuteInternal();l&&this.BuildResult(n)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(4==e&&i){var r=t[0],s=t[1],p=t[2],o=t[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=p,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var l=this.ExecuteInternal();l&&this.BuildResult2(s)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(2==e&&!i){var r=t[0],n=t[1];return this.Execute(r,n,ClipperLib.PolyFillType.pftEvenOdd,ClipperLib.PolyFillType.pftEvenOdd)}if(2==e&&i){var r=t[0],s=t[1];return this.Execute(r,s,ClipperLib.PolyFillType.pftEvenOdd,ClipperLib.PolyFillType.pftEvenOdd)}},ClipperLib.Clipper.prototype.FixHoleLinkage=function(t){if(null!==t.FirstLeft&&(t.IsHole==t.FirstLeft.IsHole||null===t.FirstLeft.Pts)){for(var e=t.FirstLeft;null!==e&&(e.IsHole==t.IsHole||null===e.Pts);)e=e.FirstLeft;t.FirstLeft=e}},ClipperLib.Clipper.prototype.ExecuteInternal=function(){try{if(this.Reset(),null===this.m_CurrentLM)return!1;var t=this.PopScanbeam();do{if(this.InsertLocalMinimaIntoAEL(t),ClipperLib.Clear(this.m_GhostJoins),this.ProcessHorizontals(!1),null===this.m_Scanbeam)break;var e=this.PopScanbeam();if(!this.ProcessIntersections(t,e))return!1;this.ProcessEdgesAtTopOfScanbeam(e),t=e}while(null!==this.m_Scanbeam||null!==this.m_CurrentLM);for(var i=0,r=this.m_PolyOuts.length;i0&&this.ReversePolyPtLinks(n.Pts)}this.JoinCommonEdges();for(var i=0,r=this.m_PolyOuts.length;i0&&0!==i.WindDelta)for(var n=0,p=this.m_GhostJoins.length;n=0&&null!==e.PrevInAEL&&e.PrevInAEL.Curr.X==e.Bot.X&&e.PrevInAEL.OutIdx>=0&&ClipperLib.ClipperBase.SlopesEqual(e.PrevInAEL,e,this.m_UseFullRange)&&0!==e.WindDelta&&0!==e.PrevInAEL.WindDelta){var l=this.AddOutPt(e.PrevInAEL,e.Bot);this.AddJoin(r,l,e.Top)}if(e.NextInAEL!=i){if(i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&ClipperLib.ClipperBase.SlopesEqual(i.PrevInAEL,i,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){var l=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(r,l,i.Top)}var s=e.NextInAEL;if(null!==s)for(;s!=i;)this.IntersectEdges(i,s,e.Curr,!1),s=s.NextInAEL}}}},ClipperLib.Clipper.prototype.InsertEdgeIntoAEL=function(t,e){if(null===this.m_ActiveEdges)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(null===e&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(null===e&&(e=this.m_ActiveEdges);null!==e.NextInAEL&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}},ClipperLib.Clipper.prototype.E2InsertsBeforeE1=function(t,e){return e.Curr.X==t.Curr.X?e.Top.Y>t.Top.Y?e.Top.XClipperLib.Clipper.TopX(e,t.Top.Y):e.Curr.X0;default:return t.WindCnt2<0}case ClipperLib.ClipType.ctUnion:switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case ClipperLib.ClipType.ctDifference:if(t.PolyTyp==ClipperLib.PolyType.ptSubject)switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0!==t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case ClipperLib.ClipType.ctXor:if(0!==t.WindDelta)return!0;switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}}return!0},ClipperLib.Clipper.prototype.SetWindingCount=function(t){for(var e=t.PrevInAEL;null!==e&&(e.PolyTyp!=t.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e)t.WindCnt=0===t.WindDelta?1:t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges;else if(0===t.WindDelta&&this.m_ClipType!=ClipperLib.ClipType.ctUnion)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(0===t.WindDelta){for(var i=!0,r=e.PrevInAEL;null!==r;)r.PolyTyp==e.PolyTyp&&0!==r.WindDelta&&(i=!i),r=r.PrevInAEL;t.WindCnt=i?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=0===t.WindDelta?1:t.WindDelta:0===t.WindDelta?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!=t;)0!==e.WindDelta&&(t.WindCnt2=0===t.WindCnt2?1:0),e=e.NextInAEL;else for(;e!=t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL},ClipperLib.Clipper.prototype.AddEdgeToSEL=function(t){null===this.m_SortedEdges?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)},ClipperLib.Clipper.prototype.CopyAELToSEL=function(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL},ClipperLib.Clipper.prototype.SwapPositionsInAEL=function(t,e){if(t.NextInAEL!=t.PrevInAEL&&e.NextInAEL!=e.PrevInAEL){if(t.NextInAEL==e){var i=e.NextInAEL;null!==i&&(i.PrevInAEL=t);var r=t.PrevInAEL;null!==r&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL==t){var i=t.NextInAEL;null!==i&&(i.PrevInAEL=e);var r=e.PrevInAEL;null!==r&&(r.NextInAEL=t),t.PrevInAEL=r,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=i}else{var i=t.NextInAEL,r=t.PrevInAEL;t.NextInAEL=e.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=i,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=r,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e)}null===t.PrevInAEL?this.m_ActiveEdges=t:null===e.PrevInAEL&&(this.m_ActiveEdges=e)}},ClipperLib.Clipper.prototype.SwapPositionsInSEL=function(t,e){if(!(null===t.NextInSEL&&null===t.PrevInSEL||null===e.NextInSEL&&null===e.PrevInSEL)){if(t.NextInSEL==e){var i=e.NextInSEL;null!==i&&(i.PrevInSEL=t);var r=t.PrevInSEL;null!==r&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i}else if(e.NextInSEL==t){var i=t.NextInSEL;null!==i&&(i.PrevInSEL=e);var r=e.PrevInSEL;null!==r&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e)}null===t.PrevInSEL?this.m_SortedEdges=t:null===e.PrevInSEL&&(this.m_SortedEdges=e)}},ClipperLib.Clipper.prototype.AddLocalMaxPoly=function(t,e,i){this.AddOutPt(t,i),0==e.WindDelta&&this.AddOutPt(e,i),t.OutIdx==e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdxe.Dx?(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,t.Side=ClipperLib.EdgeSide.esLeft,e.Side=ClipperLib.EdgeSide.esRight,n=t,p=n.PrevInAEL==e?e.PrevInAEL:n.PrevInAEL):(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,t.Side=ClipperLib.EdgeSide.esRight,e.Side=ClipperLib.EdgeSide.esLeft,n=e,p=n.PrevInAEL==t?t.PrevInAEL:n.PrevInAEL),null!==p&&p.OutIdx>=0&&ClipperLib.Clipper.TopX(p,i.Y)==ClipperLib.Clipper.TopX(n,i.Y)&&ClipperLib.ClipperBase.SlopesEqual(n,p,this.m_UseFullRange)&&0!==n.WindDelta&&0!==p.WindDelta){var o=this.AddOutPt(p,i);this.AddJoin(r,o,n.Top)}return r},ClipperLib.Clipper.prototype.CreateOutRec=function(){var t=new ClipperLib.OutRec;return t.Idx=-1,t.IsHole=!1,t.IsOpen=!1,t.FirstLeft=null,t.Pts=null,t.BottomPt=null,t.PolyNode=null,this.m_PolyOuts.push(t),t.Idx=this.m_PolyOuts.length-1,t},ClipperLib.Clipper.prototype.AddOutPt=function(t,e){var i=t.Side==ClipperLib.EdgeSide.esLeft;if(t.OutIdx<0){var r=this.CreateOutRec();r.IsOpen=0===t.WindDelta;var n=new ClipperLib.OutPt;return r.Pts=n,n.Idx=r.Idx,n.Pt.X=e.X,n.Pt.Y=e.Y,n.Next=n,n.Prev=n,r.IsOpen||this.SetHoleState(t,r),use_xyz&&(ClipperLib.IntPoint.op_Equality(e,t.Bot)?(n.Pt.X=t.Bot.X,n.Pt.Y=t.Bot.Y,n.Pt.Z=t.Bot.Z):ClipperLib.IntPoint.op_Equality(e,t.Top)?(n.Pt.X=t.Top.X,n.Pt.Y=t.Top.Y,n.Pt.Z=t.Top.Z):this.SetZ(n.Pt,t)),t.OutIdx=r.Idx,n}var r=this.m_PolyOuts[t.OutIdx],p=r.Pts;if(i&&ClipperLib.IntPoint.op_Equality(e,p.Pt))return p;if(!i&&ClipperLib.IntPoint.op_Equality(e,p.Prev.Pt))return p.Prev;var n=new ClipperLib.OutPt;return n.Idx=r.Idx,n.Pt.X=e.X,n.Pt.Y=e.Y,n.Next=p,n.Prev=p.Prev,n.Prev.Next=n,p.Prev=n,i&&(r.Pts=n),use_xyz&&(ClipperLib.IntPoint.op_Equality(e,t.Bot)?(n.Pt.X=t.Bot.X,n.Pt.Y=t.Bot.Y,n.Pt.Z=t.Bot.Z):ClipperLib.IntPoint.op_Equality(e,t.Top)?(n.Pt.X=t.Top.X,n.Pt.Y=t.Top.Y,n.Pt.Z=t.Top.Z):this.SetZ(n.Pt,t)),n},ClipperLib.Clipper.prototype.SwapPoints=function(t,e){var i=new ClipperLib.IntPoint(t.Value);t.Value.X=e.Value.X,t.Value.Y=e.Value.Y,e.Value.X=i.X,e.Value.Y=i.Y},ClipperLib.Clipper.prototype.HorzSegmentsOverlap=function(t,e,i,r){return t.X>i.X==t.Xi.X==e.Xt.X==i.Xt.X==r.X=0&&0!=r.WindDelta&&(i=!i,null===e.FirstLeft&&(e.FirstLeft=this.m_PolyOuts[r.OutIdx])),r=r.PrevInAEL;i&&(e.IsHole=!0)},ClipperLib.Clipper.prototype.GetDx=function(t,e){return t.Y==e.Y?ClipperLib.ClipperBase.horizontal:(e.X-t.X)/(e.Y-t.Y)},ClipperLib.Clipper.prototype.FirstIsBottomPt=function(t,e){for(var i=t.Prev;ClipperLib.IntPoint.op_Equality(i.Pt,t.Pt)&&i!=t;)i=i.Prev;var r=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;ClipperLib.IntPoint.op_Equality(i.Pt,t.Pt)&&i!=t;)i=i.Next;var n=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=e.Prev;ClipperLib.IntPoint.op_Equality(i.Pt,e.Pt)&&i!=e;)i=i.Prev;var p=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;ClipperLib.IntPoint.op_Equality(i.Pt,e.Pt)&&i!=e;)i=i.Next;var o=Math.abs(this.GetDx(e.Pt,i.Pt));return r>=p&&r>=o||n>=p&&n>=o},ClipperLib.Clipper.prototype.GetBottomPt=function(t){for(var e=null,i=t.Next;i!=t;)i.Pt.Y>t.Pt.Y?(t=i,e=null):i.Pt.Y==t.Pt.Y&&i.Pt.X<=t.Pt.X&&(i.Pt.Xr.Pt.Y?t:i.Pt.Yr.Pt.X?e:i.Next==i?e:r.Next==r?t:this.FirstIsBottomPt(i,r)?t:e},ClipperLib.Clipper.prototype.Param1RightOfParam2=function(t,e){do if(t=t.FirstLeft,t==e)return!0;while(null!==t);return!1},ClipperLib.Clipper.prototype.GetOutRec=function(t){for(var e=this.m_PolyOuts[t];e!=this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e},ClipperLib.Clipper.prototype.AppendPolygon=function(t,e){var i,r=this.m_PolyOuts[t.OutIdx],n=this.m_PolyOuts[e.OutIdx];i=this.Param1RightOfParam2(r,n)?n:this.Param1RightOfParam2(n,r)?r:this.GetLowermostRec(r,n);var p,o=r.Pts,l=o.Prev,s=n.Pts,h=s.Prev;t.Side==ClipperLib.EdgeSide.esLeft?(e.Side==ClipperLib.EdgeSide.esLeft?(this.ReversePolyPtLinks(s),s.Next=o,o.Prev=s,l.Next=h,h.Prev=l,r.Pts=h):(h.Next=o,o.Prev=h,s.Prev=l,l.Next=s,r.Pts=s),p=ClipperLib.EdgeSide.esLeft):(e.Side==ClipperLib.EdgeSide.esRight?(this.ReversePolyPtLinks(s),l.Next=h,h.Prev=l,s.Next=o,o.Prev=s):(l.Next=s,s.Prev=l,o.Prev=h,h.Next=o),p=ClipperLib.EdgeSide.esRight),r.BottomPt=null,i==n&&(n.FirstLeft!=r&&(r.FirstLeft=n.FirstLeft),r.IsHole=n.IsHole),n.Pts=null,n.BottomPt=null,n.FirstLeft=r;var u=t.OutIdx,a=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var C=this.m_ActiveEdges;null!==C;){if(C.OutIdx==a){C.OutIdx=u,C.Side=p;break}C=C.NextInAEL}n.Idx=r.Idx},ClipperLib.Clipper.prototype.ReversePolyPtLinks=function(t){if(null!==t){var e,i;e=t;do i=e.Next,e.Next=e.Prev,e.Prev=i,e=i;while(e!=t)}},ClipperLib.Clipper.SwapSides=function(t,e){var i=t.Side;t.Side=e.Side,e.Side=i},ClipperLib.Clipper.SwapPolyIndexes=function(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i},ClipperLib.Clipper.prototype.IntersectEdges=function(t,e,i,r){var n=!r&&null===t.NextInLML&&t.Top.X==i.X&&t.Top.Y==i.Y,p=!r&&null===e.NextInLML&&e.Top.X==i.X&&e.Top.Y==i.Y,o=t.OutIdx>=0,l=e.OutIdx>=0;if(use_lines&&(0===t.WindDelta||0===e.WindDelta))return 0===t.WindDelta&&0===e.WindDelta?(n||p)&&o&&l&&this.AddLocalMaxPoly(t,e,i):t.PolyTyp==e.PolyTyp&&t.WindDelta!=e.WindDelta&&this.m_ClipType==ClipperLib.ClipType.ctUnion?0===t.WindDelta?l&&(this.AddOutPt(t,i),o&&(t.OutIdx=-1)):o&&(this.AddOutPt(e,i),l&&(e.OutIdx=-1)):t.PolyTyp!=e.PolyTyp&&(0!==t.WindDelta||1!=Math.abs(e.WindCnt)||this.m_ClipType==ClipperLib.ClipType.ctUnion&&0!==e.WindCnt2?0!==e.WindDelta||1!=Math.abs(t.WindCnt)||this.m_ClipType==ClipperLib.ClipType.ctUnion&&0!==t.WindCnt2||(this.AddOutPt(e,i),l&&(e.OutIdx=-1)):(this.AddOutPt(t,i),o&&(t.OutIdx=-1))),n&&(t.OutIdx<0?this.DeleteFromAEL(t):ClipperLib.Error("Error intersecting polylines")),void(p&&(e.OutIdx<0?this.DeleteFromAEL(e):ClipperLib.Error("Error intersecting polylines")));if(t.PolyTyp==e.PolyTyp)if(this.IsEvenOddFillType(t)){var s=t.WindCnt;t.WindCnt=e.WindCnt,e.WindCnt=s}else t.WindCnt+e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt+=e.WindDelta,e.WindCnt-t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt-=t.WindDelta;else this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2+=e.WindDelta,this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2-=t.WindDelta;var h,u,a,C;t.PolyTyp==ClipperLib.PolyType.ptSubject?(h=this.m_SubjFillType,a=this.m_ClipFillType):(h=this.m_ClipFillType,a=this.m_SubjFillType),e.PolyTyp==ClipperLib.PolyType.ptSubject?(u=this.m_SubjFillType,C=this.m_ClipFillType):(u=this.m_ClipFillType,C=this.m_SubjFillType);var f,d;switch(h){case ClipperLib.PolyFillType.pftPositive:f=t.WindCnt;break;case ClipperLib.PolyFillType.pftNegative:f=-t.WindCnt;break;default:f=Math.abs(t.WindCnt)}switch(u){case ClipperLib.PolyFillType.pftPositive:d=e.WindCnt;break;case ClipperLib.PolyFillType.pftNegative:d=-e.WindCnt;break;default:d=Math.abs(e.WindCnt)}if(o&&l)n||p||0!==f&&1!=f||0!==d&&1!=d||t.PolyTyp!=e.PolyTyp&&this.m_ClipType!=ClipperLib.ClipType.ctXor?this.AddLocalMaxPoly(t,e,i):(this.AddOutPt(t,i),this.AddOutPt(e,i),ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e));else if(o)0!==d&&1!=d||(this.AddOutPt(t,i),ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e));else if(l)0!==f&&1!=f||(this.AddOutPt(e,i),ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e));else if(!(0!==f&&1!=f||0!==d&&1!=d||n||p)){var L,P;switch(a){case ClipperLib.PolyFillType.pftPositive:L=t.WindCnt2;break;case ClipperLib.PolyFillType.pftNegative:L=-t.WindCnt2;break;default:L=Math.abs(t.WindCnt2)}switch(C){case ClipperLib.PolyFillType.pftPositive:P=e.WindCnt2;break;case ClipperLib.PolyFillType.pftNegative:P=-e.WindCnt2;break;default:P=Math.abs(e.WindCnt2)}if(t.PolyTyp!=e.PolyTyp)this.AddLocalMinPoly(t,e,i);else if(1==f&&1==d)switch(this.m_ClipType){case ClipperLib.ClipType.ctIntersection:L>0&&P>0&&this.AddLocalMinPoly(t,e,i);break;case ClipperLib.ClipType.ctUnion:L<=0&&P<=0&&this.AddLocalMinPoly(t,e,i);break;case ClipperLib.ClipType.ctDifference:(t.PolyTyp==ClipperLib.PolyType.ptClip&&L>0&&P>0||t.PolyTyp==ClipperLib.PolyType.ptSubject&&L<=0&&P<=0)&&this.AddLocalMinPoly(t,e,i);break;case ClipperLib.ClipType.ctXor:this.AddLocalMinPoly(t,e,i)}else ClipperLib.Clipper.SwapSides(t,e)}n!=p&&(n&&t.OutIdx>=0||p&&e.OutIdx>=0)&&(ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e)),n&&this.DeleteFromAEL(t),p&&this.DeleteFromAEL(e)}, +ClipperLib.Clipper.prototype.DeleteFromAEL=function(t){var e=t.PrevInAEL,i=t.NextInAEL;null===e&&null===i&&t!=this.m_ActiveEdges||(null!==e?e.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)},ClipperLib.Clipper.prototype.DeleteFromSEL=function(t){var e=t.PrevInSEL,i=t.NextInSEL;null===e&&null===i&&t!=this.m_SortedEdges||(null!==e?e.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)},ClipperLib.Clipper.prototype.UpdateEdgeIntoAEL=function(t){null===t.NextInLML&&ClipperLib.Error("UpdateEdgeIntoAEL: invalid call");var e=t.PrevInAEL,i=t.NextInAEL;return t.NextInLML.OutIdx=t.OutIdx,null!==e?e.NextInAEL=t.NextInLML:this.m_ActiveEdges=t.NextInLML,null!==i&&(i.PrevInAEL=t.NextInLML),t.NextInLML.Side=t.Side,t.NextInLML.WindDelta=t.WindDelta,t.NextInLML.WindCnt=t.WindCnt,t.NextInLML.WindCnt2=t.WindCnt2,t=t.NextInLML,t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,t.PrevInAEL=e,t.NextInAEL=i,ClipperLib.ClipperBase.IsHorizontal(t)||this.InsertScanbeam(t.Top.Y),t},ClipperLib.Clipper.prototype.ProcessHorizontals=function(t){for(var e=this.m_SortedEdges;null!==e;)this.DeleteFromSEL(e),this.ProcessHorizontal(e,t),e=this.m_SortedEdges},ClipperLib.Clipper.prototype.GetHorzDirection=function(t,e){t.Bot.X=n){if(t.OutIdx>=0&&0!=t.WindDelta&&this.PrepareHorzJoins(t,e),h==l&&s)return r==ClipperLib.Direction.dLeftToRight?this.IntersectEdges(t,h,h.Top,!1):this.IntersectEdges(h,t,h.Top,!1),void(l.OutIdx>=0&&ClipperLib.Error("ProcessHorizontal error"));if(r==ClipperLib.Direction.dLeftToRight){var a=new ClipperLib.IntPoint(h.Curr.X,t.Curr.Y);this.IntersectEdges(t,h,a,!0)}else{var a=new ClipperLib.IntPoint(h.Curr.X,t.Curr.Y);this.IntersectEdges(h,t,a,!0)}this.SwapPositionsInAEL(t,h)}else if(r==ClipperLib.Direction.dLeftToRight&&h.Curr.X>=p||r==ClipperLib.Direction.dRightToLeft&&h.Curr.X<=n)break;h=u}if(t.OutIdx>=0&&0!==t.WindDelta&&this.PrepareHorzJoins(t,e),null===t.NextInLML||!ClipperLib.ClipperBase.IsHorizontal(t.NextInLML))break;t=this.UpdateEdgeIntoAEL(t),t.OutIdx>=0&&this.AddOutPt(t,t.Bot);var i={Dir:r,Left:n,Right:p};this.GetHorzDirection(t,i),r=i.Dir,n=i.Left,p=i.Right}if(null!==t.NextInLML)if(t.OutIdx>=0){var C=this.AddOutPt(t,t.Top);if(t=this.UpdateEdgeIntoAEL(t),0===t.WindDelta)return;var f=t.PrevInAEL,u=t.NextInAEL;if(null!==f&&f.Curr.X==t.Bot.X&&f.Curr.Y==t.Bot.Y&&0!==f.WindDelta&&f.OutIdx>=0&&f.Curr.Y>f.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(t,f,this.m_UseFullRange)){var d=this.AddOutPt(f,t.Bot);this.AddJoin(C,d,t.Top)}else if(null!==u&&u.Curr.X==t.Bot.X&&u.Curr.Y==t.Bot.Y&&0!==u.WindDelta&&u.OutIdx>=0&&u.Curr.Y>u.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(t,u,this.m_UseFullRange)){var d=this.AddOutPt(u,t.Bot);this.AddJoin(C,d,t.Top)}}else t=this.UpdateEdgeIntoAEL(t);else null!==l?l.OutIdx>=0?(r==ClipperLib.Direction.dLeftToRight?this.IntersectEdges(t,l,t.Top,!1):this.IntersectEdges(l,t,t.Top,!1),l.OutIdx>=0&&ClipperLib.Error("ProcessHorizontal error")):(this.DeleteFromAEL(t),this.DeleteFromAEL(l)):(t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t))},ClipperLib.Clipper.prototype.GetNextInAEL=function(t,e){return e==ClipperLib.Direction.dLeftToRight?t.NextInAEL:t.PrevInAEL},ClipperLib.Clipper.prototype.IsMinima=function(t){return null!==t&&t.Prev.NextInLML!=t&&t.Next.NextInLML!=t},ClipperLib.Clipper.prototype.IsMaxima=function(t,e){return null!==t&&t.Top.Y==e&&null===t.NextInLML},ClipperLib.Clipper.prototype.IsIntermediate=function(t,e){return t.Top.Y==e&&null!==t.NextInLML},ClipperLib.Clipper.prototype.GetMaximaPair=function(t){var e=null;return ClipperLib.IntPoint.op_Equality(t.Next.Top,t.Top)&&null===t.Next.NextInLML?e=t.Next:ClipperLib.IntPoint.op_Equality(t.Prev.Top,t.Top)&&null===t.Prev.NextInLML&&(e=t.Prev),null===e||e.OutIdx!=-2&&(e.NextInAEL!=e.PrevInAEL||ClipperLib.ClipperBase.IsHorizontal(e))?e:null},ClipperLib.Clipper.prototype.ProcessIntersections=function(t,e){if(null==this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(t,e),0==this.m_IntersectList.length)return!0;if(1!=this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(t){this.m_SortedEdges=null,this.m_IntersectList.length=0,ClipperLib.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},ClipperLib.Clipper.prototype.BuildIntersectList=function(t,e){if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=ClipperLib.Clipper.TopX(i,e),i=i.NextInAEL;for(var r=!0;r&&null!==this.m_SortedEdges;){for(r=!1,i=this.m_SortedEdges;null!==i.NextInSEL;){var n=i.NextInSEL,p=new ClipperLib.IntPoint;if(i.Curr.X>n.Curr.X){!this.IntersectPoint(i,n,p)&&i.Curr.X>n.Curr.X+1&&ClipperLib.Error("Intersection error"),p.Y>t&&(p.Y=t,Math.abs(i.Dx)>Math.abs(n.Dx)?p.X=ClipperLib.Clipper.TopX(n,t):p.X=ClipperLib.Clipper.TopX(i,t));var o=new ClipperLib.IntersectNode;o.Edge1=i,o.Edge2=n,o.Pt.X=p.X,o.Pt.Y=p.Y,this.m_IntersectList.push(o),this.SwapPositionsInSEL(i,n),r=!0}else i=n}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},ClipperLib.Clipper.prototype.EdgesAdjacent=function(t){return t.Edge1.NextInSEL==t.Edge2||t.Edge1.PrevInSEL==t.Edge2},ClipperLib.Clipper.IntersectNodeSort=function(t,e){return e.Pt.Y-t.Pt.Y},ClipperLib.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,e=0;e2147483647?Math.floor(t):0|t)};browser.msie?ClipperLib.Clipper.Round=R1:browser.chromium?ClipperLib.Clipper.Round=R3:browser.safari?ClipperLib.Clipper.Round=R4:ClipperLib.Clipper.Round=R2,ClipperLib.Clipper.TopX=function(t,e){return e==t.Top.Y?t.Top.X:t.Bot.X+ClipperLib.Clipper.Round(t.Dx*(e-t.Bot.Y))},ClipperLib.Clipper.prototype.IntersectPoint=function(t,e,i){i.X=0,i.Y=0;var r,n;if(ClipperLib.ClipperBase.SlopesEqual(t,e,this.m_UseFullRange)||t.Dx==e.Dx)return e.Bot.Y>t.Bot.Y?(i.X=e.Bot.X,i.Y=e.Bot.Y):(i.X=t.Bot.X,i.Y=t.Bot.Y),!1;if(0===t.Delta.X)i.X=t.Bot.X,ClipperLib.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(n=e.Bot.Y-e.Bot.X/e.Dx,i.Y=ClipperLib.Clipper.Round(i.X/e.Dx+n));else if(0===e.Delta.X)i.X=e.Bot.X,ClipperLib.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(r=t.Bot.Y-t.Bot.X/t.Dx,i.Y=ClipperLib.Clipper.Round(i.X/t.Dx+r));else{r=t.Bot.X-t.Bot.Y*t.Dx,n=e.Bot.X-e.Bot.Y*e.Dx;var p=(n-r)/(t.Dx-e.Dx);i.Y=ClipperLib.Clipper.Round(p),Math.abs(t.Dx)e.Top.Y)return i.Y=t.Top.Y,i.X=ClipperLib.Clipper.TopX(e,t.Top.Y),i.X=0&&this.AddOutPt(e,e.Bot),this.AddEdgeToSEL(e)):(e.Curr.X=ClipperLib.Clipper.TopX(e,t),e.Curr.Y=t),this.StrictlySimple){var n=e.PrevInAEL;if(e.OutIdx>=0&&0!==e.WindDelta&&null!==n&&n.OutIdx>=0&&n.Curr.X==e.Curr.X&&0!==n.WindDelta){var p=this.AddOutPt(n,e.Curr),o=this.AddOutPt(e,e.Curr);this.AddJoin(p,o,e.Curr)}}e=e.NextInAEL}}for(this.ProcessHorizontals(!0),e=this.m_ActiveEdges;null!==e;){if(this.IsIntermediate(e,t)){var p=null;e.OutIdx>=0&&(p=this.AddOutPt(e,e.Top)),e=this.UpdateEdgeIntoAEL(e);var n=e.PrevInAEL,l=e.NextInAEL;if(null!==n&&n.Curr.X==e.Bot.X&&n.Curr.Y==e.Bot.Y&&null!==p&&n.OutIdx>=0&&n.Curr.Y>n.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(e,n,this.m_UseFullRange)&&0!==e.WindDelta&&0!==n.WindDelta){var o=this.AddOutPt(n,e.Bot);this.AddJoin(p,o,e.Top)}else if(null!==l&&l.Curr.X==e.Bot.X&&l.Curr.Y==e.Bot.Y&&null!==p&&l.OutIdx>=0&&l.Curr.Y>l.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(e,l,this.m_UseFullRange)&&0!==e.WindDelta&&0!==l.WindDelta){var o=this.AddOutPt(l,e.Bot);this.AddJoin(p,o,e.Top)}}e=e.NextInAEL}},ClipperLib.Clipper.prototype.DoMaxima=function(t){var e=this.GetMaximaPair(t);if(null===e)return t.OutIdx>=0&&this.AddOutPt(t,t.Top),void this.DeleteFromAEL(t);for(var i=t.NextInAEL,r=!0;null!==i&&i!=e;)this.IntersectEdges(t,i,t.Top,!0),this.SwapPositionsInAEL(t,i),i=t.NextInAEL;t.OutIdx==-1&&e.OutIdx==-1?(this.DeleteFromAEL(t),this.DeleteFromAEL(e)):t.OutIdx>=0&&e.OutIdx>=0?this.IntersectEdges(t,e,t.Top,!1):r&&0===t.WindDelta?(t.OutIdx>=0&&(this.AddOutPt(t,t.Top),t.OutIdx=-1),this.DeleteFromAEL(t),e.OutIdx>=0&&(this.AddOutPt(e,t.Top),e.OutIdx=-1),this.DeleteFromAEL(e)):ClipperLib.Error("DoMaxima error")},ClipperLib.Clipper.ReversePaths=function(t){for(var e=0,i=t.length;e=0},ClipperLib.Clipper.prototype.PointCount=function(t){if(null===t)return 0;var e=0,i=t;do e++,i=i.Next;while(i!=t);return e},ClipperLib.Clipper.prototype.BuildResult=function(t){ClipperLib.Clear(t);for(var e=0,i=this.m_PolyOuts.length;ee.Pt.X?ClipperLib.Direction.dRightToLeft:ClipperLib.Direction.dLeftToRight,l=i.Pt.X>r.Pt.X?ClipperLib.Direction.dRightToLeft:ClipperLib.Direction.dLeftToRight;if(o==l)return!1;if(o==ClipperLib.Direction.dLeftToRight){for(;t.Next.Pt.X<=n.X&&t.Next.Pt.X>=t.Pt.X&&t.Next.Pt.Y==n.Y;)t=t.Next;p&&t.Pt.X!=n.X&&(t=t.Next),e=this.DupOutPt(t,!p),ClipperLib.IntPoint.op_Inequality(e.Pt,n)&&(t=e,t.Pt.X=n.X,t.Pt.Y=n.Y,e=this.DupOutPt(t,!p))}else{for(;t.Next.Pt.X>=n.X&&t.Next.Pt.X<=t.Pt.X&&t.Next.Pt.Y==n.Y;)t=t.Next;p||t.Pt.X==n.X||(t=t.Next),e=this.DupOutPt(t,p),ClipperLib.IntPoint.op_Inequality(e.Pt,n)&&(t=e,t.Pt.X=n.X,t.Pt.Y=n.Y,e=this.DupOutPt(t,p))}if(l==ClipperLib.Direction.dLeftToRight){for(;i.Next.Pt.X<=n.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y==n.Y;)i=i.Next;p&&i.Pt.X!=n.X&&(i=i.Next),r=this.DupOutPt(i,!p),ClipperLib.IntPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,r=this.DupOutPt(i,!p))}else{for(;i.Next.Pt.X>=n.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y==n.Y;)i=i.Next;p||i.Pt.X==n.X||(i=i.Next),r=this.DupOutPt(i,p),ClipperLib.IntPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,r=this.DupOutPt(i,p))}return o==ClipperLib.Direction.dLeftToRight==p?(t.Prev=i,i.Next=t,e.Next=r,r.Prev=e):(t.Next=i,i.Prev=t,e.Prev=r,r.Next=e),!0},ClipperLib.Clipper.prototype.JoinPoints=function(t,e,i){var r=t.OutPt1,n=new ClipperLib.OutPt,p=t.OutPt2,o=new ClipperLib.OutPt,l=t.OutPt1.Pt.Y==t.OffPt.Y;if(l&&ClipperLib.IntPoint.op_Equality(t.OffPt,t.OutPt1.Pt)&&ClipperLib.IntPoint.op_Equality(t.OffPt,t.OutPt2.Pt)){for(n=t.OutPt1.Next;n!=r&&ClipperLib.IntPoint.op_Equality(n.Pt,t.OffPt);)n=n.Next;var s=n.Pt.Y>t.OffPt.Y;for(o=t.OutPt2.Next;o!=p&&ClipperLib.IntPoint.op_Equality(o.Pt,t.OffPt);)o=o.Next;var h=o.Pt.Y>t.OffPt.Y;return s!=h&&(s?(n=this.DupOutPt(r,!1),o=this.DupOutPt(p,!0),r.Prev=p,p.Next=r,n.Next=o,o.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(p,!1),r.Next=p,p.Prev=r,n.Prev=o,o.Next=n,t.OutPt1=r,t.OutPt2=n,!0))}if(l){for(n=r;r.Prev.Pt.Y==r.Pt.Y&&r.Prev!=n&&r.Prev!=p;)r=r.Prev;for(;n.Next.Pt.Y==n.Pt.Y&&n.Next!=r&&n.Next!=p;)n=n.Next;if(n.Next==r||n.Next==p)return!1;for(o=p;p.Prev.Pt.Y==p.Pt.Y&&p.Prev!=o&&p.Prev!=n;)p=p.Prev;for(;o.Next.Pt.Y==o.Pt.Y&&o.Next!=p&&o.Next!=r;)o=o.Next;if(o.Next==p||o.Next==r)return!1;var u={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,p.Pt.X,o.Pt.X,u))return!1;var a,C=u.Left,f=u.Right,d=new ClipperLib.IntPoint;return r.Pt.X>=C&&r.Pt.X<=f?(d.X=r.Pt.X,d.Y=r.Pt.Y,a=r.Pt.X>n.Pt.X):p.Pt.X>=C&&p.Pt.X<=f?(d.X=p.Pt.X,d.Y=p.Pt.Y,a=p.Pt.X>o.Pt.X):n.Pt.X>=C&&n.Pt.X<=f?(d.X=n.Pt.X,d.Y=n.Pt.Y,a=n.Pt.X>r.Pt.X):(d.X=o.Pt.X,d.Y=o.Pt.Y,a=o.Pt.X>p.Pt.X),t.OutPt1=r,t.OutPt2=p,this.JoinHorz(r,n,p,o,d,a)}for(n=r.Next;ClipperLib.IntPoint.op_Equality(n.Pt,r.Pt)&&n!=r;)n=n.Next;var L=n.Pt.Y>r.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(r.Pt,n.Pt,t.OffPt,this.m_UseFullRange);if(L){for(n=r.Prev;ClipperLib.IntPoint.op_Equality(n.Pt,r.Pt)&&n!=r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(r.Pt,n.Pt,t.OffPt,this.m_UseFullRange))return!1}for(o=p.Next;ClipperLib.IntPoint.op_Equality(o.Pt,p.Pt)&&o!=p;)o=o.Next;var P=o.Pt.Y>p.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(p.Pt,o.Pt,t.OffPt,this.m_UseFullRange);if(P){for(o=p.Prev;ClipperLib.IntPoint.op_Equality(o.Pt,p.Pt)&&o!=p;)o=o.Prev;if(o.Pt.Y>p.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(p.Pt,o.Pt,t.OffPt,this.m_UseFullRange))return!1}return n!=r&&o!=p&&n!=o&&(e!=i||L!=P)&&(L?(n=this.DupOutPt(r,!1),o=this.DupOutPt(p,!0),r.Prev=p,p.Next=r,n.Next=o,o.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(p,!1),r.Next=p,p.Prev=r,n.Prev=o,o.Next=n,t.OutPt1=r,t.OutPt2=n,!0))},ClipperLib.Clipper.GetBounds=function(t){for(var e=0,i=t.length;er.right&&(r.right=t[e][n].X),t[e][n].Yr.bottom&&(r.bottom=t[e][n].Y);return r},ClipperLib.Clipper.prototype.GetBounds2=function(t){var e=t,i=new ClipperLib.IntRect;for(i.left=t.Pt.X,i.right=t.Pt.X,i.top=t.Pt.Y,i.bottom=t.Pt.Y,t=t.Next;t!=e;)t.Pt.Xi.right&&(i.right=t.Pt.X),t.Pt.Yi.bottom&&(i.bottom=t.Pt.Y),t=t.Next;return i},ClipperLib.Clipper.PointInPolygon=function(t,e){var i=0,r=e.length;if(r<3)return 0;for(var n=e[0],p=1;p<=r;++p){var o=p==r?e[0]:e[p];if(o.Y==t.Y&&(o.X==t.X||n.Y==t.Y&&o.X>t.X==n.X=t.X)if(o.X>t.X)i=1-i;else{var l=(n.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(n.Y-t.Y);if(0==l)return-1;l>0==o.Y>n.Y&&(i=1-i)}else if(o.X>t.X){var l=(n.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(n.Y-t.Y);if(0==l)return-1;l>0==o.Y>n.Y&&(i=1-i)}n=o}return i},ClipperLib.Clipper.prototype.PointInPolygon=function(t,e){for(var i=0,r=e;;){var n=e.Pt.X,p=e.Pt.Y,o=e.Next.Pt.X,l=e.Next.Pt.Y;if(l==t.Y&&(o==t.X||p==t.Y&&o>t.X==n=t.X)if(o>t.X)i=1-i;else{var s=(n-t.X)*(l-t.Y)-(o-t.X)*(p-t.Y);if(0==s)return-1;s>0==l>p&&(i=1-i)}else if(o>t.X){var s=(n-t.X)*(l-t.Y)-(o-t.X)*(p-t.Y);if(0==s)return-1;s>0==l>p&&(i=1-i)}if(e=e.Next,r==e)break}return i},ClipperLib.Clipper.prototype.Poly2ContainsPoly1=function(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return 0!=r;i=i.Next}while(i!=t);return!0},ClipperLib.Clipper.prototype.FixupFirstLefts1=function(t,e){for(var i=0,r=this.m_PolyOuts.length;i0&&this.ReversePolyPtLinks(n.Pts)):this.Poly2ContainsPoly1(r.Pts,n.Pts)?(n.IsHole=r.IsHole,r.IsHole=!n.IsHole,n.FirstLeft=r.FirstLeft,r.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,n),(r.IsHole^this.ReverseSolution)==this.Area(r)>0&&this.ReversePolyPtLinks(r.Pts)):(n.IsHole=r.IsHole,n.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,n))}else n.Pts=null,n.BottomPt=null,n.Idx=r.Idx,r.IsHole=p.IsHole,p==n&&(r.FirstLeft=n.FirstLeft),n.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,r)}}},ClipperLib.Clipper.prototype.UpdateOutPtIdxs=function(t){var e=t.Pts;do e.Idx=t.Idx,e=e.Prev;while(e!=t.Pts)},ClipperLib.Clipper.prototype.DoSimplePolygons=function(){for(var t=0;t0&&r&&i.push(t.m_polygon);for(var n=0,p=t.Childs(),o=p.length,l=p[n];n0&&ClipperLib.IntPoint.op_Equality(t[0],t[r]);)r--;n.m_polygon.push(t[0]);for(var p=0,o=0,l=1;l<=r;l++)ClipperLib.IntPoint.op_Inequality(n.m_polygon[p],t[l])&&(p++,n.m_polygon.push(t[l]),(t[l].Y>n.m_polygon[o].Y||t[l].Y==n.m_polygon[o].Y&&t[l].Xs.Y||n.m_polygon[o].Y==s.Y&&n.m_polygon[o].X=0&&!ClipperLib.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var r;r=this.ArcTolerance<=0?ClipperLib.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(t)*ClipperLib.ClipperOffset.def_arc_tolerance?Math.abs(t)*ClipperLib.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var n=3.14159265358979/Math.acos(1-r/Math.abs(t));this.m_sin=Math.sin(ClipperLib.ClipperOffset.two_pi/n),this.m_cos=Math.cos(ClipperLib.ClipperOffset.two_pi/n),this.m_StepsPerRad=n/ClipperLib.ClipperOffset.two_pi,t<0&&(this.m_sin=-this.m_sin);for(var e=0;e0;o--)this.m_normals[o]=new ClipperLib.DoublePoint(-this.m_normals[o-1].X,-this.m_normals[o-1].Y);this.m_normals[0]=new ClipperLib.DoublePoint(-s.X,-s.Y),l=0;for(var o=p-1;o>=0;o--)l=this.OffsetPoint(o,l,i.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(var l=0,o=1;o0;o--)this.m_normals[o]=new ClipperLib.DoublePoint(-this.m_normals[o-1].X,-this.m_normals[o-1].Y);this.m_normals[0]=new ClipperLib.DoublePoint(-this.m_normals[1].X,-this.m_normals[1].Y),l=p-1;for(var o=l-1;o>0;--o)l=this.OffsetPoint(o,l,i.m_jointype);i.m_endtype==ClipperLib.EndType.etOpenButt?(h=new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*t)),this.m_destPoly.push(h),h=new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*t)),this.m_destPoly.push(h)):(l=1, +this.m_sinA=0,i.m_endtype==ClipperLib.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(i.m_jointype==ClipperLib.JoinType.jtRound)for(var u=1,a=0,o=1;o<=n;o++){this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+u*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+a*t)));var C=u;u=u*this.m_cos-this.m_sin*a,a=C*this.m_sin+a*this.m_cos}else for(var u=-1,a=-1,o=0;o<4;++o)this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+u*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+a*t))),u<0?u=1:a<0?a=1:u=-1;this.m_destPolys.push(this.m_destPoly)}}}},ClipperLib.ClipperOffset.prototype.Execute=function(){var t=arguments,e=t[0]instanceof ClipperLib.PolyTree;if(e){var i=t[0],r=t[1];i.Clear(),this.FixOrientations(),this.DoOffset(r);var n=new ClipperLib.Clipper(0);if(n.AddPaths(this.m_destPolys,ClipperLib.PolyType.ptSubject,!0),r>0)n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftPositive,ClipperLib.PolyFillType.pftPositive);else{var p=ClipperLib.Clipper.GetBounds(this.m_destPolys),o=new ClipperLib.Path;if(o.push(new ClipperLib.IntPoint(p.left-10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.top-10)),o.push(new ClipperLib.IntPoint(p.left-10,p.top-10)),n.AddPath(o,ClipperLib.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftNegative,ClipperLib.PolyFillType.pftNegative),1==i.ChildCount()&&i.Childs()[0].ChildCount()>0){var l=i.Childs()[0];i.Childs()[0]=l.Childs()[0];for(var s=1;s0)n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftPositive,ClipperLib.PolyFillType.pftPositive);else{var p=ClipperLib.Clipper.GetBounds(this.m_destPolys),o=new ClipperLib.Path;o.push(new ClipperLib.IntPoint(p.left-10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.top-10)),o.push(new ClipperLib.IntPoint(p.left-10,p.top-10)),n.AddPath(o,ClipperLib.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftNegative,ClipperLib.PolyFillType.pftNegative),i.length>0&&i.splice(0,1)}}},ClipperLib.ClipperOffset.prototype.OffsetPoint=function(t,e,i){if(this.m_sinA=this.m_normals[e].X*this.m_normals[t].Y-this.m_normals[t].X*this.m_normals[e].Y,this.m_sinA<5e-5&&this.m_sinA>-5e-5)return e;if(this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1),this.m_sinA*this.m_delta<0)this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta))),this.m_destPoly.push(new ClipperLib.IntPoint(this.m_srcPoly[t])),this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)));else switch(i){case ClipperLib.JoinType.jtMiter:var r=1+(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y);r>=this.m_miterLim?this.DoMiter(t,e,r):this.DoSquare(t,e);break;case ClipperLib.JoinType.jtSquare:this.DoSquare(t,e);break;case ClipperLib.JoinType.jtRound:this.DoRound(t,e)}return e=t},ClipperLib.ClipperOffset.prototype.DoSquare=function(t,e){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y)/4);this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[e].X-this.m_normals[e].Y*i)),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[e].Y+this.m_normals[e].X*i)))),this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[t].X+this.m_normals[t].Y*i)),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[t].Y-this.m_normals[t].X*i))))},ClipperLib.ClipperOffset.prototype.DoMiter=function(t,e,i){var r=this.m_delta/i;this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+(this.m_normals[e].X+this.m_normals[t].X)*r),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+(this.m_normals[e].Y+this.m_normals[t].Y)*r)))},ClipperLib.ClipperOffset.prototype.DoRound=function(t,e){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y),n=ClipperLib.Cast_Int32(ClipperLib.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),p=this.m_normals[e].X,o=this.m_normals[e].Y,l=0;l1?(b=h.X,m=h.Y):P>0&&(b+=d*P,m+=L*P)),d=u.X-b,L=u.Y-m,a=d*d+L*L,a<=c&&(C[r+1]=1,r++);for(o.push({X:n[0].X,Y:n[0].Y}),r=1;r2&&v.push(o)}return!t[0]instanceof Array&&(v=v[0]),"undefined"==typeof v&&(v=[[]]),v},ClipperLib.JS.PerimeterOfPath=function(t,e,i){if("undefined"==typeof t)return 0;var r,n,p=Math.sqrt,o=0,l=0,s=0,h=0,u=0,a=t.length;if(a<2)return 0;for(e&&(t[a]=t[0],a++);--a;)r=t[a],l=r.X,s=r.Y,n=t[a-1],h=n.X,u=n.Y,o+=p((l-h)*(l-h)+(s-u)*(s-u));return e&&t.pop(),o/i},ClipperLib.JS.PerimeterOfPaths=function(t,e,i){i||(i=1);for(var r=0,n=0;n=0;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n}function am2(t,e,i,r,n,p){for(var o=32767&e,l=e>>15;--p>=0;){var s=32767&this[t],u=this[t++]>>15,h=l*s+u*o;s=o*s+((32767&h)<<15)+i[r]+(1073741823&n),n=(s>>>30)+(h>>>15)+l*u+(n>>>30),i[r++]=1073741823&s}return n}function am3(t,e,i,r,n,p){for(var o=16383&e,l=e>>14;--p>=0;){var s=16383&this[t],u=this[t++]>>14,h=l*s+u*o;s=o*s+((16383&h)<<14)+i[r]+n,n=(s>>28)+(h>>14)+l*u,i[r++]=268435455&s}return n}function int2char(t){return BI_RM.charAt(t)}function intAt(t,e){var i=BI_RC[t.charCodeAt(e)];return null==i?-1:i}function bnpCopyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function bnpFromInt(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function nbv(t){var e=nbi();return e.fromInt(t),e}function bnpFromString(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var r=t.length,n=!1,p=0;--r>=0;){var o=8==i?255&t[r]:intAt(t,r);0>o?"-"==t.charAt(r)&&(n=!0):(n=!1,0==p?this[this.t++]=o:p+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-p):this[this.t-1]|=o<=this.DB&&(p-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,p>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function bnToString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<0)for(l>l)>0&&(n=!0,p=int2char(i));o>=0;)e>l?(i=(this[o]&(1<>(l+=this.DB-e)):(i=this[o]>>(l-=e)&r,0>=l&&(l+=this.DB,--o)),i>0&&(n=!0),n&&(p+=int2char(i));return n?p:"0"}function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(e=i-t.t,0!=e)return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function nbits(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function bnpDRShiftTo(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>n|l,l=(this[i]&p)<=0;--i)e[i]=0;e[o]=l,e.t=this.t+o+1,e.s=this.s,e.clamp()}function bnpRShiftTo(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)return void(e.t=0);var r=t%this.DB,n=this.DB-r,p=(1<>r;for(var o=i+1;o>r;r>0&&(e[this.t-i-1]|=(this.s&p)<i;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=0>r?-1:0,-1>r?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()}function bnpMultiplyTo(t,e){var i=this.abs(),r=t.abs(),n=i.t;for(e.t=n+r.t;--n>=0;)e[n]=0;for(n=0;n=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function bnpDivRemTo(t,e,i){var r=t.abs();if(!(r.t<=0)){var n=this.abs();if(n.t0?(r.lShiftTo(s,p),n.lShiftTo(s,i)):(r.copyTo(p),n.copyTo(i));var u=p.t,h=p[u-1];if(0!=h){var a=h*(1<1?p[u-2]>>this.F2:0),C=this.FV/a,f=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),BigInteger.ONE.dlShiftTo(u,b),b.subTo(p,p);p.t=0;){var m=i[--L]==h?this.DM:Math.floor(i[L]*C+(i[L-1]+d)*f);if((i[L]+=p.am(0,m,i,P,0,u))0&&i.rShiftTo(s,i),0>o&&BigInteger.ZERO.subTo(i,i)}}}function bnMod(t){var e=nbi();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e}function Classic(t){this.m=t}function cConvert(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function cRevert(t){return t}function cReduce(t){t.divRemTo(this.m,null,t)}function cMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function cSqrTo(t,e){t.squareTo(e),this.reduce(e)}function bnpInvDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(e,e),e}function montRevert(t){var e=nbi();return t.copyTo(e),this.reduce(e),e}function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function montSqrTo(t,e){t.squareTo(e),this.reduce(e)}function montMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(t,e){if(t>4294967295||1>t)return BigInteger.ONE;var i=nbi(),r=nbi(),n=e.convert(this),p=nbits(t)-1;for(n.copyTo(i);--p>=0;)if(e.sqrTo(i,r),(t&1<0)e.mulTo(r,n,i);else{var o=i;i=r,r=o}return e.revert(i)}function bnModPowInt(t,e){var i;return i=256>t||e.isEven()?new Classic(e):new Montgomery(e),this.exp(t,i)}function bnClone(){var t=nbi();return this.copyTo(t),t}function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=nbv(i),n=nbi(),p=nbi(),o="";for(this.divRemTo(r,n,p);n.signum()>0;)o=(i+p.intValue()).toString(t).substr(1)+o,n.divRemTo(r,n,p);return p.intValue().toString(t)+o}function bnpFromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),n=!1,p=0,o=0,l=0;ls?"-"==t.charAt(l)&&0==this.signum()&&(n=!0):(o=e*o+s,++p>=i&&(this.dMultiply(r),this.dAddOffset(o,0),p=0,o=0))}p>0&&(this.dMultiply(Math.pow(e,p)),this.dAddOffset(o,0)),n&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(t,e,i){if("number"==typeof e)if(2>t)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var r=new Array,n=7&t;r.length=(t>>3)+1,e.nextBytes(r),n>0?r[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<=0;)8>r?(i=(this[t]&(1<>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,0>=r&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=i);return e}function bnEquals(t){return 0==this.compareTo(t)}function bnMin(t){return this.compareTo(t)<0?this:t}function bnMax(t){return this.compareTo(t)>0?this:t}function bnpBitwiseTo(t,e,i){var r,n,p=Math.min(t.t,this.t);for(r=0;p>r;++r)i[r]=e(this[r],t[r]);if(t.tt?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function bnShiftRight(t){var e=nbi();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function lbit(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function bnGetLowestSetBit(){for(var t=0;t=this.t?0!=this.s:0!=(this[e]&1<i;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=0>r?-1:0,r>0?e[i++]=r:-1>r&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function bnAdd(t){var e=nbi();return this.addTo(t,e),e}function bnSubtract(t){var e=nbi();return this.subTo(t,e),e}function bnMultiply(t){var e=nbi();return this.multiplyTo(t,e),e}function bnSquare(){var t=nbi();return this.squareTo(t),t}function bnDivide(t){var e=nbi();return this.divRemTo(t,e,null),e}function bnRemainder(t){var e=nbi();return this.divRemTo(t,null,e),e}function bnDivideAndRemainder(t){var e=nbi(),i=nbi();return this.divRemTo(t,e,i),new Array(e,i)}function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function NullExp(){}function nNop(t){return t}function nMulTo(t,e,i){t.multiplyTo(e,i)}function nSqrTo(t,e){t.squareTo(e)}function bnPow(t){return this.exp(t,new NullExp)}function bnpMultiplyLowerTo(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;var n;for(n=i.t-this.t;n>r;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(n=Math.min(t.t,e);n>r;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()}function bnpMultiplyUpperTo(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=nbi();return t.copyTo(e),this.reduce(e),e}function barrettRevert(t){return t}function barrettReduce(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function barrettSqrTo(t,e){t.squareTo(e),this.reduce(e)}function barrettMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function bnModPow(t,e){var i,r,n=t.bitLength(),p=nbv(1);if(0>=n)return p;i=18>n?1:48>n?3:144>n?4:768>n?5:6,r=8>n?new Classic(e):e.isEven()?new Barrett(e):new Montgomery(e);var o=new Array,l=3,s=i-1,u=(1<1){var h=nbi();for(r.sqrTo(o[1],h);u>=l;)o[l]=nbi(),r.mulTo(h,o[l-2],o[l]),l+=2}var a,C,f=t.t-1,d=!0,L=nbi();for(n=nbits(t[f])-1;f>=0;){for(n>=s?a=t[f]>>n-s&u:(a=(t[f]&(1<0&&(a|=t[f-1]>>this.DB+n-s)),l=i;0==(1&a);)a>>=1,--l;if((n-=l)<0&&(n+=this.DB,--f),d)o[a].copyTo(p),d=!1;else{for(;l>1;)r.sqrTo(p,L),r.sqrTo(L,p),l-=2;l>0?r.sqrTo(p,L):(C=p,p=L,L=C),r.mulTo(L,o[a],p)}for(;f>=0&&0==(t[f]&1<p)return e;for(p>n&&(p=n),p>0&&(e.rShiftTo(p,e),i.rShiftTo(p,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return p>0&&i.lShiftTo(p,i),i}function bnpModInt(t){if(0>=t)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function bnModInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return BigInteger.ZERO;for(var i=t.clone(),r=this.clone(),n=nbv(1),p=nbv(0),o=nbv(0),l=nbv(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(n.isEven()&&p.isEven()||(n.addTo(this,n),p.subTo(t,p)),n.rShiftTo(1,n)):p.isEven()||p.subTo(t,p),p.rShiftTo(1,p);for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&l.isEven()||(o.addTo(this,o),l.subTo(t,l)),o.rShiftTo(1,o)):l.isEven()||l.subTo(t,l),l.rShiftTo(1,l);i.compareTo(r)>=0?(i.subTo(r,i),e&&n.subTo(o,n),p.subTo(l,p)):(r.subTo(i,r),e&&o.subTo(n,o),l.subTo(p,l))}return 0!=r.compareTo(BigInteger.ONE)?BigInteger.ZERO:l.compareTo(t)>=0?l.subtract(t):l.signum()<0?(l.addTo(t,l),l.signum()<0?l.add(t):l):l}function bnIsProbablePrime(t){var e,i=this.abs();if(1==i.t&&i[0]<=lowprimes[lowprimes.length-1]){for(e=0;er;)r*=lowprimes[n++];for(r=i.modInt(r);n>e;)if(r%lowprimes[e++]==0)return!1}return i.millerRabin(t)}function bnpMillerRabin(t){var e=this.subtract(BigInteger.ONE),i=e.getLowestSetBit();if(0>=i)return!1;var r=e.shiftRight(i);t=t+1>>1,t>lowprimes.length&&(t=lowprimes.length);for(var n=nbi(),p=0;t>p;++p){n.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var o=n.modPow(r,this);if(0!=o.compareTo(BigInteger.ONE)&&0!=o.compareTo(e)){for(var l=1;l++=vv;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];BigInteger.prototype.chunkSize=bnpChunkSize,BigInteger.prototype.toRadix=bnpToRadix,BigInteger.prototype.fromRadix=bnpFromRadix,BigInteger.prototype.fromNumber=bnpFromNumber,BigInteger.prototype.bitwiseTo=bnpBitwiseTo,BigInteger.prototype.changeBit=bnpChangeBit,BigInteger.prototype.addTo=bnpAddTo,BigInteger.prototype.dMultiply=bnpDMultiply,BigInteger.prototype.dAddOffset=bnpDAddOffset,BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo,BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo,BigInteger.prototype.modInt=bnpModInt,BigInteger.prototype.millerRabin=bnpMillerRabin,BigInteger.prototype.clone=bnClone,BigInteger.prototype.intValue=bnIntValue,BigInteger.prototype.byteValue=bnByteValue,BigInteger.prototype.shortValue=bnShortValue,BigInteger.prototype.signum=bnSigNum,BigInteger.prototype.toByteArray=bnToByteArray,BigInteger.prototype.equals=bnEquals,BigInteger.prototype.min=bnMin,BigInteger.prototype.max=bnMax,BigInteger.prototype.and=bnAnd,BigInteger.prototype.or=bnOr,BigInteger.prototype.xor=bnXor,BigInteger.prototype.andNot=bnAndNot,BigInteger.prototype.not=bnNot,BigInteger.prototype.shiftLeft=bnShiftLeft,BigInteger.prototype.shiftRight=bnShiftRight,BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit,BigInteger.prototype.bitCount=bnBitCount,BigInteger.prototype.testBit=bnTestBit,BigInteger.prototype.setBit=bnSetBit,BigInteger.prototype.clearBit=bnClearBit,BigInteger.prototype.flipBit=bnFlipBit,BigInteger.prototype.add=bnAdd,BigInteger.prototype.subtract=bnSubtract,BigInteger.prototype.multiply=bnMultiply,BigInteger.prototype.divide=bnDivide,BigInteger.prototype.remainder=bnRemainder,BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder,BigInteger.prototype.modPow=bnModPow,BigInteger.prototype.modInverse=bnModInverse,BigInteger.prototype.pow=bnPow,BigInteger.prototype.gcd=bnGCD,BigInteger.prototype.isProbablePrime=bnIsProbablePrime,BigInteger.prototype.square=bnSquare;var Int128=BigInteger;if(Int128.prototype.IsNegative=function(){return-1==this.compareTo(Int128.ZERO)?!0:!1},Int128.op_Equality=function(t,e){return 0==t.compareTo(e)?!0:!1},Int128.op_Inequality=function(t,e){return 0!=t.compareTo(e)?!0:!1},Int128.op_GreaterThan=function(t,e){return t.compareTo(e)>0?!0:!1},Int128.op_LessThan=function(t,e){return t.compareTo(e)<0?!0:!1},Int128.op_Addition=function(t,e){return new Int128(t).add(new Int128(e))},Int128.op_Subtraction=function(t,e){return new Int128(t).subtract(new Int128(e))},Int128.Int128Mul=function(t,e){return new Int128(t).multiply(new Int128(e))},Int128.op_Division=function(t,e){return t.divide(e)},Int128.prototype.ToDouble=function(){return parseFloat(this.toString())},"undefined"==typeof Inherit)var Inherit=function(t,e){var i;if("undefined"==typeof Object.getOwnPropertyNames){for(i in e.prototype)("undefined"==typeof t.prototype[i]||t.prototype[i]==Object.prototype[i])&&(t.prototype[i]=e.prototype[i]);for(i in e)"undefined"==typeof t[i]&&(t[i]=e[i]);t.$baseCtor=e}else{for(var r=Object.getOwnPropertyNames(e.prototype),n=0;n0?this.m_Childs[0]:this.GetNextSiblingUp()},ClipperLib.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index==this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},ClipperLib.PolyNode.prototype.Childs=function(){return this.m_Childs},ClipperLib.PolyNode.prototype.Parent=function(){return this.m_Parent},ClipperLib.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},ClipperLib.PolyTree=function(){this.m_AllPolys=[],ClipperLib.PolyNode.call(this)},ClipperLib.PolyTree.prototype.Clear=function(){for(var t=0,e=this.m_AllPolys.length;e>t;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},ClipperLib.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},ClipperLib.PolyTree.prototype.Total=function(){return this.m_AllPolys.length},Inherit(ClipperLib.PolyTree,ClipperLib.PolyNode),ClipperLib.Math_Abs_Int64=ClipperLib.Math_Abs_Int32=ClipperLib.Math_Abs_Double=function(t){return Math.abs(t)},ClipperLib.Math_Max_Int32_Int32=function(t,e){return Math.max(t,e)},browser.msie||browser.opera||browser.safari?ClipperLib.Cast_Int32=function(t){return 0|t}:ClipperLib.Cast_Int32=function(t){return~~t},browser.chrome?ClipperLib.Cast_Int64=function(t){return-2147483648>t||t>2147483647?0>t?Math.ceil(t):Math.floor(t):~~t}:browser.firefox&&"function"==typeof Number.toInteger?ClipperLib.Cast_Int64=function(t){return Number.toInteger(t)}:browser.msie7||browser.msie8?ClipperLib.Cast_Int64=function(t){return parseInt(t,10)}:browser.msie?ClipperLib.Cast_Int64=function(t){return-2147483648>t||t>2147483647?0>t?Math.ceil(t):Math.floor(t):0|t}:ClipperLib.Cast_Int64=function(t){return 0>t?Math.ceil(t):Math.floor(t)},ClipperLib.Clear=function(t){t.length=0},ClipperLib.PI=3.141592653589793,ClipperLib.PI2=6.283185307179586,ClipperLib.IntPoint=function(){var t=arguments,e=t.length;if(this.X=0,this.Y=0,use_xyz)if(this.Z=0,3==e)this.X=t[0],this.Y=t[1],this.Z=t[2];else if(2==e)this.X=t[0],this.Y=t[1],this.Z=0;else if(1==e)if(t[0]instanceof ClipperLib.DoublePoint){var i=t[0];this.X=ClipperLib.Clipper.Round(i.X),this.Y=ClipperLib.Clipper.Round(i.Y),this.Z=0}else{var r=t[0];"undefined"==typeof r.Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z}else this.X=0,this.Y=0,this.Z=0;else if(2==e)this.X=t[0],this.Y=t[1];else if(1==e)if(t[0]instanceof ClipperLib.DoublePoint){var i=t[0];this.X=ClipperLib.Clipper.Round(i.X),this.Y=ClipperLib.Clipper.Round(i.Y)}else{var r=t[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},ClipperLib.IntPoint.op_Equality=function(t,e){return t.X==e.X&&t.Y==e.Y},ClipperLib.IntPoint.op_Inequality=function(t,e){return t.X!=e.X||t.Y!=e.Y},use_xyz?(ClipperLib.IntPoint0=function(){this.X=0,this.Y=0,this.Z=0},ClipperLib.IntPoint1=function(t){this.X=t.X,this.Y=t.Y,this.Z=t.Z},ClipperLib.IntPoint1dp=function(t){this.X=ClipperLib.Clipper.Round(t.X),this.Y=ClipperLib.Clipper.Round(t.Y),this.Z=0},ClipperLib.IntPoint2=function(t,e){this.X=t,this.Y=e,this.Z=0},ClipperLib.IntPoint3=function(t,e,i){this.X=t,this.Y=e,this.Z=i}):(ClipperLib.IntPoint0=function(){this.X=0,this.Y=0},ClipperLib.IntPoint1=function(t){this.X=t.X,this.Y=t.Y},ClipperLib.IntPoint1dp=function(t){this.X=ClipperLib.Clipper.Round(t.X),this.Y=ClipperLib.Clipper.Round(t.Y)},ClipperLib.IntPoint2=function(t,e){this.X=t,this.Y=e}),ClipperLib.IntRect=function(){var t=arguments,e=t.length;4==e?(this.left=t[0],this.top=t[1],this.right=t[2],this.bottom=t[3]):1==e?(this.left=ir.left,this.top=ir.top,this.right=ir.right,this.bottom=ir.bottom):(this.left=0,this.top=0,this.right=0,this.bottom=0)},ClipperLib.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},ClipperLib.IntRect1=function(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom},ClipperLib.IntRect4=function(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r},ClipperLib.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},ClipperLib.PolyType={ptSubject:0,ptClip:1},ClipperLib.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},ClipperLib.JoinType={jtSquare:0,jtRound:1,jtMiter:2},ClipperLib.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},use_deprecated&&(ClipperLib.EndType_={etSquare:0,etRound:1,etButt:2,etClosed:3}),ClipperLib.EdgeSide={esLeft:0,esRight:1},ClipperLib.Direction={dRightToLeft:0,dLeftToRight:1},ClipperLib.TEdge=function(){this.Bot=new ClipperLib.IntPoint,this.Curr=new ClipperLib.IntPoint,this.Top=new ClipperLib.IntPoint,this.Delta=new ClipperLib.IntPoint,this.Dx=0,this.PolyTyp=ClipperLib.PolyType.ptSubject,this.Side=ClipperLib.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},ClipperLib.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new ClipperLib.IntPoint},ClipperLib.MyIntersectNodeSort=function(){},ClipperLib.MyIntersectNodeSort.Compare=function(t,e){return e.Pt.Y-t.Pt.Y},ClipperLib.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},ClipperLib.Scanbeam=function(){this.Y=0,this.Next=null},ClipperLib.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},ClipperLib.OutPt=function(){this.Idx=0,this.Pt=new ClipperLib.IntPoint,this.Next=null,this.Prev=null},ClipperLib.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new ClipperLib.IntPoint},ClipperLib.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_MinimaList=null,this.m_CurrentLM=null,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},ClipperLib.ClipperBase.horizontal=-9007199254740992,ClipperLib.ClipperBase.Skip=-2,ClipperLib.ClipperBase.Unassigned=-1,ClipperLib.ClipperBase.tolerance=1e-20,use_int32?(ClipperLib.ClipperBase.loRange=46340,ClipperLib.ClipperBase.hiRange=46340):(ClipperLib.ClipperBase.loRange=47453132,ClipperLib.ClipperBase.hiRange=0xfffffffffffff),ClipperLib.ClipperBase.near_zero=function(t){return t>-ClipperLib.ClipperBase.tolerance&&te.X==t.Xe.Y==t.Ye.X==t.Xe.Y==t.Yt;++t){for(var i=0,r=this.m_edges[t].length;r>i;++i)this.m_edges[t][i]=null;ClipperLib.Clear(this.m_edges[t])}ClipperLib.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},ClipperLib.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==this.m_MinimaList;){var t=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=t}this.m_CurrentLM=null},ClipperLib.ClipperBase.prototype.RangeTest=function(t,e){e.Value?(t.X>ClipperLib.ClipperBase.hiRange||t.Y>ClipperLib.ClipperBase.hiRange||-t.X>ClipperLib.ClipperBase.hiRange||-t.Y>ClipperLib.ClipperBase.hiRange)&&ClipperLib.Error("Coordinate outside allowed range in RangeTest()."):(t.X>ClipperLib.ClipperBase.loRange||t.Y>ClipperLib.ClipperBase.loRange||-t.X>ClipperLib.ClipperBase.loRange||-t.Y>ClipperLib.ClipperBase.loRange)&&(e.Value=!0,this.RangeTest(t,e))},ClipperLib.ClipperBase.prototype.InitEdge=function(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,t.OutIdx=-1},ClipperLib.ClipperBase.prototype.InitEdge2=function(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y),this.SetDx(t),t.PolyTyp=e},ClipperLib.ClipperBase.prototype.FindNextLocMin=function(t){for(var e;;){for(;ClipperLib.IntPoint.op_Inequality(t.Bot,t.Prev.Bot)||ClipperLib.IntPoint.op_Equality(t.Curr,t.Top);)t=t.Next;if(t.Dx!=ClipperLib.ClipperBase.horizontal&&t.Prev.Dx!=ClipperLib.ClipperBase.horizontal)break;for(;t.Prev.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Prev;for(e=t;t.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Next;if(t.Top.Y!=t.Prev.Bot.Y){e.Prev.Bot.Xp.Next.Top.X&&(p=i.Prev)}for(;t!=p;)t.NextInLML=t.Next,t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Prev.Top.X&&this.ReverseHorizontal(t),t=t.Next;t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Prev.Top.X&&this.ReverseHorizontal(t),p=p.Next}else{for(;p.Top.Y==p.Prev.Bot.Y&&p.Prev.OutIdx!=ClipperLib.ClipperBase.Skip;)p=p.Prev;if(p.Dx==ClipperLib.ClipperBase.horizontal&&p.Prev.OutIdx!=ClipperLib.ClipperBase.Skip){for(i=p;i.Next.Dx==ClipperLib.ClipperBase.horizontal;)i=i.Next;i.Next.Top.X==p.Prev.Top.X?e||(p=i.Next):i.Next.Top.X>p.Prev.Top.X&&(p=i.Next)}for(;t!=p;)t.NextInLML=t.Prev,t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Next.Top.X&&this.ReverseHorizontal(t),t=t.Prev;t.Dx==ClipperLib.ClipperBase.horizontal&&t!=n&&t.Bot.X!=t.Next.Top.X&&this.ReverseHorizontal(t),p=p.Prev}if(p.OutIdx==ClipperLib.ClipperBase.Skip){if(t=p,e){for(;t.Top.Y==t.Next.Bot.Y;)t=t.Next;for(;t!=p&&t.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Prev}else{for(;t.Top.Y==t.Prev.Bot.Y;)t=t.Prev;for(;t!=p&&t.Dx==ClipperLib.ClipperBase.horizontal;)t=t.Next}if(t==p)p=e?t.Next:t.Prev;else{t=e?p.Next:p.Prev;var o=new ClipperLib.LocalMinima;o.Next=null,o.Y=t.Bot.Y,o.LeftBound=null,o.RightBound=t,o.RightBound.WindDelta=0,p=this.ProcessBound(o.RightBound,e),this.InsertLocalMinima(o)}}return p},ClipperLib.ClipperBase.prototype.AddPath=function(t,e,i){use_lines?i||e!=ClipperLib.PolyType.ptClip||ClipperLib.Error("AddPath: Open paths must be subject."):i||ClipperLib.Error("AddPath: Open paths have been disabled.");var r=t.length-1;if(i)for(;r>0&&ClipperLib.IntPoint.op_Equality(t[r],t[0]);)--r;for(;r>0&&ClipperLib.IntPoint.op_Equality(t[r],t[r-1]);)--r;if(i&&2>r||!i&&1>r)return!1;for(var n=new Array,p=0;r>=p;p++)n.push(new ClipperLib.TEdge);var o=!0;n[1].Curr.X=t[1].X,n[1].Curr.Y=t[1].Y;var l={Value:this.m_UseFullRange};this.RangeTest(t[0],l),this.m_UseFullRange=l.Value,l.Value=this.m_UseFullRange,this.RangeTest(t[r],l),this.m_UseFullRange=l.Value,this.InitEdge(n[0],n[1],n[r],t[0]),this.InitEdge(n[r],n[0],n[r-1],t[r]);for(var p=r-1;p>=1;--p)l.Value=this.m_UseFullRange,this.RangeTest(t[p],l),this.m_UseFullRange=l.Value,this.InitEdge(n[p],n[p+1],n[p-1],t[p]);for(var s=n[0],u=s,h=s;;)if(ClipperLib.IntPoint.op_Equality(u.Curr,u.Next.Curr)){if(u==u.Next)break;u==s&&(s=u.Next),u=this.RemoveEdge(u),h=u}else{if(u.Prev==u.Next)break;if(!i||!ClipperLib.ClipperBase.SlopesEqual(u.Prev.Curr,u.Curr,u.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(u.Prev.Curr,u.Curr,u.Next.Curr)){if(u=u.Next,u==h)break}else u==s&&(s=u.Next),u=this.RemoveEdge(u),u=u.Prev,h=u}if(!i&&u==u.Next||i&&u.Prev==u.Next)return!1;i||(this.m_HasOpenPaths=!0,s.Prev.OutIdx=ClipperLib.ClipperBase.Skip);u=s;do this.InitEdge2(u,e),u=u.Next,o&&u.Curr.Y!=s.Curr.Y&&(o=!1);while(u!=s);if(o){if(i)return!1;u.Prev.OutIdx=ClipperLib.ClipperBase.Skip,u.Prev.Bot.Xn;++n)this.AddPath(t[n],e,i)&&(r=!0);return r},ClipperLib.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(t,e,i){return ClipperLib.IntPoint.op_Equality(t,i)||ClipperLib.IntPoint.op_Equality(t,e)||ClipperLib.IntPoint.op_Equality(i,e)?!1:t.X!=i.X?e.X>t.X==e.Xt.Y==e.Y=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;null!==e.Next&&t.Ythis.m_Scanbeam.Y){var e=new ClipperLib.Scanbeam;e.Y=t,e.Next=this.m_Scanbeam,this.m_Scanbeam=e}else{for(var i=this.m_Scanbeam;null!==i.Next&&t<=i.Next.Y;)i=i.Next;if(t==i.Y)return;var e=new ClipperLib.Scanbeam;e.Y=t,e.Next=i.Next,i.Next=e}},ClipperLib.Clipper.prototype.Execute=function(){var t=arguments,e=t.length,i=t[1]instanceof ClipperLib.PolyTree;if(4==e&&!i){var r=t[0],n=t[1],p=t[2],o=t[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&ClipperLib.Error("Error: PolyTree struct is need for open path clipping."),this.m_ExecuteLocked=!0,ClipperLib.Clear(n),this.m_SubjFillType=p,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{var l=this.ExecuteInternal();l&&this.BuildResult(n)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(4==e&&i){var r=t[0],s=t[1],p=t[2],o=t[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=p,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var l=this.ExecuteInternal();l&&this.BuildResult2(s)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(2==e&&!i){var r=t[0],n=t[1];return this.Execute(r,n,ClipperLib.PolyFillType.pftEvenOdd,ClipperLib.PolyFillType.pftEvenOdd)}if(2==e&&i){var r=t[0],s=t[1];return this.Execute(r,s,ClipperLib.PolyFillType.pftEvenOdd,ClipperLib.PolyFillType.pftEvenOdd)}},ClipperLib.Clipper.prototype.FixHoleLinkage=function(t){if(null!==t.FirstLeft&&(t.IsHole==t.FirstLeft.IsHole||null===t.FirstLeft.Pts)){for(var e=t.FirstLeft;null!==e&&(e.IsHole==t.IsHole||null===e.Pts);)e=e.FirstLeft;t.FirstLeft=e}},ClipperLib.Clipper.prototype.ExecuteInternal=function(){try{if(this.Reset(),null===this.m_CurrentLM)return!1;var t=this.PopScanbeam();do{if(this.InsertLocalMinimaIntoAEL(t),ClipperLib.Clear(this.m_GhostJoins),this.ProcessHorizontals(!1),null===this.m_Scanbeam)break;var e=this.PopScanbeam();if(!this.ProcessIntersections(t,e))return!1;this.ProcessEdgesAtTopOfScanbeam(e),t=e}while(null!==this.m_Scanbeam||null!==this.m_CurrentLM);for(var i=0,r=this.m_PolyOuts.length;r>i;i++){var n=this.m_PolyOuts[i];null===n.Pts||n.IsOpen||(n.IsHole^this.ReverseSolution)==this.Area(n)>0&&this.ReversePolyPtLinks(n.Pts)}this.JoinCommonEdges();for(var i=0,r=this.m_PolyOuts.length;r>i;i++){var n=this.m_PolyOuts[i];null===n.Pts||n.IsOpen||this.FixupOutPolygon(n)}return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{ClipperLib.Clear(this.m_Joins),ClipperLib.Clear(this.m_GhostJoins)}},ClipperLib.Clipper.prototype.PopScanbeam=function(){var t=this.m_Scanbeam.Y,e=this.m_Scanbeam;return this.m_Scanbeam=this.m_Scanbeam.Next,e=null,t},ClipperLib.Clipper.prototype.DisposeAllPolyPts=function(){for(var t=0,e=this.m_PolyOuts.length;e>t;++t)this.DisposeOutRec(t);ClipperLib.Clear(this.m_PolyOuts)},ClipperLib.Clipper.prototype.DisposeOutRec=function(t){var e=this.m_PolyOuts[t];null!==e.Pts&&this.DisposeOutPts(e.Pts),e=null,this.m_PolyOuts[t]=null},ClipperLib.Clipper.prototype.DisposeOutPts=function(t){if(null!==t){var e=null;for(t.Prev.Next=null;null!==t;)e=t,t=t.Next,e=null}},ClipperLib.Clipper.prototype.AddJoin=function(t,e,i){var r=new ClipperLib.Join;r.OutPt1=t,r.OutPt2=e,r.OffPt.X=i.X,r.OffPt.Y=i.Y,this.m_Joins.push(r)},ClipperLib.Clipper.prototype.AddGhostJoin=function(t,e){var i=new ClipperLib.Join;i.OutPt1=t,i.OffPt.X=e.X,i.OffPt.Y=e.Y,this.m_GhostJoins.push(i)},use_xyz&&(ClipperLib.Clipper.prototype.SetZ=function(t,e){t.Z=0,null!==this.ZFillFunction&&(e.OutIdx<0?this.ZFillFunction(e.Bot,e.Top,t):this.ZFillFunction(e.Top,e.Bot,t))}),ClipperLib.Clipper.prototype.InsertLocalMinimaIntoAEL=function(t){for(;null!==this.m_CurrentLM&&this.m_CurrentLM.Y==t;){var e=this.m_CurrentLM.LeftBound,i=this.m_CurrentLM.RightBound;this.PopLocalMinima();var r=null;if(null===e?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(r=this.AddOutPt(i,i.Bot))):null==i?(this.InsertEdgeIntoAEL(e,null),this.SetWindingCount(e),this.IsContributing(e)&&(r=this.AddOutPt(e,e.Bot)),this.InsertScanbeam(e.Top.Y)):(this.InsertEdgeIntoAEL(e,null),this.InsertEdgeIntoAEL(i,e),this.SetWindingCount(e),i.WindCnt=e.WindCnt,i.WindCnt2=e.WindCnt2,this.IsContributing(e)&&(r=this.AddLocalMinPoly(e,i,e.Bot)),this.InsertScanbeam(e.Top.Y)),null!=i&&(ClipperLib.ClipperBase.IsHorizontal(i)?this.AddEdgeToSEL(i):this.InsertScanbeam(i.Top.Y)),null!=e&&null!=i){if(null!==r&&ClipperLib.ClipperBase.IsHorizontal(i)&&this.m_GhostJoins.length>0&&0!==i.WindDelta)for(var n=0,p=this.m_GhostJoins.length;p>n;n++){var o=this.m_GhostJoins[n];this.HorzSegmentsOverlap(o.OutPt1.Pt,o.OffPt,i.Bot,i.Top)&&this.AddJoin(o.OutPt1,r,o.OffPt)}if(e.OutIdx>=0&&null!==e.PrevInAEL&&e.PrevInAEL.Curr.X==e.Bot.X&&e.PrevInAEL.OutIdx>=0&&ClipperLib.ClipperBase.SlopesEqual(e.PrevInAEL,e,this.m_UseFullRange)&&0!==e.WindDelta&&0!==e.PrevInAEL.WindDelta){var l=this.AddOutPt(e.PrevInAEL,e.Bot);this.AddJoin(r,l,e.Top)}if(e.NextInAEL!=i){if(i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&ClipperLib.ClipperBase.SlopesEqual(i.PrevInAEL,i,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){var l=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(r,l,i.Top)}var s=e.NextInAEL;if(null!==s)for(;s!=i;)this.IntersectEdges(i,s,e.Curr,!1),s=s.NextInAEL}}}},ClipperLib.Clipper.prototype.InsertEdgeIntoAEL=function(t,e){if(null===this.m_ActiveEdges)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(null===e&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(null===e&&(e=this.m_ActiveEdges);null!==e.NextInAEL&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}},ClipperLib.Clipper.prototype.E2InsertsBeforeE1=function(t,e){return e.Curr.X==t.Curr.X?e.Top.Y>t.Top.Y?e.Top.XClipperLib.Clipper.TopX(e,t.Top.Y):e.Curr.X0;default:return t.WindCnt2<0}case ClipperLib.ClipType.ctUnion:switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case ClipperLib.ClipType.ctDifference:if(t.PolyTyp==ClipperLib.PolyType.ptSubject)switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0!==t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case ClipperLib.ClipType.ctXor:if(0!==t.WindDelta)return!0;switch(i){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===t.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}}return!0},ClipperLib.Clipper.prototype.SetWindingCount=function(t){for(var e=t.PrevInAEL;null!==e&&(e.PolyTyp!=t.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e)t.WindCnt=0===t.WindDelta?1:t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges;else if(0===t.WindDelta&&this.m_ClipType!=ClipperLib.ClipType.ctUnion)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(0===t.WindDelta){for(var i=!0,r=e.PrevInAEL;null!==r;)r.PolyTyp==e.PolyTyp&&0!==r.WindDelta&&(i=!i),r=r.PrevInAEL;t.WindCnt=i?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=0===t.WindDelta?1:t.WindDelta:0===t.WindDelta?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!=t;)0!==e.WindDelta&&(t.WindCnt2=0===t.WindCnt2?1:0),e=e.NextInAEL;else for(;e!=t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL},ClipperLib.Clipper.prototype.AddEdgeToSEL=function(t){null===this.m_SortedEdges?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)},ClipperLib.Clipper.prototype.CopyAELToSEL=function(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL},ClipperLib.Clipper.prototype.SwapPositionsInAEL=function(t,e){if(t.NextInAEL!=t.PrevInAEL&&e.NextInAEL!=e.PrevInAEL){if(t.NextInAEL==e){var i=e.NextInAEL;null!==i&&(i.PrevInAEL=t);var r=t.PrevInAEL;null!==r&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL==t){var i=t.NextInAEL;null!==i&&(i.PrevInAEL=e);var r=e.PrevInAEL;null!==r&&(r.NextInAEL=t),t.PrevInAEL=r,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=i}else{var i=t.NextInAEL,r=t.PrevInAEL;t.NextInAEL=e.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=i,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=r,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e)}null===t.PrevInAEL?this.m_ActiveEdges=t:null===e.PrevInAEL&&(this.m_ActiveEdges=e)}},ClipperLib.Clipper.prototype.SwapPositionsInSEL=function(t,e){if(!(null===t.NextInSEL&&null===t.PrevInSEL||null===e.NextInSEL&&null===e.PrevInSEL)){if(t.NextInSEL==e){var i=e.NextInSEL;null!==i&&(i.PrevInSEL=t);var r=t.PrevInSEL;null!==r&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i}else if(e.NextInSEL==t){var i=t.NextInSEL;null!==i&&(i.PrevInSEL=e);var r=e.PrevInSEL;null!==r&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e)}null===t.PrevInSEL?this.m_SortedEdges=t:null===e.PrevInSEL&&(this.m_SortedEdges=e)}},ClipperLib.Clipper.prototype.AddLocalMaxPoly=function(t,e,i){this.AddOutPt(t,i),0==e.WindDelta&&this.AddOutPt(e,i),t.OutIdx==e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdxe.Dx?(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,t.Side=ClipperLib.EdgeSide.esLeft,e.Side=ClipperLib.EdgeSide.esRight,n=t,p=n.PrevInAEL==e?e.PrevInAEL:n.PrevInAEL):(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,t.Side=ClipperLib.EdgeSide.esRight,e.Side=ClipperLib.EdgeSide.esLeft,n=e,p=n.PrevInAEL==t?t.PrevInAEL:n.PrevInAEL),null!==p&&p.OutIdx>=0&&ClipperLib.Clipper.TopX(p,i.Y)==ClipperLib.Clipper.TopX(n,i.Y)&&ClipperLib.ClipperBase.SlopesEqual(n,p,this.m_UseFullRange)&&0!==n.WindDelta&&0!==p.WindDelta){var o=this.AddOutPt(p,i);this.AddJoin(r,o,n.Top)}return r},ClipperLib.Clipper.prototype.CreateOutRec=function(){var t=new ClipperLib.OutRec;return t.Idx=-1,t.IsHole=!1,t.IsOpen=!1,t.FirstLeft=null,t.Pts=null,t.BottomPt=null,t.PolyNode=null,this.m_PolyOuts.push(t),t.Idx=this.m_PolyOuts.length-1,t},ClipperLib.Clipper.prototype.AddOutPt=function(t,e){var i=t.Side==ClipperLib.EdgeSide.esLeft;if(t.OutIdx<0){var r=this.CreateOutRec();r.IsOpen=0===t.WindDelta;var n=new ClipperLib.OutPt;return r.Pts=n,n.Idx=r.Idx,n.Pt.X=e.X,n.Pt.Y=e.Y,n.Next=n,n.Prev=n,r.IsOpen||this.SetHoleState(t,r),use_xyz&&(ClipperLib.IntPoint.op_Equality(e,t.Bot)?(n.Pt.X=t.Bot.X,n.Pt.Y=t.Bot.Y,n.Pt.Z=t.Bot.Z):ClipperLib.IntPoint.op_Equality(e,t.Top)?(n.Pt.X=t.Top.X,n.Pt.Y=t.Top.Y,n.Pt.Z=t.Top.Z):this.SetZ(n.Pt,t)),t.OutIdx=r.Idx,n}var r=this.m_PolyOuts[t.OutIdx],p=r.Pts;if(i&&ClipperLib.IntPoint.op_Equality(e,p.Pt))return p;if(!i&&ClipperLib.IntPoint.op_Equality(e,p.Prev.Pt))return p.Prev;var n=new ClipperLib.OutPt;return n.Idx=r.Idx,n.Pt.X=e.X,n.Pt.Y=e.Y,n.Next=p,n.Prev=p.Prev,n.Prev.Next=n,p.Prev=n,i&&(r.Pts=n),use_xyz&&(ClipperLib.IntPoint.op_Equality(e,t.Bot)?(n.Pt.X=t.Bot.X,n.Pt.Y=t.Bot.Y,n.Pt.Z=t.Bot.Z):ClipperLib.IntPoint.op_Equality(e,t.Top)?(n.Pt.X=t.Top.X,n.Pt.Y=t.Top.Y,n.Pt.Z=t.Top.Z):this.SetZ(n.Pt,t)),n},ClipperLib.Clipper.prototype.SwapPoints=function(t,e){var i=new ClipperLib.IntPoint(t.Value);t.Value.X=e.Value.X,t.Value.Y=e.Value.Y,e.Value.X=i.X,e.Value.Y=i.Y},ClipperLib.Clipper.prototype.HorzSegmentsOverlap=function(t,e,i,r){return t.X>i.X==t.Xi.X==e.Xt.X==i.Xt.X==r.X=0&&0!=r.WindDelta&&(i=!i,null===e.FirstLeft&&(e.FirstLeft=this.m_PolyOuts[r.OutIdx])),r=r.PrevInAEL;i&&(e.IsHole=!0)},ClipperLib.Clipper.prototype.GetDx=function(t,e){return t.Y==e.Y?ClipperLib.ClipperBase.horizontal:(e.X-t.X)/(e.Y-t.Y)},ClipperLib.Clipper.prototype.FirstIsBottomPt=function(t,e){for(var i=t.Prev;ClipperLib.IntPoint.op_Equality(i.Pt,t.Pt)&&i!=t;)i=i.Prev;var r=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;ClipperLib.IntPoint.op_Equality(i.Pt,t.Pt)&&i!=t;)i=i.Next;var n=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=e.Prev;ClipperLib.IntPoint.op_Equality(i.Pt,e.Pt)&&i!=e;)i=i.Prev;var p=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;ClipperLib.IntPoint.op_Equality(i.Pt,e.Pt)&&i!=e;)i=i.Next;var o=Math.abs(this.GetDx(e.Pt,i.Pt));return r>=p&&r>=o||n>=p&&n>=o},ClipperLib.Clipper.prototype.GetBottomPt=function(t){for(var e=null,i=t.Next;i!=t;)i.Pt.Y>t.Pt.Y?(t=i,e=null):i.Pt.Y==t.Pt.Y&&i.Pt.X<=t.Pt.X&&(i.Pt.Xr.Pt.Y?t:i.Pt.Yr.Pt.X?e:i.Next==i?e:r.Next==r?t:this.FirstIsBottomPt(i,r)?t:e},ClipperLib.Clipper.prototype.Param1RightOfParam2=function(t,e){do if(t=t.FirstLeft,t==e)return!0;while(null!==t);return!1},ClipperLib.Clipper.prototype.GetOutRec=function(t){for(var e=this.m_PolyOuts[t];e!=this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e},ClipperLib.Clipper.prototype.AppendPolygon=function(t,e){var i,r=this.m_PolyOuts[t.OutIdx],n=this.m_PolyOuts[e.OutIdx];i=this.Param1RightOfParam2(r,n)?n:this.Param1RightOfParam2(n,r)?r:this.GetLowermostRec(r,n);var p,o=r.Pts,l=o.Prev,s=n.Pts,u=s.Prev;t.Side==ClipperLib.EdgeSide.esLeft?(e.Side==ClipperLib.EdgeSide.esLeft?(this.ReversePolyPtLinks(s),s.Next=o,o.Prev=s,l.Next=u,u.Prev=l,r.Pts=u):(u.Next=o,o.Prev=u,s.Prev=l,l.Next=s,r.Pts=s),p=ClipperLib.EdgeSide.esLeft):(e.Side==ClipperLib.EdgeSide.esRight?(this.ReversePolyPtLinks(s),l.Next=u,u.Prev=l,s.Next=o,o.Prev=s):(l.Next=s,s.Prev=l,o.Prev=u,u.Next=o),p=ClipperLib.EdgeSide.esRight),r.BottomPt=null,i==n&&(n.FirstLeft!=r&&(r.FirstLeft=n.FirstLeft),r.IsHole=n.IsHole),n.Pts=null,n.BottomPt=null,n.FirstLeft=r;var h=t.OutIdx,a=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var C=this.m_ActiveEdges;null!==C;){if(C.OutIdx==a){C.OutIdx=h,C.Side=p;break}C=C.NextInAEL}n.Idx=r.Idx},ClipperLib.Clipper.prototype.ReversePolyPtLinks=function(t){if(null!==t){var e,i;e=t;do i=e.Next,e.Next=e.Prev,e.Prev=i,e=i;while(e!=t)}},ClipperLib.Clipper.SwapSides=function(t,e){var i=t.Side;t.Side=e.Side,e.Side=i},ClipperLib.Clipper.SwapPolyIndexes=function(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i},ClipperLib.Clipper.prototype.IntersectEdges=function(t,e,i,r){var n=!r&&null===t.NextInLML&&t.Top.X==i.X&&t.Top.Y==i.Y,p=!r&&null===e.NextInLML&&e.Top.X==i.X&&e.Top.Y==i.Y,o=t.OutIdx>=0,l=e.OutIdx>=0;if(use_lines&&(0===t.WindDelta||0===e.WindDelta))return 0===t.WindDelta&&0===e.WindDelta?(n||p)&&o&&l&&this.AddLocalMaxPoly(t,e,i):t.PolyTyp==e.PolyTyp&&t.WindDelta!=e.WindDelta&&this.m_ClipType==ClipperLib.ClipType.ctUnion?0===t.WindDelta?l&&(this.AddOutPt(t,i),o&&(t.OutIdx=-1)):o&&(this.AddOutPt(e,i),l&&(e.OutIdx=-1)):t.PolyTyp!=e.PolyTyp&&(0!==t.WindDelta||1!=Math.abs(e.WindCnt)||this.m_ClipType==ClipperLib.ClipType.ctUnion&&0!==e.WindCnt2?0!==e.WindDelta||1!=Math.abs(t.WindCnt)||this.m_ClipType==ClipperLib.ClipType.ctUnion&&0!==t.WindCnt2||(this.AddOutPt(e,i),l&&(e.OutIdx=-1)):(this.AddOutPt(t,i),o&&(t.OutIdx=-1))),n&&(t.OutIdx<0?this.DeleteFromAEL(t):ClipperLib.Error("Error intersecting polylines")),void(p&&(e.OutIdx<0?this.DeleteFromAEL(e):ClipperLib.Error("Error intersecting polylines")));if(t.PolyTyp==e.PolyTyp)if(this.IsEvenOddFillType(t)){var s=t.WindCnt;t.WindCnt=e.WindCnt,e.WindCnt=s}else t.WindCnt+e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt+=e.WindDelta,e.WindCnt-t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt-=t.WindDelta;else this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2+=e.WindDelta,this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2-=t.WindDelta;var u,h,a,C;t.PolyTyp==ClipperLib.PolyType.ptSubject?(u=this.m_SubjFillType,a=this.m_ClipFillType):(u=this.m_ClipFillType,a=this.m_SubjFillType),e.PolyTyp==ClipperLib.PolyType.ptSubject?(h=this.m_SubjFillType,C=this.m_ClipFillType):(h=this.m_ClipFillType,C=this.m_SubjFillType);var f,d;switch(u){case ClipperLib.PolyFillType.pftPositive:f=t.WindCnt;break;case ClipperLib.PolyFillType.pftNegative:f=-t.WindCnt;break;default:f=Math.abs(t.WindCnt)}switch(h){case ClipperLib.PolyFillType.pftPositive:d=e.WindCnt;break;case ClipperLib.PolyFillType.pftNegative:d=-e.WindCnt;break;default:d=Math.abs(e.WindCnt)}if(o&&l)n||p||0!==f&&1!=f||0!==d&&1!=d||t.PolyTyp!=e.PolyTyp&&this.m_ClipType!=ClipperLib.ClipType.ctXor?this.AddLocalMaxPoly(t,e,i):(this.AddOutPt(t,i),this.AddOutPt(e,i),ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e));else if(o)(0===d||1==d)&&(this.AddOutPt(t,i),ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e));else if(l)(0===f||1==f)&&(this.AddOutPt(e,i),ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e));else if(!(0!==f&&1!=f||0!==d&&1!=d||n||p)){var L,P;switch(a){case ClipperLib.PolyFillType.pftPositive:L=t.WindCnt2;break;case ClipperLib.PolyFillType.pftNegative:L=-t.WindCnt2;break;default:L=Math.abs(t.WindCnt2)}switch(C){case ClipperLib.PolyFillType.pftPositive:P=e.WindCnt2;break;case ClipperLib.PolyFillType.pftNegative:P=-e.WindCnt2;break;default:P=Math.abs(e.WindCnt2)}if(t.PolyTyp!=e.PolyTyp)this.AddLocalMinPoly(t,e,i);else if(1==f&&1==d)switch(this.m_ClipType){case ClipperLib.ClipType.ctIntersection:L>0&&P>0&&this.AddLocalMinPoly(t,e,i);break;case ClipperLib.ClipType.ctUnion:0>=L&&0>=P&&this.AddLocalMinPoly(t,e,i);break;case ClipperLib.ClipType.ctDifference:(t.PolyTyp==ClipperLib.PolyType.ptClip&&L>0&&P>0||t.PolyTyp==ClipperLib.PolyType.ptSubject&&0>=L&&0>=P)&&this.AddLocalMinPoly(t,e,i);break;case ClipperLib.ClipType.ctXor:this.AddLocalMinPoly(t,e,i)}else ClipperLib.Clipper.SwapSides(t,e)}n!=p&&(n&&t.OutIdx>=0||p&&e.OutIdx>=0)&&(ClipperLib.Clipper.SwapSides(t,e),ClipperLib.Clipper.SwapPolyIndexes(t,e)),n&&this.DeleteFromAEL(t), -p&&this.DeleteFromAEL(e)},ClipperLib.Clipper.prototype.DeleteFromAEL=function(t){var e=t.PrevInAEL,i=t.NextInAEL;(null!==e||null!==i||t==this.m_ActiveEdges)&&(null!==e?e.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)},ClipperLib.Clipper.prototype.DeleteFromSEL=function(t){var e=t.PrevInSEL,i=t.NextInSEL;(null!==e||null!==i||t==this.m_SortedEdges)&&(null!==e?e.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)},ClipperLib.Clipper.prototype.UpdateEdgeIntoAEL=function(t){null===t.NextInLML&&ClipperLib.Error("UpdateEdgeIntoAEL: invalid call");var e=t.PrevInAEL,i=t.NextInAEL;return t.NextInLML.OutIdx=t.OutIdx,null!==e?e.NextInAEL=t.NextInLML:this.m_ActiveEdges=t.NextInLML,null!==i&&(i.PrevInAEL=t.NextInLML),t.NextInLML.Side=t.Side,t.NextInLML.WindDelta=t.WindDelta,t.NextInLML.WindCnt=t.WindCnt,t.NextInLML.WindCnt2=t.WindCnt2,t=t.NextInLML,t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,t.PrevInAEL=e,t.NextInAEL=i,ClipperLib.ClipperBase.IsHorizontal(t)||this.InsertScanbeam(t.Top.Y),t},ClipperLib.Clipper.prototype.ProcessHorizontals=function(t){for(var e=this.m_SortedEdges;null!==e;)this.DeleteFromSEL(e),this.ProcessHorizontal(e,t),e=this.m_SortedEdges},ClipperLib.Clipper.prototype.GetHorzDirection=function(t,e){t.Bot.X=n){if(t.OutIdx>=0&&0!=t.WindDelta&&this.PrepareHorzJoins(t,e),u==l&&s)return r==ClipperLib.Direction.dLeftToRight?this.IntersectEdges(t,u,u.Top,!1):this.IntersectEdges(u,t,u.Top,!1),void(l.OutIdx>=0&&ClipperLib.Error("ProcessHorizontal error"));if(r==ClipperLib.Direction.dLeftToRight){var a=new ClipperLib.IntPoint(u.Curr.X,t.Curr.Y);this.IntersectEdges(t,u,a,!0)}else{var a=new ClipperLib.IntPoint(u.Curr.X,t.Curr.Y);this.IntersectEdges(u,t,a,!0)}this.SwapPositionsInAEL(t,u)}else if(r==ClipperLib.Direction.dLeftToRight&&u.Curr.X>=p||r==ClipperLib.Direction.dRightToLeft&&u.Curr.X<=n)break;u=h}if(t.OutIdx>=0&&0!==t.WindDelta&&this.PrepareHorzJoins(t,e),null===t.NextInLML||!ClipperLib.ClipperBase.IsHorizontal(t.NextInLML))break;t=this.UpdateEdgeIntoAEL(t),t.OutIdx>=0&&this.AddOutPt(t,t.Bot);var i={Dir:r,Left:n,Right:p};this.GetHorzDirection(t,i),r=i.Dir,n=i.Left,p=i.Right}if(null!==t.NextInLML)if(t.OutIdx>=0){var C=this.AddOutPt(t,t.Top);if(t=this.UpdateEdgeIntoAEL(t),0===t.WindDelta)return;var f=t.PrevInAEL,h=t.NextInAEL;if(null!==f&&f.Curr.X==t.Bot.X&&f.Curr.Y==t.Bot.Y&&0!==f.WindDelta&&f.OutIdx>=0&&f.Curr.Y>f.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(t,f,this.m_UseFullRange)){var d=this.AddOutPt(f,t.Bot);this.AddJoin(C,d,t.Top)}else if(null!==h&&h.Curr.X==t.Bot.X&&h.Curr.Y==t.Bot.Y&&0!==h.WindDelta&&h.OutIdx>=0&&h.Curr.Y>h.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(t,h,this.m_UseFullRange)){var d=this.AddOutPt(h,t.Bot);this.AddJoin(C,d,t.Top)}}else t=this.UpdateEdgeIntoAEL(t);else null!==l?l.OutIdx>=0?(r==ClipperLib.Direction.dLeftToRight?this.IntersectEdges(t,l,t.Top,!1):this.IntersectEdges(l,t,t.Top,!1),l.OutIdx>=0&&ClipperLib.Error("ProcessHorizontal error")):(this.DeleteFromAEL(t),this.DeleteFromAEL(l)):(t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t))},ClipperLib.Clipper.prototype.GetNextInAEL=function(t,e){return e==ClipperLib.Direction.dLeftToRight?t.NextInAEL:t.PrevInAEL},ClipperLib.Clipper.prototype.IsMinima=function(t){return null!==t&&t.Prev.NextInLML!=t&&t.Next.NextInLML!=t},ClipperLib.Clipper.prototype.IsMaxima=function(t,e){return null!==t&&t.Top.Y==e&&null===t.NextInLML},ClipperLib.Clipper.prototype.IsIntermediate=function(t,e){return t.Top.Y==e&&null!==t.NextInLML},ClipperLib.Clipper.prototype.GetMaximaPair=function(t){var e=null;return ClipperLib.IntPoint.op_Equality(t.Next.Top,t.Top)&&null===t.Next.NextInLML?e=t.Next:ClipperLib.IntPoint.op_Equality(t.Prev.Top,t.Top)&&null===t.Prev.NextInLML&&(e=t.Prev),null===e||-2!=e.OutIdx&&(e.NextInAEL!=e.PrevInAEL||ClipperLib.ClipperBase.IsHorizontal(e))?e:null},ClipperLib.Clipper.prototype.ProcessIntersections=function(t,e){if(null==this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(t,e),0==this.m_IntersectList.length)return!0;if(1!=this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(i){this.m_SortedEdges=null,this.m_IntersectList.length=0,ClipperLib.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},ClipperLib.Clipper.prototype.BuildIntersectList=function(t,e){if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=ClipperLib.Clipper.TopX(i,e),i=i.NextInAEL;for(var r=!0;r&&null!==this.m_SortedEdges;){for(r=!1,i=this.m_SortedEdges;null!==i.NextInSEL;){var n=i.NextInSEL,p=new ClipperLib.IntPoint;if(i.Curr.X>n.Curr.X){!this.IntersectPoint(i,n,p)&&i.Curr.X>n.Curr.X+1&&ClipperLib.Error("Intersection error"),p.Y>t&&(p.Y=t,Math.abs(i.Dx)>Math.abs(n.Dx)?p.X=ClipperLib.Clipper.TopX(n,t):p.X=ClipperLib.Clipper.TopX(i,t));var o=new ClipperLib.IntersectNode;o.Edge1=i,o.Edge2=n,o.Pt.X=p.X,o.Pt.Y=p.Y,this.m_IntersectList.push(o),this.SwapPositionsInSEL(i,n),r=!0}else i=n}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},ClipperLib.Clipper.prototype.EdgesAdjacent=function(t){return t.Edge1.NextInSEL==t.Edge2||t.Edge1.PrevInSEL==t.Edge2},ClipperLib.Clipper.IntersectNodeSort=function(t,e){return e.Pt.Y-t.Pt.Y},ClipperLib.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var t=this.m_IntersectList.length,e=0;t>e;e++){if(!this.EdgesAdjacent(this.m_IntersectList[e])){for(var i=e+1;t>i&&!this.EdgesAdjacent(this.m_IntersectList[i]);)i++;if(i==t)return!1;var r=this.m_IntersectList[e];this.m_IntersectList[e]=this.m_IntersectList[i],this.m_IntersectList[i]=r}this.SwapPositionsInSEL(this.m_IntersectList[e].Edge1,this.m_IntersectList[e].Edge2)}return!0},ClipperLib.Clipper.prototype.ProcessIntersectList=function(){for(var t=0,e=this.m_IntersectList.length;e>t;t++){var i=this.m_IntersectList[t];this.IntersectEdges(i.Edge1,i.Edge2,i.Pt,!0),this.SwapPositionsInAEL(i.Edge1,i.Edge2)}this.m_IntersectList.length=0};var R1=function(t){return 0>t?Math.ceil(t-.5):Math.round(t)},R2=function(t){return 0>t?Math.ceil(t-.5):Math.floor(t+.5)},R3=function(t){return 0>t?-Math.round(Math.abs(t)):Math.round(t)},R4=function(t){return 0>t?(t-=.5,-2147483648>t?Math.ceil(t):0|t):(t+=.5,t>2147483647?Math.floor(t):0|t)};browser.msie?ClipperLib.Clipper.Round=R1:browser.chromium?ClipperLib.Clipper.Round=R3:browser.safari?ClipperLib.Clipper.Round=R4:ClipperLib.Clipper.Round=R2,ClipperLib.Clipper.TopX=function(t,e){return e==t.Top.Y?t.Top.X:t.Bot.X+ClipperLib.Clipper.Round(t.Dx*(e-t.Bot.Y))},ClipperLib.Clipper.prototype.IntersectPoint=function(t,e,i){i.X=0,i.Y=0;var r,n;if(ClipperLib.ClipperBase.SlopesEqual(t,e,this.m_UseFullRange)||t.Dx==e.Dx)return e.Bot.Y>t.Bot.Y?(i.X=e.Bot.X,i.Y=e.Bot.Y):(i.X=t.Bot.X,i.Y=t.Bot.Y),!1;if(0===t.Delta.X)i.X=t.Bot.X,ClipperLib.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(n=e.Bot.Y-e.Bot.X/e.Dx,i.Y=ClipperLib.Clipper.Round(i.X/e.Dx+n));else if(0===e.Delta.X)i.X=e.Bot.X,ClipperLib.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(r=t.Bot.Y-t.Bot.X/t.Dx,i.Y=ClipperLib.Clipper.Round(i.X/t.Dx+r));else{r=t.Bot.X-t.Bot.Y*t.Dx,n=e.Bot.X-e.Bot.Y*e.Dx;var p=(n-r)/(t.Dx-e.Dx);i.Y=ClipperLib.Clipper.Round(p),Math.abs(t.Dx)e.Top.Y)return i.Y=t.Top.Y,i.X=ClipperLib.Clipper.TopX(e,t.Top.Y),i.X=0&&this.AddOutPt(e,e.Bot),this.AddEdgeToSEL(e)):(e.Curr.X=ClipperLib.Clipper.TopX(e,t),e.Curr.Y=t),this.StrictlySimple){var n=e.PrevInAEL;if(e.OutIdx>=0&&0!==e.WindDelta&&null!==n&&n.OutIdx>=0&&n.Curr.X==e.Curr.X&&0!==n.WindDelta){var p=this.AddOutPt(n,e.Curr),o=this.AddOutPt(e,e.Curr);this.AddJoin(p,o,e.Curr)}}e=e.NextInAEL}}for(this.ProcessHorizontals(!0),e=this.m_ActiveEdges;null!==e;){if(this.IsIntermediate(e,t)){var p=null;e.OutIdx>=0&&(p=this.AddOutPt(e,e.Top)),e=this.UpdateEdgeIntoAEL(e);var n=e.PrevInAEL,l=e.NextInAEL;if(null!==n&&n.Curr.X==e.Bot.X&&n.Curr.Y==e.Bot.Y&&null!==p&&n.OutIdx>=0&&n.Curr.Y>n.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(e,n,this.m_UseFullRange)&&0!==e.WindDelta&&0!==n.WindDelta){var o=this.AddOutPt(n,e.Bot);this.AddJoin(p,o,e.Top)}else if(null!==l&&l.Curr.X==e.Bot.X&&l.Curr.Y==e.Bot.Y&&null!==p&&l.OutIdx>=0&&l.Curr.Y>l.Top.Y&&ClipperLib.ClipperBase.SlopesEqual(e,l,this.m_UseFullRange)&&0!==e.WindDelta&&0!==l.WindDelta){var o=this.AddOutPt(l,e.Bot);this.AddJoin(p,o,e.Top)}}e=e.NextInAEL}},ClipperLib.Clipper.prototype.DoMaxima=function(t){var e=this.GetMaximaPair(t);if(null===e)return t.OutIdx>=0&&this.AddOutPt(t,t.Top),void this.DeleteFromAEL(t);for(var i=t.NextInAEL,r=!0;null!==i&&i!=e;)this.IntersectEdges(t,i,t.Top,!0),this.SwapPositionsInAEL(t,i),i=t.NextInAEL;-1==t.OutIdx&&-1==e.OutIdx?(this.DeleteFromAEL(t),this.DeleteFromAEL(e)):t.OutIdx>=0&&e.OutIdx>=0?this.IntersectEdges(t,e,t.Top,!1):r&&0===t.WindDelta?(t.OutIdx>=0&&(this.AddOutPt(t,t.Top),t.OutIdx=-1),this.DeleteFromAEL(t),e.OutIdx>=0&&(this.AddOutPt(e,t.Top),e.OutIdx=-1),this.DeleteFromAEL(e)):ClipperLib.Error("DoMaxima error")},ClipperLib.Clipper.ReversePaths=function(t){for(var e=0,i=t.length;i>e;e++)t[e].reverse()},ClipperLib.Clipper.Orientation=function(t){return ClipperLib.Clipper.Area(t)>=0},ClipperLib.Clipper.prototype.PointCount=function(t){if(null===t)return 0;var e=0,i=t;do e++,i=i.Next;while(i!=t);return e},ClipperLib.Clipper.prototype.BuildResult=function(t){ClipperLib.Clear(t);for(var e=0,i=this.m_PolyOuts.length;i>e;e++){var r=this.m_PolyOuts[e];if(null!==r.Pts){var n=r.Pts.Prev,p=this.PointCount(n);if(!(2>p)){for(var o=new Array(p),l=0;p>l;l++)o[l]=n.Pt,n=n.Prev;t.push(o)}}}},ClipperLib.Clipper.prototype.BuildResult2=function(t){t.Clear();for(var e=0,i=this.m_PolyOuts.length;i>e;e++){var r=this.m_PolyOuts[e],n=this.PointCount(r.Pts);if(!(r.IsOpen&&2>n||!r.IsOpen&&3>n)){this.FixHoleLinkage(r);var p=new ClipperLib.PolyNode;t.m_AllPolys.push(p),r.PolyNode=p,p.m_polygon.length=n;for(var o=r.Pts.Prev,l=0;n>l;l++)p.m_polygon[l]=o.Pt,o=o.Prev}}for(var e=0,i=this.m_PolyOuts.length;i>e;e++){var r=this.m_PolyOuts[e];null!==r.PolyNode&&(r.IsOpen?(r.PolyNode.IsOpen=!0,t.AddChild(r.PolyNode)):null!==r.FirstLeft&&null!=r.FirstLeft.PolyNode?r.FirstLeft.PolyNode.AddChild(r.PolyNode):t.AddChild(r.PolyNode))}},ClipperLib.Clipper.prototype.FixupOutPolygon=function(t){var e=null;t.BottomPt=null;for(var i=t.Pts;;){if(i.Prev==i||i.Prev==i.Next)return this.DisposeOutPts(i),void(t.Pts=null);if(ClipperLib.IntPoint.op_Equality(i.Pt,i.Next.Pt)||ClipperLib.IntPoint.op_Equality(i.Pt,i.Prev.Pt)||ClipperLib.ClipperBase.SlopesEqual(i.Prev.Pt,i.Pt,i.Next.Pt,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt))){e=null;var r=i;i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev,r=null}else{if(i==e)break;null===e&&(e=i),i=i.Next}}t.Pts=i},ClipperLib.Clipper.prototype.DupOutPt=function(t,e){var i=new ClipperLib.OutPt;return i.Pt.X=t.Pt.X,i.Pt.Y=t.Pt.Y,i.Idx=t.Idx,e?(i.Next=t.Next,i.Prev=t,t.Next.Prev=i,t.Next=i):(i.Prev=t.Prev,i.Next=t,t.Prev.Next=i,t.Prev=i),i},ClipperLib.Clipper.prototype.GetOverlap=function(t,e,i,r,n){return e>t?r>i?(n.Left=Math.max(t,i),n.Right=Math.min(e,r)):(n.Left=Math.max(t,r),n.Right=Math.min(e,i)):r>i?(n.Left=Math.max(e,i),n.Right=Math.min(t,r)):(n.Left=Math.max(e,r),n.Right=Math.min(t,i)),n.Lefte.Pt.X?ClipperLib.Direction.dRightToLeft:ClipperLib.Direction.dLeftToRight,l=i.Pt.X>r.Pt.X?ClipperLib.Direction.dRightToLeft:ClipperLib.Direction.dLeftToRight;if(o==l)return!1;if(o==ClipperLib.Direction.dLeftToRight){for(;t.Next.Pt.X<=n.X&&t.Next.Pt.X>=t.Pt.X&&t.Next.Pt.Y==n.Y;)t=t.Next;p&&t.Pt.X!=n.X&&(t=t.Next),e=this.DupOutPt(t,!p),ClipperLib.IntPoint.op_Inequality(e.Pt,n)&&(t=e,t.Pt.X=n.X,t.Pt.Y=n.Y,e=this.DupOutPt(t,!p))}else{for(;t.Next.Pt.X>=n.X&&t.Next.Pt.X<=t.Pt.X&&t.Next.Pt.Y==n.Y;)t=t.Next;p||t.Pt.X==n.X||(t=t.Next),e=this.DupOutPt(t,p),ClipperLib.IntPoint.op_Inequality(e.Pt,n)&&(t=e,t.Pt.X=n.X,t.Pt.Y=n.Y,e=this.DupOutPt(t,p))}if(l==ClipperLib.Direction.dLeftToRight){for(;i.Next.Pt.X<=n.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y==n.Y;)i=i.Next;p&&i.Pt.X!=n.X&&(i=i.Next),r=this.DupOutPt(i,!p),ClipperLib.IntPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,r=this.DupOutPt(i,!p))}else{for(;i.Next.Pt.X>=n.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y==n.Y;)i=i.Next;p||i.Pt.X==n.X||(i=i.Next),r=this.DupOutPt(i,p),ClipperLib.IntPoint.op_Inequality(r.Pt,n)&&(i=r,i.Pt.X=n.X,i.Pt.Y=n.Y,r=this.DupOutPt(i,p))}return o==ClipperLib.Direction.dLeftToRight==p?(t.Prev=i,i.Next=t,e.Next=r,r.Prev=e):(t.Next=i,i.Prev=t,e.Prev=r,r.Next=e),!0},ClipperLib.Clipper.prototype.JoinPoints=function(t,e,i){var r=t.OutPt1,n=new ClipperLib.OutPt,p=t.OutPt2,o=new ClipperLib.OutPt,l=t.OutPt1.Pt.Y==t.OffPt.Y;if(l&&ClipperLib.IntPoint.op_Equality(t.OffPt,t.OutPt1.Pt)&&ClipperLib.IntPoint.op_Equality(t.OffPt,t.OutPt2.Pt)){for(n=t.OutPt1.Next;n!=r&&ClipperLib.IntPoint.op_Equality(n.Pt,t.OffPt);)n=n.Next;var s=n.Pt.Y>t.OffPt.Y;for(o=t.OutPt2.Next;o!=p&&ClipperLib.IntPoint.op_Equality(o.Pt,t.OffPt);)o=o.Next;var u=o.Pt.Y>t.OffPt.Y;return s==u?!1:s?(n=this.DupOutPt(r,!1),o=this.DupOutPt(p,!0),r.Prev=p,p.Next=r,n.Next=o,o.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(p,!1),r.Next=p,p.Prev=r,n.Prev=o,o.Next=n,t.OutPt1=r,t.OutPt2=n,!0)}if(l){for(n=r;r.Prev.Pt.Y==r.Pt.Y&&r.Prev!=n&&r.Prev!=p;)r=r.Prev;for(;n.Next.Pt.Y==n.Pt.Y&&n.Next!=r&&n.Next!=p;)n=n.Next;if(n.Next==r||n.Next==p)return!1;for(o=p;p.Prev.Pt.Y==p.Pt.Y&&p.Prev!=o&&p.Prev!=n;)p=p.Prev;for(;o.Next.Pt.Y==o.Pt.Y&&o.Next!=p&&o.Next!=r;)o=o.Next;if(o.Next==p||o.Next==r)return!1;var h={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,p.Pt.X,o.Pt.X,h))return!1;var a,C=h.Left,f=h.Right,d=new ClipperLib.IntPoint;return r.Pt.X>=C&&r.Pt.X<=f?(d.X=r.Pt.X,d.Y=r.Pt.Y,a=r.Pt.X>n.Pt.X):p.Pt.X>=C&&p.Pt.X<=f?(d.X=p.Pt.X,d.Y=p.Pt.Y,a=p.Pt.X>o.Pt.X):n.Pt.X>=C&&n.Pt.X<=f?(d.X=n.Pt.X,d.Y=n.Pt.Y,a=n.Pt.X>r.Pt.X):(d.X=o.Pt.X,d.Y=o.Pt.Y,a=o.Pt.X>p.Pt.X),t.OutPt1=r,t.OutPt2=p,this.JoinHorz(r,n,p,o,d,a)}for(n=r.Next;ClipperLib.IntPoint.op_Equality(n.Pt,r.Pt)&&n!=r;)n=n.Next;var L=n.Pt.Y>r.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(r.Pt,n.Pt,t.OffPt,this.m_UseFullRange);if(L){for(n=r.Prev;ClipperLib.IntPoint.op_Equality(n.Pt,r.Pt)&&n!=r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(r.Pt,n.Pt,t.OffPt,this.m_UseFullRange))return!1}for(o=p.Next;ClipperLib.IntPoint.op_Equality(o.Pt,p.Pt)&&o!=p;)o=o.Next;var P=o.Pt.Y>p.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(p.Pt,o.Pt,t.OffPt,this.m_UseFullRange);if(P){for(o=p.Prev;ClipperLib.IntPoint.op_Equality(o.Pt,p.Pt)&&o!=p;)o=o.Prev;if(o.Pt.Y>p.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual(p.Pt,o.Pt,t.OffPt,this.m_UseFullRange))return!1}return n==r||o==p||n==o||e==i&&L==P?!1:L?(n=this.DupOutPt(r,!1),o=this.DupOutPt(p,!0),r.Prev=p,p.Next=r,n.Next=o,o.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),o=this.DupOutPt(p,!1),r.Next=p,p.Prev=r,n.Prev=o,o.Next=n,t.OutPt1=r,t.OutPt2=n,!0)},ClipperLib.Clipper.GetBounds=function(t){for(var e=0,i=t.length;i>e&&0==t[e].length;)e++;if(e==i)return new ClipperLib.IntRect(0,0,0,0);var r=new ClipperLib.IntRect;for(r.left=t[e][0].X,r.right=r.left,r.top=t[e][0].Y,r.bottom=r.top;i>e;e++)for(var n=0,p=t[e].length;p>n;n++)t[e][n].Xr.right&&(r.right=t[e][n].X),t[e][n].Yr.bottom&&(r.bottom=t[e][n].Y);return r},ClipperLib.Clipper.prototype.GetBounds2=function(t){var e=t,i=new ClipperLib.IntRect;for(i.left=t.Pt.X,i.right=t.Pt.X,i.top=t.Pt.Y,i.bottom=t.Pt.Y,t=t.Next;t!=e;)t.Pt.Xi.right&&(i.right=t.Pt.X),t.Pt.Yi.bottom&&(i.bottom=t.Pt.Y),t=t.Next;return i},ClipperLib.Clipper.PointInPolygon=function(t,e){var i=0,r=e.length;if(3>r)return 0;for(var n=e[0],p=1;r>=p;++p){var o=p==r?e[0]:e[p];if(o.Y==t.Y&&(o.X==t.X||n.Y==t.Y&&o.X>t.X==n.X=t.X)if(o.X>t.X)i=1-i;else{var l=(n.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(n.Y-t.Y);if(0==l)return-1;l>0==o.Y>n.Y&&(i=1-i)}else if(o.X>t.X){var l=(n.X-t.X)*(o.Y-t.Y)-(o.X-t.X)*(n.Y-t.Y);if(0==l)return-1;l>0==o.Y>n.Y&&(i=1-i)}n=o}return i},ClipperLib.Clipper.prototype.PointInPolygon=function(t,e){for(var i=0,r=e;;){var n=e.Pt.X,p=e.Pt.Y,o=e.Next.Pt.X,l=e.Next.Pt.Y;if(l==t.Y&&(o==t.X||p==t.Y&&o>t.X==n=t.X)if(o>t.X)i=1-i;else{var s=(n-t.X)*(l-t.Y)-(o-t.X)*(p-t.Y);if(0==s)return-1;s>0==l>p&&(i=1-i)}else if(o>t.X){var s=(n-t.X)*(l-t.Y)-(o-t.X)*(p-t.Y);if(0==s)return-1;s>0==l>p&&(i=1-i)}if(e=e.Next,r==e)break}return i},ClipperLib.Clipper.prototype.Poly2ContainsPoly1=function(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return 0!=r;i=i.Next}while(i!=t);return!0},ClipperLib.Clipper.prototype.FixupFirstLefts1=function(t,e){for(var i=0,r=this.m_PolyOuts.length;r>i;i++){var n=this.m_PolyOuts[i];null!==n.Pts&&n.FirstLeft==t&&this.Poly2ContainsPoly1(n.Pts,e.Pts)&&(n.FirstLeft=e)}},ClipperLib.Clipper.prototype.FixupFirstLefts2=function(t,e){for(var i=0,r=this.m_PolyOuts,n=r.length,p=r[i];n>i;i++,p=r[i])p.FirstLeft==t&&(p.FirstLeft=e)},ClipperLib.Clipper.ParseFirstLeft=function(t){for(;null!=t&&null==t.Pts;)t=t.FirstLeft;return t},ClipperLib.Clipper.prototype.JoinCommonEdges=function(){for(var t=0,e=this.m_Joins.length;e>t;t++){var i=this.m_Joins[t],r=this.GetOutRec(i.OutPt1.Idx),n=this.GetOutRec(i.OutPt2.Idx);if(null!=r.Pts&&null!=n.Pts){var p;if(p=r==n?r:this.Param1RightOfParam2(r,n)?n:this.Param1RightOfParam2(n,r)?r:this.GetLowermostRec(r,n),this.JoinPoints(i,r,n))if(r==n){if(r.Pts=i.OutPt1,r.BottomPt=null,n=this.CreateOutRec(),n.Pts=i.OutPt2,this.UpdateOutPtIdxs(n),this.m_UsingPolyTree)for(var o=0,l=this.m_PolyOuts.length;l-1>o;o++){var s=this.m_PolyOuts[o];null!=s.Pts&&ClipperLib.Clipper.ParseFirstLeft(s.FirstLeft)==r&&s.IsHole!=r.IsHole&&this.Poly2ContainsPoly1(s.Pts,i.OutPt2)&&(s.FirstLeft=n)}this.Poly2ContainsPoly1(n.Pts,r.Pts)?(n.IsHole=!r.IsHole,n.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,r),(n.IsHole^this.ReverseSolution)==this.Area(n)>0&&this.ReversePolyPtLinks(n.Pts)):this.Poly2ContainsPoly1(r.Pts,n.Pts)?(n.IsHole=r.IsHole,r.IsHole=!n.IsHole,n.FirstLeft=r.FirstLeft,r.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,n),(r.IsHole^this.ReverseSolution)==this.Area(r)>0&&this.ReversePolyPtLinks(r.Pts)):(n.IsHole=r.IsHole,n.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,n))}else n.Pts=null,n.BottomPt=null,n.Idx=r.Idx,r.IsHole=p.IsHole,p==n&&(r.FirstLeft=n.FirstLeft),n.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,r)}}},ClipperLib.Clipper.prototype.UpdateOutPtIdxs=function(t){var e=t.Pts;do e.Idx=t.Idx,e=e.Prev;while(e!=t.Pts)},ClipperLib.Clipper.prototype.DoSimplePolygons=function(){for(var t=0;te)return 0;for(var i=0,r=0,n=e-1;e>r;++r)i+=(t[n].X+t[r].X)*(t[n].Y-t[r].Y),n=r;return.5*-i},ClipperLib.Clipper.prototype.Area=function(t){var e=t.Pts;if(null==e)return 0;var i=0;do i+=(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next;while(e!=t.Pts);return.5*i},use_deprecated&&(ClipperLib.Clipper.OffsetPaths=function(t,e,i,r,n){var p=new ClipperLib.Paths,o=new ClipperLib.ClipperOffset(n,n);return o.AddPaths(t,i,r),o.Execute(p,e),p}),ClipperLib.Clipper.SimplifyPolygon=function(t,e){var i=new Array,r=new ClipperLib.Clipper(0);return r.StrictlySimple=!0,r.AddPath(t,ClipperLib.PolyType.ptSubject,!0),r.Execute(ClipperLib.ClipType.ctUnion,i,e,e),i},ClipperLib.Clipper.SimplifyPolygons=function(t,e){"undefined"==typeof e&&(e=ClipperLib.PolyFillType.pftEvenOdd);var i=new Array,r=new ClipperLib.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(t,ClipperLib.PolyType.ptSubject,!0),r.Execute(ClipperLib.ClipType.ctUnion,i,e,e),i},ClipperLib.Clipper.DistanceSqrd=function(t,e){var i=t.X-e.X,r=t.Y-e.Y;return i*i+r*r},ClipperLib.Clipper.DistanceFromLineSqrd=function(t,e,i){var r=e.Y-i.Y,n=i.X-e.X,p=r*e.X+n*e.Y;return p=r*t.X+n*t.Y-p,p*p/(r*r+n*n)},ClipperLib.Clipper.SlopesNearCollinear=function(t,e,i,r){return ClipperLib.Clipper.DistanceFromLineSqrd(e,t,i)=r*r+n*n},ClipperLib.Clipper.ExcludeOp=function(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e},ClipperLib.Clipper.CleanPolygon=function(t,e){"undefined"==typeof e&&(e=1.415);var i=t.length;if(0==i)return new Array;for(var r=new Array(i),n=0;i>n;++n)r[n]=new ClipperLib.OutPt;for(var n=0;i>n;++n)r[n].Pt=t[n],r[n].Next=r[(n+1)%i],r[n].Next.Prev=r[n],r[n].Idx=0;for(var p=e*e,o=r[0];0==o.Idx&&o.Next!=o.Prev;)ClipperLib.Clipper.PointsAreClose(o.Pt,o.Prev.Pt,p)?(o=ClipperLib.Clipper.ExcludeOp(o),i--):ClipperLib.Clipper.PointsAreClose(o.Prev.Pt,o.Next.Pt,p)?(ClipperLib.Clipper.ExcludeOp(o.Next),o=ClipperLib.Clipper.ExcludeOp(o),i-=2):ClipperLib.Clipper.SlopesNearCollinear(o.Prev.Pt,o.Pt,o.Next.Pt,p)?(o=ClipperLib.Clipper.ExcludeOp(o),i--):(o.Idx=1,o=o.Next);3>i&&(i=0);for(var l=new Array(i),n=0;i>n;++n)l[n]=new ClipperLib.IntPoint(o.Pt),o=o.Next;return r=null,l},ClipperLib.Clipper.CleanPolygons=function(t,e){for(var i=new Array(t.length),r=0,n=t.length;n>r;r++)i[r]=ClipperLib.Clipper.CleanPolygon(t[r],e);return i},ClipperLib.Clipper.Minkowski=function(t,e,i,r){var n=r?1:0,p=t.length,o=e.length,l=new Array;if(i)for(var s=0;o>s;s++){for(var u=new Array(p),h=0,a=t.length,C=t[h];a>h;h++,C=t[h])u[h]=new ClipperLib.IntPoint(e[s].X+C.X,e[s].Y+C.Y);l.push(u)}else for(var s=0;o>s;s++){for(var u=new Array(p),h=0,a=t.length,C=t[h];a>h;h++,C=t[h])u[h]=new ClipperLib.IntPoint(e[s].X-C.X,e[s].Y-C.Y);l.push(u)}for(var f=new Array,s=0;o-1+n>s;s++)for(var h=0;p>h;h++){var d=new Array;d.push(l[s%o][h%p]),d.push(l[(s+1)%o][h%p]),d.push(l[(s+1)%o][(h+1)%p]),d.push(l[s%o][(h+1)%p]),ClipperLib.Clipper.Orientation(d)||d.reverse(),f.push(d)}var L=new ClipperLib.Clipper(0);return L.AddPaths(f,ClipperLib.PolyType.ptSubject,!0),L.Execute(ClipperLib.ClipType.ctUnion,l,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero),l},ClipperLib.Clipper.MinkowskiSum=function(){var t=arguments,e=t.length;if(3==e){var i=t[0],r=t[1],n=t[2];return ClipperLib.Clipper.Minkowski(i,r,!0,n)}if(4==e){for(var p,i=t[0],o=t[1],l=t[2],n=t[3],s=new ClipperLib.Clipper,u=0,h=o.length;h>u;++u){var p=ClipperLib.Clipper.Minkowski(i,o[u],!0,n);s.AddPaths(p,ClipperLib.PolyType.ptSubject,!0)}n&&s.AddPaths(o,ClipperLib.PolyType.ptClip,!0);var a=new ClipperLib.Paths;return s.Execute(ClipperLib.ClipType.ctUnion,a,l,l),a}},ClipperLib.Clipper.MinkowskiDiff=function(t,e,i){return ClipperLib.Clipper.Minkowski(t,e,!1,i)},ClipperLib.Clipper.PolyTreeToPaths=function(t){var e=new Array;return ClipperLib.Clipper.AddPolyNodeToPaths(t,ClipperLib.Clipper.NodeType.ntAny,e),e},ClipperLib.Clipper.AddPolyNodeToPaths=function(t,e,i){var r=!0;switch(e){case ClipperLib.Clipper.NodeType.ntOpen:return;case ClipperLib.Clipper.NodeType.ntClosed:r=!t.IsOpen}t.m_polygon.length>0&&r&&i.push(t.m_polygon);for(var n=0,p=t.Childs(),o=p.length,l=p[n];o>n;n++,l=p[n])ClipperLib.Clipper.AddPolyNodeToPaths(l,e,i)},ClipperLib.Clipper.OpenPathsFromPolyTree=function(t){for(var e=new ClipperLib.Paths,i=0,r=t.ChildCount();r>i;i++)t.Childs()[i].IsOpen&&e.push(t.Childs()[i].m_polygon);return e},ClipperLib.Clipper.ClosedPathsFromPolyTree=function(t){var e=new ClipperLib.Paths;return ClipperLib.Clipper.AddPolyNodeToPaths(t,ClipperLib.Clipper.NodeType.ntClosed,e),e},Inherit(ClipperLib.Clipper,ClipperLib.ClipperBase),ClipperLib.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},ClipperLib.ClipperOffset=function(t,e){"undefined"==typeof t&&(t=2),"undefined"==typeof e&&(e=ClipperLib.ClipperOffset.def_arc_tolerance),this.m_destPolys=new ClipperLib.Paths,this.m_srcPoly=new ClipperLib.Path,this.m_destPoly=new ClipperLib.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new ClipperLib.IntPoint,this.m_polyNodes=new ClipperLib.PolyNode,this.MiterLimit=t,this.ArcTolerance=e,this.m_lowest.X=-1},ClipperLib.ClipperOffset.two_pi=6.28318530717959,ClipperLib.ClipperOffset.def_arc_tolerance=.25,ClipperLib.ClipperOffset.prototype.Clear=function(){ClipperLib.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},ClipperLib.ClipperOffset.Round=ClipperLib.Clipper.Round,ClipperLib.ClipperOffset.prototype.AddPath=function(t,e,i){var r=t.length-1;if(!(0>r)){var n=new ClipperLib.PolyNode;if(n.m_jointype=e,n.m_endtype=i,i==ClipperLib.EndType.etClosedLine||i==ClipperLib.EndType.etClosedPolygon)for(;r>0&&ClipperLib.IntPoint.op_Equality(t[0],t[r]);)r--;n.m_polygon.push(t[0]);for(var p=0,o=0,l=1;r>=l;l++)ClipperLib.IntPoint.op_Inequality(n.m_polygon[p],t[l])&&(p++,n.m_polygon.push(t[l]),(t[l].Y>n.m_polygon[o].Y||t[l].Y==n.m_polygon[o].Y&&t[l].Xp||i!=ClipperLib.EndType.etClosedPolygon&&0>p)&&(this.m_polyNodes.AddChild(n),i==ClipperLib.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new ClipperLib.IntPoint(0,o);else{var s=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[o].Y>s.Y||n.m_polygon[o].Y==s.Y&&n.m_polygon[o].Xr;r++)this.AddPath(t[r],e,i)},ClipperLib.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!ClipperLib.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5;var r;r=this.ArcTolerance<=0?ClipperLib.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(t)*ClipperLib.ClipperOffset.def_arc_tolerance?Math.abs(t)*ClipperLib.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var n=3.14159265358979/Math.acos(1-r/Math.abs(t));this.m_sin=Math.sin(ClipperLib.ClipperOffset.two_pi/n),this.m_cos=Math.cos(ClipperLib.ClipperOffset.two_pi/n),this.m_StepsPerRad=n/ClipperLib.ClipperOffset.two_pi,0>t&&(this.m_sin=-this.m_sin);for(var e=0;e=t&&(3>p||i.m_endtype!=ClipperLib.EndType.etClosedPolygon)))if(this.m_destPoly=new Array,1!=p){this.m_normals.length=0;for(var o=0;p-1>o;o++)this.m_normals.push(ClipperLib.ClipperOffset.GetUnitNormal(this.m_srcPoly[o],this.m_srcPoly[o+1]));if(i.m_endtype==ClipperLib.EndType.etClosedLine||i.m_endtype==ClipperLib.EndType.etClosedPolygon?this.m_normals.push(ClipperLib.ClipperOffset.GetUnitNormal(this.m_srcPoly[p-1],this.m_srcPoly[0])):this.m_normals.push(new ClipperLib.DoublePoint(this.m_normals[p-2])),i.m_endtype==ClipperLib.EndType.etClosedPolygon){for(var l=p-1,o=0;p>o;o++)l=this.OffsetPoint(o,l,i.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(i.m_endtype==ClipperLib.EndType.etClosedLine){for(var l=p-1,o=0;p>o;o++)l=this.OffsetPoint(o,l,i.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;for(var s=this.m_normals[p-1],o=p-1;o>0;o--)this.m_normals[o]=new ClipperLib.DoublePoint(-this.m_normals[o-1].X,-this.m_normals[o-1].Y);this.m_normals[0]=new ClipperLib.DoublePoint(-s.X,-s.Y),l=0;for(var o=p-1;o>=0;o--)l=this.OffsetPoint(o,l,i.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(var l=0,o=1;p-1>o;++o)l=this.OffsetPoint(o,l,i.m_jointype);var u;if(i.m_endtype==ClipperLib.EndType.etOpenButt){var o=p-1;u=new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[o].X+this.m_normals[o].X*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[o].Y+this.m_normals[o].Y*t)),this.m_destPoly.push(u),u=new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[o].X-this.m_normals[o].X*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[o].Y-this.m_normals[o].Y*t)),this.m_destPoly.push(u)}else{var o=p-1;l=p-2,this.m_sinA=0,this.m_normals[o]=new ClipperLib.DoublePoint(-this.m_normals[o].X,-this.m_normals[o].Y),i.m_endtype==ClipperLib.EndType.etOpenSquare?this.DoSquare(o,l):this.DoRound(o,l)}for(var o=p-1;o>0;o--)this.m_normals[o]=new ClipperLib.DoublePoint(-this.m_normals[o-1].X,-this.m_normals[o-1].Y);this.m_normals[0]=new ClipperLib.DoublePoint(-this.m_normals[1].X,-this.m_normals[1].Y),l=p-1;for(var o=l-1;o>0;--o)l=this.OffsetPoint(o,l,i.m_jointype);i.m_endtype==ClipperLib.EndType.etOpenButt?(u=new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*t)),this.m_destPoly.push(u),u=new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*t)), -this.m_destPoly.push(u)):(l=1,this.m_sinA=0,i.m_endtype==ClipperLib.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(i.m_jointype==ClipperLib.JoinType.jtRound)for(var h=1,a=0,o=1;n>=o;o++){this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+h*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+a*t)));var C=h;h=h*this.m_cos-this.m_sin*a,a=C*this.m_sin+a*this.m_cos}else for(var h=-1,a=-1,o=0;4>o;++o)this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+h*t),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+a*t))),0>h?h=1:0>a?a=1:h=-1;this.m_destPolys.push(this.m_destPoly)}}}},ClipperLib.ClipperOffset.prototype.Execute=function(){var t=arguments,e=t[0]instanceof ClipperLib.PolyTree;if(e){var i=t[0],r=t[1];i.Clear(),this.FixOrientations(),this.DoOffset(r);var n=new ClipperLib.Clipper(0);if(n.AddPaths(this.m_destPolys,ClipperLib.PolyType.ptSubject,!0),r>0)n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftPositive,ClipperLib.PolyFillType.pftPositive);else{var p=ClipperLib.Clipper.GetBounds(this.m_destPolys),o=new ClipperLib.Path;if(o.push(new ClipperLib.IntPoint(p.left-10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.top-10)),o.push(new ClipperLib.IntPoint(p.left-10,p.top-10)),n.AddPath(o,ClipperLib.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftNegative,ClipperLib.PolyFillType.pftNegative),1==i.ChildCount()&&i.Childs()[0].ChildCount()>0){var l=i.Childs()[0];i.Childs()[0]=l.Childs()[0];for(var s=1;s0)n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftPositive,ClipperLib.PolyFillType.pftPositive);else{var p=ClipperLib.Clipper.GetBounds(this.m_destPolys),o=new ClipperLib.Path;o.push(new ClipperLib.IntPoint(p.left-10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.bottom+10)),o.push(new ClipperLib.IntPoint(p.right+10,p.top-10)),o.push(new ClipperLib.IntPoint(p.left-10,p.top-10)),n.AddPath(o,ClipperLib.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(ClipperLib.ClipType.ctUnion,i,ClipperLib.PolyFillType.pftNegative,ClipperLib.PolyFillType.pftNegative),i.length>0&&i.splice(0,1)}}},ClipperLib.ClipperOffset.prototype.OffsetPoint=function(t,e,i){if(this.m_sinA=this.m_normals[e].X*this.m_normals[t].Y-this.m_normals[t].X*this.m_normals[e].Y,this.m_sinA<5e-5&&this.m_sinA>-5e-5)return e;if(this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1),this.m_sinA*this.m_delta<0)this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta))),this.m_destPoly.push(new ClipperLib.IntPoint(this.m_srcPoly[t])),this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)));else switch(i){case ClipperLib.JoinType.jtMiter:var r=1+(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y);r>=this.m_miterLim?this.DoMiter(t,e,r):this.DoSquare(t,e);break;case ClipperLib.JoinType.jtSquare:this.DoSquare(t,e);break;case ClipperLib.JoinType.jtRound:this.DoRound(t,e)}return e=t},ClipperLib.ClipperOffset.prototype.DoSquare=function(t,e){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y)/4);this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[e].X-this.m_normals[e].Y*i)),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[e].Y+this.m_normals[e].X*i)))),this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[t].X+this.m_normals[t].Y*i)),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[t].Y-this.m_normals[t].X*i))))},ClipperLib.ClipperOffset.prototype.DoMiter=function(t,e,i){var r=this.m_delta/i;this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+(this.m_normals[e].X+this.m_normals[t].X)*r),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+(this.m_normals[e].Y+this.m_normals[t].Y)*r)))},ClipperLib.ClipperOffset.prototype.DoRound=function(t,e){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y),n=ClipperLib.Cast_Int32(ClipperLib.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),p=this.m_normals[e].X,o=this.m_normals[e].Y,l=0;n>l;++l)this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+p*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+o*this.m_delta))),i=p,p=p*this.m_cos-this.m_sin*o,o=i*this.m_sin+o*this.m_cos;this.m_destPoly.push(new ClipperLib.IntPoint(ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta)))},ClipperLib.Error=function(t){try{throw new Error(t)}catch(e){alert(e.message)}},ClipperLib.JS={},ClipperLib.JS.AreaOfPolygon=function(t,e){return e||(e=1),ClipperLib.Clipper.Area(t)/(e*e)},ClipperLib.JS.AreaOfPolygons=function(t,e){e||(e=1);for(var i=0,r=0;re)return t;i||(t=[t]);for(var r,n,p,o,l,s,u,h=t.length,a=[],C=0;h>C;C++)if(n=t[C],r=n.length,0!==r)if(3>r)p=n,a.push(p);else{for(p=n,o=e*e,l=n[0],s=1,u=1;r>u;u++)(n[u].X-l.X)*(n[u].X-l.X)+(n[u].Y-l.Y)*(n[u].Y-l.Y)<=o||(p[s]=n[u],l=n[u],s++);l=n[s-1],(n[0].X-l.X)*(n[0].X-l.X)+(n[0].Y-l.Y)*(n[0].Y-l.Y)<=o&&s--,r>s&&p.splice(s,r-s),p.length&&a.push(p)}return!i&&a.length?a=a[0]:i||0!==a.length?i&&0===a.length&&(a=[[]]):a=[],a},ClipperLib.JS.Clone=function(t){if(!(t instanceof Array))return[];if(0===t.length)return[];if(1==t.length&&0===t[0].length)return[[]];var e=t[0]instanceof Array;e||(t=[t]);var i,r,n,p,o=t.length,l=new Array(o);for(r=0;o>r;r++){for(i=t[r].length,p=new Array(i),n=0;i>n;n++)p[n]={X:t[r][n].X,Y:t[r][n].Y};l[r]=p}return e||(l=l[0]),l},ClipperLib.JS.Lighten=function(t,e){if(!(t instanceof Array))return[];if("number"!=typeof e||null===e)return ClipperLib.Error("Tolerance is not a number in Lighten()."),ClipperLib.JS.Clone(t);if(0===t.length||1==t.length&&0===t[0].length||0>e)return ClipperLib.JS.Clone(t);t[0]instanceof Array||(t=[t]);var i,r,n,p,o,l,s,u,h,a,C,f,d,L,P,b,m,y=t.length,c=e*e,v=[];for(i=0;y>i;i++)if(n=t[i],l=n.length,0!=l){for(p=0;1e6>p;p++){for(o=[],l=n.length,n[l-1].X!=n[0].X||n[l-1].Y!=n[0].Y?(f=1,n.push({X:n[0].X,Y:n[0].Y}),l=n.length):f=0,C=[],r=0;l-2>r;r++)s=n[r],h=n[r+1],u=n[r+2],b=s.X,m=s.Y,d=u.X-b,L=u.Y-m,(0!==d||0!==L)&&(P=((h.X-b)*d+(h.Y-m)*L)/(d*d+L*L),P>1?(b=u.X,m=u.Y):P>0&&(b+=d*P,m+=L*P)),d=h.X-b,L=h.Y-m,a=d*d+L*L,c>=a&&(C[r+1]=1,r++);for(o.push({X:n[0].X,Y:n[0].Y}),r=1;l-1>r;r++)C[r]||o.push({X:n[r].X,Y:n[r].Y});if(o.push({X:n[l-1].X,Y:n[l-1].Y}),f&&n.pop(),!C.length)break;n=o}l=o.length,o[l-1].X==o[0].X&&o[l-1].Y==o[0].Y&&o.pop(),o.length>2&&v.push(o)}return!t[0]instanceof Array&&(v=v[0]),"undefined"==typeof v&&(v=[[]]),v},ClipperLib.JS.PerimeterOfPath=function(t,e,i){if("undefined"==typeof t)return 0;var r,n,p=Math.sqrt,o=0,l=0,s=0,u=0,h=0,a=t.length;if(2>a)return 0;for(e&&(t[a]=t[0],a++);--a;)r=t[a],l=r.X,s=r.Y,n=t[a-1],u=n.X,h=n.Y,o+=p((l-u)*(l-u)+(s-h)*(s-h));return e&&t.pop(),o/i},ClipperLib.JS.PerimeterOfPaths=function(t,e,i){i||(i=1);for(var r=0,n=0;nl;l++)for(p=r[l],i.holes[l]=p.Contour(),s=0,u=p.Childs(),h=u.length;h>s;s++)o=u[s],ClipperLib.JS.AddOuterPolyNodeToExPolygons(o,e);e.push(i)},ClipperLib.JS.ExPolygonsToPaths=function(t){var e,i,r,n,p=new ClipperLib.Paths;for(e=0,r=t.length;r>e;e++)for(p.push(t[e].outer),i=0,n=t[e].holes.length;n>i;i++)p.push(t[e].holes[i]);return p},ClipperLib.JS.PolyTreeToExPolygons=function(t){var e,i,r,n,p=new ClipperLib.ExPolygons;for(i=0,r=t.Childs(),n=r.length;n>i;i++)e=r[i],ClipperLib.JS.AddOuterPolyNodeToExPolygons(e,p);return p},module.exports=ClipperLib; +(function (global){ +(function(){function n(n,t){if(n!==t){var r=null===n,e=n===b,u=n===n,i=null===t,o=t===b,f=t===t;if(n>t&&!i||!u||r&&!o&&f||e&&f)return 1;if(n-1;);return r}function o(n,t){for(var r=n.length;r--&&t.indexOf(n.charAt(r))>-1;);return r}function f(t,r){return n(t.criteria,r.criteria)||t.index-r.index}function a(t,r,e){for(var u=-1,i=t.criteria,o=r.criteria,f=i.length,a=e.length;++u=a)return c;var l=e[u];return c*("asc"===l||l===!0?1:-1)}}return t.index-r.index}function c(n){return qn[n]}function l(n){return Mn[n]}function s(n,t,r){return t?n=Vn[n]:r&&(n=Yn[n]),"\\"+n}function p(n){return"\\"+Yn[n]}function h(n,t,r){for(var e=n.length,u=t+(r?0:-1);r?u--:++u=9&&n<=13||32==n||160==n||5760==n||6158==n||n>=8192&&(n<=8202||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function g(n,t){for(var r=-1,e=n.length,u=-1,i=[];++r=T?_r(t):null,c=t.length;a&&(o=Hn,f=!1,t=a);n:for(;++iu?0:u+r),e=e===b||e>u?u:+e||0,e<0&&(e+=u),u=r>e?0:e>>>0,r>>>=0;ru?0:u+t),r=r===b||r>u?u:+r||0,r<0&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0;for(var i=zi(u);++e=T,a=f?_r():null,c=[];a?(u=Hn,o=!1):(f=!1,a=t?[]:c);n:for(;++e>>1,o=n[i];(r?o<=t:o2?r[u-2]:b,o=u>2?r[2]:b,f=u>1?r[u-1]:b;for("function"==typeof i?(i=or(i,f,5),u-=2):(i="function"==typeof f?f:b,u-=i?1:0),o&&Qr(r[0],r[1],o)&&(i=u<3?b:i,u=1);++e-1?e[o]:b}return Et(e,u,n)}}function br(n){return function(r,e,u){return r&&r.length?(e=Dr(e,u,3),t(r,e,n)):-1}}function Ar(n){return function(t,r,e){return r=Dr(r,e,3),Et(t,r,n,!0)}}function jr(n){return function(){for(var t,r=arguments.length,e=n?r:-1,u=0,i=zi(r);n?e--:++e=T)return t.plant(e).value();for(var u=0,o=r?i[u].apply(this,n):e;++u=t||!mo(t))return"";var u=t-e;return r=null==r?" ":r+"",gi(r,_o(u/r.length)).slice(0,u)}function Wr(n,t,r,e){function u(){for(var t=-1,f=arguments.length,a=-1,c=e.length,l=zi(c+f);++aa))return!1;for(;++f-1&&n%1==0&&n-1&&n%1==0&&n<=$o}function ee(n){return n===n&&!Wu(n)}function ue(n,t){var r=n[1],e=t[1],u=r|e,i=u-1;)po.call(t,i,1);return t}function Ee(n,t,r){var e=[];if(!n||!n.length)return e;var u=-1,i=[],o=n.length;for(t=Dr(t,r,3);++u-1:!!u&&Mr(n,t,r)>-1}function nu(n,t,r){var e=Cf(n)?ct:Bt;return t=Dr(t,r,3),e(n,t)}function tu(n,t){return nu(n,Si(t))}function ru(n,t,r){var e=Cf(n)?at:Ot;return t=Dr(t,r,3),e(n,function(n,r,e){return!t(n,r,e)})}function eu(n,t,r){if(r?Qr(n,t,r):null==t){n=le(n);var e=n.length;return e>0?n[Yt(0,e-1)]:b}var u=-1,i=Yu(n),e=i.length,o=e-1;for(t=Ao(t<0?0:+t||0,e);++u0&&(r=t.apply(this,arguments)),n<=1&&(t=b),r}}function hu(n,t,r){function e(){h&&oo(h),c&&oo(c),_=0,c=h=v=b}function u(t,r){r&&oo(r),c=h=v=b,t&&(_=gf(),l=n.apply(p,a),h||c||(a=p=b))}function i(){var n=t-(gf()-s);n<=0||n>t?u(v,c):h=so(i,n)}function o(){u(y,h)}function f(){if(a=arguments,s=gf(),p=this,v=y&&(h||!d),g===!1)var r=d&&!h;else{c||d||(_=s);var e=g-(s-_),u=e<=0||e>g;u?(c&&(c=oo(c)),_=s,l=n.apply(p,a)):c||(c=so(o,e))}return u&&h?h=oo(h):h||t===g||(h=so(i,t)),r&&(u=!0,l=n.apply(p,a)),!u||h||c||(a=p=b),l}var a,c,l,s,p,h,v,_=0,g=!1,y=!0;if("function"!=typeof n)throw new Ji(z);if(t=t<0?0:+t||0,r===!0){var d=!0;y=!1}else Wu(r)&&(d=!!r.leading,g="maxWait"in r&&bo(+r.maxWait||0,t),y="trailing"in r?!!r.trailing:y);return f.cancel=e,f}function vu(n,t){if("function"!=typeof n||t&&"function"!=typeof t)throw new Ji(z);var r=function(){var e=arguments,u=t?t.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var o=n.apply(this,e);return r.cache=i.set(u,o),o};return r.cache=new vu.Cache,r}function _u(n){if("function"!=typeof n)throw new Ji(z);return function(){return!n.apply(this,arguments)}}function gu(n){return pu(2,n)}function yu(n,t){if("function"!=typeof n)throw new Ji(z);return t=bo(t===b?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=bo(r.length-t,0),i=zi(u);++et}function ju(n,t){return n>=t}function ku(n){return v(n)&&Zr(n)&&no.call(n,"callee")&&!co.call(n,"callee")}function Iu(n){return n===!0||n===!1||v(n)&&ro.call(n)==P}function Ru(n){return v(n)&&ro.call(n)==K}function Ou(n){return!!n&&1===n.nodeType&&v(n)&&!zu(n)}function Eu(n){return null==n||(Zr(n)&&(Cf(n)||qu(n)||ku(n)||v(n)&&Su(n.splice))?!n.length:!Df(n).length)}function Cu(n,t,r,e){r="function"==typeof r?or(r,e,3):b;var u=r?r(n,t):b;return u===b?Nt(n,t,r):!!u}function Uu(n){return v(n)&&"string"==typeof n.message&&ro.call(n)==V}function $u(n){return"number"==typeof n&&mo(n)}function Su(n){return Wu(n)&&ro.call(n)==Y}function Wu(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function Fu(n,t,r,e){return r="function"==typeof r?or(r,e,3):b,Lt(n,Pr(t),r)}function Nu(n){return Bu(n)&&n!=+n}function Tu(n){return null!=n&&(Su(n)?uo.test(Qi.call(n)):v(n)&&$n.test(n))}function Lu(n){return null===n}function Bu(n){return"number"==typeof n||v(n)&&ro.call(n)==J}function zu(n){var t;if(!v(n)||ro.call(n)!=X||ku(n)||!no.call(n,"constructor")&&(t=n.constructor,"function"==typeof t&&!(t instanceof t)))return!1;var r;return Ut(n,function(n,t){r=t}),r===b||no.call(n,r)}function Du(n){return Wu(n)&&ro.call(n)==Z}function qu(n){return"string"==typeof n||v(n)&&ro.call(n)==Q}function Mu(n){return v(n)&&re(n.length)&&!!zn[ro.call(n)]}function Pu(n){return n===b}function Ku(n,t){return n0;++e=Ao(t,r)&&n=0&&n.indexOf(t,r)==r}function pi(n){return n=u(n),n&&dn.test(n)?n.replace(gn,l):n}function hi(n){return n=u(n),n&&In.test(n)?n.replace(kn,s):n||"(?:)"}function vi(n,t,r){n=u(n),t=+t;var e=n.length;if(e>=t||!mo(t))return n;var i=(t-e)/2,o=yo(i),f=_o(i);return r=Sr("",f,r),r.slice(0,o)+n+r}function _i(n,t,r){return(r?Qr(n,t,r):null==t)?t=0:t&&(t=+t),n=wi(n),ko(n,t||(Un.test(n)?16:10))}function gi(n,t){var r="";if(n=u(n),t=+t,t<1||!n||!mo(t))return r;do t%2&&(r+=n),t=yo(t/2),n+=n;while(t);return r}function yi(n,t,r){return n=u(n),r=null==r?0:Ao(r<0?0:+r||0,n.length),n.lastIndexOf(t,r)==r}function di(n,t,r){var e=G.templateSettings;r&&Qr(n,t,r)&&(t=r=b),n=u(n),t=yt(dt({},r||t),e,gt);var i,o,f=yt(dt({},t.imports),e.imports,gt),a=Df(f),c=tr(f,a),l=0,s=t.interpolate||Fn,h="__p += '",v=Yi((t.escape||Fn).source+"|"+s.source+"|"+(s===xn?En:Fn).source+"|"+(t.evaluate||Fn).source+"|$","g"),_="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++Bn+"]")+"\n";n.replace(v,function(t,r,e,u,f,a){return e||(e=u),h+=n.slice(l,a).replace(Nn,p),r&&(i=!0,h+="' +\n__e("+r+") +\n'"),f&&(o=!0,h+="';\n"+f+";\n__p += '"),e&&(h+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),l=a+t.length,t}),h+="';\n";var g=t.variable;g||(h="with (obj) {\n"+h+"\n}\n"),h=(o?h.replace(pn,""):h).replace(hn,"$1").replace(vn,"$1;"),h="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var y=Hf(function(){return Mi(a,_+"return "+h).apply(b,c)});if(y.source=h,Uu(y))throw y;return y}function wi(n,t,r){var e=n;return(n=u(n))?(r?Qr(e,t,r):null==t)?n.slice(d(n),w(n)+1):(t+="",n.slice(i(n,t),o(n,t)+1)):n}function mi(n,t,r){var e=n;return n=u(n),n?(r?Qr(e,t,r):null==t)?n.slice(d(n)):n.slice(i(n,t+"")):n}function xi(n,t,r){var e=n;return n=u(n),n?(r?Qr(e,t,r):null==t)?n.slice(0,w(n)+1):n.slice(0,o(n,t+"")+1):n}function bi(n,t,r){r&&Qr(n,t,r)&&(t=b);var e=S,i=W;if(null!=t)if(Wu(t)){var o="separator"in t?t.separator:o;e="length"in t?+t.length||0:e,i="omission"in t?u(t.omission):i}else e=+t||0;if(n=u(n),e>=n.length)return n;var f=e-i.length;if(f<1)return i;var a=n.slice(0,f);if(null==o)return a+i;if(Du(o)){if(n.slice(f).search(o)){var c,l,s=n.slice(0,f);for(o.global||(o=Yi(o.source,(Cn.exec(o)||"")+"g")),o.lastIndex=0;c=o.exec(s);)l=c.index;a=a.slice(0,null==l?f:l)}}else if(n.indexOf(o,f)!=f){var p=a.lastIndexOf(o);p>-1&&(a=a.slice(0,p))}return a+i}function Ai(n){return n=u(n),n&&yn.test(n)?n.replace(_n,m):n}function ji(n,t,r){return r&&Qr(n,t,r)&&(t=b),n=u(n),n.match(t||Tn)||[]}function ki(n,t,r){return r&&Qr(n,t,r)&&(t=b),v(n)?Oi(n):xt(n,t)}function Ii(n){return function(){return n}}function Ri(n){return n}function Oi(n){return zt(bt(n,!0))}function Ei(n,t){return Dt(n,bt(t,!0))}function Ci(n,t,r){if(null==r){var e=Wu(t),u=e?Df(t):b,i=u&&u.length?Wt(t,u):b;(i?i.length:e)||(i=!1,r=t,t=n,n=this)}i||(i=Wt(t,Df(t)));var o=!0,f=-1,a=Su(n),c=i.length;r===!1?o=!1:Wu(r)&&"chain"in r&&(o=r.chain);for(;++f>>1,$o=9007199254740991,So=vo&&new vo,Wo={};G.support={};G.templateSettings={escape:wn,evaluate:mn,interpolate:xn,variable:"",imports:{_:G}};var Fo=function(){function n(){}return function(t){if(Wu(t)){n.prototype=t;var r=new n;n.prototype=b}return r||{}}}(),No=pr($t),To=pr(St,!0),Lo=hr(),Bo=hr(!0),zo=So?function(n,t){return So.set(n,t),n}:Ri,Do=So?function(n){return So.get(n)}:$i,qo=Pt("length"),Mo=function(){var n=0,t=0;return function(r,e){var u=gf(),i=N-(u-t);if(t=u,i>0){if(++n>=F)return r}else n=0;return zo(r,e)}}(),Po=yu(function(n,t){return v(n)&&Zr(n)?jt(n,Ct(t,!1,!0)):[]}),Ko=br(),Vo=br(!0),Yo=yu(function(n){for(var t=n.length,e=t,u=zi(s),i=Mr(),o=i==r,f=[];e--;){var a=n[e]=Zr(a=n[e])?a:[];u[e]=o&&a.length>=120?_r(e&&a):null}var c=n[0],l=-1,s=c?c.length:0,p=u[0];n:for(;++l2?n[t-2]:b,e=t>1?n[t-1]:b;return t>2&&"function"==typeof r?t-=2:(r=t>1&&"function"==typeof e?(--t,e):b,e=b),n.length=t,Le(n,r,e)}),tf=yu(function(n){return n=Ct(n),this.thru(function(t){return rt(Cf(t)?t:[se(t)],n)})}),rf=yu(function(n,t){return wt(n,Ct(t))}),ef=lr(function(n,t,r){no.call(n,r)?++n[r]:n[r]=1}),uf=xr(No),of=xr(To,!0),ff=kr(ut,No),af=kr(it,To),cf=lr(function(n,t,r){no.call(n,r)?n[r].push(t):n[r]=[t]}),lf=lr(function(n,t,r){n[r]=t}),sf=yu(function(n,t,r){var e=-1,u="function"==typeof t,i=ne(t),o=Zr(n)?zi(n.length):[];return No(n,function(n){var f=u?t:i&&null!=n?n[t]:b;o[++e]=f?f.apply(n,r):Xr(n,t,r)}),o}),pf=lr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),hf=Ur(st,No),vf=Ur(pt,To),_f=yu(function(n,t){if(null==n)return[];var r=t[2];return r&&Qr(t[0],t[1],r)&&(t.length=1),Ht(n,Ct(t),[])}),gf=jo||function(){return(new Di).getTime()},yf=yu(function(n,t,r){var e=j;if(r.length){var u=g(r,yf.placeholder);e|=E}return Tr(n,e,t,r,u)}),df=yu(function(n,t){t=t.length?Ct(t):Xu(n);for(var r=-1,e=t.length;++r0||t<0)?new qn(r):(n<0?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==b&&(t=+t||0,r=t<0?r.dropRight(-t):r.take(t-n)),r)},qn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},qn.prototype.toArray=function(){return this.take(Oo)},$t(qn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=G[e?"take"+("last"==t?"Right":""):t];u&&(G.prototype[t]=function(){var t=e?[1]:arguments,i=this.__chain__,o=this.__wrapped__,f=!!this.__actions__.length,a=o instanceof qn,c=t[0],l=a||Cf(o);l&&r&&"function"==typeof c&&1!=c.length&&(a=l=!1);var s=function(n){return e&&i?u(n,1)[0]:u.apply(b,lt([n],t))},p={func:Me,args:[s],thisArg:b},h=a&&!f;if(e&&!i)return h?(o=o.clone(),o.__actions__.push(p),n.call(o)):u.call(b,this.value())[0];if(!e&&l){o=h?o:new qn(this);var v=n.apply(o,t);return v.__actions__.push(p),new nn(v,i)}return this.thru(s)})}),ut(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(n){var t=(/^(?:replace|split)$/.test(n)?Hi:Xi)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);G.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),$t(qn.prototype,function(n,t){var r=G[t];if(r){var e=r.name,u=Wo[e]||(Wo[e]=[]);u.push({name:t,func:r})}}),Wo[$r(b,k).name]=[{name:"wrapper",func:b}],qn.prototype.clone=Mn,qn.prototype.reverse=Pn,qn.prototype.value=Kn,G.prototype.chain=Pe,G.prototype.commit=Ke,G.prototype.concat=tf,G.prototype.plant=Ve,G.prototype.reverse=Ye,G.prototype.toString=Ge,G.prototype.run=G.prototype.toJSON=G.prototype.valueOf=G.prototype.value=Je,G.prototype.collect=G.prototype.map,G.prototype.head=G.prototype.first,G.prototype.select=G.prototype.filter,G.prototype.tail=G.prototype.rest,G}var b,A="3.10.1",j=1,k=2,I=4,R=8,O=16,E=32,C=64,U=128,$=256,S=30,W="...",F=150,N=16,T=200,L=1,B=2,z="Expected a function",D="__lodash_placeholder__",q="[object Arguments]",M="[object Array]",P="[object Boolean]",K="[object Date]",V="[object Error]",Y="[object Function]",G="[object Map]",J="[object Number]",X="[object Object]",Z="[object RegExp]",H="[object Set]",Q="[object String]",nn="[object WeakMap]",tn="[object ArrayBuffer]",rn="[object Float32Array]",en="[object Float64Array]",un="[object Int8Array]",on="[object Int16Array]",fn="[object Int32Array]",an="[object Uint8Array]",cn="[object Uint8ClampedArray]",ln="[object Uint16Array]",sn="[object Uint32Array]",pn=/\b__p \+= '';/g,hn=/\b(__p \+=) '' \+/g,vn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_n=/&(?:amp|lt|gt|quot|#39|#96);/g,gn=/[&<>"'`]/g,yn=RegExp(_n.source),dn=RegExp(gn.source),wn=/<%-([\s\S]+?)%>/g,mn=/<%([\s\S]+?)%>/g,xn=/<%=([\s\S]+?)%>/g,bn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,An=/^\w*$/,jn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,kn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,In=RegExp(kn.source),Rn=/[\u0300-\u036f\ufe20-\ufe23]/g,On=/\\(\\)?/g,En=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Cn=/\w*$/,Un=/^0[xX]/,$n=/^\[object .+?Constructor\]$/,Sn=/^\d+$/,Wn=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Fn=/($^)/,Nn=/['\n\r\u2028\u2029\\]/g,Tn=function(){var n="[A-Z\\xc0-\\xd6\\xd8-\\xde]",t="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(n+"+(?="+n+t+")|"+n+"?"+t+"|"+n+"+|[0-9]+","g")}(),Ln=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],Bn=-1,zn={};zn[rn]=zn[en]=zn[un]=zn[on]=zn[fn]=zn[an]=zn[cn]=zn[ln]=zn[sn]=!0,zn[q]=zn[M]=zn[tn]=zn[P]=zn[K]=zn[V]=zn[Y]=zn[G]=zn[J]=zn[X]=zn[Z]=zn[H]=zn[Q]=zn[nn]=!1;var Dn={};Dn[q]=Dn[M]=Dn[tn]=Dn[P]=Dn[K]=Dn[rn]=Dn[en]=Dn[un]=Dn[on]=Dn[fn]=Dn[J]=Dn[X]=Dn[Z]=Dn[Q]=Dn[an]=Dn[cn]=Dn[ln]=Dn[sn]=!0,Dn[V]=Dn[Y]=Dn[G]=Dn[H]=Dn[nn]=!1;var qn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Mn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Pn={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Kn={function:!0,object:!0},Vn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Yn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Gn=Kn[typeof exports]&&exports&&!exports.nodeType&&exports,Jn=Kn[typeof module]&&module&&!module.nodeType&&module,Xn=Gn&&Jn&&"object"==typeof global&&global&&global.Object&&global,Zn=Kn[typeof self]&&self&&self.Object&&self,Hn=Kn[typeof window]&&window&&window.Object&&window,Qn=Jn&&Jn.exports===Gn&&Gn,nt=Xn||Hn!==(this&&this.window)&&Hn||Zn||this,tt=x();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(nt._=tt,define(function(){return tt})):Gn&&Jn?Qn?(Jn.exports=tt)._=tt:Gn._=tt:nt._=tt}).call(this); +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],4:[function(require,module,exports){ -(function (global){ -(function(){function n(n,t){if(n!==t){var r=null===n,e=n===b,u=n===n,i=null===t,o=t===b,f=t===t;if(n>t&&!i||!u||r&&!o&&f||e&&f)return 1;if(t>n&&!r||!f||i&&!e&&u||o&&u)return-1}return 0}function t(n,t,r){for(var e=n.length,u=r?e:-1;r?u--:++u-1;);return r}function o(n,t){for(var r=n.length;r--&&t.indexOf(n.charAt(r))>-1;);return r}function f(t,r){return n(t.criteria,r.criteria)||t.index-r.index}function a(t,r,e){for(var u=-1,i=t.criteria,o=r.criteria,f=i.length,a=e.length;++u=a)return c;var l=e[u];return c*("asc"===l||l===!0?1:-1)}}return t.index-r.index}function c(n){return qn[n]}function l(n){return Mn[n]}function s(n,t,r){return t?n=Vn[n]:r&&(n=Yn[n]),"\\"+n}function p(n){return"\\"+Yn[n]}function h(n,t,r){for(var e=n.length,u=t+(r?0:-1);r?u--:++u=n&&n>=9&&13>=n||32==n||160==n||5760==n||6158==n||n>=8192&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function g(n,t){for(var r=-1,e=n.length,u=-1,i=[];++rt,u=r?n.length:0,i=Vr(0,u,this.__views__),o=i.start,f=i.end,a=f-o,c=e?f:o-1,l=this.__iteratees__,s=l.length,p=0,h=Ao(a,this.__takeCount__);if(!r||T>u||u==a&&h==a)return er(e&&r?n.reverse():n,this.__actions__);var v=[];n:for(;a--&&h>p;){c+=t;for(var _=-1,g=n[c];++_=T?_r(t):null,c=t.length;a&&(o=Hn,f=!1,t=a);n:for(;++ir&&(r=-r>u?0:u+r),e=e===b||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;u>r;)n[r++]=t;return n}function Ot(n,t){var r=[];return No(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Et(n,t,r,e){var u;return r(n,function(n,r,i){return t(n,r,i)?(u=e?r:n,!1):void 0}),u}function Ct(n,t,r,e){e||(e=[]);for(var u=-1,i=n.length;++ue;)n=n[t[e++]];return e&&e==u?n:b}}function Nt(n,t,r,e,u,i){return n===t?!0:null==n||null==t||!Wu(n)&&!v(t)?n!==n&&t!==t:Tt(n,t,Nt,r,e,u,i)}function Tt(n,t,r,e,u,i,o){var f=Cf(n),a=Cf(t),c=M,l=M;f||(c=ro.call(n),c==q?c=X:c!=X&&(f=Mu(n))),a||(l=ro.call(t),l==q?l=X:l!=X&&(a=Mu(t)));var s=c==X,p=l==X,h=c==l;if(h&&!f&&!s)return Br(n,t,c);if(!u){var v=s&&no.call(n,"__wrapped__"),_=p&&no.call(t,"__wrapped__");if(v||_)return r(v?n.value():n,_?t.value():t,e,u,i,o)}if(!h)return!1;i||(i=[]),o||(o=[]);for(var g=i.length;g--;)if(i[g]==n)return o[g]==t;i.push(n),o.push(t);var y=(f?Lr:zr)(n,t,r,e,u,i,o);return i.pop(),o.pop(),y}function Lt(n,t,r){var e=t.length,u=e,i=!r;if(null==n)return!u;for(n=se(n);e--;){var o=t[e];if(i&&o[2]?o[1]!==n[o[0]]:!(o[0]in n))return!1}for(;++et&&(t=-t>u?0:u+t),r=r===b||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0;for(var i=zi(u);++e=T,a=f?_r():null,c=[];a?(u=Hn,o=!1):(f=!1,a=t?[]:c);n:for(;++e=u){for(;u>e;){var i=e+u>>>1,o=n[i];(r?t>=o:t>o)&&null!==o?e=i+1:u=i}return u}return ir(n,t,Ri,r)}function ir(n,t,r,e){t=r(t);for(var u=0,i=n?n.length:0,o=t!==t,f=null===t,a=t===b;i>u;){var c=yo((u+i)/2),l=r(n[c]),s=l!==b,p=l===l;if(o)var h=p||e;else h=f?p&&s&&(e||null!=l):a?p&&(e||s):null==l?!1:e?t>=l:t>l;h?u=c+1:i=c}return Ao(i,Co)}function or(n,t,r){if("function"!=typeof n)return Ri;if(t===b)return n;switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)};case 5:return function(r,e,u,i,o){return n.call(t,r,e,u,i,o)}}return function(){return n.apply(t,arguments)}}function fr(n){var t=new io(n.byteLength),r=new ho(t);return r.set(new ho(n)),t}function ar(n,t,r){for(var e=r.length,u=-1,i=bo(n.length-e,0),o=-1,f=t.length,a=zi(f+i);++o2?r[u-2]:b,o=u>2?r[2]:b,f=u>1?r[u-1]:b;for("function"==typeof i?(i=or(i,f,5),u-=2):(i="function"==typeof f?f:b,u-=i?1:0),o&&Qr(r[0],r[1],o)&&(i=3>u?b:i,u=1);++e-1?e[o]:b}return Et(e,u,n)}}function br(n){return function(r,e,u){return r&&r.length?(e=Dr(e,u,3),t(r,e,n)):-1}}function Ar(n){return function(t,r,e){return r=Dr(r,e,3),Et(t,r,n,!0)}}function jr(n){return function(){for(var t,r=arguments.length,e=n?r:-1,u=0,i=zi(r);n?e--:++e=T)return t.plant(e).value();for(var u=0,o=r?i[u].apply(this,n):e;++um){var R=f?et(f):b,O=bo(c-m,0),U=v?I:b,$=v?b:I,S=v?x:b,W=v?b:x;t|=v?E:C,t&=~(v?C:E),_||(t&=~(j|k));var F=[n,t,r,S,U,W,$,R,a,O],N=$r.apply(b,F);return te(n)&&Mo(N,F),N.placeholder=A,N}}var T=p?r:this,L=h?T[n]:n;return f&&(x=ae(x,f)),s&&a=t||!wo(t))return"";var u=t-e;return r=null==r?" ":r+"",gi(r,_o(u/r.length)).slice(0,u)}function Wr(n,t,r,e){function u(){for(var t=-1,f=arguments.length,a=-1,c=e.length,l=zi(c+f);++aa))return!1;for(;++f-1&&n%1==0&&t>n}function Qr(n,t,r){if(!Wu(r))return!1;var e=typeof t;if("number"==e?Zr(r)&&Hr(t,r.length):"string"==e&&t in r){var u=r[t];return n===n?n===u:u!==u}return!1}function ne(n,t){var r=typeof n;if("string"==r&&An.test(n)||"number"==r)return!0;if(Cf(n))return!1;var e=!bn.test(n);return e||null!=t&&n in se(t)}function te(n){var t=qr(n);if(!(t in qn.prototype))return!1;var r=G[t];if(n===r)return!0;var e=Do(r);return!!e&&n===e[0]}function re(n){return"number"==typeof n&&n>-1&&n%1==0&&$o>=n}function ee(n){return n===n&&!Wu(n)}function ue(n,t){var r=n[1],e=t[1],u=r|e,i=U>u,o=e==U&&r==R||e==U&&r==$&&n[7].length<=t[8]||e==(U|$)&&r==R;if(!i&&!o)return n;e&j&&(n[2]=t[2],u|=r&j?0:I);var f=t[3];if(f){var a=n[3];n[3]=a?ar(a,f,t[4]):et(f),n[4]=a?g(n[3],D):et(t[4])}return f=t[5],f&&(a=n[5],n[5]=a?cr(a,f,t[6]):et(f),n[6]=a?g(n[5],D):et(t[6])),f=t[7],f&&(n[7]=et(f)),e&U&&(n[8]=null==n[8]?t[8]:Ao(n[8],t[8])),null==n[9]&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function ie(n,t){return n===b?t:Uf(n,t,ie)}function oe(n,t){n=se(n);for(var r=-1,e=t.length,u={};++re;)o[++i]=Jt(n,e,e+=t);return o}function _e(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++tt?0:t)):[]}function ye(n,t,r){var e=n?n.length:0;return e?((r?Qr(n,t,r):null==t)&&(t=1),t=e-(+t||0),Jt(n,0,0>t?0:t)):[]}function de(n,t,r){return n&&n.length?rr(n,Dr(t,r,3),!0,!0):[]}function me(n,t,r){return n&&n.length?rr(n,Dr(t,r,3),!0):[]}function we(n,t,r,e){var u=n?n.length:0;return u?(r&&"number"!=typeof r&&Qr(n,t,r)&&(r=0,e=u),Rt(n,t,r,e)):[]}function xe(n){return n?n[0]:b}function be(n,t,r){var e=n?n.length:0;return r&&Qr(n,t,r)&&(t=!1),e?Ct(n,t):[]}function Ae(n){var t=n?n.length:0;return t?Ct(n,!0):[]}function je(n,t,e){var u=n?n.length:0;if(!u)return-1;if("number"==typeof e)e=0>e?bo(u+e,0):e;else if(e){var i=ur(n,t);return u>i&&(t===t?t===n[i]:n[i]!==n[i])?i:-1}return r(n,t,e||0)}function ke(n){return ye(n,1)}function Ie(n){var t=n?n.length:0;return t?n[t-1]:b}function Re(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if("number"==typeof r)u=(0>r?bo(e+r,0):Ao(r||0,e-1))+1;else if(r){u=ur(n,t,!0)-1;var i=n[u];return(t===t?t===i:i!==i)?u:-1}if(t!==t)return h(n,u,!0);for(;u--;)if(n[u]===t)return u;return-1}function Oe(){var n=arguments,t=n[0];if(!t||!t.length)return t;for(var r=0,e=Mr(),u=n.length;++r-1;)po.call(t,i,1);return t}function Ee(n,t,r){var e=[];if(!n||!n.length)return e;var u=-1,i=[],o=n.length;for(t=Dr(t,r,3);++ut?0:t)):[]}function Se(n,t,r){var e=n?n.length:0;return e?((r?Qr(n,t,r):null==t)&&(t=1),t=e-(+t||0),Jt(n,0>t?0:t)):[]}function We(n,t,r){return n&&n.length?rr(n,Dr(t,r,3),!1,!0):[]}function Fe(n,t,r){return n&&n.length?rr(n,Dr(t,r,3)):[]}function Ne(n,t,e,u){var i=n?n.length:0;if(!i)return[];null!=t&&"boolean"!=typeof t&&(u=e,e=Qr(n,t,u)?b:t,t=!1);var o=Dr();return(null!=e||o!==xt)&&(e=o(e,u,3)),t&&Mr()==r?y(n,e):nr(n,e)}function Te(n){if(!n||!n.length)return[];var t=-1,r=0;n=at(n,function(n){return Zr(n)?(r=bo(n.length,r),!0):void 0});for(var e=zi(r);++tr?bo(u+r,0):r||0,"string"==typeof n||!Cf(n)&&qu(n)?u>=r&&n.indexOf(t,r)>-1:!!u&&Mr(n,t,r)>-1}function nu(n,t,r){var e=Cf(n)?ct:Bt;return t=Dr(t,r,3),e(n,t)}function tu(n,t){return nu(n,Si(t))}function ru(n,t,r){var e=Cf(n)?at:Ot;return t=Dr(t,r,3),e(n,function(n,r,e){return!t(n,r,e)})}function eu(n,t,r){if(r?Qr(n,t,r):null==t){n=le(n);var e=n.length;return e>0?n[Yt(0,e-1)]:b}var u=-1,i=Yu(n),e=i.length,o=e-1;for(t=Ao(0>t?0:+t||0,e);++u0&&(r=t.apply(this,arguments)),1>=n&&(t=b),r}}function hu(n,t,r){function e(){h&&oo(h),c&&oo(c),_=0,c=h=v=b}function u(t,r){r&&oo(r),c=h=v=b,t&&(_=gf(),l=n.apply(p,a),h||c||(a=p=b))}function i(){var n=t-(gf()-s);0>=n||n>t?u(v,c):h=so(i,n)}function o(){u(y,h)}function f(){if(a=arguments,s=gf(),p=this,v=y&&(h||!d),g===!1)var r=d&&!h;else{c||d||(_=s);var e=g-(s-_),u=0>=e||e>g;u?(c&&(c=oo(c)),_=s,l=n.apply(p,a)):c||(c=so(o,e))}return u&&h?h=oo(h):h||t===g||(h=so(i,t)),r&&(u=!0,l=n.apply(p,a)),!u||h||c||(a=p=b),l}var a,c,l,s,p,h,v,_=0,g=!1,y=!0;if("function"!=typeof n)throw new Ji(z);if(t=0>t?0:+t||0,r===!0){var d=!0;y=!1}else Wu(r)&&(d=!!r.leading,g="maxWait"in r&&bo(+r.maxWait||0,t),y="trailing"in r?!!r.trailing:y);return f.cancel=e,f}function vu(n,t){if("function"!=typeof n||t&&"function"!=typeof t)throw new Ji(z);var r=function(){var e=arguments,u=t?t.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var o=n.apply(this,e);return r.cache=i.set(u,o),o};return r.cache=new vu.Cache,r}function _u(n){if("function"!=typeof n)throw new Ji(z);return function(){return!n.apply(this,arguments)}}function gu(n){return pu(2,n)}function yu(n,t){if("function"!=typeof n)throw new Ji(z);return t=bo(t===b?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=bo(r.length-t,0),i=zi(u);++et}function ju(n,t){return n>=t}function ku(n){return v(n)&&Zr(n)&&no.call(n,"callee")&&!co.call(n,"callee")}function Iu(n){return n===!0||n===!1||v(n)&&ro.call(n)==P}function Ru(n){return v(n)&&ro.call(n)==K}function Ou(n){return!!n&&1===n.nodeType&&v(n)&&!zu(n)}function Eu(n){return null==n?!0:Zr(n)&&(Cf(n)||qu(n)||ku(n)||v(n)&&Su(n.splice))?!n.length:!Df(n).length}function Cu(n,t,r,e){r="function"==typeof r?or(r,e,3):b;var u=r?r(n,t):b;return u===b?Nt(n,t,r):!!u}function Uu(n){return v(n)&&"string"==typeof n.message&&ro.call(n)==V}function $u(n){return"number"==typeof n&&wo(n)}function Su(n){return Wu(n)&&ro.call(n)==Y}function Wu(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function Fu(n,t,r,e){return r="function"==typeof r?or(r,e,3):b,Lt(n,Pr(t),r)}function Nu(n){return Bu(n)&&n!=+n}function Tu(n){return null==n?!1:Su(n)?uo.test(Qi.call(n)):v(n)&&$n.test(n)}function Lu(n){return null===n}function Bu(n){return"number"==typeof n||v(n)&&ro.call(n)==J}function zu(n){var t;if(!v(n)||ro.call(n)!=X||ku(n)||!no.call(n,"constructor")&&(t=n.constructor,"function"==typeof t&&!(t instanceof t)))return!1;var r;return Ut(n,function(n,t){r=t}),r===b||no.call(n,r)}function Du(n){return Wu(n)&&ro.call(n)==Z}function qu(n){return"string"==typeof n||v(n)&&ro.call(n)==Q}function Mu(n){return v(n)&&re(n.length)&&!!zn[ro.call(n)]}function Pu(n){return n===b}function Ku(n,t){return t>n}function Vu(n,t){return t>=n}function Yu(n){var t=n?qo(n):0;return re(t)?t?et(n):[]:ii(n)}function Gu(n){return wt(n,ni(n))}function Ju(n,t,r){var e=Fo(n);return r&&Qr(n,t,r)&&(t=b),t?dt(e,t):e}function Xu(n){return Wt(n,ni(n))}function Zu(n,t,r){var e=null==n?b:Ft(n,pe(t),t+"");return e===b?r:e}function Hu(n,t){if(null==n)return!1;var r=no.call(n,t);if(!r&&!ne(t)){if(t=pe(t),n=1==t.length?n:Ft(n,Jt(t,0,-1)),null==n)return!1;t=Ie(t),r=no.call(n,t)}return r||re(n.length)&&Hr(t,n.length)&&(Cf(n)||ku(n))}function Qu(n,t,r){r&&Qr(n,t,r)&&(t=b);for(var e=-1,u=Df(n),i=u.length,o={};++e0;++e=Ao(t,r)&&nr?0:+r||0,e),r-=t.length,r>=0&&n.indexOf(t,r)==r}function pi(n){return n=u(n),n&&dn.test(n)?n.replace(gn,l):n}function hi(n){return n=u(n),n&&In.test(n)?n.replace(kn,s):n||"(?:)"}function vi(n,t,r){n=u(n),t=+t;var e=n.length;if(e>=t||!wo(t))return n;var i=(t-e)/2,o=yo(i),f=_o(i);return r=Sr("",f,r),r.slice(0,o)+n+r}function _i(n,t,r){return(r?Qr(n,t,r):null==t)?t=0:t&&(t=+t),n=mi(n),ko(n,t||(Un.test(n)?16:10))}function gi(n,t){var r="";if(n=u(n),t=+t,1>t||!n||!wo(t))return r;do t%2&&(r+=n),t=yo(t/2),n+=n;while(t);return r}function yi(n,t,r){return n=u(n),r=null==r?0:Ao(0>r?0:+r||0,n.length),n.lastIndexOf(t,r)==r}function di(n,t,r){var e=G.templateSettings;r&&Qr(n,t,r)&&(t=r=b),n=u(n),t=yt(dt({},r||t),e,gt);var i,o,f=yt(dt({},t.imports),e.imports,gt),a=Df(f),c=tr(f,a),l=0,s=t.interpolate||Fn,h="__p += '",v=Yi((t.escape||Fn).source+"|"+s.source+"|"+(s===xn?En:Fn).source+"|"+(t.evaluate||Fn).source+"|$","g"),_="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++Bn+"]")+"\n";n.replace(v,function(t,r,e,u,f,a){return e||(e=u),h+=n.slice(l,a).replace(Nn,p),r&&(i=!0,h+="' +\n__e("+r+") +\n'"),f&&(o=!0,h+="';\n"+f+";\n__p += '"),e&&(h+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),l=a+t.length,t}),h+="';\n";var g=t.variable;g||(h="with (obj) {\n"+h+"\n}\n"),h=(o?h.replace(pn,""):h).replace(hn,"$1").replace(vn,"$1;"),h="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var y=Hf(function(){return Mi(a,_+"return "+h).apply(b,c)});if(y.source=h,Uu(y))throw y;return y}function mi(n,t,r){var e=n;return(n=u(n))?(r?Qr(e,t,r):null==t)?n.slice(d(n),m(n)+1):(t+="",n.slice(i(n,t),o(n,t)+1)):n}function wi(n,t,r){var e=n;return n=u(n),n?(r?Qr(e,t,r):null==t)?n.slice(d(n)):n.slice(i(n,t+"")):n}function xi(n,t,r){var e=n;return n=u(n),n?(r?Qr(e,t,r):null==t)?n.slice(0,m(n)+1):n.slice(0,o(n,t+"")+1):n}function bi(n,t,r){r&&Qr(n,t,r)&&(t=b);var e=S,i=W;if(null!=t)if(Wu(t)){var o="separator"in t?t.separator:o;e="length"in t?+t.length||0:e,i="omission"in t?u(t.omission):i}else e=+t||0;if(n=u(n),e>=n.length)return n;var f=e-i.length;if(1>f)return i;var a=n.slice(0,f);if(null==o)return a+i;if(Du(o)){if(n.slice(f).search(o)){var c,l,s=n.slice(0,f);for(o.global||(o=Yi(o.source,(Cn.exec(o)||"")+"g")),o.lastIndex=0;c=o.exec(s);)l=c.index;a=a.slice(0,null==l?f:l)}}else if(n.indexOf(o,f)!=f){var p=a.lastIndexOf(o);p>-1&&(a=a.slice(0,p))}return a+i}function Ai(n){return n=u(n),n&&yn.test(n)?n.replace(_n,w):n}function ji(n,t,r){return r&&Qr(n,t,r)&&(t=b),n=u(n),n.match(t||Tn)||[]}function ki(n,t,r){return r&&Qr(n,t,r)&&(t=b),v(n)?Oi(n):xt(n,t)}function Ii(n){return function(){return n}}function Ri(n){return n}function Oi(n){return zt(bt(n,!0))}function Ei(n,t){return Dt(n,bt(t,!0))}function Ci(n,t,r){if(null==r){var e=Wu(t),u=e?Df(t):b,i=u&&u.length?Wt(t,u):b;(i?i.length:e)||(i=!1,r=t,t=n,n=this)}i||(i=Wt(t,Df(t)));var o=!0,f=-1,a=Su(n),c=i.length;r===!1?o=!1:Wu(r)&&"chain"in r&&(o=r.chain);for(;++fn||!wo(n))return[];var e=-1,u=zi(Ao(n,Eo));for(t=or(t,r,1);++ee?u[e]=t(e):t(e);return u}function Ti(n){var t=++to;return u(n)+t}function Li(n,t){return(+n||0)+(+t||0)}function Bi(n,t,r){return r&&Qr(n,t,r)&&(t=b),t=Dr(t,r,3),1==t.length?vt(Cf(n)?n:le(n),t):Qt(n,t)}_=_?tt.defaults(nt.Object(),_,tt.pick(nt,Ln)):nt;var zi=_.Array,Di=_.Date,qi=_.Error,Mi=_.Function,Pi=_.Math,Ki=_.Number,Vi=_.Object,Yi=_.RegExp,Gi=_.String,Ji=_.TypeError,Xi=zi.prototype,Zi=Vi.prototype,Hi=Gi.prototype,Qi=Mi.prototype.toString,no=Zi.hasOwnProperty,to=0,ro=Zi.toString,eo=nt._,uo=Yi("^"+Qi.call(no).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),io=_.ArrayBuffer,oo=_.clearTimeout,fo=_.parseFloat,ao=Pi.pow,co=Zi.propertyIsEnumerable,lo=Kr(_,"Set"),so=_.setTimeout,po=Xi.splice,ho=_.Uint8Array,vo=Kr(_,"WeakMap"),_o=Pi.ceil,go=Kr(Vi,"create"),yo=Pi.floor,mo=Kr(zi,"isArray"),wo=_.isFinite,xo=Kr(Vi,"keys"),bo=Pi.max,Ao=Pi.min,jo=Kr(Di,"now"),ko=_.parseInt,Io=Pi.random,Ro=Ki.NEGATIVE_INFINITY,Oo=Ki.POSITIVE_INFINITY,Eo=4294967295,Co=Eo-1,Uo=Eo>>>1,$o=9007199254740991,So=vo&&new vo,Wo={};G.support={};G.templateSettings={escape:mn,evaluate:wn,interpolate:xn,variable:"",imports:{_:G}};var Fo=function(){function n(){}return function(t){if(Wu(t)){n.prototype=t;var r=new n;n.prototype=b}return r||{}}}(),No=pr($t),To=pr(St,!0),Lo=hr(),Bo=hr(!0),zo=So?function(n,t){return So.set(n,t),n}:Ri,Do=So?function(n){return So.get(n)}:$i,qo=Pt("length"),Mo=function(){var n=0,t=0;return function(r,e){var u=gf(),i=N-(u-t);if(t=u,i>0){if(++n>=F)return r}else n=0;return zo(r,e)}}(),Po=yu(function(n,t){return v(n)&&Zr(n)?jt(n,Ct(t,!1,!0)):[]}),Ko=br(),Vo=br(!0),Yo=yu(function(n){for(var t=n.length,e=t,u=zi(s),i=Mr(),o=i==r,f=[];e--;){var a=n[e]=Zr(a=n[e])?a:[];u[e]=o&&a.length>=120?_r(e&&a):null}var c=n[0],l=-1,s=c?c.length:0,p=u[0];n:for(;++l2?n[t-2]:b,e=t>1?n[t-1]:b;return t>2&&"function"==typeof r?t-=2:(r=t>1&&"function"==typeof e?(--t,e):b,e=b),n.length=t,Le(n,r,e)}),tf=yu(function(n){return n=Ct(n),this.thru(function(t){return rt(Cf(t)?t:[se(t)],n)})}),rf=yu(function(n,t){return mt(n,Ct(t))}),ef=lr(function(n,t,r){no.call(n,r)?++n[r]:n[r]=1}),uf=xr(No),of=xr(To,!0),ff=kr(ut,No),af=kr(it,To),cf=lr(function(n,t,r){no.call(n,r)?n[r].push(t):n[r]=[t]}),lf=lr(function(n,t,r){n[r]=t}),sf=yu(function(n,t,r){var e=-1,u="function"==typeof t,i=ne(t),o=Zr(n)?zi(n.length):[];return No(n,function(n){var f=u?t:i&&null!=n?n[t]:b;o[++e]=f?f.apply(n,r):Xr(n,t,r)}),o}),pf=lr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),hf=Ur(st,No),vf=Ur(pt,To),_f=yu(function(n,t){if(null==n)return[];var r=t[2];return r&&Qr(t[0],t[1],r)&&(t.length=1),Ht(n,Ct(t),[])}),gf=jo||function(){return(new Di).getTime()},yf=yu(function(n,t,r){var e=j;if(r.length){var u=g(r,yf.placeholder);e|=E}return Tr(n,e,t,r,u)}),df=yu(function(n,t){t=t.length?Ct(t):Xu(n);for(var r=-1,e=t.length;++r0||0>t)?new qn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==b&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r)},qn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},qn.prototype.toArray=function(){return this.take(Oo)},$t(qn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=G[e?"take"+("last"==t?"Right":""):t];u&&(G.prototype[t]=function(){var t=e?[1]:arguments,i=this.__chain__,o=this.__wrapped__,f=!!this.__actions__.length,a=o instanceof qn,c=t[0],l=a||Cf(o);l&&r&&"function"==typeof c&&1!=c.length&&(a=l=!1);var s=function(n){return e&&i?u(n,1)[0]:u.apply(b,lt([n],t))},p={func:Me,args:[s],thisArg:b},h=a&&!f;if(e&&!i)return h?(o=o.clone(),o.__actions__.push(p),n.call(o)):u.call(b,this.value())[0];if(!e&&l){o=h?o:new qn(this);var v=n.apply(o,t);return v.__actions__.push(p),new nn(v,i)}return this.thru(s)})}),ut(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(n){var t=(/^(?:replace|split)$/.test(n)?Hi:Xi)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);G.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),$t(qn.prototype,function(n,t){var r=G[t];if(r){var e=r.name,u=Wo[e]||(Wo[e]=[]);u.push({name:t,func:r})}}),Wo[$r(b,k).name]=[{name:"wrapper",func:b}],qn.prototype.clone=Mn,qn.prototype.reverse=Pn,qn.prototype.value=Kn,G.prototype.chain=Pe,G.prototype.commit=Ke,G.prototype.concat=tf,G.prototype.plant=Ve,G.prototype.reverse=Ye,G.prototype.toString=Ge,G.prototype.run=G.prototype.toJSON=G.prototype.valueOf=G.prototype.value=Je,G.prototype.collect=G.prototype.map,G.prototype.head=G.prototype.first,G.prototype.select=G.prototype.filter,G.prototype.tail=G.prototype.rest,G}var b,A="3.10.1",j=1,k=2,I=4,R=8,O=16,E=32,C=64,U=128,$=256,S=30,W="...",F=150,N=16,T=200,L=1,B=2,z="Expected a function",D="__lodash_placeholder__",q="[object Arguments]",M="[object Array]",P="[object Boolean]",K="[object Date]",V="[object Error]",Y="[object Function]",G="[object Map]",J="[object Number]",X="[object Object]",Z="[object RegExp]",H="[object Set]",Q="[object String]",nn="[object WeakMap]",tn="[object ArrayBuffer]",rn="[object Float32Array]",en="[object Float64Array]",un="[object Int8Array]",on="[object Int16Array]",fn="[object Int32Array]",an="[object Uint8Array]",cn="[object Uint8ClampedArray]",ln="[object Uint16Array]",sn="[object Uint32Array]",pn=/\b__p \+= '';/g,hn=/\b(__p \+=) '' \+/g,vn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_n=/&(?:amp|lt|gt|quot|#39|#96);/g,gn=/[&<>"'`]/g,yn=RegExp(_n.source),dn=RegExp(gn.source),mn=/<%-([\s\S]+?)%>/g,wn=/<%([\s\S]+?)%>/g,xn=/<%=([\s\S]+?)%>/g,bn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,An=/^\w*$/,jn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,kn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,In=RegExp(kn.source),Rn=/[\u0300-\u036f\ufe20-\ufe23]/g,On=/\\(\\)?/g,En=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Cn=/\w*$/,Un=/^0[xX]/,$n=/^\[object .+?Constructor\]$/,Sn=/^\d+$/,Wn=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Fn=/($^)/,Nn=/['\n\r\u2028\u2029\\]/g,Tn=function(){var n="[A-Z\\xc0-\\xd6\\xd8-\\xde]",t="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(n+"+(?="+n+t+")|"+n+"?"+t+"|"+n+"+|[0-9]+","g")}(),Ln=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],Bn=-1,zn={};zn[rn]=zn[en]=zn[un]=zn[on]=zn[fn]=zn[an]=zn[cn]=zn[ln]=zn[sn]=!0,zn[q]=zn[M]=zn[tn]=zn[P]=zn[K]=zn[V]=zn[Y]=zn[G]=zn[J]=zn[X]=zn[Z]=zn[H]=zn[Q]=zn[nn]=!1;var Dn={};Dn[q]=Dn[M]=Dn[tn]=Dn[P]=Dn[K]=Dn[rn]=Dn[en]=Dn[un]=Dn[on]=Dn[fn]=Dn[J]=Dn[X]=Dn[Z]=Dn[Q]=Dn[an]=Dn[cn]=Dn[ln]=Dn[sn]=!0,Dn[V]=Dn[Y]=Dn[G]=Dn[H]=Dn[nn]=!1;var qn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Mn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Pn={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Kn={"function":!0,object:!0},Vn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Yn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Gn=Kn[typeof exports]&&exports&&!exports.nodeType&&exports,Jn=Kn[typeof module]&&module&&!module.nodeType&&module,Xn=Gn&&Jn&&"object"==typeof global&&global&&global.Object&&global,Zn=Kn[typeof self]&&self&&self.Object&&self,Hn=Kn[typeof window]&&window&&window.Object&&window,Qn=Jn&&Jn.exports===Gn&&Gn,nt=Xn||Hn!==(this&&this.window)&&Hn||Zn||this,tt=x();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(nt._=tt,define(function(){return tt})):Gn&&Jn?Qn?(Jn.exports=tt)._=tt:Gn._=tt:nt._=tt}).call(this); +function drainQueue(){if(!draining){draining=!0;for(var e,o=queue.length;o;){e=queue,queue=[];for(var r=-1;++rn)){n|=0;var e,l,b,f,g,o,u,x,i,s,h,c,v,_,k,m,B,S,w,N,d,p,j,q,y=n+n+1,z=t-1,A=a-1,C=n+1,D=C*(C+1)/2,E=new BlurStack,F=E;for(b=1;y>b;b++)if(F=F.next=new BlurStack,b==C)var G=F;F.next=E;var H=null,I=null;u=o=0;var J=mul_table[n],K=shg_table[n];for(l=0;a>l;l++){for(m=B=S=w=x=i=s=h=0,c=C*(N=r[o]),v=C*(d=r[o+1]),_=C*(p=r[o+2]),k=C*(j=r[o+3]),x+=D*N,i+=D*d,s+=D*p,h+=D*j,F=E,b=0;C>b;b++)F.r=N,F.g=d,F.b=p,F.a=j,F=F.next;for(b=1;C>b;b++)f=o+((b>z?z:b)<<2),x+=(F.r=N=r[f])*(q=C-b),i+=(F.g=d=r[f+1])*q,s+=(F.b=p=r[f+2])*q,h+=(F.a=j=r[f+3])*q,m+=N,B+=d,S+=p,w+=j,F=F.next;for(H=E,I=G,e=0;t>e;e++)r[o+3]=j=h*J>>K,0!=j?(j=255/j,r[o]=(x*J>>K)*j,r[o+1]=(i*J>>K)*j,r[o+2]=(s*J>>K)*j):r[o]=r[o+1]=r[o+2]=0,x-=c,i-=v,s-=_,h-=k,c-=H.r,v-=H.g,_-=H.b,k-=H.a,f=u+((f=e+n+1)e;e++){for(B=S=w=m=i=s=h=x=0,o=e<<2,c=C*(N=r[o]),v=C*(d=r[o+1]),_=C*(p=r[o+2]),k=C*(j=r[o+3]),x+=D*N,i+=D*d,s+=D*p,h+=D*j,F=E,b=0;C>b;b++)F.r=N,F.g=d,F.b=p,F.a=j,F=F.next;for(g=t,b=1;n>=b;b++)o=g+e<<2,x+=(F.r=N=r[o])*(q=C-b),i+=(F.g=d=r[o+1])*q,s+=(F.b=p=r[o+2])*q,h+=(F.a=j=r[o+3])*q,m+=N,B+=d,S+=p,w+=j,F=F.next,A>b&&(g+=t);for(o=e,H=E,I=G,l=0;a>l;l++)f=o<<2,r[f+3]=j=h*J>>K,j>0?(j=255/j,r[f]=(x*J>>K)*j,r[f+1]=(i*J>>K)*j,r[f+2]=(s*J>>K)*j):r[f]=r[f+1]=r[f+2]=0,x-=c,i-=v,s-=_,h-=k,c-=H.r,v-=H.g,_-=H.b,k-=H.a,f=e+((f=l+C)>K,0!=j?(j=255/j,r[o]=(x*J>>K)*j,r[o+1]=(i*J>>K)*j,r[o+2]=(s*J>>K)*j):r[o]=r[o+1]=r[o+2]=0,x-=c,i-=v,s-=_,h-=k,c-=H.r,v-=H.g,_-=H.b,k-=H.a,f=u+((f=e+n+1)>K,j>0?(j=255/j,r[f]=(x*J>>K)*j,r[f+1]=(i*J>>K)*j,r[f+2]=(s*J>>K)*j):r[f]=r[f+1]=r[f+2]=0,x-=c,i-=v,s-=_,h-=k,c-=H.r,v-=H.g,_-=H.b,k-=H.a,f=e+((f=l+C)=e+n||e?new java.lang.String(t,e,n)+"":t}function appendElement(t,e){t.currentElement?t.currentElement.appendChild(e):t.document.appendChild(e)}if(DOMParser.prototype.parseFromString=function(t,e){var n=this.options,r=new XMLReader,o=n.domBuilder||new DOMHandler,i=n.errorHandler,a=n.locator,c=n.xmlns||{},l={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return a&&o.setDocumentLocator(a),r.errorHandler=buildErrorHandler(i,o,a),r.domBuilder=n.domBuilder||o,/\/x?html?$/.test(e)&&(l.nbsp=" ",l.copy="©",c[""]="http://www.w3.org/1999/xhtml"),t?r.parse(t,c,l):r.errorHandler.error("invalid document source"),o.document},DOMHandler.prototype={startDocument:function(){this.document=(new DOMImplementation).createDocument(null,null,null),this.locator&&(this.document.documentURI=this.locator.systemId)},startElement:function(t,e,n,r){var o=this.document,i=o.createElementNS(t,n||e),a=r.length;appendElement(this,i),this.currentElement=i,this.locator&&position(this.locator,i);for(var c=0;a>c;c++){var t=r.getURI(c),l=r.getValue(c),n=r.getQName(c),s=o.createAttributeNS(t,n);s.getOffset&&position(s.getOffset(1),s),s.value=s.nodeValue=l,i.setAttributeNode(s)}},endElement:function(t,e,n){var r=this.currentElement;r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(t,e){},endPrefixMapping:function(t){},processingInstruction:function(t,e){var n=this.document.createProcessingInstruction(t,e);this.locator&&position(this.locator,n),appendElement(this,n)},ignorableWhitespace:function(t,e,n){},characters:function(t,e,n){if(t=_toString.apply(this,arguments),this.currentElement&&t){if(this.cdata){var r=this.document.createCDATASection(t);this.currentElement.appendChild(r)}else{var r=this.document.createTextNode(t);this.currentElement.appendChild(r)}this.locator&&position(this.locator,r)}},skippedEntity:function(t){},endDocument:function(){this.document.normalize()},setDocumentLocator:function(t){(this.locator=t)&&(t.lineNumber=0)},comment:function(t,e,n){t=_toString.apply(this,arguments);var r=this.document.createComment(t);this.locator&&position(this.locator,r),appendElement(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,e,n){var r=this.document.implementation;if(r&&r.createDocumentType){var o=r.createDocumentType(t,e,n);this.locator&&position(this.locator,o),appendElement(this,o)}},warning:function(t){console.warn(t,_locator(this.locator))},error:function(t){console.error(t,_locator(this.locator))},fatalError:function(t){throw console.error(t,_locator(this.locator)),t}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){DOMHandler.prototype[t]=function(){return null}}),"function"==typeof require){var XMLReader=require("./sax").XMLReader,DOMImplementation=exports.DOMImplementation=require("./dom").DOMImplementation;exports.XMLSerializer=require("./dom").XMLSerializer,exports.DOMParser=DOMParser} +function DOMParser(t){this.options=t||{locator:{}}}function buildErrorHandler(t,e,n){function r(e){var r=t[e];!r&&i&&(r=2==t.length?function(n){t(e,n)}:t),o[e]=r&&function(t){r("[xmldom "+e+"]\t"+t+_locator(n))}||function(){}}if(!t){if(e instanceof DOMHandler)return e;t=e}var o={},i=t instanceof Function;return n=n||{},r("warning"),r("error"),r("fatalError"),o}function DOMHandler(){this.cdata=!1}function position(t,e){e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber}function _locator(t){if(t)return"\n@"+(t.systemId||"")+"#[line:"+t.lineNumber+",col:"+t.columnNumber+"]"}function _toString(t,e,n){return"string"==typeof t?t.substr(e,n):t.length>=e+n||e?new java.lang.String(t,e,n)+"":t}function appendElement(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}DOMParser.prototype.parseFromString=function(t,e){var n=this.options,r=new XMLReader,o=n.domBuilder||new DOMHandler,i=n.errorHandler,a=n.locator,c=n.xmlns||{},l={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return a&&o.setDocumentLocator(a),r.errorHandler=buildErrorHandler(i,o,a),r.domBuilder=n.domBuilder||o,/\/x?html?$/.test(e)&&(l.nbsp=" ",l.copy="©",c[""]="http://www.w3.org/1999/xhtml"),c.xml=c.xml||"http://www.w3.org/XML/1998/namespace",t?r.parse(t,c,l):r.errorHandler.error("invalid doc source"),o.doc},DOMHandler.prototype={startDocument:function(){this.doc=(new DOMImplementation).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(t,e,n,r){var o=this.doc,i=o.createElementNS(t,n||e),a=r.length;appendElement(this,i),this.currentElement=i,this.locator&&position(this.locator,i);for(var c=0;c=0))throw DOMException(NOT_FOUND_ERR,new Error);for(var i=t.length-1;i>o;)t[o]=t[++o];if(t.length=i,e){var r=e.ownerDocument;r&&(_onRemoveAttribute(r,e,n),n.ownerElement=null)}}function DOMImplementation(e){if(this._features={},e)for(var t in e)this._features=e[t]}function Node(){}function _xmlEncoder(e){return"<"==e&&"<"||">"==e&&">"||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function _visitNode(e,t){if(t(e))return!0;if(e=e.firstChild)do if(_visitNode(e,t))return!0;while(e=e.nextSibling)}function Document(){}function _onAddAttribute(e,t,n){e&&e._inc++;var o=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==o&&(t._nsMap[n.prefix?n.localName:""]=n.value)}function _onRemoveAttribute(e,t,n,o){e&&e._inc++;var i=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==i&&delete t._nsMap[n.prefix?n.localName:""]}function _onUpdateChild(e,t,n){if(e&&e._inc){e._inc++;var o=t.childNodes;if(n)o[o.length++]=n;else{for(var i=t.firstChild,r=0;i;)o[r++]=i,i=i.nextSibling;o.length=r}}}function _removeChild(e,t){var n=t.previousSibling,o=t.nextSibling;return n?n.nextSibling=o:e.firstChild=o,o?o.previousSibling=n:e.lastChild=n,_onUpdateChild(e.ownerDocument,e),t}function _insertBefore(e,t,n){var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===DOCUMENT_FRAGMENT_NODE){var i=t.firstChild;if(null==i)return t;var r=t.lastChild}else i=r=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,r.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,null==n?e.lastChild=r:n.previousSibling=r;do i.parentNode=e;while(i!==r&&(i=i.nextSibling));return _onUpdateChild(e.ownerDocument||e,e),t.nodeType==DOCUMENT_FRAGMENT_NODE&&(t.firstChild=t.lastChild=null),t}function _appendSingleChild(e,t){var n=t.parentNode;if(n){var o=e.lastChild;n.removeChild(t);var o=e.lastChild}var o=e.lastChild;return t.parentNode=e,t.previousSibling=o,t.nextSibling=null,o?o.nextSibling=t:e.firstChild=t,e.lastChild=t,_onUpdateChild(e.ownerDocument,e,t),t}function Element(){this._nsMap={}}function Attr(){}function CharacterData(){}function Text(){}function Comment(){}function CDATASection(){}function DocumentType(){}function Notation(){}function Entity(){}function EntityReference(){}function DocumentFragment(){}function ProcessingInstruction(){}function XMLSerializer(){}function serializeToString(e,t){switch(e.nodeType){case ELEMENT_NODE:var n=e.attributes,o=n.length,i=e.firstChild,r=e.tagName,a=htmlns===e.namespaceURI;t.push("<",r);for(var s=0;o>s;s++)serializeToString(n.item(s),t,a);if(i||a&&!/^(?:meta|link|img|br|hr|input)$/i.test(r)){if(t.push(">"),a&&/^script$/i.test(r))i&&t.push(i.data);else for(;i;)serializeToString(i,t),i=i.nextSibling;t.push("")}else t.push("/>");return;case DOCUMENT_NODE:case DOCUMENT_FRAGMENT_NODE:for(var i=e.firstChild;i;)serializeToString(i,t),i=i.nextSibling;return;case ATTRIBUTE_NODE:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,_xmlEncoder),'"');case TEXT_NODE:return t.push(e.data.replace(/[<&]/g,_xmlEncoder));case CDATA_SECTION_NODE:return t.push("");case COMMENT_NODE:return t.push("");case DOCUMENT_TYPE_NODE:var u=e.publicId,d=e.systemId;if(t.push("');else if(d&&"."!=d)t.push(' SYSTEM "',d,'">');else{var c=e.internalSubset;c&&t.push(" [",c,"]"),t.push(">")}return;case PROCESSING_INSTRUCTION_NODE:return t.push("");case ENTITY_REFERENCE_NODE:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function importNode(e,t,n){var o;switch(t.nodeType){case ELEMENT_NODE:o=t.cloneNode(!1),o.ownerDocument=e;case DOCUMENT_FRAGMENT_NODE:break;case ATTRIBUTE_NODE:n=!0}if(o||(o=t.cloneNode(!1)),o.ownerDocument=e,o.parentNode=null,n)for(var i=t.firstChild;i;)o.appendChild(importNode(e,i,n)),i=i.nextSibling;return o}function cloneNode(e,t,n){var o=new t.constructor;for(var i in t){var r=t[i];"object"!=typeof r&&r!=o[i]&&(o[i]=r)}switch(t.childNodes&&(o.childNodes=new NodeList),o.ownerDocument=e,o.nodeType){case ELEMENT_NODE:var a=t.attributes,s=o.attributes=new NamedNodeMap,u=a.length;s._ownerElement=o;for(var d=0;u>d;d++)o.setAttributeNode(cloneNode(e,a.item(d),!0));break;case ATTRIBUTE_NODE:n=!0}if(n)for(var c=t.firstChild;c;)o.appendChild(cloneNode(e,c,n)),c=c.nextSibling;return o}function __set__(e,t,n){e[t]=n}function getTextContent(e){switch(e.nodeType){case 1:case 11:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(getTextContent(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}var htmlns="http://www.w3.org/1999/xhtml",NodeType={},ELEMENT_NODE=NodeType.ELEMENT_NODE=1,ATTRIBUTE_NODE=NodeType.ATTRIBUTE_NODE=2,TEXT_NODE=NodeType.TEXT_NODE=3,CDATA_SECTION_NODE=NodeType.CDATA_SECTION_NODE=4,ENTITY_REFERENCE_NODE=NodeType.ENTITY_REFERENCE_NODE=5,ENTITY_NODE=NodeType.ENTITY_NODE=6,PROCESSING_INSTRUCTION_NODE=NodeType.PROCESSING_INSTRUCTION_NODE=7,COMMENT_NODE=NodeType.COMMENT_NODE=8,DOCUMENT_NODE=NodeType.DOCUMENT_NODE=9,DOCUMENT_TYPE_NODE=NodeType.DOCUMENT_TYPE_NODE=10,DOCUMENT_FRAGMENT_NODE=NodeType.DOCUMENT_FRAGMENT_NODE=11,NOTATION_NODE=NodeType.NOTATION_NODE=12,ExceptionCode={},ExceptionMessage={},INDEX_SIZE_ERR=ExceptionCode.INDEX_SIZE_ERR=(ExceptionMessage[1]="Index size error",1),DOMSTRING_SIZE_ERR=ExceptionCode.DOMSTRING_SIZE_ERR=(ExceptionMessage[2]="DOMString size error",2),HIERARCHY_REQUEST_ERR=ExceptionCode.HIERARCHY_REQUEST_ERR=(ExceptionMessage[3]="Hierarchy request error",3),WRONG_DOCUMENT_ERR=ExceptionCode.WRONG_DOCUMENT_ERR=(ExceptionMessage[4]="Wrong document",4),INVALID_CHARACTER_ERR=ExceptionCode.INVALID_CHARACTER_ERR=(ExceptionMessage[5]="Invalid character",5),NO_DATA_ALLOWED_ERR=ExceptionCode.NO_DATA_ALLOWED_ERR=(ExceptionMessage[6]="No data allowed",6),NO_MODIFICATION_ALLOWED_ERR=ExceptionCode.NO_MODIFICATION_ALLOWED_ERR=(ExceptionMessage[7]="No modification allowed",7),NOT_FOUND_ERR=ExceptionCode.NOT_FOUND_ERR=(ExceptionMessage[8]="Not found",8),NOT_SUPPORTED_ERR=ExceptionCode.NOT_SUPPORTED_ERR=(ExceptionMessage[9]="Not supported",9),INUSE_ATTRIBUTE_ERR=ExceptionCode.INUSE_ATTRIBUTE_ERR=(ExceptionMessage[10]="Attribute in use",10),INVALID_STATE_ERR=ExceptionCode.INVALID_STATE_ERR=(ExceptionMessage[11]="Invalid state",11),SYNTAX_ERR=ExceptionCode.SYNTAX_ERR=(ExceptionMessage[12]="Syntax error",12),INVALID_MODIFICATION_ERR=ExceptionCode.INVALID_MODIFICATION_ERR=(ExceptionMessage[13]="Invalid modification",13),NAMESPACE_ERR=ExceptionCode.NAMESPACE_ERR=(ExceptionMessage[14]="Invalid namespace",14),INVALID_ACCESS_ERR=ExceptionCode.INVALID_ACCESS_ERR=(ExceptionMessage[15]="Invalid access",15);DOMException.prototype=Error.prototype,copy(ExceptionCode,DOMException),NodeList.prototype={length:0,item:function(e){return this[e]||null}},LiveNodeList.prototype.item=function(e){return _updateLiveList(this),this[e]},_extends(LiveNodeList,NodeList),NamedNodeMap.prototype={length:0,item:NodeList.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new DOMException(INUSE_ATTRIBUTE_ERR);var n=this.getNamedItem(e.nodeName);return _addNamedNode(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new DOMException(INUSE_ATTRIBUTE_ERR);return t=this.getNamedItemNS(e.namespaceURI,e.localName),_addNamedNode(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return _removeNamedNode(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return _removeNamedNode(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var o=this[n];if(o.localName==t&&o.namespaceURI==e)return o}return null}},DOMImplementation.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return n&&(!t||t in n)?!0:!1},createDocument:function(e,t,n){var o=new Document;if(o.doctype=n,n&&o.appendChild(n),o.implementation=this,o.childNodes=new NodeList,t){var i=o.createElementNS(e,t);o.appendChild(i)}return o},createDocumentType:function(e,t,n){var o=new DocumentType;return o.name=e,o.nodeName=e,o.publicId=t,o.systemId=n,o}},Node.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return _insertBefore(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return _removeChild(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return cloneNode(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==TEXT_NODE&&e.nodeType==TEXT_NODE?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var o in n)if(n[o]==e)return o;t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return null==t}},copy(NodeType,Node),copy(NodeType,Node.prototype),Document.prototype={nodeName:"#document",nodeType:DOCUMENT_NODE,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==DOCUMENT_FRAGMENT_NODE){for(var n=e.firstChild;n;){var o=n.nextSibling;this.insertBefore(n,t),n=o}return e}return null==this.documentElement&&1==e.nodeType&&(this.documentElement=e),_insertBefore(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),_removeChild(this,e)},importNode:function(e,t){return importNode(this,e,t)},getElementById:function(e){var t=null;return _visitNode(this.documentElement,function(n){return 1==n.nodeType&&n.getAttribute("id")==e?(t=n,!0):void 0}),t},createElement:function(e){var t=new Element;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new NodeList;var n=t.attributes=new NamedNodeMap;return n._ownerElement=t,t},createDocumentFragment:function(){var e=new DocumentFragment;return e.ownerDocument=this,e.childNodes=new NodeList,e},createTextNode:function(e){var t=new Text;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new Comment;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new CDATASection;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new ProcessingInstruction;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new Attr;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new EntityReference;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new Element,o=t.split(":"),i=n.attributes=new NamedNodeMap;return n.childNodes=new NodeList,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new Attr,o=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,n}},_extends(Document,Node),Element.prototype={nodeType:ELEMENT_NODE,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===DOCUMENT_FRAGMENT_NODE?this.insertBefore(e,null):_appendSingleChild(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var o=this.ownerDocument.createAttributeNS(e,t);o.value=o.nodeValue=n,this.setAttributeNode(o)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new LiveNodeList(this,function(t){var n=[];return _visitNode(t,function(o){o===t||o.nodeType!=ELEMENT_NODE||"*"!==e&&o.tagName!=e||n.push(o)}),n})},getElementsByTagNameNS:function(e,t){return new LiveNodeList(this,function(n){var o=[];return _visitNode(n,function(i){i===n||i.nodeType!==ELEMENT_NODE||i.namespaceURI!==e||"*"!==t&&i.localName!=t||o.push(i)}),o})}},Document.prototype.getElementsByTagName=Element.prototype.getElementsByTagName,Document.prototype.getElementsByTagNameNS=Element.prototype.getElementsByTagNameNS,_extends(Element,Node),Attr.prototype.nodeType=ATTRIBUTE_NODE,_extends(Attr,Node),CharacterData.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(ExceptionMessage[3])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){var o=this.data.substring(0,e),i=this.data.substring(e+t);n=o+n+i,this.nodeValue=this.data=n,this.length=n.length}},_extends(CharacterData,Node),Text.prototype={nodeName:"#text",nodeType:TEXT_NODE,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var o=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(o,this.nextSibling),o}},_extends(Text,CharacterData),Comment.prototype={nodeName:"#comment",nodeType:COMMENT_NODE},_extends(Comment,CharacterData),CDATASection.prototype={nodeName:"#cdata-section",nodeType:CDATA_SECTION_NODE},_extends(CDATASection,CharacterData),DocumentType.prototype.nodeType=DOCUMENT_TYPE_NODE,_extends(DocumentType,Node),Notation.prototype.nodeType=NOTATION_NODE,_extends(Notation,Node),Entity.prototype.nodeType=ENTITY_NODE,_extends(Entity,Node),EntityReference.prototype.nodeType=ENTITY_REFERENCE_NODE,_extends(EntityReference,Node),DocumentFragment.prototype.nodeName="#document-fragment",DocumentFragment.prototype.nodeType=DOCUMENT_FRAGMENT_NODE,_extends(DocumentFragment,Node),ProcessingInstruction.prototype.nodeType=PROCESSING_INSTRUCTION_NODE,_extends(ProcessingInstruction,Node),XMLSerializer.prototype.serializeToString=function(e){var t=[];return serializeToString(e,t),t.join("")},Node.prototype.toString=function(){return XMLSerializer.prototype.serializeToString(this)};try{Object.defineProperty&&(Object.defineProperty(LiveNodeList.prototype,"length",{get:function(){return _updateLiveList(this),this.$$length}}),Object.defineProperty(Node.prototype,"textContent",{get:function(){return getTextContent(this)},set:function(e){switch(this.nodeType){case 1:case 11:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=value,this.nodeValue=e}}}),__set__=function(e,t,n){e["$$"+t]=n})}catch(e){}"function"==typeof require&&(exports.DOMImplementation=DOMImplementation,exports.XMLSerializer=XMLSerializer); +function copy(e,t){for(var n in e)t[n]=e[n]}function _extends(e,t){function n(){}var o=e.prototype;if(Object.create){var i=Object.create(t.prototype);o.__proto__=i}o instanceof t||(n.prototype=t.prototype,n=new n,copy(o,n),e.prototype=o=n),o.constructor!=e&&("function"!=typeof e&&console.error("unknow Class:"+e),o.constructor=e)}function DOMException(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,ExceptionMessage[e]),this.message=ExceptionMessage[e],Error.captureStackTrace&&Error.captureStackTrace(this,DOMException);return n.code=e,t&&(this.message=this.message+": "+t),n}function NodeList(){}function LiveNodeList(e,t){this._node=e,this._refresh=t,_updateLiveList(this)}function _updateLiveList(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);__set__(e,"length",n.length),copy(n,e),e._inc=t}}function NamedNodeMap(){}function _findNodeIndex(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function _addNamedNode(e,t,n,o){if(o?t[_findNodeIndex(t,o)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(o&&_onRemoveAttribute(i,e,o),_onAddAttribute(i,e,n))}}function _removeNamedNode(e,t,n){var o=_findNodeIndex(t,n);if(!(o>=0))throw DOMException(NOT_FOUND_ERR,new Error(e.tagName+"@"+n));for(var i=t.length-1;o"==e&&">"||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function _visitNode(e,t){if(t(e))return!0;if(e=e.firstChild)do if(_visitNode(e,t))return!0;while(e=e.nextSibling)}function Document(){}function _onAddAttribute(e,t,n){e&&e._inc++;var o=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==o&&(t._nsMap[n.prefix?n.localName:""]=n.value)}function _onRemoveAttribute(e,t,n,o){e&&e._inc++;var i=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==i&&delete t._nsMap[n.prefix?n.localName:""]}function _onUpdateChild(e,t,n){if(e&&e._inc){e._inc++;var o=t.childNodes;if(n)o[o.length++]=n;else{for(var i=t.firstChild,r=0;i;)o[r++]=i,i=i.nextSibling;o.length=r}}}function _removeChild(e,t){var n=t.previousSibling,o=t.nextSibling;return n?n.nextSibling=o:e.firstChild=o,o?o.previousSibling=n:e.lastChild=n,_onUpdateChild(e.ownerDocument,e),t}function _insertBefore(e,t,n){var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===DOCUMENT_FRAGMENT_NODE){var i=t.firstChild;if(null==i)return t;var r=t.lastChild}else i=r=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,r.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,null==n?e.lastChild=r:n.previousSibling=r;do i.parentNode=e;while(i!==r&&(i=i.nextSibling));return _onUpdateChild(e.ownerDocument||e,e),t.nodeType==DOCUMENT_FRAGMENT_NODE&&(t.firstChild=t.lastChild=null),t}function _appendSingleChild(e,t){var n=t.parentNode;if(n){var o=e.lastChild;n.removeChild(t);var o=e.lastChild}var o=e.lastChild;return t.parentNode=e,t.previousSibling=o,t.nextSibling=null,o?o.nextSibling=t:e.firstChild=t,e.lastChild=t,_onUpdateChild(e.ownerDocument,e,t),t}function Element(){this._nsMap={}}function Attr(){}function CharacterData(){}function Text(){}function Comment(){}function CDATASection(){}function DocumentType(){}function Notation(){}function Entity(){}function EntityReference(){}function DocumentFragment(){}function ProcessingInstruction(){}function XMLSerializer(){}function nodeSerializeToString(e,t){var n=[],o=9==this.nodeType?this.documentElement:this,i=o.prefix,r=o.namespaceURI;if(r&&null==i){var i=o.lookupPrefix(r);if(null==i)var a=[{namespace:r,prefix:null}]}return serializeToString(this,n,e,t,a),n.join("")}function needNamespaceDefine(e,t,n){var o=e.prefix||"",i=e.namespaceURI;if(!o&&!i)return!1;if("xml"===o&&"http://www.w3.org/XML/1998/namespace"===i||"http://www.w3.org/2000/xmlns/"==i)return!1;for(var r=n.length;r--;){var a=n[r];if(a.prefix==o)return a.namespace!=i}return!0}function serializeToString(e,t,n,o,i){if(o){if(e=o(e),!e)return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case ELEMENT_NODE:i||(i=[]);var r=(i.length,e.attributes),a=r.length,s=e.firstChild,u=e.tagName;n=htmlns===e.namespaceURI||n,t.push("<",u);for(var d=0;d"),n&&/^script$/i.test(u))for(;s;)s.data?t.push(s.data):serializeToString(s,t,n,o,i),s=s.nextSibling;else for(;s;)serializeToString(s,t,n,o,i),s=s.nextSibling;t.push("")}else t.push("/>");return;case DOCUMENT_NODE:case DOCUMENT_FRAGMENT_NODE:for(var s=e.firstChild;s;)serializeToString(s,t,n,o,i),s=s.nextSibling;return;case ATTRIBUTE_NODE:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,_xmlEncoder),'"');case TEXT_NODE:return t.push(e.data.replace(/[<&]/g,_xmlEncoder));case CDATA_SECTION_NODE:return t.push("");case COMMENT_NODE:return t.push("");case DOCUMENT_TYPE_NODE:var E=e.publicId,m=e.systemId;if(t.push("');else if(m&&"."!=m)t.push(' SYSTEM "',m,'">');else{var h=e.internalSubset;h&&t.push(" [",h,"]"),t.push(">")}return;case PROCESSING_INSTRUCTION_NODE:return t.push("");case ENTITY_REFERENCE_NODE:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function importNode(e,t,n){var o;switch(t.nodeType){case ELEMENT_NODE:o=t.cloneNode(!1),o.ownerDocument=e;case DOCUMENT_FRAGMENT_NODE:break;case ATTRIBUTE_NODE:n=!0}if(o||(o=t.cloneNode(!1)),o.ownerDocument=e,o.parentNode=null,n)for(var i=t.firstChild;i;)o.appendChild(importNode(e,i,n)),i=i.nextSibling;return o}function cloneNode(e,t,n){var o=new t.constructor;for(var i in t){var r=t[i];"object"!=typeof r&&r!=o[i]&&(o[i]=r)}switch(t.childNodes&&(o.childNodes=new NodeList),o.ownerDocument=e,o.nodeType){case ELEMENT_NODE:var a=t.attributes,s=o.attributes=new NamedNodeMap,u=a.length;s._ownerElement=o;for(var d=0;d0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var o in n)if(n[o]==e)return o;t=t.nodeType==ATTRIBUTE_NODE?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==ATTRIBUTE_NODE?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return null==t}},copy(NodeType,Node),copy(NodeType,Node.prototype),Document.prototype={nodeName:"#document",nodeType:DOCUMENT_NODE,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==DOCUMENT_FRAGMENT_NODE){for(var n=e.firstChild;n;){var o=n.nextSibling;this.insertBefore(n,t),n=o}return e}return null==this.documentElement&&e.nodeType==ELEMENT_NODE&&(this.documentElement=e),_insertBefore(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),_removeChild(this,e)},importNode:function(e,t){return importNode(this,e,t)},getElementById:function(e){var t=null;return _visitNode(this.documentElement,function(n){if(n.nodeType==ELEMENT_NODE&&n.getAttribute("id")==e)return t=n,!0}),t},createElement:function(e){var t=new Element;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new NodeList;var n=t.attributes=new NamedNodeMap;return n._ownerElement=t,t},createDocumentFragment:function(){var e=new DocumentFragment;return e.ownerDocument=this,e.childNodes=new NodeList,e},createTextNode:function(e){var t=new Text;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new Comment;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new CDATASection;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new ProcessingInstruction;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new Attr;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new EntityReference;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new Element,o=t.split(":"),i=n.attributes=new NamedNodeMap;return n.childNodes=new NodeList,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new Attr,o=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,n}},_extends(Document,Node),Element.prototype={nodeType:ELEMENT_NODE,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===DOCUMENT_FRAGMENT_NODE?this.insertBefore(e,null):_appendSingleChild(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var o=this.ownerDocument.createAttributeNS(e,t);o.value=o.nodeValue=""+n,this.setAttributeNode(o)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new LiveNodeList(this,function(t){var n=[];return _visitNode(t,function(o){o===t||o.nodeType!=ELEMENT_NODE||"*"!==e&&o.tagName!=e||n.push(o)}),n})},getElementsByTagNameNS:function(e,t){return new LiveNodeList(this,function(n){var o=[];return _visitNode(n,function(i){i===n||i.nodeType!==ELEMENT_NODE||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||o.push(i)}),o})}},Document.prototype.getElementsByTagName=Element.prototype.getElementsByTagName,Document.prototype.getElementsByTagNameNS=Element.prototype.getElementsByTagNameNS,_extends(Element,Node),Attr.prototype.nodeType=ATTRIBUTE_NODE,_extends(Attr,Node),CharacterData.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){var o=this.data.substring(0,e),i=this.data.substring(e+t);n=o+n+i,this.nodeValue=this.data=n,this.length=n.length}},_extends(CharacterData,Node),Text.prototype={nodeName:"#text",nodeType:TEXT_NODE,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var o=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(o,this.nextSibling),o}},_extends(Text,CharacterData),Comment.prototype={nodeName:"#comment",nodeType:COMMENT_NODE},_extends(Comment,CharacterData),CDATASection.prototype={nodeName:"#cdata-section",nodeType:CDATA_SECTION_NODE},_extends(CDATASection,CharacterData),DocumentType.prototype.nodeType=DOCUMENT_TYPE_NODE,_extends(DocumentType,Node),Notation.prototype.nodeType=NOTATION_NODE,_extends(Notation,Node),Entity.prototype.nodeType=ENTITY_NODE,_extends(Entity,Node),EntityReference.prototype.nodeType=ENTITY_REFERENCE_NODE,_extends(EntityReference,Node),DocumentFragment.prototype.nodeName="#document-fragment",DocumentFragment.prototype.nodeType=DOCUMENT_FRAGMENT_NODE,_extends(DocumentFragment,Node),ProcessingInstruction.prototype.nodeType=PROCESSING_INSTRUCTION_NODE,_extends(ProcessingInstruction,Node),XMLSerializer.prototype.serializeToString=function(e,t,n){return nodeSerializeToString.call(e,t,n)},Node.prototype.toString=nodeSerializeToString;try{Object.defineProperty&&(Object.defineProperty(LiveNodeList.prototype,"length",{get:function(){return _updateLiveList(this),this.$$length}}),Object.defineProperty(Node.prototype,"textContent",{get:function(){return getTextContent(this)},set:function(e){switch(this.nodeType){case ELEMENT_NODE:case DOCUMENT_FRAGMENT_NODE:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),__set__=function(e,t,n){e["$$"+t]=n})}catch(e){}exports.DOMImplementation=DOMImplementation,exports.XMLSerializer=XMLSerializer; },{}],8:[function(require,module,exports){ -function XMLReader(){}function parse(e,t,r,a,n){function s(e){if(e>65535){e-=65536;var t=55296+(e>>10),r=56320+(1023&e);return String.fromCharCode(t,r)}return String.fromCharCode(e)}function i(e){var t=e.slice(1,-1);return t in r?r[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(n.error("entity not found:"+e),e)}function c(t){var r=e.substring(S,t).replace(/&#?\w+;/g,i);m&&o(S),a.characters(r,0,t-S),S=t}function o(t,r){for(;t>=l&&(r=f.exec(e));)u=r.index,l=u+r[0].length,m.lineNumber++;m.columnNumber=t-u+1}for(var u=0,l=0,f=/.+(?:\r\n?|\n)|.*$/g,m=a.locator,p=[{currentNSMap:t}],d={},S=0;;){var _=e.indexOf("<",S);if(0>_){if(!e.substr(S).match(/^\s*$/)){var h=a.document,g=h.createTextNode(e.substr(S));h.appendChild(g),a.currentElement=g}return}switch(_>S&&c(_),e.charAt(_+1)){case"/":var w=e.indexOf(">",_+3),b=e.substring(_+2,w),v=p.pop(),x=v.localNSMap;if(v.tagName!=b&&n.fatalError("end tag name: "+b+" is not match the current start tagName:"+v.tagName),a.endElement(v.uri,v.localName,b),x)for(var T in x)a.endPrefixMapping(T);w++;break;case"?":m&&o(_),w=parseInstruction(e,_,a);break;case"!":m&&o(_),w=parseDCC(e,_,a,n);break;default:try{m&&o(_);var N=new ElementAttributes,w=parseElementStartPart(e,_,N,i,n),E=N.length;if(E&&m){for(var A=copyLocator(m,{}),_=0;E>_;_++){var C=N[_];o(C.offset),C.offset=copyLocator(m,{})}copyLocator(A,m)}!N.closed&&fixSelfClosed(e,w,N.tagName,d)&&(N.closed=!0,r.nbsp||n.warning("unclosed xml attribute")),appendElement(N,a,p),"http://www.w3.org/1999/xhtml"!==N.uri||N.closed?w++:w=parseHtmlSpecialContent(e,w,N.tagName,i,a)}catch(F){n.error("element parse error: "+F),w=-1}}0>w?c(_+1):S=w}}function copyLocator(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function parseElementStartPart(e,t,r,a,n){for(var s,i,c=++t,o=S_TAG;;){var u=e.charAt(c);switch(u){case"=":if(o===S_ATTR)s=e.slice(t,c),o=S_EQ;else{if(o!==S_ATTR_S)throw new Error("attribute equal must after attrName");o=S_EQ}break;case"'":case'"':if(o===S_EQ){if(t=c+1,c=e.indexOf(u,t),!(c>0))throw new Error("attribute value no end '"+u+"' match");i=e.slice(t,c).replace(/&#?\w+;/g,a),r.add(s,i,t-1),o=S_E}else{if(o!=S_V)throw new Error('attribute value must after "="');i=e.slice(t,c).replace(/&#?\w+;/g,a),r.add(s,i,t),n.warning('attribute "'+s+'" missed start quot('+u+")!!"),t=c+1,o=S_E}break;case"/":switch(o){case S_TAG:r.setTagName(e.slice(t,c));case S_E:case S_S:case S_C:o=S_C,r.closed=!0;case S_V:case S_ATTR:case S_ATTR_S:break;default:throw new Error("attribute invalid close char('/')")}break;case"":n.error("unexpected end of input");case">":switch(o){case S_TAG:r.setTagName(e.slice(t,c));case S_E:case S_S:case S_C:break;case S_V:case S_ATTR:i=e.slice(t,c),"/"===i.slice(-1)&&(r.closed=!0,i=i.slice(0,-1));case S_ATTR_S:o===S_ATTR_S&&(i=s),o==S_V?(n.warning('attribute "'+i+'" missed quot(")!!'),r.add(s,i.replace(/&#?\w+;/g,a),t)):(n.warning('attribute "'+i+'" missed value!! "'+i+'" instead!!'),r.add(i,i,t));break;case S_EQ:throw new Error("attribute value missed!!")}return c;case"€":u=" ";default:if(" ">=u)switch(o){case S_TAG:r.setTagName(e.slice(t,c)),o=S_S;break;case S_ATTR:s=e.slice(t,c),o=S_ATTR_S;break;case S_V:var i=e.slice(t,c).replace(/&#?\w+;/g,a);n.warning('attribute "'+i+'" missed quot(")!!'),r.add(s,i,t);case S_E:o=S_S}else switch(o){case S_ATTR_S:n.warning('attribute "'+s+'" missed value!! "'+s+'" instead!!'),r.add(s,s,t),t=c,o=S_ATTR;break;case S_E:n.warning('attribute space is required"'+s+'"!!');case S_S:o=S_ATTR,t=c;break;case S_EQ:o=S_V,t=c;break;case S_C:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function appendElement(e,t,r){for(var a=e.tagName,n=null,s=r[r.length-1].currentNSMap,i=e.length;i--;){var c=e[i],o=c.qName,u=c.value,l=o.indexOf(":");if(l>0)var f=c.prefix=o.slice(0,l),m=o.slice(l+1),p="xmlns"===f&&m;else m=o,f=null,p="xmlns"===o&&"";c.localName=m,p!==!1&&(null==n&&(n={},_copy(s,s={})),s[p]=n[p]=u,c.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(p,u))}for(var i=e.length;i--;){c=e[i];var f=c.prefix;f&&("xml"===f&&(c.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==f&&(c.uri=s[f]))}var l=a.indexOf(":");l>0?(f=e.prefix=a.slice(0,l),m=e.localName=a.slice(l+1)):(f=null,m=e.localName=a);var d=e.uri=s[f||""];if(t.startElement(d,m,a,e),e.closed){if(t.endElement(d,m,a),n)for(f in n)t.endPrefixMapping(f)}else e.currentNSMap=s,e.localNSMap=n,r.push(e)}function parseHtmlSpecialContent(e,t,r,a,n){if(/^(?:script|textarea)$/i.test(r)){var s=e.indexOf("",t),i=e.substring(t+1,s);if(/[&<]/.test(i))return/^script$/i.test(r)?(n.characters(i,0,i.length),s):(i=i.replace(/&#?\w+;/g,a),n.characters(i,0,i.length),s)}return t+1}function fixSelfClosed(e,t,r,a){var n=a[r];return null==n&&(n=a[r]=e.lastIndexOf("")),t>n}function _copy(e,t){for(var r in e)t[r]=e[r]}function parseDCC(e,t,r,a){var n=e.charAt(t+2);switch(n){case"-":if("-"===e.charAt(t+3)){var s=e.indexOf("-->",t+4);return s>t?(r.comment(e,t+4,s-t-4),s+3):(a.error("Unclosed comment"),-1)}return-1;default:if("CDATA["==e.substr(t+3,6)){var s=e.indexOf("]]>",t+9);return r.startCDATA(),r.characters(e,t+9,s-t-9),r.endCDATA(),s+3}var i=split(e,t),c=i.length;if(c>1&&/!doctype/i.test(i[0][0])){var o=i[1][0],u=c>3&&/^public$/i.test(i[2][0])&&i[3][0],l=c>4&&i[4][0],f=i[c-1];return r.startDTD(o,u&&u.replace(/^(['"])(.*?)\1$/,"$2"),l&&l.replace(/^(['"])(.*?)\1$/,"$2")),r.endDTD(),f.index+f[0].length}}return-1}function parseInstruction(e,t,r){var a=e.indexOf("?>",t);if(a){var n=e.substring(t,a).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(n){n[0].length;return r.processingInstruction(n[1],n[2]),a+2}return-1}return-1}function ElementAttributes(e){}function _set_proto_(e,t){return e.__proto__=t,e}function split(e,t){var r,a=[],n=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(n.lastIndex=t,n.exec(e);r=n.exec(e);)if(a.push(r),r[1])return a}var nameStartChar=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,nameChar=new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"·̀-ͯ\\ux203F-⁀]"),tagNamePattern=new RegExp("^"+nameStartChar.source+nameChar.source+"*(?::"+nameStartChar.source+nameChar.source+"*)?$"),S_TAG=0,S_ATTR=1,S_ATTR_S=2,S_EQ=3,S_V=4,S_E=5,S_S=6,S_C=7;XMLReader.prototype={parse:function(e,t,r){var a=this.domBuilder;a.startDocument(),_copy(t,t={}),parse(e,t,r,a,this.errorHandler),a.endDocument()}},ElementAttributes.prototype={setTagName:function(e){if(!tagNamePattern.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},add:function(e,t,r){if(!tagNamePattern.test(e))throw new Error("invalid attribute:"+e);this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getOffset:function(e){return this[e].offset},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},_set_proto_({},_set_proto_.prototype)instanceof _set_proto_||(_set_proto_=function(e,t){function r(){}r.prototype=t,r=new r;for(t in e)r[t]=e[t];return r}),"function"==typeof require&&(exports.XMLReader=XMLReader); +function XMLReader(){}function parse(e,t,r,a,n){function s(e){if(e>65535){e-=65536;var t=55296+(e>>10),r=56320+(1023&e);return String.fromCharCode(t,r)}return String.fromCharCode(e)}function c(e){var t=e.slice(1,-1);return t in r?r[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(n.error("entity not found:"+e),e)}function i(t){if(t>p){var r=e.substring(p,t).replace(/&#?\w+;/g,c);m&&o(p),a.characters(r,0,t-p),p=t}}function o(t,r){for(;t>=l&&(r=_.exec(e));)u=r.index,l=u+r[0].length,m.lineNumber++;m.columnNumber=t-u+1}for(var u=0,l=0,_=/.*(?:\r\n?|\n)|.*$/g,m=a.locator,f=[{currentNSMap:t}],d={},p=0;;){try{var T=e.indexOf("<",p);if(T<0){if(!e.substr(p).match(/^\s*$/)){var S=a.doc,h=S.createTextNode(e.substr(p));S.appendChild(h),a.currentElement=h}return}switch(T>p&&i(T),e.charAt(T+1)){case"/":var A=e.indexOf(">",T+3),g=e.substring(T+2,A),w=f.pop();A<0?(g=e.substring(T+2).replace(/[\s<].*/,""),n.error("end tag name: "+g+" is not complete:"+w.tagName),A=T+1+g.length):g.match(/\sp?p=A:i(Math.max(T,p)+1)}}function copyLocator(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function parseElementStartPart(e,t,r,a,n,s){for(var c,i,o=++t,u=S_TAG;;){var l=e.charAt(o);switch(l){case"=":if(u===S_ATTR)c=e.slice(t,o),u=S_EQ;else{if(u!==S_ATTR_SPACE)throw new Error("attribute equal must after attrName");u=S_EQ}break;case"'":case'"':if(u===S_EQ||u===S_ATTR){if(u===S_ATTR&&(s.warning('attribute value must after "="'),c=e.slice(t,o)),t=o+1,o=e.indexOf(l,t),!(o>0))throw new Error("attribute value no end '"+l+"' match");i=e.slice(t,o).replace(/&#?\w+;/g,n),r.add(c,i,t-1),u=S_ATTR_END}else{if(u!=S_ATTR_NOQUOT_VALUE)throw new Error('attribute value must after "="');i=e.slice(t,o).replace(/&#?\w+;/g,n),r.add(c,i,t),s.warning('attribute "'+c+'" missed start quot('+l+")!!"),t=o+1,u=S_ATTR_END}break;case"/":switch(u){case S_TAG:r.setTagName(e.slice(t,o));case S_ATTR_END:case S_TAG_SPACE:case S_TAG_CLOSE:u=S_TAG_CLOSE,r.closed=!0;case S_ATTR_NOQUOT_VALUE:case S_ATTR:case S_ATTR_SPACE:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),u==S_TAG&&r.setTagName(e.slice(t,o)),o;case">":switch(u){case S_TAG:r.setTagName(e.slice(t,o));case S_ATTR_END:case S_TAG_SPACE:case S_TAG_CLOSE:break;case S_ATTR_NOQUOT_VALUE:case S_ATTR:i=e.slice(t,o),"/"===i.slice(-1)&&(r.closed=!0,i=i.slice(0,-1));case S_ATTR_SPACE:u===S_ATTR_SPACE&&(i=c),u==S_ATTR_NOQUOT_VALUE?(s.warning('attribute "'+i+'" missed quot(")!!'),r.add(c,i.replace(/&#?\w+;/g,n),t)):("http://www.w3.org/1999/xhtml"===a[""]&&i.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+i+'" missed value!! "'+i+'" instead!!'),r.add(i,i,t));break;case S_EQ:throw new Error("attribute value missed!!")}return o;case"€":l=" ";default:if(l<=" ")switch(u){case S_TAG:r.setTagName(e.slice(t,o)),u=S_TAG_SPACE;break;case S_ATTR:c=e.slice(t,o),u=S_ATTR_SPACE;break;case S_ATTR_NOQUOT_VALUE:var i=e.slice(t,o).replace(/&#?\w+;/g,n);s.warning('attribute "'+i+'" missed quot(")!!'),r.add(c,i,t);case S_ATTR_END:u=S_TAG_SPACE}else switch(u){case S_ATTR_SPACE:r.tagName;"http://www.w3.org/1999/xhtml"===a[""]&&c.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+c+'" missed value!! "'+c+'" instead2!!'),r.add(c,c,t),t=o,u=S_ATTR;break;case S_ATTR_END:s.warning('attribute space is required"'+c+'"!!');case S_TAG_SPACE:u=S_ATTR,t=o;break;case S_EQ:u=S_ATTR_NOQUOT_VALUE,t=o;break;case S_TAG_CLOSE:throw new Error("elements closed character '/' and '>' must be connected to")}}o++}}function appendElement(e,t,r){for(var a=e.tagName,n=null,s=e.length;s--;){var c=e[s],i=c.qName,o=c.value,u=i.indexOf(":");if(u>0)var l=c.prefix=i.slice(0,u),_=i.slice(u+1),m="xmlns"===l&&_;else _=i,l=null,m="xmlns"===i&&"";c.localName=_,m!==!1&&(null==n&&(n={},_copy(r,r={})),r[m]=n[m]=o,c.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(m,o))}for(var s=e.length;s--;){c=e[s];var l=c.prefix;l&&("xml"===l&&(c.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==l&&(c.uri=r[l||""]))}var u=a.indexOf(":");u>0?(l=e.prefix=a.slice(0,u),_=e.localName=a.slice(u+1)):(l=null,_=e.localName=a);var f=e.uri=r[l||""];if(t.startElement(f,_,a,e),!e.closed)return e.currentNSMap=r,e.localNSMap=n,!0;if(t.endElement(f,_,a),n)for(l in n)t.endPrefixMapping(l)}function parseHtmlSpecialContent(e,t,r,a,n){if(/^(?:script|textarea)$/i.test(r)){var s=e.indexOf("",t),c=e.substring(t+1,s);if(/[&<]/.test(c))return/^script$/i.test(r)?(n.characters(c,0,c.length),s):(c=c.replace(/&#?\w+;/g,a),n.characters(c,0,c.length),s)}return t+1}function fixSelfClosed(e,t,r,a){var n=a[r];return null==n&&(n=e.lastIndexOf(""),n",t+4);return s>t?(r.comment(e,t+4,s-t-4),s+3):(a.error("Unclosed comment"),-1)}return-1;default:if("CDATA["==e.substr(t+3,6)){var s=e.indexOf("]]>",t+9);return r.startCDATA(),r.characters(e,t+9,s-t-9),r.endCDATA(),s+3}var c=split(e,t),i=c.length;if(i>1&&/!doctype/i.test(c[0][0])){var o=c[1][0],u=i>3&&/^public$/i.test(c[2][0])&&c[3][0],l=i>4&&c[4][0],_=c[i-1];return r.startDTD(o,u&&u.replace(/^(['"])(.*?)\1$/,"$2"),l&&l.replace(/^(['"])(.*?)\1$/,"$2")),r.endDTD(),_.index+_[0].length}}return-1}function parseInstruction(e,t,r){var a=e.indexOf("?>",t);if(a){var n=e.substring(t,a).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(n){n[0].length;return r.processingInstruction(n[1],n[2]),a+2}return-1}return-1}function ElementAttributes(e){}function _set_proto_(e,t){return e.__proto__=t,e}function split(e,t){var r,a=[],n=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(n.lastIndex=t,n.exec(e);r=n.exec(e);)if(a.push(r),r[1])return a}var nameStartChar=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,nameChar=new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),tagNamePattern=new RegExp("^"+nameStartChar.source+nameChar.source+"*(?::"+nameStartChar.source+nameChar.source+"*)?$"),S_TAG=0,S_ATTR=1,S_ATTR_SPACE=2,S_EQ=3,S_ATTR_NOQUOT_VALUE=4,S_ATTR_END=5,S_TAG_SPACE=6,S_TAG_CLOSE=7;XMLReader.prototype={parse:function(e,t,r){var a=this.domBuilder;a.startDocument(),_copy(t,t={}),parse(e,t,r,a,this.errorHandler),a.endDocument()}},ElementAttributes.prototype={setTagName:function(e){if(!tagNamePattern.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},add:function(e,t,r){if(!tagNamePattern.test(e))throw new Error("invalid attribute:"+e);this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},_set_proto_({},_set_proto_.prototype)instanceof _set_proto_||(_set_proto_=function(e,t){function r(){}r.prototype=t,r=new r;for(t in e)r[t]=e[t];return r}),exports.XMLReader=XMLReader; },{}],9:[function(require,module,exports){ -"use strict";function importCommands(r){for(var i in r)g[i]=r[i]}var _=require("lodash"),vg=require("./libraries/vg/vg"),img=require("./libraries/img/img"),g={};for(var k in vg)g[k]=vg[k];delete g["delete"];for(var k in img)g[k]=img[k];importCommands(require("./libraries/math")),importCommands(require("./libraries/string")),importCommands(require("./libraries/list")),importCommands(require("./libraries/data")),importCommands(require("./libraries/image")),importCommands(require("./libraries/graphics")),importCommands(require("./libraries/easing")),g.importSVG=function(r){return g.svg.parseString(r)},g.importImage=function(r){var i=g.Layer.fromImage(r);return new g.Img(i.toCanvas())},g.importText=function(r){return r?String(r):""},g.importCSV=function(r,i){function e(r,i){var e,t,n=[],m="",a=!1;for(r=r.trim(),t=0;t0)){var i=r[0];if(i&&(i.commands||i.shapes))return vg.merge(r);if(i instanceof img.Img)return img.merge(r)}return null},g.mix=function(r,i,e){if(e=void 0!==e?e:.5,"number"==typeof r)return r*(1-e)+i*e;if("object"==typeof r){for(var t={},n=Object.keys(r),m=0,a=n.length;a>m;m+=1){var o=n[m],s=r[o],u=i[o];void 0!==s&&void 0!==u&&(t[o]=g.mix(s,u,e))}return t}return 0},module.exports=g; -},{"./libraries/data":10,"./libraries/easing":12,"./libraries/graphics":13,"./libraries/image":14,"./libraries/img/img":18,"./libraries/list":21,"./libraries/math":22,"./libraries/string":23,"./libraries/vg/vg":45,"lodash":4}],10:[function(require,module,exports){ -"use strict";var _=require("lodash"),list=require("./list"),g={};g.convert=function(t,n,r,u,o){var e=arguments.length;if(2===e){var a=arguments[1];n=a.inMin,r=a.inMax,u=a.outMin,o=a.outMax}else 3===e&&(n=arguments[1][0],r=arguments[1][1],u=arguments[2][0],o=arguments[2][1]);try{t=(t-n)/(r-n)}catch(i){t=n}return u+t*(o-u)},g.filterData=function(t,n,r,u){if(null===u||void 0===u)return t;for(var o=[],e=0;e"===r&&i>u?o.push(a):">="===r&&i>=u?o.push(a):"<"===r&&u>i?o.push(a):"<="===r&&u>=i&&o.push(a)}return o},g.groupBy=function(t,n){return _.values(_.groupBy(t,n))},g.keys=function(t){for(var n=[],r=0;r=a?e*=10:.35>=a?e*=5:.75>=a&&(e*=2),t=Math.ceil(t/e)*e,n=Math.floor(n/e)*e+.5*e,u=t;n>u;u+=e)i.push(u);return i},module.exports=g; +"use strict";function importCommands(r){for(var i in r)g[i]=r[i]}var _=require("lodash"),vg=require("./libraries/vg/vg"),img=require("./libraries/img/img"),g={};for(var k in vg)g[k]=vg[k];delete g.delete;for(var k in img)g[k]=img[k];importCommands(require("./libraries/math")),importCommands(require("./libraries/string")),importCommands(require("./libraries/list")),importCommands(require("./libraries/data")),importCommands(require("./libraries/image")),importCommands(require("./libraries/graphics")),importCommands(require("./libraries/easing")),g.importSVG=function(r){return g.svg.parseString(r)},g.importImage=function(r){var i=g.Layer.fromImage(r);return new g.Img(i.toCanvas())},g.importText=function(r){return r?String(r):""},g.importCSV=function(r,i){function e(r,i){var e,t,n=[],m="",a=!1;for(r=r.trim(),t=0;t0)){var i=r[0];if(i&&(i.commands||i.shapes||i.fontFamily))return vg.merge(r);if(i instanceof img.Img)return img.merge(r)}return null},g.mix=function(r,i,e){if(e=void 0!==e?e:.5,"number"==typeof r)return r*(1-e)+i*e;if("object"==typeof r){for(var t={},n=Object.keys(r),m=0,a=n.length;m"===n)for(o=0,i=t.length;oe&&a.push(u);else if(">="===n)for(o=0,i=t.length;o=e&&a.push(u);else if("<"===n)for(o=0,i=t.length;o=0;s--)if(u[s]!=n[s])return!1;for(s=u.length-1;s>=0;s--)if(l=u[s],!_deepEqual(e[l],t[l]))return!1;return!0},module.exports=deepEqual; +},{"./list":21,"lodash":3}],11:[function(require,module,exports){ +"use strict";function isBuffer(){return!1}function isObject(e){return"object"==typeof e&&null!==e}function objectToString(e){return Object.prototype.toString.call(e)}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isNullOrUndefined(e){return null===e||void 0===e}var util={isObject:isObject,isRegExp:isRegExp,isDate:isDate,isNullOrUndefined:isNullOrUndefined,isBuffer:isBuffer},pSlice=Array.prototype.slice,deepEqual={},isArguments,_deepEqual,objEquiv;_deepEqual=function(e,t){if(e===t)return!0;if(util.isBuffer(e)&&util.isBuffer(t)){if(e.length!==t.length)return!1;for(var i=0;i=0;s--)if(u[s]!=n[s])return!1;for(s=u.length-1;s>=0;s--)if(l=u[s],!_deepEqual(e[l],t[l]))return!1;return!0},module.exports=deepEqual; },{}],12:[function(require,module,exports){ -"use strict";var g={};g.easeInQuad=function(t,n,e,u){return e*(t/=u)*t+n},g.easeOutQuad=function(t,n,e,u){return-e*(t/=u)*(t-2)+n},g.easeInOutQuad=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},g.easeInCubic=function(t,n,e,u){return e*(t/=u)*t*t+n},g.easeOutCubic=function(t,n,e,u){return e*((t=t/u-1)*t*t+1)+n},g.easeInOutCubic=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},g.easeInQuart=function(t,n,e,u){return e*(t/=u)*t*t*t+n},g.easeOutQuart=function(t,n,e,u){return-e*((t=t/u-1)*t*t*t-1)+n},g.easeInOutQuart=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},g.easeInQuint=function(t,n,e,u){return e*(t/=u)*t*t*t*t+n},g.easeOutQuint=function(t,n,e,u){return e*((t=t/u-1)*t*t*t*t+1)+n},g.easeInOutQuint=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},g.easeInSine=function(t,n,e,u){return-e*Math.cos(t/u*(Math.PI/2))+e+n},g.easeOutSine=function(t,n,e,u){return e*Math.sin(t/u*(Math.PI/2))+n},g.easeInOutSine=function(t,n,e,u){return-e/2*(Math.cos(Math.PI*t/u)-1)+n},g.easeInExpo=function(t,n,e,u){return 0===t?n:e*Math.pow(2,10*(t/u-1))+n},g.easeOutExpo=function(t,n,e,u){return t===u?n+e:e*(-Math.pow(2,-10*t/u)+1)+n},g.easeInOutExpo=function(t,n,e,u){return 0===t?n:t===u?n+e:(t/=u/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(-Math.pow(2,-10*--t)+2)+n},g.easeInCirc=function(t,n,e,u){return-e*(Math.sqrt(1-(t/=u)*t)-1)+n},g.easeOutCirc=function(t,n,e,u){return e*Math.sqrt(1-(t=t/u-1)*t)+n},g.easeInOutCirc=function(t,n,e,u){return(t/=u/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},g.easeInElastic=function(t,n,e,u){var a=1.70158,r=0,i=e;return 0===t?n:1===(t/=u)?n+e:(r||(r=.3*u),it?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t*u-a)*(2*Math.PI)/r))+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*u-a)*(2*Math.PI)/r)*.5+e+n)},g.easeInBack=function(t,n,e,u,a){return void 0===a&&(a=1.70158),e*(t/=u)*t*((a+1)*t-a)+n},g.easeOutBack=function(t,n,e,u,a){return void 0===a&&(a=1.70158),e*((t=t/u-1)*t*((a+1)*t+a)+1)+n},g.easeInOutBack=function(t,n,e,u,a){return void 0===a&&(a=1.70158),(t/=u/2)<1?e/2*(t*t*(((a*=1.525)+1)*t-a))+n:e/2*((t-=2)*t*(((a*=1.525)+1)*t+a)+2)+n},g.easeInBounce=function(t,n,e,u){return e-g.easeOutBounce(u-t,0,e,u)+n},g.easeOutBounce=function(t,n,e,u){return(t/=u)<1/2.75?e*(7.5625*t*t)+n:2/2.75>t?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:2.5/2.75>t?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n},g.easeInOutBounce=function(t,n,e,u){return u/2>t?.5*g.easeInBounce(2*t,0,e,u)+n:.5*g.easeOutBounce(2*t-u,0,e,u)+.5*e+n},g.easing=function(t){var n=g[t],e=Array.prototype.slice.call(arguments,1);return n.apply(null,e)},module.exports=g; +"use strict";var g={};g.easeInQuad=function(t,n,e,u){return e*(t/=u)*t+n},g.easeOutQuad=function(t,n,e,u){return-e*(t/=u)*(t-2)+n},g.easeInOutQuad=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},g.easeInCubic=function(t,n,e,u){return e*(t/=u)*t*t+n},g.easeOutCubic=function(t,n,e,u){return e*((t=t/u-1)*t*t+1)+n},g.easeInOutCubic=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},g.easeInQuart=function(t,n,e,u){return e*(t/=u)*t*t*t+n},g.easeOutQuart=function(t,n,e,u){return-e*((t=t/u-1)*t*t*t-1)+n},g.easeInOutQuart=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},g.easeInQuint=function(t,n,e,u){return e*(t/=u)*t*t*t*t+n},g.easeOutQuint=function(t,n,e,u){return e*((t=t/u-1)*t*t*t*t+1)+n},g.easeInOutQuint=function(t,n,e,u){return(t/=u/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},g.easeInSine=function(t,n,e,u){return-e*Math.cos(t/u*(Math.PI/2))+e+n},g.easeOutSine=function(t,n,e,u){return e*Math.sin(t/u*(Math.PI/2))+n},g.easeInOutSine=function(t,n,e,u){return-e/2*(Math.cos(Math.PI*t/u)-1)+n},g.easeInExpo=function(t,n,e,u){return 0===t?n:e*Math.pow(2,10*(t/u-1))+n},g.easeOutExpo=function(t,n,e,u){return t===u?n+e:e*(-Math.pow(2,-10*t/u)+1)+n},g.easeInOutExpo=function(t,n,e,u){return 0===t?n:t===u?n+e:(t/=u/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(-Math.pow(2,-10*--t)+2)+n},g.easeInCirc=function(t,n,e,u){return-e*(Math.sqrt(1-(t/=u)*t)-1)+n},g.easeOutCirc=function(t,n,e,u){return e*Math.sqrt(1-(t=t/u-1)*t)+n},g.easeInOutCirc=function(t,n,e,u){return(t/=u/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},g.easeInElastic=function(t,n,e,u){var a=1.70158,r=0,i=e;return 0===t?n:1===(t/=u)?n+e:(r||(r=.3*u),i0&&void 0!==r[0].x&&void 0!==r[0].y?(p=!0,u=transformShape):r instanceof img.Img&&(u=transformImage),i=0;n>i;i+=1){for(g=new vg.Transform,s=0;s0&&void 0!==r[0].x&&void 0!==r[0].y){var t=n===g.HORIZONTAL||n===g.BOTH?-1:1,e=n===g.VERTICAL||n===g.BOTH?-1:1;return vg.scale(r,new vg.Point(t,e),vg.centerPoint(r))}if(r instanceof img.Img){var a=r,o=a.toLayer(!1);return(n===g.HORIZONTAL||n===g.BOTH)&&o.flipHorizontal(),(n===g.VERTICAL||n===g.BOTH)&&o.flipVertical(),a.withCanvas(o.toCanvas())}},g.fit=function(r,n,t,e,a){if(r){a=void 0!==a?a:!1;var o,i,g,s=vg.bounds(r),f=s.x,u=s.y,v=s.width,l=s.height;return v=v>1e-12?v:0,l=l>1e-12?l:0,o=new vg.Transform,o=o.translate(n.x,n.y),a?(i=v>0?t/v:1,g=l>0?e/l:1):(i=v>0?t/v:Number.MAX_VALUE,g=l>0?e/l:Number.MAX_VALUE,i=g=Math.min(i,g)),o=o.scale(i,g),o=o.translate(-v/2-f,-l/2-u),transform(r,o)}},g.fitTo=function(r,n,t){if(r){if(!n)return r;var e=vg.bounds(n),a=e.x,o=e.y,i=e.width,s=e.height;return g.fit(r,{x:a+i/2,y:o+s/2},i,s,t)}},g.hslAdjust=function(r,n,t,e,a){function o(e){if(e instanceof vg.Group){for(var i=[],g=0;gv&&(v=f),u>v&&(v=u),l=s,l>f&&(l=f),l>u&&(l=u),c=v-l,d=(l+v)/2,d>0&&c>0&&(.5>=d?(m=c/(v+l)*w,m>1&&(m=1),r=d*(1+m)):(m=c/(2-v-l)*w,m>1&&(m=1),r=d+m-d*m),h=s===v?f===l?5+(v-u)/c+n:1-(v-f)/c+n:f===v?u===l?1+(v-s)/c+n:3-(v-u)/c+n:s===l?3+(v-f)/c+n:5-(v-s)/c+n,0>h&&(h+=6),h>=6&&(h-=6),p=d+d-r,y=h>>0,T=(r-p)*(h-y),0===y?(s=r,f=p+T,u=p):1===y?(s=r-T,f=r,u=p):2===y?(s=p,f=r,u=p+T):3===y?(s=p,f=r-T,u=r):4===y?(s=p+T,f=p,u=r):5===y&&(s=r,f=p,u=r-T))),s=s*C+x,f=f*C+x,u=u*C+x,0>s&&(s=0),0>f&&(f=0),0>u&&(u=0),s>1&&(s=1),f>1&&(f=1),u>1&&(u=1),new vg.Color(s,f,u,A.a+a)}if(a||(a=0),r instanceof img.Img){var i=r,g=i.toLayer(!1);return g.addFilter("hslAdjust",{h:n,s:t,l:e,a:a}),i.withCanvas(g.toCanvas())}n=clamp(n,-1,1),t=clamp(t,-1,1),e=clamp(e,-1,1),a=clamp(a,-1,1);var s,f,u,v,l,c,h,m,d,p,T,y,w=1+t*(0>t?1:2),C=0>e?1+e:1-e,x=0>e?0:e;return n=6*n%6,o(r)},g.rgbAdjust=function(r,n,t,e,a){function o(r){if(r instanceof img.Img){var i=r,g=i.toLayer(!1);return g.addFilter("rgbAdjust",{r:n,g:t,b:e,a:a}),i.withCanvas(g.toCanvas())}if(r instanceof vg.Group){for(var s=[],f=0;f0&&void 0!==r[0].x&&void 0!==r[0].y?(p=!0,u=transformShape):r instanceof img.Img&&(u=transformImage),i=0;i0&&void 0!==r[0].x&&void 0!==r[0].y){var t=n===g.HORIZONTAL||n===g.BOTH?-1:1,e=n===g.VERTICAL||n===g.BOTH?-1:1;return vg.scale(r,new vg.Point(t,e),vg.centerPoint(r))}if(r instanceof img.Img){var o=r,a=o.toLayer(!1);return n!==g.HORIZONTAL&&n!==g.BOTH||a.flipHorizontal(),n!==g.VERTICAL&&n!==g.BOTH||a.flipVertical(),o.withCanvas(a.toCanvas())}},g.fit=function(r,n,t,e,o){if(r){o=void 0!==o&&o;var a,i,g,s=vg.bounds(r),f=s.x,u=s.y,v=s.width,l=s.height;return v=v>1e-12?v:0,l=l>1e-12?l:0,a=new vg.Transform,a=a.translate(n.x,n.y),o?(i=v>0?t/v:1,g=l>0?e/l:1):(i=v>0?t/v:Number.MAX_VALUE,g=l>0?e/l:Number.MAX_VALUE,i=g=Math.min(i,g)),a=a.scale(i,g),a=a.translate(-v/2-f,-l/2-u),transform(r,a)}},g.fitTo=function(r,n,t){if(r){if(!n)return r;var e=vg.bounds(n),o=e.x,a=e.y,i=e.width,s=e.height;return g.fit(r,{x:o+i/2,y:a+s/2},i,s,t)}},g.hslAdjust=function(r,n,t,e,o){function a(e){if(e instanceof vg.Group){for(var i=[],g=0;gv&&(v=f),u>v&&(v=u),l=s,f0&&c>0&&(d<=.5?(m=c/(v+l)*w,m>1&&(m=1),r=d*(1+m)):(m=c/(2-v-l)*w,m>1&&(m=1),r=d+m-d*m),h=s===v?f===l?5+(v-u)/c+n:1-(v-f)/c+n:f===v?u===l?1+(v-s)/c+n:3-(v-u)/c+n:s===l?3+(v-f)/c+n:5-(v-s)/c+n,h<0&&(h+=6),h>=6&&(h-=6),p=d+d-r,T=h>>0,y=(r-p)*(h-T),0===T?(s=r,f=p+y,u=p):1===T?(s=r-y,f=r,u=p):2===T?(s=p,f=r,u=p+y):3===T?(s=p,f=r-y,u=r):4===T?(s=p+y,f=p,u=r):5===T&&(s=r,f=p,u=r-y))),s=s*x+C,f=f*x+C,u=u*x+C,s<0&&(s=0),f<0&&(f=0),u<0&&(u=0),s>1&&(s=1),f>1&&(f=1),u>1&&(u=1),new vg.Color(s,f,u,A.a+o)}if(o||(o=0),r instanceof img.Img){var i=r,g=i.toLayer(!1);return g.addFilter("hslAdjust",{h:n,s:t,l:e,a:o}),i.withCanvas(g.toCanvas())}n=clamp(n,-1,1),t=clamp(t,-1,1),e=clamp(e,-1,1),o=clamp(o,-1,1);var s,f,u,v,l,c,h,m,d,p,y,T,w=1+t*(t<0?1:2),x=e<0?1+e:1-e,C=e<0?0:e;return n=6*n%6,a(r)},g.rgbAdjust=function(r,n,t,e,o){function a(r){if(r instanceof img.Img){var i=r,g=i.toLayer(!1);return g.addFilter("rgbAdjust",{r:n,g:t,b:e,a:o}),i.withCanvas(g.toCanvas())}if(r instanceof vg.Group){for(var s=[],f=0;f1?t:1;for(var e=a.canvas,r=e.width,n=e.height,i=e.getContext("2d"),o=i.getImageData(0,0,e.width,e.height),d=o.data,s=4*e.width,g=[],h=0;n>h;h+=t)for(var u=0;r>u;u+=t){var v=h*s+4*u,l=d[v],c=d[v+1],w=d[v+2],m=d[v+3];g.push({x:u-r/2,y:h-n/2,r:l,g:c,b:w,a:m,color:new vg.Color(l/255,c/255,w/255,m/255)})}return g},g.twirl=function(a,t,e,r){var n=a.toLayer(!1);return n.addFilter("twirl",{dx:t.x,dy:t.y,radius:e,angle:r}),a.withCanvas(n.toCanvas())},module.exports=g; +},{"./img/img":18,"./math":22,"./vg/vg":45,"lodash":3}],14:[function(require,module,exports){ +"use strict";var vg=require("./vg/vg"),img=require("./img/img"),Img=img.Img,Layer=img.Layer,ImageCanvas=img.ImageCanvas,g={};g.blend=function(a,t,e){var r=a.bounds(),n=t.bounds(),i=new vg.Rect(r.x,r.y,r.width,r.height).unite(n),o=Math.ceil(i.width),d=Math.ceil(i.height),s=o/2+i.x,g=d/2+i.y,h=new ImageCanvas(o,d),u=h.addLayer(a.toLayer());u.translate(-s,-g);var v=h.addLayer(t.toLayer());return v.translate(-s,-g),v.blendmode=e,new Img(h.render(),s,g)},g.blur=function(a,t){var e=a.toLayer(!1);return e.addFilter("blur",{radius:t}),a.withCanvas(e.toCanvas())},g.brighten=function(a,t,e){var r=a.toLayer(!1);return r.addFilter("brightness",{brightness:t/100,contrast:e/100}),a.withCanvas(r.toCanvas())},g.bump=function(a,t,e,r){var n=a.toLayer(!1);return n.addFilter("bump",{dx:t.x,dy:t.y,radius:e,zoom:r/100}),a.withCanvas(n.toCanvas())},g.colorImage=function(a,t,e){var r=Layer.fromColor(e);return r.width=a,r.height=t,new Img(r.toCanvas())},g.crop=function(a,t){return a.crop(t)},g.crossEdges=function(a,t){var e=a.toLayer(!1);return e.addFilter("crossedges",{strength:t/100}),a.withCanvas(e.toCanvas())},g.dent=function(a,t,e,r){var n=a.toLayer(!1);return n.addFilter("dent",{dx:t.x,dy:t.y,radius:e,zoom:r/100}),a.withCanvas(n.toCanvas())},g.emboss=function(a,t,e){var r=a.toLayer(!1);return r.addFilter("emboss",{amount:t/100,angle:e}),a.withCanvas(r.toCanvas())},g.equalize=function(a){var t=a.toLayer(!1);return t.addFilter("equalize"),a.withCanvas(t.toCanvas())},g.findEdges=function(a){var t=a.toLayer(!1);return t.addFilter("findedges"),a.withCanvas(t.toCanvas())},g.glow=function(a,t,e){var r=a.toLayer(!1);return r.addFilter("glow",{amount:t/100,kernelSize:e}),a.withCanvas(r.toCanvas())},g.gradientImage=function(a,t,e,r,n,i,o){var d=Layer.fromGradient(e,r,n,i,o/100);return d.width=a,d.height=t,new Img(d.toCanvas())},g.histogram=function(a,t,e){var r,n,i,o,d=a.getPixels(),s=new Array(256);for(r=0;r1?t:1;for(var e=a.canvas,r=e.width,n=e.height,i=e.getContext("2d"),o=i.getImageData(0,0,e.width,e.height),d=o.data,s=4*e.width,g=[],h=0;h65535){e-=655 },{"./canvasrenderer":17,"./process":19,"async":1}],16:[function(require,module,exports){ -"use strict";function addAliases(n){var t,e,i,o=Object.keys(aliases);for(t=0;t=t&&t>=e?(o=n-e,i=60*(t-e)/o):t>n&&n>=e?(o=t-e,i=60*(t-n)/o+60):t>=e&&e>n?(o=t-n,i=60*(e-n)/o+120):e>t&&t>n?(o=e-n,i=60*(e-t)/o+180):e>n&&n>=t?(o=e-t,i=60*(n-t)/o+240):(o=n-t,i=60*(n-e)/o+300),r=V*n+W*t+X*e,[i%360,U(T(o,0),1),U(T(r,0),1)]}function a(n,t,e){n%=360;var i,o,r,a;return n>=0&&60>n?(a=t*n/60,r=e-V*t-W*a,i=r+t,o=r+a):n>=60&&120>n?(a=t*(n-60)/60,o=e+X*t+V*a,r=o-t,i=o-a):n>=120&&180>n?(a=t*(n-120)/60,i=e-W*t-X*a,o=i+t,r=i+a):n>=180&&240>n?(a=t*(n-180)/60,r=e+V*t+W*a,i=r-t,o=r-a):n>=240&&300>n?(a=t*(n-240)/60,o=e-X*t-V*a,r=o+t,i=o+a):(a=t*(n-300)/60,i=e+W*t+X*a,o=i-t,r=i-a),i=255*U(T(i,0),1),o=255*U(T(o,0),1),r=255*U(T(r,0),1),[i,o,r]}function l(){L=I+G-G*F,P=q+H-H*F,Q=z+J-J*F}function d(){L=I*G+I*(1-K)+G*(1-F),P=q*H+q*(1-K)+H*(1-F),Q=z*J+z*(1-K)+J*(1-F)}function c(){L=T(G*F-I*K,0)+I*(1-K)+G*(1-F),P=T(H*F-q*K,0)+q*(1-K)+H*(1-F),Q=T(J*F-z*K,0)+z*(1-K)+J*(1-F)}function u(){L=0===I?0:G/I*255,P=0===q?0:H/q*255,Q=0===z?0:J/z*255}function s(){L=I+G-I*G,P=q+H-q*H,Q=z+J-z*J}function f(){L=T(I*K,G*F)+I*(1-K)+G*(1-F),P=T(q*K,H*F)+q*(1-K)+H*(1-F),Q=T(z*K,J*F)+z*(1-K)+J*(1-F)}function h(){L=U(I*K,G*F)+I*(1-K)+G*(1-F),P=U(q*K,H*F)+q*(1-K)+H*(1-F),Q=U(z*K,J*F)+z*(1-K)+J*(1-F)}function g(){I*K*.3+q*K*.59+z*K*.11>=G*F*.3+H*F*.59+J*F*.11?(L=G*F,P=H*F,Q=J*F):(L=I*K,P=q*K,Q=z*K),L+=I*(1-K)+G*(1-F),P+=q*(1-K)+H*(1-F),Q+=z*(1-K)+J*(1-F)}function v(){G*F*.3+H*F*.59+J*F*.11>I*K*.3+q*K*.59+z*K*.11?(L=G*F,P=H*F,Q=J*F):(L=I*K,P=q*K,Q=z*K),L+=I*(1-K)+G*(1-F),P+=q*(1-K)+H*(1-F),Q+=z*(1-K)+J*(1-F)}function y(){L=U(G+I,255),P=U(H+q,255),Q=U(J+z,255)}function p(){L=G+I,P=H+q,Q=J+z,L=255>L?0:L-255,P=255>P?0:P-255,Q=255>Q?0:Q-255}function m(){L=I+G-2*U(I*K,G*F),P=q+H-2*U(q*K,H*F),Q=z+J-2*U(z*K,J*F)}function b(){L=I*K+G*F-2*I*G+I*(1-K)+G*(1-F),P=q*K+H*F-2*q*H+q*(1-K)+H*(1-F),Q=z*K+J*F-2*z*J+z*(1-K)+J*(1-F)}function x(){L=K>=2*G?2*I*G+I*(1-K)+G*(1-F):I*(1+K)+G*(1+F)-2*G*I-K*F,P=K>=2*H?2*q*H+q*(1-K)+H*(1-F):q*(1+K)+H*(1+F)-2*H*q-K*F,Q=K>=2*J?2*z*J+z*(1-K)+J*(1-F):z*(1+K)+J*(1+F)-2*J*z-K*F}function k(){var n,t=Math.pow;return 0===K?(L=I,P=q,void(Q=z)):(n=G/K,F>=2*I?L=G*(F+(2*I-F)*(1-n))+I*(1-K)+G*(1-F):2*I>F&&K>=4*G?L=K*(2*I-F)*(16*t(n,3)-12*t(n,2)-3*n)+I-I*K+G:2*I>F&&4*G>K&&(L=K*(2*I-F)*(t(n,.5)-n)+I-I*K+G),n=H/K,F>=2*q?P=H*(F+(2*q-F)*(1-n))+q*(1-K)+H*(1-F):2*q>F&&K>=4*H?P=K*(2*q-F)*(16*t(n,3)-12*t(n,2)-3*n)+q-q*K+H:2*q>F&&4*H>K&&(P=K*(2*q-F)*(t(n,.5)-n)+q-q*K+H),n=J/K,void(F>=2*z?Q=J*(F+(2*z-F)*(1-n))+z*(1-K)+J*(1-F):2*z>F&&K>=4*J?Q=K*(2*z-F)*(16*t(n,3)-12*t(n,2)-3*n)+z-z*K+J:2*z>F&&4*J>K&&(Q=K*(2*z-F)*(t(n,.5)-n)+z-z*K+J)))}function w(){L=F>=2*I?2*I*G+I*(1-K)+G*(1-F):I*(1+K)+G*(1+F)-F*K-2*I*G,P=F>=2*q?2*q*H+q*(1-K)+H*(1-F):q*(1+K)+H*(1+F)-F*K-2*q*H,Q=F>=2*z?2*z*J+z*(1-K)+J*(1-F):z*(1+K)+J*(1+F)-F*K-2*z*J}function M(){return 0===K?(L=I,P=q,void(Q=z)):(I===F&&0===G?L=I*(1-K):I===F?L=F*K+I*(1-K)+G*(1-F):F>I&&(L=F*K*U(1,G/K*F/(F-I))+I*(1-K)+G*(1-F)),q===F&&0===H?P=q*(1-K):I===F?P=F*K+q*(1-K)+H*(1-F):F>I&&(P=F*K*U(1,H/K*F/(F-q))+q*(1-K)+H*(1-F)),void(z===F&&0===J?Q=z*(1-K):I===F?Q=F*K+z*(1-K)+J*(1-F):F>I&&(Q=F*K*U(1,J/K*F/(F-z))+z*(1-K)+J*(1-F))))}function _(){return 0===K?(L=I,P=q,void(Q=z)):(0===I&&G===K?L=F*K+G*(1-F):0===I?L=G*(1-F):I>0&&(L=F*K*(1-U(1,(1-G/K)*F/I))+I*(1-K)+G*(1-F)),0===q&&H===K?P=F*K+H*(1-F):0===q?P=H*(1-F):q>0&&(P=F*K*(1-U(1,(1-H/K)*F/q))+q*(1-K)+H*(1-F)),void(0===z&&J===K?Q=F*K+J*(1-F):0===z?Q=J*(1-F):z>0&&(Q=F*K*(1-U(1,(1-J/K)*F/z))+z*(1-K)+J*(1-F))))}function O(){var n=2*I+G-256,t=2*q+H-256,e=2*z+J-256;L=0>n||128>I&&0>n?0:n>255?255:n,P=0>t||128>q&&0>t?0:t>255?255:t,Q=0>e||128>z&&0>e?0:e>255?255:e}function A(){var n;128>I?I?(n=255-(255-G<<8)/(2*I),L=0>n?0:n):L=0:(n=2*I-256,255>n?(n=(G<<8)/(255-n),L=n>255?255:n):L=0>n?0:n),128>q?q?(n=255-(255-H<<8)/(2*q),P=0>n?0:n):P=0:(n=2*q-256,255>n?(n=(H<<8)/(255-n),P=n>255?255:n):P=0>n?0:n),128>z?z?(n=255-(255-J<<8)/(2*z),Q=0>n?0:n):Q=0:(n=2*z-256,255>n?(n=(J<<8)/(255-n),Q=n>255?255:n):Q=0>n?0:n)}function B(){var n;128>I?(n=2*I,L=n>G?G:n):(n=2*I-256,L=G>n?G:n),128>q?(n=2*q,P=n>H?H:n):(n=2*q-256,P=H>n?H:n),128>z?(n=2*z,Q=n>J?J:n):(n=2*z-256,Q=J>n?J:n)}function C(){var n;128>I?L=128>255-(255-G<<8)/(2*I)||0===I?0:255:(n=2*I-256,L=255>n&&128>(G<<8)/(255-n)?0:255),128>q?P=128>255-(255-H<<8)/(2*q)||0===q?0:255:(n=2*q-256,P=255>n&&128>(H<<8)/(255-n)?0:255),128>z?Q=128>255-(255-J<<8)/(2*z)||0===z?0:255:(n=2*z-256,Q=255>n&&128>(J<<8)/(255-n)?0:255)}function N(){var n=r(G,H,J),t=r(I,q,z),e=a(t[0],n[1],n[2]);L=e[0],P=e[1],Q=e[2]}function j(){var n=r(G,H,J),t=r(I,q,z),e=a(n[0],t[1],n[2]);L=e[0],P=e[1],Q=e[2]}function R(){var n=r(G,H,J),t=r(I,q,z),e=a(n[0],n[1],t[2]);L=e[0],P=e[1],Q=e[2]}function S(){var n=r(G,H,J),t=r(I,q,z),e=a(t[0],t[1],n[2]);L=e[0],P=e[1],Q=e[2]}function D(n,t){var e=n.x+n.width,i=n.y+n.height,o=t.x+t.width,r=t.y+t.height,a=T(n.x,t.x),l=T(n.y,t.y),d=T(U(e,o)-a,0),c=T(U(i,r)-l,0);return[a,l,d,c]}var E,I,q,z,F,G,H,J,K,L,P,Q,T=Math.max,U=Math.min,V=.2126,W=.7152,X=.0722;E={"source-over":l,multiply:d,subtract:c,divide:u,screen:s,lighten:f,darken:h,"darker-color":g,"lighter-color":v,add:y,"linear-burn":p,difference:m,exclusion:b,overlay:x,"soft-light":k,"hard-light":w,"color-dodge":M,"color-burn":_,"linear-light":O,"vivid-light":A,"pin-light":B,"hard-mix":C,hue:N,saturation:j,luminosity:R,color:S},function(){function r(){F=y[d+3]/255*p,K=n[l+3]/255,h=F+K-F*K,g=255/h,I=y[d]/255*F,q=y[d+1]/255*F,z=y[d+2]/255*F,G=n[l]/255*K,H=n[l+1]/255*K,J=n[l+2]/255*K,m(),t[l]=L*g,t[l+1]=P*g,t[l+2]=Q*g,t[l+3]=255*h}function a(){G=n[l],H=n[l+1],J=n[l+2],I=y[d],q=y[d+1],z=y[d+2],m(),t[l]=L,t[l+1]=P,t[l+2]=Q,t[l+3]=n[l+3],s=p*y[d+3]/255,1>s&&(f=1-s,t[l]=n[l]*f+t[l]*s,t[l+1]=n[l+1]*f+t[l+1]*s,t[l+2]=n[l+2]*f+t[l+2]*s)}var l,d,c,u,s,f,h,g,v,y=o.data,p=0===o.opacity?0:o.opacity||1,m=E[o.type||"_svg_normal"],b=o.dx||0,x=o.dy||0,k=D({x:0,y:0,width:e,height:i},{x:b,y:x,width:o.width,height:o.height}),w=k[0],M=k[1],_=k[2],O=k[3];for(v=0===m.name.indexOf("_svg_")?r:a,u=0;i>u;u+=1)for(c=0;e>c;c+=1)l=4*(u*e+c),u>=M&&c>=w&&w+_>c&&M+O>u?(d=4*((u-x)*o.width+c-b),v()):(t[l]=n[l],t[l+1]=n[l+1],t[l+2]=n[l+2],t[l+3]=n[l+3])}()},blend=function(){for(var n,t={blend:_blend},e=["source-over","add","multiply","subtract","divide","screen","lighten","darken","darker-color","lighter-color","linear-burn","difference","exclusion","overlay","soft-light","hard-light","color-dodge","color-burn","linear-light","vivid-light","pin-light","hard-mix","hue","saturation","luminosity","color"],i=0;i=t&&t>=e?(o=n-e,i=60*(t-e)/o):t>n&&n>=e?(o=t-e,i=60*(t-n)/o+60):t>=e&&e>n?(o=t-n,i=60*(e-n)/o+120):e>t&&t>n?(o=e-n,i=60*(e-t)/o+180):e>n&&n>=t?(o=e-t,i=60*(n-t)/o+240):(o=n-t,i=60*(n-e)/o+300),r=V*n+W*t+X*e,[i%360,U(T(o,0),1),U(T(r,0),1)]}function a(n,t,e){n%=360;var i,o,r,a;return n>=0&&n<60?(a=t*n/60,r=e-V*t-W*a,i=r+t,o=r+a):n>=60&&n<120?(a=t*(n-60)/60,o=e+X*t+V*a,r=o-t,i=o-a):n>=120&&n<180?(a=t*(n-120)/60,i=e-W*t-X*a,o=i+t,r=i+a):n>=180&&n<240?(a=t*(n-180)/60,r=e+V*t+W*a,i=r-t,o=r-a):n>=240&&n<300?(a=t*(n-240)/60,o=e-X*t-V*a,r=o+t,i=o+a):(a=t*(n-300)/60,i=e+W*t+X*a,o=i-t,r=i-a),i=255*U(T(i,0),1),o=255*U(T(o,0),1),r=255*U(T(r,0),1),[i,o,r]}function l(){L=I+G-G*F,P=q+H-H*F,Q=z+J-J*F}function d(){L=I*G+I*(1-K)+G*(1-F),P=q*H+q*(1-K)+H*(1-F),Q=z*J+z*(1-K)+J*(1-F)}function c(){L=T(G*F-I*K,0)+I*(1-K)+G*(1-F),P=T(H*F-q*K,0)+q*(1-K)+H*(1-F),Q=T(J*F-z*K,0)+z*(1-K)+J*(1-F)}function u(){L=0===I?0:G/I*255,P=0===q?0:H/q*255,Q=0===z?0:J/z*255}function f(){L=I+G-I*G,P=q+H-q*H,Q=z+J-z*J}function s(){L=T(I*K,G*F)+I*(1-K)+G*(1-F),P=T(q*K,H*F)+q*(1-K)+H*(1-F),Q=T(z*K,J*F)+z*(1-K)+J*(1-F)}function h(){L=U(I*K,G*F)+I*(1-K)+G*(1-F),P=U(q*K,H*F)+q*(1-K)+H*(1-F),Q=U(z*K,J*F)+z*(1-K)+J*(1-F)}function v(){G*F*.3+H*F*.59+J*F*.11<=I*K*.3+q*K*.59+z*K*.11?(L=G*F,P=H*F,Q=J*F):(L=I*K,P=q*K,Q=z*K),L+=I*(1-K)+G*(1-F),P+=q*(1-K)+H*(1-F),Q+=z*(1-K)+J*(1-F)}function g(){G*F*.3+H*F*.59+J*F*.11>I*K*.3+q*K*.59+z*K*.11?(L=G*F,P=H*F,Q=J*F):(L=I*K,P=q*K,Q=z*K),L+=I*(1-K)+G*(1-F),P+=q*(1-K)+H*(1-F),Q+=z*(1-K)+J*(1-F)}function y(){L=U(G+I,255),P=U(H+q,255),Q=U(J+z,255)}function p(){L=G+I,P=H+q,Q=J+z,L=L<255?0:L-255,P=P<255?0:P-255,Q=Q<255?0:Q-255}function m(){L=I+G-2*U(I*K,G*F),P=q+H-2*U(q*K,H*F),Q=z+J-2*U(z*K,J*F)}function b(){L=I*K+G*F-2*I*G+I*(1-K)+G*(1-F),P=q*K+H*F-2*q*H+q*(1-K)+H*(1-F),Q=z*K+J*F-2*z*J+z*(1-K)+J*(1-F)}function x(){L=2*G<=K?2*I*G+I*(1-K)+G*(1-F):I*(1+K)+G*(1+F)-2*G*I-K*F,P=2*H<=K?2*q*H+q*(1-K)+H*(1-F):q*(1+K)+H*(1+F)-2*H*q-K*F,Q=2*J<=K?2*z*J+z*(1-K)+J*(1-F):z*(1+K)+J*(1+F)-2*J*z-K*F}function k(){var n,t=Math.pow;return 0===K?(L=I,P=q,void(Q=z)):(n=G/K,2*I<=F?L=G*(F+(2*I-F)*(1-n))+I*(1-K)+G*(1-F):2*I>F&&4*G<=K?L=K*(2*I-F)*(16*t(n,3)-12*t(n,2)-3*n)+I-I*K+G:2*I>F&&4*G>K&&(L=K*(2*I-F)*(t(n,.5)-n)+I-I*K+G),n=H/K,2*q<=F?P=H*(F+(2*q-F)*(1-n))+q*(1-K)+H*(1-F):2*q>F&&4*H<=K?P=K*(2*q-F)*(16*t(n,3)-12*t(n,2)-3*n)+q-q*K+H:2*q>F&&4*H>K&&(P=K*(2*q-F)*(t(n,.5)-n)+q-q*K+H),n=J/K,void(2*z<=F?Q=J*(F+(2*z-F)*(1-n))+z*(1-K)+J*(1-F):2*z>F&&4*J<=K?Q=K*(2*z-F)*(16*t(n,3)-12*t(n,2)-3*n)+z-z*K+J:2*z>F&&4*J>K&&(Q=K*(2*z-F)*(t(n,.5)-n)+z-z*K+J)))}function w(){L=2*I<=F?2*I*G+I*(1-K)+G*(1-F):I*(1+K)+G*(1+F)-F*K-2*I*G,P=2*q<=F?2*q*H+q*(1-K)+H*(1-F):q*(1+K)+H*(1+F)-F*K-2*q*H,Q=2*z<=F?2*z*J+z*(1-K)+J*(1-F):z*(1+K)+J*(1+F)-F*K-2*z*J}function M(){return 0===K?(L=I,P=q,void(Q=z)):(I===F&&0===G?L=I*(1-K):I===F?L=F*K+I*(1-K)+G*(1-F):I0&&(L=F*K*(1-U(1,(1-G/K)*F/I))+I*(1-K)+G*(1-F)),0===q&&H===K?P=F*K+H*(1-F):0===q?P=H*(1-F):q>0&&(P=F*K*(1-U(1,(1-H/K)*F/q))+q*(1-K)+H*(1-F)),void(0===z&&J===K?Q=F*K+J*(1-F):0===z?Q=J*(1-F):z>0&&(Q=F*K*(1-U(1,(1-J/K)*F/z))+z*(1-K)+J*(1-F))))}function O(){var n=2*I+G-256,t=2*q+H-256,e=2*z+J-256;L=n<0||I<128&&n<0?0:n>255?255:n,P=t<0||q<128&&t<0?0:t>255?255:t,Q=e<0||z<128&&e<0?0:e>255?255:e}function A(){var n;I<128?I?(n=255-(255-G<<8)/(2*I),L=n<0?0:n):L=0:(n=2*I-256,n<255?(n=(G<<8)/(255-n),L=n>255?255:n):L=n<0?0:n),q<128?q?(n=255-(255-H<<8)/(2*q),P=n<0?0:n):P=0:(n=2*q-256,n<255?(n=(H<<8)/(255-n),P=n>255?255:n):P=n<0?0:n),z<128?z?(n=255-(255-J<<8)/(2*z),Q=n<0?0:n):Q=0:(n=2*z-256,n<255?(n=(J<<8)/(255-n),Q=n>255?255:n):Q=n<0?0:n)}function B(){var n;I<128?(n=2*I,L=Gn?G:n),q<128?(n=2*q,P=Hn?H:n),z<128?(n=2*z,Q=Jn?J:n)}function C(){var n;I<128?L=255-(255-G<<8)/(2*I)<128||0===I?0:255:(n=2*I-256,L=n<255&&(G<<8)/(255-n)<128?0:255),q<128?P=255-(255-H<<8)/(2*q)<128||0===q?0:255:(n=2*q-256,P=n<255&&(H<<8)/(255-n)<128?0:255),z<128?Q=255-(255-J<<8)/(2*z)<128||0===z?0:255:(n=2*z-256,Q=n<255&&(J<<8)/(255-n)<128?0:255)}function N(){var n=r(G,H,J),t=r(I,q,z),e=a(t[0],n[1],n[2]);L=e[0],P=e[1],Q=e[2]}function j(){var n=r(G,H,J),t=r(I,q,z),e=a(n[0],t[1],n[2]);L=e[0],P=e[1],Q=e[2]}function R(){var n=r(G,H,J),t=r(I,q,z),e=a(n[0],n[1],t[2]);L=e[0],P=e[1],Q=e[2]}function S(){var n=r(G,H,J),t=r(I,q,z),e=a(t[0],t[1],n[2]);L=e[0],P=e[1],Q=e[2]}function D(n,t){var e=n.x+n.width,i=n.y+n.height,o=t.x+t.width,r=t.y+t.height,a=T(n.x,t.x),l=T(n.y,t.y),d=T(U(e,o)-a,0),c=T(U(i,r)-l,0);return[a,l,d,c]}var E,I,q,z,F,G,H,J,K,L,P,Q,T=Math.max,U=Math.min,V=.2126,W=.7152,X=.0722;E={"source-over":l,multiply:d,subtract:c,divide:u,screen:f,lighten:s,darken:h,"darker-color":v,"lighter-color":g,add:y,"linear-burn":p,difference:m,exclusion:b,overlay:x,"soft-light":k,"hard-light":w,"color-dodge":M,"color-burn":_,"linear-light":O,"vivid-light":A,"pin-light":B,"hard-mix":C,hue:N,saturation:j,luminosity:R,color:S},function(){function r(){F=y[d+3]/255*p,K=n[l+3]/255,h=F+K-F*K,v=255/h,I=y[d]/255*F,q=y[d+1]/255*F,z=y[d+2]/255*F,G=n[l]/255*K,H=n[l+1]/255*K,J=n[l+2]/255*K,m(),t[l]=L*v,t[l+1]=P*v,t[l+2]=Q*v,t[l+3]=255*h}function a(){G=n[l],H=n[l+1],J=n[l+2],I=y[d],q=y[d+1],z=y[d+2],m(),t[l]=L,t[l+1]=P,t[l+2]=Q,t[l+3]=n[l+3],f=p*y[d+3]/255,f<1&&(s=1-f,t[l]=n[l]*s+t[l]*f,t[l+1]=n[l+1]*s+t[l+1]*f,t[l+2]=n[l+2]*s+t[l+2]*f)}var l,d,c,u,f,s,h,v,g,y=o.data,p=0===o.opacity?0:o.opacity||1,m=E[o.type||"_svg_normal"],b=o.dx||0,x=o.dy||0,k=D({x:0,y:0,width:e,height:i},{x:b,y:x,width:o.width,height:o.height}),w=k[0],M=k[1],_=k[2],O=k[3];for(g=0===m.name.indexOf("_svg_")?r:a,u=0;u=M&&c>=w&&cu;u+=1)t=v.transformPoint(c[u]),0===u?(r=i=t.x,n=d=t.y):(t.xi&&(i=t.x),t.yd&&(d=t.y));return{x:r,y:n,width:i-r,height:d-n}}function rectIntersect(e,a){var t=e.x+e.width,r=e.y+e.height,n=a.x+a.width,i=a.y+a.height,d=Math.max(e.x,a.x),h=Math.max(e.y,a.y),o=Math.max(Math.min(t,n)-d,0),s=Math.max(Math.min(r,i)-h,0);return{x:d,y:h,width:o,height:s}}function calcLayerRect(e,a){var t=transformRect(e,a);return t=rectIntersect(t,{x:0,y:0,width:e.width,height:e.height}),{x:Math.round(t.x),y:Math.round(t.y),width:Math.ceil(t.width),height:Math.ceil(t.height)}}function getTransformedLayerData(e,a,t){var r=document.createElement("canvas"),n=r.getContext("2d");return r.width=t.width,r.height=t.height,n.translate(-t.x,-t.y),transformLayer(n,e,a),n.drawImage(a.img,0,0),n.getImageData(0,0,t.width,t.height)}var blend=require("./blend"),process=require("./process"),util=require("./util"),nativeBlendModes=blend.getNativeModes(),CanvasRenderer={};CanvasRenderer.toImage=function(e){var a=new Image;return a.width=e.width,a.height=e.height,a.src=e.toDataURL(),a},CanvasRenderer.load=function(e,a){return a.isFill()?CanvasRenderer.generateColor(e,a):a.isGradient()?CanvasRenderer.generateGradient(e,a):a.isHtmlCanvas()?CanvasRenderer.loadHtmlCanvas(a.data):a.isImage()?CanvasRenderer.loadImage(a.data):a.isImageCanvas()?CanvasRenderer.loadImageCanvas(a.data):void 0},CanvasRenderer.loadHtmlCanvas=function(e){return e},CanvasRenderer.loadImageCanvas=function(e){return e.render()},CanvasRenderer.loadImage=function(e){var a=document.createElement("canvas"),t=a.getContext("2d");return a.width=e.width,a.height=e.height,t.drawImage(e,0,0,a.width,a.height),a},CanvasRenderer.generateColor=function(e,a){var t=void 0!==a.width?a.width:e.width,r=void 0!==a.height?a.height:e.height,n=document.createElement("canvas"),i=n.getContext("2d");return n.width=t,n.height=r,i.fillStyle=a.data,i.fillRect(0,0,t,r),n},CanvasRenderer.generateGradient=function(e,a){var t,r,n,i,d,h=void 0!==a.width?a.width:e.width,o=void 0!==a.height?a.height:e.height,s=h/2,g=o/2,l=document.createElement("canvas"),m=l.getContext("2d"),c=a.data,v=c.type||"linear",u=c.rotation||0;return"radial"===v?t=m.createRadialGradient(s,g,0,s,g,Math.min(h,o)/2):(0>u&&(u+=360),u>=0&&45>u?(r=0,n=o/2*(45-u)/45,i=h,d=o-n):u>=45&&135>u?(r=h*(u-45)/90,n=0,i=h-r,d=o):u>=135&&225>u?(r=h,n=o*(u-135)/90,i=0,d=o-n):u>=225&&315>u?(r=h*(1-(u-225)/90),n=o,i=h-r,d=0):u>=315&&(r=0,n=o-o/2*(u-315)/45,i=h,d=o-n),t=m.createLinearGradient(r,n,i,d)),t.addColorStop(c.spread||0,c.startColor),t.addColorStop(1,c.endColor),l.width=h,l.height=o,m.fillStyle=t,m.fillRect(0,0,h,o),l},CanvasRenderer.processImage=function(e,a){if(0===a.length)return e;for(var t,r,n=e.getContext("2d"),i=e.width,d=e.height,h=n.getImageData(0,0,i,d),o=createImageData(n,i,d),s=0;s0&&(r=h,h=o,o=r),t=a[s],process[t.name](h.data,o.data,i,d,t.options);return n.putImageData(o,0,0),e},CanvasRenderer.processMask=function(e,a){if(0===a.layers.length)return e;a.width=e.width,a.height=e.height;var t=CanvasRenderer.renderBW(a),r=t.getContext("2d").getImageData(0,0,t.width,t.height).data,n={name:"mask",options:{data:r,x:0,y:0,width:t.width,height:t.height}};return CanvasRenderer.processImage(e,[n])},CanvasRenderer.processLayer=function(e,a){var t=CanvasRenderer.load(e,a),r=CanvasRenderer.processMask(t,a.mask);return CanvasRenderer.processImage(r,a.filters)},CanvasRenderer.mergeManualBlend=function(e,a){return function(t){for(var r,n,i,d,h,o,s=t.getContext("2d"),g=e.width,l=e.height,m=s.getImageData(0,0,g,l),c=createImageData(s,g,l),v=0;v0&&o.height>0){if(v>0&&(d=m,m=c,c=d),i=getTransformedLayerData(e,r,o),h={data:i.data,width:o.width,height:o.height,opacity:r.opacity,dx:o.x,dy:o.y},void 0===blend[r.blendmode])throw new Error("No blend mode named '"+r.blendmode+"'");n=blend.realBlendMode(r.blendmode),blend[n](m.data,c.data,g,l,h)}return s.putImageData(c,0,0),t}},CanvasRenderer.singleLayerWithOpacity=function(e,a){var t=document.createElement("canvas"),r=t.getContext("2d");return t.width=e.width,t.height=e.height,r.save(),transformLayer(r,e,a),1!==a.opacity&&(r.globalAlpha=a.opacity),r.drawImage(a.img,0,0),r.restore(),t},CanvasRenderer.mergeNativeBlend=function(e,a){return function(t){for(var r,n=t.getContext("2d"),i=0;ii&&(i=t.x),t.yd&&(d=t.y));return{x:r,y:n,width:i-r,height:d-n}}function rectIntersect(e,a){var t=e.x+e.width,r=e.y+e.height,n=a.x+a.width,i=a.y+a.height,d=Math.max(e.x,a.x),h=Math.max(e.y,a.y),o=Math.max(Math.min(t,n)-d,0),s=Math.max(Math.min(r,i)-h,0);return{x:d,y:h,width:o,height:s}}function calcLayerRect(e,a){var t=transformRect(e,a);return t=rectIntersect(t,{x:0,y:0,width:e.width,height:e.height}),{x:Math.round(t.x),y:Math.round(t.y),width:Math.ceil(t.width),height:Math.ceil(t.height)}}function getTransformedLayerData(e,a,t){var r=document.createElement("canvas"),n=r.getContext("2d");return r.width=t.width,r.height=t.height,n.translate(-t.x,-t.y),transformLayer(n,e,a),n.drawImage(a.img,0,0),n.getImageData(0,0,t.width,t.height)}var blend=require("./blend"),process=require("./process"),util=require("./util"),nativeBlendModes=blend.getNativeModes(),CanvasRenderer={};CanvasRenderer.toImage=function(e){var a=new Image;return a.width=e.width,a.height=e.height,a.src=e.toDataURL(),a},CanvasRenderer.load=function(e,a){return a.isFill()?CanvasRenderer.generateColor(e,a):a.isGradient()?CanvasRenderer.generateGradient(e,a):a.isHtmlCanvas()?CanvasRenderer.loadHtmlCanvas(a.data):a.isImage()?CanvasRenderer.loadImage(a.data):a.isImageCanvas()?CanvasRenderer.loadImageCanvas(a.data):void 0},CanvasRenderer.loadHtmlCanvas=function(e){return e},CanvasRenderer.loadImageCanvas=function(e){return e.render()},CanvasRenderer.loadImage=function(e){var a=document.createElement("canvas"),t=a.getContext("2d");return a.width=e.width,a.height=e.height,t.drawImage(e,0,0,a.width,a.height),a},CanvasRenderer.generateColor=function(e,a){var t=void 0!==a.width?a.width:e.width,r=void 0!==a.height?a.height:e.height,n=document.createElement("canvas"),i=n.getContext("2d");return n.width=t,n.height=r,i.fillStyle=a.data,i.fillRect(0,0,t,r),n},CanvasRenderer.generateGradient=function(e,a){var t,r,n,i,d,h=void 0!==a.width?a.width:e.width,o=void 0!==a.height?a.height:e.height,s=h/2,g=o/2,l=document.createElement("canvas"),m=l.getContext("2d"),c=a.data,v=c.type||"linear",u=c.rotation||0;return"radial"===v?t=m.createRadialGradient(s,g,0,s,g,Math.min(h,o)/2):(u<0&&(u+=360),0<=u&&u<45?(r=0,n=o/2*(45-u)/45,i=h,d=o-n):45<=u&&u<135?(r=h*(u-45)/90,n=0,i=h-r,d=o):135<=u&&u<225?(r=h,n=o*(u-135)/90,i=0,d=o-n):225<=u&&u<315?(r=h*(1-(u-225)/90),n=o,i=h-r,d=0):315<=u&&(r=0,n=o-o/2*(u-315)/45,i=h,d=o-n),t=m.createLinearGradient(r,n,i,d)),t.addColorStop(c.spread||0,c.startColor),t.addColorStop(1,c.endColor),l.width=h,l.height=o,m.fillStyle=t,m.fillRect(0,0,h,o),l},CanvasRenderer.processImage=function(e,a){if(0===a.length)return e;for(var t,r,n=e.getContext("2d"),i=e.width,d=e.height,h=n.getImageData(0,0,i,d),o=createImageData(n,i,d),s=0;s0&&(r=h,h=o,o=r),t=a[s],process[t.name](h.data,o.data,i,d,t.options);return n.putImageData(o,0,0),e},CanvasRenderer.processMask=function(e,a){if(0===a.layers.length)return e;a.width=e.width,a.height=e.height;var t=CanvasRenderer.renderBW(a),r=t.getContext("2d").getImageData(0,0,t.width,t.height).data,n={name:"mask",options:{data:r,x:0,y:0,width:t.width,height:t.height}};return CanvasRenderer.processImage(e,[n])},CanvasRenderer.processLayer=function(e,a){var t=CanvasRenderer.load(e,a),r=CanvasRenderer.processMask(t,a.mask);return CanvasRenderer.processImage(r,a.filters)},CanvasRenderer.mergeManualBlend=function(e,a){return function(t){for(var r,n,i,d,h,o,s=t.getContext("2d"),g=e.width,l=e.height,m=s.getImageData(0,0,g,l),c=createImageData(s,g,l),v=0;v0&&o.height>0){if(v>0&&(d=m,m=c,c=d),i=getTransformedLayerData(e,r,o),h={data:i.data,width:o.width,height:o.height,opacity:r.opacity,dx:o.x,dy:o.y},void 0===blend[r.blendmode])throw new Error("No blend mode named '"+r.blendmode+"'");n=blend.realBlendMode(r.blendmode),blend[n](m.data,c.data,g,l,h)}return s.putImageData(c,0,0),t}},CanvasRenderer.singleLayerWithOpacity=function(e,a){var t=document.createElement("canvas"),r=t.getContext("2d");return t.width=e.width,t.height=e.height,r.save(),transformLayer(r,e,a),1!==a.opacity&&(r.globalAlpha=a.opacity),r.drawImage(a.img,0,0),r.restore(),t},CanvasRenderer.mergeNativeBlend=function(e,a){return function(t){for(var r,n=t.getContext("2d"),i=0;i=2)if(i=t,o=e,s="linear",h=0,l=0,3===arguments.length)"string"==typeof r?s=r:"number"==typeof r&&(h=r);else if(4===arguments.length)if("number"==typeof r)h=r,l=a;else if("linear"===r)h=a;else{if("radial"!==r)throw new Error("Wrong argument provided: "+r);s=r,l=a}else 5===arguments.length&&(s=r,h=a,l=n);if(!i&&0!==i)throw new Error("No startColor was given.");if(!o&&0!==o)throw new Error("No endColor was given.");try{m.startColor=toColor(i)}catch(u){throw new Error("startColor is not a valid color: "+i)}try{m.endColor=toColor(o)}catch(d){throw new Error("endColor is not a valid color: "+o)}if(void 0===s&&(s="linear"),"linear"!==s&&"radial"!==s)throw new Error("Unknown gradient type: "+s);if(m.type=s,void 0===l&&(l=0),"number"!=typeof l)throw new Error("Spread value is not a number: "+l);if("linear"===s){if(void 0===h&&(h=0),"number"!=typeof h)throw new Error("Rotation value is not a number: "+h);m.rotation=h}return m.spread=clamp(l,0,.99),m}function findType(t){if("string"==typeof t)return TYPE_PATH;if(t instanceof Image)return TYPE_IMAGE;if(t instanceof HTMLCanvasElement)return TYPE_HTML_CANVAS;if(t instanceof ImageCanvas)return TYPE_IMAGE_CANVAS;if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b&&void 0!==t.a)return TYPE_FILL;if(void 0!==t.startColor&&void 0!==t.endColor)return TYPE_GRADIENT;throw new Error("Cannot establish type for data ",t)}function isPoint(t){return t?void 0!==t.x&&void 0!==t.y:!1}function pointFromArray(t){var e=t[0],r=t.length>1?t[1]:e;return{x:e,y:r}}function pointFromNumber(t){return{x:t,y:t}}function isValidArg(t){return void 0!==t&&null!==t}function convertArg(t){return Array.isArray(t)?pointFromArray(t):"number"==typeof t?pointFromNumber(t):isPoint(t)?t:void 0}function loadImage(t,e){var r=new Image;r.onload=function(){e(null,[t,this])},r.src=t}function loadImages(t,e){async.map(t,loadImage,function(t,r){if(e){for(var a,n,i={},o=0;od;d+=1)t=i.transformPoint(u[d]),0===d?(e=a=t.x,r=n=t.y):(t.xa&&(a=t.x),t.yn&&(n=t.y));return{x:e,y:r,width:a-e,height:n-r}},Img.prototype.colorize=function(t){var e=Layer.fromColor(t);e.width=this.originalWidth,e.height=this.originalHeight;var r=new Img(e.toCanvas());return r=r._transform(this.transform.matrix()),img.merge([this,r])},Img.prototype.desaturate=function(t){var e=this.toLayer(!1);return e.addFilter("desaturate",t),this.withCanvas(e.toCanvas())},Img.prototype.crop=function(t){function e(t,e){var r=t.x+t.width,a=t.y+t.height,n=e.x+e.width,i=e.y+e.height,o=Math.max(t.x,e.x),s=Math.max(t.y,e.y),h=Math.max(Math.min(r,n)-o,0),l=Math.max(Math.min(a,i)-s,0);return{x:o,y:s,width:h,height:l}}var r=this.bounds(),a=t.bounds(),n=e(r,a),i=Math.ceil(n.width),o=Math.ceil(n.height);if(0===n.width||0===n.height)throw new Error("Resulting image has no dimensions");var s=new img.ImageCanvas(i,o),h=s.addLayer(this.toLayer());return h.translate(i/2-a.width-a.x,o/2-a.height-a.y),ir.x&&h.translate(a.width-i,0),or.y&&h.translate(0,a.height-o),new Img(s.render(),n.x+i/2,n.y+o/2)},Img.prototype.draw=function(t){t.save();var e=this.transform.matrix();t.transform(e[0],e[1],e[3],e[4],e[6],e[7]),t.translate(-this.originalWidth/2,-this.originalHeight/2),t.drawImage(this.canvas,0,0),t.restore()},Img.prototype.toLayer=function(t){var e=document.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height;var r=e.getContext("2d");r.drawImage(this.canvas,0,0);var a=img.Layer.fromHtmlCanvas(e);return void 0===t&&(t=!0),t&&(a.transform=this.transform),a},Img.prototype.getPixels=function(){return new Pixels(this.canvas)},Img.prototype.toImage=function(){var t=this.bounds(),e=this.crop({bounds:function(){return t}}),r=new Image;return r.width=e.canvas.width,r.height=e.canvas.height,r.src=e.canvas.toDataURL(),r},img={},img.Layer=Layer,img.ImageCanvas=ImageCanvas,img.Img=Img,img.Pixels=Pixels;var async=require("async");img.loadImages=loadImages,img.merge=merge,module.exports=img; +"use strict";function toColor(t,e,r,a,n){var i,o,s,h,l,d,y,g;if(void 0===t)i=o=s=0,h=1;else if(Array.isArray(t))g=e||{},i=void 0!==t[0]?t[0]:0,o=void 0!==t[1]?t[1]:0,s=void 0!==t[2]?t[2]:0,h=void 0!==t[3]?t[3]:g.base||1;else if(void 0!==t.r)g=e||{},i=t.r,o=t.g,s=t.b,h=void 0!==t.a?t.a:g.base||1;else if("string"==typeof t){if(0===t.indexOf("#"))return t;if(0===t.indexOf("rgb"))return t;if(colors.indexOf(t)!==-1)return t}else"number"==typeof t&&(1===arguments.length?(i=o=s=t,h=1):2===arguments.length?(i=o=s=t,"number"==typeof e?h=e:(g=e,h=g.base||1)):3===arguments.length?"number"==typeof r?(i=t,o=e,s=r,h=1):(i=o=s=t,h=e,g=r):4===arguments.length?(i=t,o=e,s=r,"number"==typeof a?h=a:(g=a||{},h=g.base||1)):(i=t,o=e,s=r,h=a,g=n));if("number"!=typeof i||"number"!=typeof o||"number"!=typeof s||"number"!=typeof h)throw new Error("Invalid color arguments");return g=g||{},void 0!==g.base&&(i/=g.base,o/=g.base,s/=g.base,h/=g.base),l=Math.round(255*i),d=Math.round(255*o),y=Math.round(255*s),"rgba("+l+", "+d+", "+y+", "+h+")"}function toGradientData(t,e,r,a,n){var i,o,s,h,l,d,y={};if(1===arguments.length)d=t||{},i=d.startColor,o=d.endColor,s=d.type,h=d.rotation,l=d.spread;else if(arguments.length>=2)if(i=t,o=e,s="linear",h=0,l=0,3===arguments.length)"string"==typeof r?s=r:"number"==typeof r&&(h=r);else if(4===arguments.length)if("number"==typeof r)h=r,l=a;else if("linear"===r)h=a;else{if("radial"!==r)throw new Error("Wrong argument provided: "+r);s=r,l=a}else 5===arguments.length&&(s=r,h=a,l=n);if(!i&&0!==i)throw new Error("No startColor was given.");if(!o&&0!==o)throw new Error("No endColor was given.");try{y.startColor=toColor(i)}catch(t){throw new Error("startColor is not a valid color: "+i)}try{y.endColor=toColor(o)}catch(t){throw new Error("endColor is not a valid color: "+o)}if(void 0===s&&(s="linear"),"linear"!==s&&"radial"!==s)throw new Error("Unknown gradient type: "+s);if(y.type=s,void 0===l&&(l=0),"number"!=typeof l)throw new Error("Spread value is not a number: "+l);if("linear"===s){if(void 0===h&&(h=0),"number"!=typeof h)throw new Error("Rotation value is not a number: "+h);y.rotation=h}return y.spread=clamp(l,0,.99),y}function findType(t){if("string"==typeof t)return TYPE_PATH;if(t instanceof Image)return TYPE_IMAGE;if(t instanceof HTMLCanvasElement)return TYPE_HTML_CANVAS;if(t instanceof ImageCanvas)return TYPE_IMAGE_CANVAS;if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b&&void 0!==t.a)return TYPE_FILL;if(void 0!==t.startColor&&void 0!==t.endColor)return TYPE_GRADIENT;throw new Error("Cannot establish type for data ",t)}function isPoint(t){return!!t&&(void 0!==t.x&&void 0!==t.y)}function pointFromArray(t){var e=t[0],r=t.length>1?t[1]:e;return{x:e,y:r}}function pointFromNumber(t){return{x:t,y:t}}function isValidArg(t){return void 0!==t&&null!==t}function convertArg(t){return Array.isArray(t)?pointFromArray(t):"number"==typeof t?pointFromNumber(t):isPoint(t)?t:void 0}function loadImage(t,e){var r=new Image;r.onload=function(){e(null,[t,this])},r.src=t}function loadImages(t,e){async.map(t,loadImage,function(t,r){if(e){for(var a,n,i={},o=0;oa&&(a=t.x),t.yn&&(n=t.y));return{x:e,y:r,width:a-e,height:n-r}},Img.prototype.colorize=function(t){var e=Layer.fromColor(t);e.width=this.originalWidth,e.height=this.originalHeight;var r=new Img(e.toCanvas());return r=r._transform(this.transform.matrix()),img.merge([this,r])},Img.prototype.desaturate=function(t){var e=this.toLayer(!1);return e.addFilter("desaturate",t),this.withCanvas(e.toCanvas())},Img.prototype.crop=function(t){function e(t,e){var r=t.x+t.width,a=t.y+t.height,n=e.x+e.width,i=e.y+e.height,o=Math.max(t.x,e.x),s=Math.max(t.y,e.y),h=Math.max(Math.min(r,n)-o,0),l=Math.max(Math.min(a,i)-s,0);return{x:o,y:s,width:h,height:l}}var r=this.bounds(),a=t.bounds(),n=e(r,a),i=Math.ceil(n.width),o=Math.ceil(n.height);if(0===n.width||0===n.height)throw new Error("Resulting image has no dimensions");var s=new img.ImageCanvas(i,o),h=s.addLayer(this.toLayer());return h.translate(i/2-a.width-a.x,o/2-a.height-a.y),ir.x&&h.translate(a.width-i,0),or.y&&h.translate(0,a.height-o),new Img(s.render(),n.x+i/2,n.y+o/2)},Img.prototype.draw=function(t){t.save();var e=this.transform.matrix();t.transform(e[0],e[1],e[3],e[4],e[6],e[7]),t.translate(-this.originalWidth/2,-this.originalHeight/2),t.drawImage(this.canvas,0,0),t.restore()},Img.prototype.toLayer=function(t){var e=document.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height;var r=e.getContext("2d");r.drawImage(this.canvas,0,0);var a=img.Layer.fromHtmlCanvas(e);return void 0===t&&(t=!0),t&&(a.transform=this.transform),a},Img.prototype.getPixels=function(){return new Pixels(this.canvas)},Img.prototype.toImage=function(){var t=this.bounds(),e=this.crop({bounds:function(){return t}}),r=new Image;return r.width=e.canvas.width,r.height=e.canvas.height,r.src=e.canvas.toDataURL(),r},img={},img.Layer=Layer,img.ImageCanvas=ImageCanvas,img.Img=Img,img.Pixels=Pixels;var async=require("async");img.loadImages=loadImages,img.merge=merge,module.exports=img; },{"./asyncrenderer":15,"./canvasrenderer":17,"./util":20,"async":1}],19:[function(require,module,exports){ -"use strict";function defaultOptions(o,n){if(!o)return n;var t,r={};for(t in n)n.hasOwnProperty(t)&&("undefined"==typeof o[t]?r[t]=n[t]:r[t]=o[t]);return r}function smoothstep(o,n,t){return o>t?0:t>=n?1:(t=(t-o)/(n-o),t*t*(3-2*t))}function noise(){return.5*Math.random()+.5}function colorDistance(o,n,t){return clamp(o*n+(1-o)*t,0,255)}function convolve3x3(o,n,t,r,a,e,i,u){var f,l,c,s,p,v,d,m,h,x,g,O,M,T,I,b,y,_,z,U,k,S,w=a[0][0],B=a[0][1],R=a[0][2],P=a[1][0],L=a[1][1],N=a[1][2],Y=a[2][0],q=a[2][1],A=a[2][2];for(l=0;r>l;l+=1)for(m=l*t*4,h=m-4*t,x=m+4*t,1>l&&(h=m),l>=t-1&&(x=m),f=0;t>f;f+=1)c=4*(l*t+f),g=4*f,O=g-4,M=g+4,1>f&&(O=g),f>=t-1&&(M=g),T=h+O,I=h+g,b=h+M,y=m+O,_=m+g,z=m+M,U=x+O,k=x+g,S=x+M,s=o[T]*w+o[I]*B+o[b]*R+o[y]*P+o[_]*L+o[z]*N+o[U]*Y+o[k]*q+o[S]*A,p=o[T+1]*w+o[I+1]*B+o[b+1]*R+o[y+1]*P+o[_+1]*L+o[z+1]*N+o[U+1]*Y+o[k+1]*q+o[S+1]*A,v=o[T+2]*w+o[I+2]*B+o[b+2]*R+o[y+2]*P+o[_+2]*L+o[z+2]*N+o[U+2]*Y+o[k+2]*q+o[S+2]*A,d=e?o[T+3]*w+o[I+3]*B+o[b+3]*R+o[y+3]*P+o[_+3]*L+o[z+3]*N+o[U+3]*Y+o[k+3]*q+o[S+3]*A:o[c+3],u&&(s=p=v=(s+p+v)/3),i&&(s=255-s,p=255-p,v=255-v),n[c]=s,n[c+1]=p,n[c+2]=v,n[c+3]=d}function convolve5x5(o,n,t,r,a,e,i,u){var f,l,c,s,p,v,d,m,h,x,g,O,M,T,I,b,y,_,z,U,k,S,w,B,R,P,L,N,Y,q,A,j,D,C,E,F,G,H,J,K,Q,V,W=a[0][0],X=a[0][1],Z=a[0][2],$=(a[0][3],a[0][4]),oo=a[1][0],no=a[1][1],to=a[1][2],ro=(a[1][3],a[1][4]),ao=a[2][0],eo=a[2][1],io=a[2][2],uo=(a[2][3],a[2][4]),fo=a[3][0],lo=a[3][1],co=a[3][2],so=(a[3][3],a[3][4]),po=a[4][0],vo=a[4][1],mo=a[4][2],ho=(a[4][3],a[4][4]);for(l=0;r>l;l+=1)for(m=l*t*4,h=m-4*t,g=m-4*t*2,x=m+4*t,O=m+4*t*2,1>l&&(h=m),l>=t-1&&(x=m),2>l&&(g=h),l>=t-2&&(O=x),f=0;t>f;f+=1)c=4*(l*t+f),M=4*f,T=M-4,I=M+4,b=M-8,y=M+8,1>f&&(T=M),f>=t-1&&(I=M),2>f&&(b=T),f>=t-2&&(y=I),_=g+b,z=g+T,U=g+M,k=g+I,S=g+y,w=h+b,B=h+T,R=h+M,P=h+I,L=h+y,N=m+b,Y=m+T,q=m+M,A=m+I,j=m+y,D=x+b,C=x+T,E=x+M,F=x+I,G=x+y,H=O+b,J=O+T,K=O+M,Q=O+I,V=O+y,s=o[_]*W+o[z]*X+o[U]*Z+o[k]*$+o[U]*$+o[w]*oo+o[B]*no+o[R]*to+o[P]*ro+o[R]*ro+o[N]*ao+o[Y]*eo+o[q]*io+o[A]*uo+o[q]*uo+o[D]*fo+o[C]*lo+o[E]*co+o[F]*so+o[E]*so+o[H]*po+o[J]*vo+o[K]*mo+o[Q]*ho+o[K]*ho,p=o[_+1]*W+o[z+1]*X+o[U+1]*Z+o[k+1]*$+o[U+1]*$+o[w+1]*oo+o[B+1]*no+o[R+1]*to+o[P+1]*ro+o[R+1]*ro+o[N+1]*ao+o[Y+1]*eo+o[q+1]*io+o[A+1]*uo+o[q+1]*uo+o[D+1]*fo+o[C+1]*lo+o[E+1]*co+o[F+1]*so+o[E+1]*so+o[H+1]*po+o[J+1]*vo+o[K+1]*mo+o[Q+1]*ho+o[K+1]*ho,v=o[_+2]*W+o[z+2]*X+o[U+2]*Z+o[k+2]*$+o[U+2]*$+o[w+2]*oo+o[B+2]*no+o[R+2]*to+o[P+2]*ro+o[R+2]*ro+o[N+2]*ao+o[Y+2]*eo+o[q+2]*io+o[A+2]*uo+o[q+2]*uo+o[D+2]*fo+o[C+2]*lo+o[E+2]*co+o[F+2]*so+o[E+2]*so+o[H+2]*po+o[J+2]*vo+o[K+2]*mo+o[Q+2]*ho+o[K+2]*ho,d=e?o[_+3]*W+o[z+3]*X+o[U+3]*Z+o[k+3]*$+o[U+3]*$+o[w+3]*oo+o[B+3]*no+o[R+3]*to+o[P+3]*ro+o[R+3]*ro+o[N+3]*ao+o[Y+3]*eo+o[q+3]*io+o[A+3]*uo+o[q+3]*uo+o[D+3]*fo+o[C+3]*lo+o[E+3]*co+o[F+3]*so+o[E+3]*so+o[H+3]*po+o[J+3]*vo+o[K+3]*mo+o[Q+3]*ho+o[K+3]*ho:o[c+3],u&&(s=p=v=(s+p+v)/3),i&&(s=255-s,p=255-p,v=255-v),n[c]=s,n[c+1]=p,n[c+2]=v,n[c+3]=d}function gaussian(o,n,t,r,a){var e,i,u,f,l,c,s,p,v,d,m,h,x,g,O,M=[],T=13,I=[[1]];for(a=clamp(a,3,T),x=-a/2+(a%2?.5:0),g=a+x,u=1;T>u;u+=1)I[0][u]=0;for(u=1;T>u;u+=1)for(I[u]=[1],f=1;T>f;f+=1)I[u][f]=I[u-1][f]+I[u-1][f-1];for(O=I[a-1],u=0,h=0;a>u;u+=1)h+=O[u];for(u=0;a>u;u+=1)O[u]/=h;for(i=0;r>i;i+=1)for(e=0;t>e;e+=1){for(l=c=s=p=0,u=x;g>u;u+=1)d=e+u,m=i,h=O[u-x],0>d&&(d=0),d>=t&&(d=t-1),v=4*(m*t+d),l+=o[v]*h,c+=o[v+1]*h,s+=o[v+2]*h,p+=o[v+3]*h;v=4*(i*t+e),M[v]=l,M[v+1]=c,M[v+2]=s,M[v+3]=p}for(i=0;r>i;i+=1)for(e=0;t>e;e+=1){for(l=c=s=p=0,u=x;g>u;u+=1)d=e,m=i+u,h=O[u-x],0>m&&(m=0),m>=r&&(m=r-1),v=4*(m*t+d),l+=M[v]*h,c+=M[v+1]*h,s+=M[v+2]*h,p+=M[v+3]*h;v=4*(i*t+e),n[v]=l,n[v+1]=c,n[v+2]=s,n[v+3]=p}}function getPixel(o,n){return n*=4,[o[n+0],o[n+1],o[n+2],o[n+3]]}function setPixel(o,n,t){n*=4,o[n+0]=t[0],o[n+1]=t[1],o[n+2]=t[2],o[n+3]=t[3]}function polar(o,n,t,r,a,e,i){t=a/2+(t||0),r=e/2+(r||0);var u,f,l,c,s,p,v;for(u=0;e>u;u+=1)for(f=0;a>f;f+=1)l=f-t,c=u-r,s=Math.sqrt(Math.pow(l,2)+Math.pow(c,2)),p=Math.atan2(c,l),v=i(s,p),s=v[0],p=v[1],setPixel(n,f+u*a,getPixel(o,Math.round(t+Math.cos(p)*s)+Math.round(r+Math.sin(p)*s)*a))}var stackblur=require("stackblur"),util=require("./util"),clamp=util.clamp,LUMINOSITY_ITU_R_BT601="ITU-R BT.601",LUMINOSITY_ITU_R_BT709="ITU-R BT.709",process={invert:function(o,n,t,r){var a,e=t*r*4;for(a=0;e>a;a+=4)n[a]=255-o[a],n[a+1]=255-o[a+1],n[a+2]=255-o[a+2],n[a+3]=o[a+3]},sepia:function(o,n,t,r){var a,e,i,u,f=t*r*4;for(a=0;f>a;a+=4)e=o[a],i=o[a+1],u=o[a+2],n[a]=.393*e+.769*i+.189*u,n[a+1]=.349*e+.686*i+.168*u,n[a+2]=.272*e+.534*i+.131*u,n[a+3]=o[a+3]},solarize:function(o,n,t,r){var a,e,i,u,f=t*r*4;for(a=0;f>a;a+=4)e=o[a],i=o[a+1],u=o[a+2],n[a]=e>127?255-e:e,n[a+1]=i>127?255-i:i,n[a+2]=u>127?255-u:u,n[a+3]=o[a+3]},brightness:function(o,n,t,r,a){a=defaultOptions(a,{brightness:1,contrast:0});var e,i,u,f,l,c=t*r*4,s=clamp(a.contrast,-1,1)/2,p=1+clamp(a.brightness,-1,1),v=0>p?-p:p,d=0>p?0:p;for(s=.5*Math.tan((s+1)*Math.PI/4),l=255*-(s-.5),e=0;c>e;e+=4)i=o[e],u=o[e+1],f=o[e+2],i=(i+i*v+d)*s+l,u=(u+u*v+d)*s+l,f=(f+f*v+d)*s+l,n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},desaturate:function(o,n,t,r,a){a=defaultOptions(a,{method:LUMINOSITY_ITU_R_BT601});var e,i,u,f,l,c=t*r*4;for(a.method===LUMINOSITY_ITU_R_BT601?(u=.3,f=.59,l=.11):a.method===LUMINOSITY_ITU_R_BT709&&(u=.2125,f=.7154,l=.0721),e=0;c>e;e+=4)i=o[e]*u+o[e+1]*f+o[e+2]*l,n[e]=i,n[e+1]=i,n[e+2]=i,n[e+3]=o[e+3]},lighten:function(o,n,t,r,a){a=defaultOptions(a,{amount:.25});var e,i=t*r*4,u=1+clamp(a.amount,0,1);for(e=0;i>e;e+=4)n[e]=o[e]*u,n[e+1]=o[e+1]*u,n[e+2]=o[e+2]*u,n[e+3]=o[e+3]},noise:function(o,n,t,r,a){a=defaultOptions(a,{amount:.5,strength:.5,mono:!1});var e,i,u,f,l,c=t*r*4,s=clamp(a.amount,0,1),p=clamp(a.strength,0,1),v=!!a.mono,d=Math.random;for(e=0;c>e;e+=4)u=o[e],f=o[e+1],l=o[e+2],i=d(),s>i&&(v?(i=p*(i/s*2-1)*255,u+=i,f+=i,l+=i):(u+=p*d()*255,f+=p*d()*255,l+=p*d()*255)),n[e]=u,n[e+1]=f,n[e+2]=l,n[e+3]=o[e+3]},flipv:function(o,n,t,r){var a,e,i,u;for(e=0;r>e;e+=1)for(a=0;t>a;a+=1)i=4*(e*t+a),u=4*(e*t+(t-a-1)),n[u]=o[i],n[u+1]=o[i+1],n[u+2]=o[i+2],n[u+3]=o[i+3]},fliph:function(o,n,t,r){var a,e,i,u;for(e=0;r>e;e+=1)for(a=0;t>a;a+=1)i=4*(e*t+a),u=4*((r-e-1)*t+a),n[u]=o[i],n[u+1]=o[i+1],n[u+2]=o[i+2],n[u+3]=o[i+3]},blur:function(o,n,t,r,a){a=defaultOptions(a,{radius:10});for(var e=0;ee;e+=4)i=o[e]+s[e]*c,u=o[e+1]+s[e+1]*c,f=o[e+2]+s[e+2]*c,i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},convolve3x3:function(o,n,t,r,a){convolve3x3(o,n,t,r,a.kernel)},convolve5x5:function(o,n,t,r,a){convolve5x5(o,n,t,r,a.kernel)},sharpen3x3:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=-clamp(a.strength,0,1);convolve3x3(o,n,t,r,[[e,e,e],[e,1-8*e,e],[e,e,e]])},sharpen5x5:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=-clamp(a.strength,0,1);convolve5x5(o,n,t,r,[[e,e,e,e,e],[e,e,e,e,e],[e,e,1-24*e,e,e],[e,e,e,e,e],[e,e,e,e,e]])},soften3x3:function(o,n,t,r){var a=1/9;convolve3x3(o,n,t,r,[[a,a,a],[a,a,a],[a,a,a]])},soften5x5:function(o,n,t,r){var a=.04;convolve5x5(o,n,t,r,[[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a]])},crossedges:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=5*clamp(a.strength,0,1);convolve3x3(o,n,t,r,[[0,-e,0],[-e,0,e],[0,e,0]],!1,!0)},emboss:function(o,n,t,r,a){a=defaultOptions(a,{amount:1,angle:0});var e,i=t*r*4,u=a.amount,f=a.angle,l=Math.cos(-f)*u,c=Math.sin(-f)*u,s=-l-c,p=-l,v=c-l,d=-c,m=c,h=-c+l,x=l,g=c+l,O=[];for(convolve3x3(o,O,t,r,[[s,d,h],[p,0,x],[v,m,g]]),e=0;i>e;e+=4)n[e]=128+O[e],n[e+1]=128+O[e+1],n[e+2]=128+O[e+2],n[e+3]=o[e+3]},findedges:function(o,n,t,r){var a,e,i,u,f,l,c,s=t*r*4,p=[],v=[];for(convolve3x3(o,p,t,r,[[-1,0,1],[-2,0,2],[-1,0,1]]),convolve3x3(o,v,t,r,[[-1,-2,-1],[0,0,0],[1,2,1]]),a=0;s>a;a+=4)e=p[a],i=v[a],u=p[a+1],f=v[a+1],l=p[a+2],c=v[a+2],0>e&&(e=-e),0>i&&(i=-i),0>u&&(u=-u),0>f&&(f=-f),0>l&&(l=-l),0>c&&(c=-c),n[a]=255-.8*(e+i),n[a+1]=255-.8*(u+f),n[a+2]=255-.8*(l+c),n[a+3]=o[a+3]},edgeenhance3x3:function(o,n,t,r){var a=-1/9;convolve3x3(o,n,t,r,[[a,a,a],[a,17/9,a],[a,a,a]])},edgeenhance5x5:function(o,n,t,r){var a=-0.04;convolve5x5(o,n,t,r,[[a,a,a,a,a],[a,a,a,a,a],[a,a,1.96,a,a],[a,a,a,a,a],[a,a,a,a,a]])},laplace3x3:function(o,n,t,r){convolve3x3(o,n,t,r,[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]],!1,!0,!0)},laplace5x5:function(o,n,t,r){convolve5x5(o,n,t,r,[[-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1],[-1,-1,24,-1,-1],[-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1]],!1,!0,!0)},rgbAdjust:function(o,n,t,r,a){a=defaultOptions(a,{r:0,g:0,b:0,a:0});var e,i,u,f,l,c=t*r*4,s=255*clamp(a.r,-1,1),p=255*clamp(a.g,-1,1),v=255*clamp(a.b,-1,1),d=255*clamp(a.a,-1,1);for(e=0;c>e;e+=4)i=o[e]+s,u=o[e+1]+p,f=o[e+2]+v,l=o[e+3]+d,0>i&&(i=0),0>u&&(u=0),0>f&&(f=0),0>l&&(l=0),i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),l>255&&(l=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=l},colorfilter:function(o,n,t,r,a){a=defaultOptions(a,{luminosity:!1,r:1,g:.5,b:0});var e,i,u,f,l,c,s,p,v,d,m,h=t*r*4,x=!!a.luminosity,g=clamp(a.r,0,1),O=clamp(a.g,0,1),M=clamp(a.b,0,1);for(e=0;h>e;e+=4)i=o[e]/255,u=o[e+1]/255,f=o[e+2]/255,p=.3*i+.59*u+.11*f,i=(i+i*g)/2,u=(u+u*O)/2,f=(f+f*M)/2,x&&(l=c=i,u>c&&(c=u),f>c&&(c=f),l>u&&(l=u),l>f&&(l=f),d=c-l,s=i===c?(u-f)/d%6:u===c?(f-i)/d+2:(i-u)/d+4,v=s>>0,m=d*(s-v),i=u=f=p-(.3*i+.59*u+.11*f),0===v?(i+=d,u+=m):1===v?(i+=d-m,u+=d):2===v?(u+=d,f+=m):3===v?(u+=d-m,f+=d):4===v?(i+=m,f+=d):5===v&&(i+=d,f+=d-m)),n[e]=255*i,n[e+1]=255*u,n[e+2]=255*f,n[e+3]=o[e+3]},hslAdjust:function(o,n,t,r,a){a=defaultOptions(a,{h:.5,s:.3,l:.1,a:0});var e,i,u,f,l,c,s,p,v,d,m,h,x,g,O,M=t*r*4,T=clamp(a.h,-1,1),I=clamp(a.s,-1,1),b=clamp(a.l,-1,1),y=255*clamp(a.a,-1,1),_=1+I*(0>I?1:2),z=0>b?1+b:1-b,U=0>b?0:255*b;for(T=6*T%6,e=0;M>e;e+=4)i=o[e],u=o[e+1],f=o[e+2],l=o[e+3]+y,(0!==T||0!==I)&&(c=i,u>c&&(c=u),f>c&&(c=f),s=i,s>u&&(s=u),s>f&&(s=f),p=c-s,m=(s+c)/510,m>0&&p>0&&(.5>=m?(d=p/(c+s)*_,d>1&&(d=1),h=m*(1+d)):(d=p/(510-c-s)*_,d>1&&(d=1),h=m+d-m*d),v=i===c?u===s?5+(c-f)/p+T:1-(c-u)/p+T:u===c?f===s?1+(c-i)/p+T:3-(c-f)/p+T:i===s?3+(c-u)/p+T:5-(c-i)/p+T,0>v&&(v+=6),v>=6&&(v-=6),x=m+m-h,O=v>>0,g=(h-x)*(v-O),0===O?(i=h,u=x+g,f=x):1===O?(i=h-g,u=h,f=x):2===O?(i=x,u=h,f=x+g):3===O?(i=x,u=h-g,f=h):4===O?(i=x+g,u=x,f=h):5===O&&(i=h,u=x,f=h-g),i*=255,u*=255,f*=255)),i=i*z+U,u=u*z+U,f=f*z+U,0>i&&(i=0),0>u&&(u=0),0>f&&(f=0),0>l&&(l=0),i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),l>255&&(l=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=l},posterize:function(o,n,t,r,a){a=defaultOptions(a,{levels:5});var e,i=t*r*4,u=clamp(a.levels,2,256),f=256/u,l=256/(u-1);for(e=0;i>e;e+=4)n[e]=l*(o[e]/f>>0),n[e+1]=l*(o[e+1]/f>>0),n[e+2]=l*(o[e+2]/f>>0),n[e+3]=o[e+3]},removenoise:function(o,n,t,r){var a,e,i,u,f,l,c,s,p,v,d,m,h,x,g,O,M,T,I;for(e=0;r>e;e+=1)for(s=e*t*4,p=s-4*t,v=s+4*t,1>e&&(p=s),e>=t-1&&(v=s),a=0;t>a;a+=1)c=4*(e*t+a),d=4*a,m=d-4,h=d+4,1>a&&(m=d),a>=t-1&&(h=d),x=M=o[s+m],l=o[s+h],x>l&&(x=l),l>M&&(M=l),l=o[p+d],x>l&&(x=l),l>M&&(M=l),l=o[v+d],x>l&&(x=l),l>M&&(M=l),g=o[s+m+1],l=o[s+h+1],g>l&&(g=l),l=o[p+d+1],g>l&&(g=l),l=o[v+d+1],g>l&&(g=l),O=o[s+m+2],l=o[s+h+2],O>l&&(O=l),l=o[p+d+2],O>l&&(O=l),l=o[v+d+2],O>l&&(O=l),i=o[c],u=o[c+1],f=o[c+2],x>i&&(i=x),i>M&&(i=M),g>u&&(u=g),u>T&&(u=T),O>f&&(f=O),f>I&&(f=I),n[c]=i,n[c+1]=u,n[c+2]=f,n[c+3]=o[c+3]},mosaic:function(o,n,t,r,a){a=defaultOptions(a,{blockSize:8});var e,i,u,f,l,c,s,p,v,d,m,h,x,g,O=clamp(a.blockSize,1,Math.max(t,r)),M=Math.ceil(r/O),T=Math.ceil(t/O);for(e=0,v=0,s=0;M>s;s+=1){for(i=clamp(e+O,0,r),u=0,p=0;T>p;p+=1){for(f=clamp(u+O,0,t),l=e*t+u<<2,d=o[l],m=o[l+1],h=o[l+2],x=e;i>x;x+=1)for(g=u;f>g;g+=1)c=x*t+g<<2,n[c]=d,n[c+1]=m,n[c+2]=h,n[c+3]=o[c+3];u=f,v+=1}e=i}},equalize:function(o,n,t,r,a){var e,i,u,f,l=t*r,c=Math.round,s=new Array(256);for(i=0;256>i;i+=1)s[i]=0;for(i=0;l>i;i+=1)e=4*i,u=clamp(c(.3*o[e]+.59*o[e+1]+.11*o[e+2]),0,255),n[e+3]=u,s[u]+=1;var p=new Array(256);for(p[0]=s[0],i=1;256>i;i+=1)p[i]=p[i-1]+s[i];for(i=0;256>i;i+=1)p[i]=p[i]/l*255;for(i=0;l>i;i+=1)e=4*i,u=n[e+3],f=p[u]/(u||1),n[e]=clamp(c(o[e]*f),0,255),n[e+1]=clamp(c(o[e+1]*f),0,255),n[e+2]=clamp(c(o[e+2]*f),0,255),n[e+3]=o[e+3]},mask:function(o,n,t,r,a){var e,i=t*r*4,u=a.data;for(e=0;i>e;e+=4)n[e]=o[e],n[e+1]=o[e+1],n[e+2]=o[e+2],n[e+3]=o[e+3]*u[e]/255*u[e+3]/255},bump:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,zoom:0});var e=a.radius,i=clamp(a.zoom,0,1);return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o*smoothstep(0,i,o/e),n]})},dent:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,zoom:0});var e=a.radius,i=clamp(a.zoom,0,1);return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[2*o-o*smoothstep(0,i,o/e),n]})},pinch:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,zoom:0});var e=util.distance(0,0,t,r),i=clamp(.75*a.zoom,-.75,.75);return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o*Math.pow(e/o,i)*(1-i),n]})},splash:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0});var e=a.radius;return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o>e?e:o,n]})},twirl:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,angle:0});var e=util.radians(a.angle),i=a.radius;return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o,n+(1-smoothstep(-i,i,o))*e]})}};module.exports=process; +"use strict";function defaultOptions(o,n){if(!o)return n;var t,r={};for(t in n)n.hasOwnProperty(t)&&("undefined"==typeof o[t]?r[t]=n[t]:r[t]=o[t]);return r}function smoothstep(o,n,t){return t=n?1:(t=(t-o)/(n-o),t*t*(3-2*t))}function noise(){return.5*Math.random()+.5}function colorDistance(o,n,t){return clamp(o*n+(1-o)*t,0,255)}function convolve3x3(o,n,t,r,a,e,i,u){var f,l,c,s,p,v,d,m,h,x,g,O,M,T,I,b,y,_,z,U,k,S,w=a[0][0],B=a[0][1],R=a[0][2],P=a[1][0],L=a[1][1],N=a[1][2],Y=a[2][0],q=a[2][1],A=a[2][2];for(l=0;l=t-1&&(x=m),f=0;f=t-1&&(M=g),T=h+O,I=h+g,b=h+M,y=m+O,_=m+g,z=m+M,U=x+O,k=x+g,S=x+M,s=o[T]*w+o[I]*B+o[b]*R+o[y]*P+o[_]*L+o[z]*N+o[U]*Y+o[k]*q+o[S]*A,p=o[T+1]*w+o[I+1]*B+o[b+1]*R+o[y+1]*P+o[_+1]*L+o[z+1]*N+o[U+1]*Y+o[k+1]*q+o[S+1]*A,v=o[T+2]*w+o[I+2]*B+o[b+2]*R+o[y+2]*P+o[_+2]*L+o[z+2]*N+o[U+2]*Y+o[k+2]*q+o[S+2]*A,d=e?o[T+3]*w+o[I+3]*B+o[b+3]*R+o[y+3]*P+o[_+3]*L+o[z+3]*N+o[U+3]*Y+o[k+3]*q+o[S+3]*A:o[c+3],u&&(s=p=v=(s+p+v)/3),i&&(s=255-s,p=255-p,v=255-v),n[c]=s,n[c+1]=p,n[c+2]=v,n[c+3]=d}function convolve5x5(o,n,t,r,a,e,i,u){var f,l,c,s,p,v,d,m,h,x,g,O,M,T,I,b,y,_,z,U,k,S,w,B,R,P,L,N,Y,q,A,j,D,C,E,F,G,H,J,K,Q,V,W=a[0][0],X=a[0][1],Z=a[0][2],$=(a[0][3],a[0][4]),oo=a[1][0],no=a[1][1],to=a[1][2],ro=(a[1][3],a[1][4]),ao=a[2][0],eo=a[2][1],io=a[2][2],uo=(a[2][3],a[2][4]),fo=a[3][0],lo=a[3][1],co=a[3][2],so=(a[3][3],a[3][4]),po=a[4][0],vo=a[4][1],mo=a[4][2],ho=(a[4][3],a[4][4]);for(l=0;l=t-1&&(x=m),l<2&&(g=h),l>=t-2&&(O=x),f=0;f=t-1&&(I=M),f<2&&(b=T),f>=t-2&&(y=I),_=g+b,z=g+T,U=g+M,k=g+I,S=g+y,w=h+b,B=h+T,R=h+M,P=h+I,L=h+y,N=m+b,Y=m+T,q=m+M,A=m+I,j=m+y,D=x+b,C=x+T,E=x+M,F=x+I,G=x+y,H=O+b,J=O+T,K=O+M,Q=O+I,V=O+y,s=o[_]*W+o[z]*X+o[U]*Z+o[k]*$+o[U]*$+o[w]*oo+o[B]*no+o[R]*to+o[P]*ro+o[R]*ro+o[N]*ao+o[Y]*eo+o[q]*io+o[A]*uo+o[q]*uo+o[D]*fo+o[C]*lo+o[E]*co+o[F]*so+o[E]*so+o[H]*po+o[J]*vo+o[K]*mo+o[Q]*ho+o[K]*ho,p=o[_+1]*W+o[z+1]*X+o[U+1]*Z+o[k+1]*$+o[U+1]*$+o[w+1]*oo+o[B+1]*no+o[R+1]*to+o[P+1]*ro+o[R+1]*ro+o[N+1]*ao+o[Y+1]*eo+o[q+1]*io+o[A+1]*uo+o[q+1]*uo+o[D+1]*fo+o[C+1]*lo+o[E+1]*co+o[F+1]*so+o[E+1]*so+o[H+1]*po+o[J+1]*vo+o[K+1]*mo+o[Q+1]*ho+o[K+1]*ho,v=o[_+2]*W+o[z+2]*X+o[U+2]*Z+o[k+2]*$+o[U+2]*$+o[w+2]*oo+o[B+2]*no+o[R+2]*to+o[P+2]*ro+o[R+2]*ro+o[N+2]*ao+o[Y+2]*eo+o[q+2]*io+o[A+2]*uo+o[q+2]*uo+o[D+2]*fo+o[C+2]*lo+o[E+2]*co+o[F+2]*so+o[E+2]*so+o[H+2]*po+o[J+2]*vo+o[K+2]*mo+o[Q+2]*ho+o[K+2]*ho,d=e?o[_+3]*W+o[z+3]*X+o[U+3]*Z+o[k+3]*$+o[U+3]*$+o[w+3]*oo+o[B+3]*no+o[R+3]*to+o[P+3]*ro+o[R+3]*ro+o[N+3]*ao+o[Y+3]*eo+o[q+3]*io+o[A+3]*uo+o[q+3]*uo+o[D+3]*fo+o[C+3]*lo+o[E+3]*co+o[F+3]*so+o[E+3]*so+o[H+3]*po+o[J+3]*vo+o[K+3]*mo+o[Q+3]*ho+o[K+3]*ho:o[c+3],u&&(s=p=v=(s+p+v)/3),i&&(s=255-s,p=255-p,v=255-v),n[c]=s,n[c+1]=p,n[c+2]=v,n[c+3]=d}function gaussian(o,n,t,r,a){var e,i,u,f,l,c,s,p,v,d,m,h,x,g,O,M=[],T=13,I=[[1]];for(a=clamp(a,3,T),x=-a/2+(a%2?.5:0),g=a+x,u=1;u=t&&(d=t-1),v=4*(m*t+d),l+=o[v]*h,c+=o[v+1]*h,s+=o[v+2]*h,p+=o[v+3]*h;v=4*(i*t+e),M[v]=l,M[v+1]=c,M[v+2]=s,M[v+3]=p}for(i=0;i=r&&(m=r-1),v=4*(m*t+d),l+=M[v]*h,c+=M[v+1]*h,s+=M[v+2]*h,p+=M[v+3]*h;v=4*(i*t+e),n[v]=l,n[v+1]=c,n[v+2]=s,n[v+3]=p}}function getPixel(o,n){return n*=4,[o[n+0],o[n+1],o[n+2],o[n+3]]}function setPixel(o,n,t){n*=4,o[n+0]=t[0],o[n+1]=t[1],o[n+2]=t[2],o[n+3]=t[3]}function polar(o,n,t,r,a,e,i){t=a/2+(t||0),r=e/2+(r||0);var u,f,l,c,s,p,v;for(u=0;u127?255-e:e,n[a+1]=i>127?255-i:i,n[a+2]=u>127?255-u:u,n[a+3]=o[a+3]},brightness:function(o,n,t,r,a){a=defaultOptions(a,{brightness:1,contrast:0});var e,i,u,f,l,c=t*r*4,s=clamp(a.contrast,-1,1)/2,p=1+clamp(a.brightness,-1,1),v=p<0?-p:p,d=p<0?0:p;for(s=.5*Math.tan((s+1)*Math.PI/4),l=255*-(s-.5),e=0;e255&&(i=255),u>255&&(u=255),f>255&&(f=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},convolve3x3:function(o,n,t,r,a){convolve3x3(o,n,t,r,a.kernel)},convolve5x5:function(o,n,t,r,a){convolve5x5(o,n,t,r,a.kernel)},sharpen3x3:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=-clamp(a.strength,0,1);convolve3x3(o,n,t,r,[[e,e,e],[e,1-8*e,e],[e,e,e]])},sharpen5x5:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=-clamp(a.strength,0,1);convolve5x5(o,n,t,r,[[e,e,e,e,e],[e,e,e,e,e],[e,e,1-24*e,e,e],[e,e,e,e,e],[e,e,e,e,e]])},soften3x3:function(o,n,t,r){var a=1/9;convolve3x3(o,n,t,r,[[a,a,a],[a,a,a],[a,a,a]])},soften5x5:function(o,n,t,r){var a=.04;convolve5x5(o,n,t,r,[[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a]])},crossedges:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=5*clamp(a.strength,0,1);convolve3x3(o,n,t,r,[[0,-e,0],[-e,0,e],[0,e,0]],!1,!0)},emboss:function(o,n,t,r,a){a=defaultOptions(a,{amount:1,angle:0});var e,i=t*r*4,u=a.amount,f=a.angle,l=Math.cos(-f)*u,c=Math.sin(-f)*u,s=-l-c,p=-l,v=c-l,d=-c,m=c,h=-c+l,x=l,g=c+l,O=[];for(convolve3x3(o,O,t,r,[[s,d,h],[p,0,x],[v,m,g]]),e=0;e255&&(i=255),u>255&&(u=255),f>255&&(f=255),l>255&&(l=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=l},colorfilter:function(o,n,t,r,a){a=defaultOptions(a,{luminosity:!1,r:1,g:.5,b:0});var e,i,u,f,l,c,s,p,v,d,m,h=t*r*4,x=!!a.luminosity,g=clamp(a.r,0,1),O=clamp(a.g,0,1),M=clamp(a.b,0,1);for(e=0;ec&&(c=u),f>c&&(c=f),u>0,m=d*(s-v),i=u=f=p-(.3*i+.59*u+.11*f),0===v?(i+=d,u+=m):1===v?(i+=d-m,u+=d):2===v?(u+=d,f+=m):3===v?(u+=d-m,f+=d):4===v?(i+=m,f+=d):5===v&&(i+=d,f+=d-m)),n[e]=255*i,n[e+1]=255*u,n[e+2]=255*f,n[e+3]=o[e+3]},hslAdjust:function(o,n,t,r,a){a=defaultOptions(a,{h:.5,s:.3,l:.1,a:0});var e,i,u,f,l,c,s,p,v,d,m,h,x,g,O,M=t*r*4,T=clamp(a.h,-1,1),I=clamp(a.s,-1,1),b=clamp(a.l,-1,1),y=255*clamp(a.a,-1,1),_=1+I*(I<0?1:2),z=b<0?1+b:1-b,U=b<0?0:255*b;for(T=6*T%6,e=0;ec&&(c=u),f>c&&(c=f),s=i,u0&&p>0&&(m<=.5?(d=p/(c+s)*_,d>1&&(d=1),h=m*(1+d)):(d=p/(510-c-s)*_,d>1&&(d=1),h=m+d-m*d),v=i===c?u===s?5+(c-f)/p+T:1-(c-u)/p+T:u===c?f===s?1+(c-i)/p+T:3-(c-f)/p+T:i===s?3+(c-u)/p+T:5-(c-i)/p+T,v<0&&(v+=6),v>=6&&(v-=6),x=m+m-h,O=v>>0,g=(h-x)*(v-O),0===O?(i=h,u=x+g,f=x):1===O?(i=h-g,u=h,f=x):2===O?(i=x,u=h,f=x+g):3===O?(i=x,u=h-g,f=h):4===O?(i=x+g,u=x,f=h):5===O&&(i=h,u=x,f=h-g),i*=255,u*=255,f*=255)),i=i*z+U,u=u*z+U,f=f*z+U,i<0&&(i=0),u<0&&(u=0),f<0&&(f=0),l<0&&(l=0),i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),l>255&&(l=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=l},posterize:function(o,n,t,r,a){a=defaultOptions(a,{levels:5});var e,i=t*r*4,u=clamp(a.levels,2,256),f=256/u,l=256/(u-1);for(e=0;e>0),n[e+1]=l*(o[e+1]/f>>0),n[e+2]=l*(o[e+2]/f>>0),n[e+3]=o[e+3]},removenoise:function(o,n,t,r){var a,e,i,u,f,l,c,s,p,v,d,m,h,x,g,O,M,T,I;for(e=0;e=t-1&&(v=s),a=0;a=t-1&&(h=d),x=M=o[s+m],l=o[s+h],lM&&(M=l),l=o[p+d],lM&&(M=l),l=o[v+d],lM&&(M=l),g=o[s+m+1],l=o[s+h+1],lM&&(i=M),uT&&(u=T),fI&&(f=I),n[c]=i,n[c+1]=u,n[c+2]=f,n[c+3]=o[c+3]},mosaic:function(o,n,t,r,a){a=defaultOptions(a,{blockSize:8});var e,i,u,f,l,c,s,p,v,d,m,h,x,g,O=clamp(a.blockSize,1,Math.max(t,r)),M=Math.ceil(r/O),T=Math.ceil(t/O);for(e=0,v=0,s=0;se?e:o,n]})},twirl:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,angle:0});var e=util.radians(a.angle),i=a.radius;return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o,n+(1-smoothstep(-i,i,o))*e]})}};module.exports=process; },{"./util":20,"stackblur":5}],20:[function(require,module,exports){ @@ -85,66 +85,66 @@ function XMLReader(){}function parse(e,t,r,a,n){function s(e){if(e>65535){e-=655 },{}],21:[function(require,module,exports){ -"use strict";var deepEqual=require("./deepequal"),util=require("./util"),g={};g.combine=function(){var n,r,t=[];for(n=0;nr;r+=1)e=n[r],g.contains(i,e)||(i.push(e),u.push(n[r]));return u},g.first=function(n){return n&&0!==n.length?n[0]:null},g.get=function(n,r){return n&&0!==n.length?n[r]:null},g.interleave=function(){if(0===arguments.length)return[];for(var n=[],r=0;;){for(var t=0;tr))return n;n.push(e[r])}r+=1}},g.last=function(n){return n&&0!==n.length?n[n.length-1]:null},g.pick=function(n,r,t){if(!n||0===n.length||0>=r)return[];t||0===t||(t=Math.random());for(var e=util.randomGenerator(t||0),u=[],i=0;r>i;i+=1)u.push(n[Math.floor(e(0,n.length))]);return u},g.randomSample=function(n,r,t){if(!n||0===n.length||0>=r)return[];t||0===t||(t=Math.random());var e=g.shuffle(n,t);return r?g.slice(e,0,r):e},g.repeat=function(n,r,t){if(!n)return[];if(0>=r)return[];var e,u,i,l=[];if(t)for(e=0;eu;u+=1)l.push(i);else for(e=0;r>e;e+=1)l.push.apply(l,n);return l},g.rest=function(n){return n?n.slice(1):[]},g.reverse=function(n){return n.slice().reverse()},g.second=function(n){return!n||n.length<2?null:n[1]},g.shift=function(n,r){if(!n)return[];r%=n.length;var t=n.slice(0,r),e=n.slice(r);return e.push.apply(e,t),e},g.shuffle=function(n,r){var t,e,u,i;for(r||0===r||(r=Math.random()),i=util.randomGenerator(r||0),t=n.length-1;t>0;t--)e=Math.floor(i(0,t+1)),u=n[t],n[t]=n[e],n[e]=u;return n},g.slice=function(n,r,t,e){if(!n)return[];var u,i;return e?(u=n.slice(0,r),i=n.slice(r+t),u.push.apply(u,i),u):n.slice(r,r+t)},g.sort=function(n,r){if(r){if("string"==typeof r)return n.slice().sort(function(n,t){return n[r]>t[r]?1:n[r]===t[r]?0:-1});if("function"==typeof r)return n.slice().sort(r)}return n&&void 0!==n[0]&&null!==n[0]&&"number"==typeof n[0]?n.slice().sort(function(n,r){return n-r}):n.slice().sort()},g["switch"]=function(n){var r=arguments.length-1;return n%=r,0>n&&(n+=r),arguments[n+1]},g.takeEvery=function(n,r,t){var e,u=[];for(t=t||0,e=0;et;t+=1)e=n[t],u=r[t],i[e]=u;return i},module.exports=g; +"use strict";var deepEqual=require("./deepequal"),util=require("./util"),g={};g.combine=function(){var r,n,e=[];for(r=0;rn))return r;r.push(t[n])}n+=1}},g.last=function(r){return r&&0!==r.length?r[r.length-1]:null},g.pick=function(r,n,e){if(!r||0===r.length||n<=0)return[];e||0===e||(e=Math.random());for(var t=util.randomGenerator(e||0),u=[],i=0;i0;e--)t=Math.floor(i(0,e+1)),u=r[e],r[e]=r[t],r[t]=u;return r},g.slice=function(r,n,e,t){if(!r)return[];var u,i;return t?(u=r.slice(0,n),i=r.slice(n+e),u.push.apply(u,i),u):r.slice(n,n+e)},g.sort=function(r,n){if(n){if("string"==typeof n)return r.slice().sort(function(r,e){return r[n]>e[n]?1:r[n]===e[n]?0:-1});if("function"==typeof n)return r.slice().sort(n)}return r&&void 0!==r[0]&&null!==r[0]&&"number"==typeof r[0]?r.slice().sort(function(r,n){return r-n}):r.slice().sort()},g.switch=function(r){var n=arguments.length-1;return r%=n,r<0&&(r+=n),arguments[r+1]},g.takeEvery=function(r,n,e){var t,u=[];for(e=e||0,t=0;t1?r=arguments:1!==arguments.length||Array.isArray(r)||(r=[r]),!r||0===r.length)return[0];var n,t=[],e=0;for(n=0;n1?r=arguments:1!==arguments.length||Array.isArray(r)||(r=[r]),!r||0===r.length)return 0;var n,t=0;for(n=0;nr;if(">"===t)return r>n;if("<="===t)return n>=r;if(">="===t)return r>=n;if("=="===t)return r===n;if("!="===t)return r!==n;throw new Error("Unknown comparison operation "+t)},g.cos=Math.cos,g.degrees=function(r){return 180*r/Math.PI},g.divide=function(r,n){function t(r){if(0===r)throw new Error("Divide by zero")}var e=arguments.length;if(2===e)return t(n),r/n;if(1===e)return t(r),1/r;if(0===e)throw new Error("Wrong number of arguments");return _.reduce([].slice.call(arguments,1),function(r,n){return t(n),r/n},arguments[0])},g.e=function(){return Math.E},g.even=function(r){return r%2===0},g.floor=Math.floor,g.integer=function(r){return 0|r},g.log=function(r){return r>0?Math.log(r):-Math.log(-r)},g.makeNumbers=function(r,n){if(!r)return[];n||(n="");var t,e,u=[],o=r.split(n);for(t=0;tu||!e&&0!==e)&&(e=Math.random()),3===u||4===u?(n=n||0,t=t||(0===t?0:1)):2===u?(t=n||(0===n?0:1),n=0):1===u&&(n=0,t=1),n>t){var o=t;t=n,n=o}for(var a,g=t-n,i=[],f=util.randomGenerator(e||0),s=0;r>s;s+=1)a=n+f(0,1)*g,i.push(a);return i},g.range=function(r,n,t,e){if(r===n)return[];if(0!==t&&(t=t||(n>r?1:-1)),t>0&&r>n)return[];if(0>t&&n>r)return[];if(0===t)return[];var u,o=[];if(n>r)if(e)for(u=r;n>=u;u+=t)o.push(u);else for(u=r;n>u;u+=t)o.push(u);else if(e)for(u=r;u>=n;u+=t)o.push(u);else for(u=r;u>n;u+=t)o.push(u);return o},g.round=function(r,n){return n=0|n,n?Math.round(r/n)*n:Math.round(r)},g.sample=function(r,n,t,e){var u,o,a=[];for(a.length=r,u=e?(t-n)/r:(t-n)/(r-1),o=0;r>o;o+=1)a[o]=n+o*u;return a},g.sineWave=function(r,n,t,e,u){void 0===n&&(n=-1),void 0===t&&(t=1),void 0===e&&(e=1),void 0===u&&(u=0);var o=(t-n)/2;return n+o+Math.sin((u+r)*TWO_PI/e)*o},g.squareWave=function(r,n,t,e,u){void 0===n&&(n=-1),void 0===t&&(t=1),void 0===e&&(e=1),void 0===u&&(u=0);var o=e/2,a=(r+u)%e;return o>a?t:n},g.triangleWave=function(r,n,t,e,u){void 0===n&&(n=-1),void 0===t&&(t=1),void 0===e&&(e=1),void 0===u&&(u=0);var o=(t-n)/2,a=TWO_PI/e,g=0,i=r+u+e/4;return i%e!==0&&(g=i*a%TWO_PI),0>g&&(g+=TWO_PI),2*o*(1+-Math.abs(g/TWO_PI*2-1))+n},g.sawtoothWave=function(r,n,t,e,u){void 0===n&&(n=-1),void 0===t&&(t=1),void 0===e&&(e=1),void 0===u&&(u=0);var o=(t-n)/2,a=TWO_PI/e,g=0,i=r+u;return i%e!==0&&(g=i*a%TWO_PI),0>g&&(g+=TWO_PI),2*(g/TWO_PI)*o+n},g.sign=function(r){return r>0?1:0===r?0:-1},g.sin=Math.sin,g.sqrt=Math.sqrt,g.subtract=function(r,n){var t=arguments.length;if(2===t)return r-n;if(1===t)return-r;if(0===t)throw new Error("Wrong number of arguments");return _.reduce([].slice.call(arguments,1),function(r,n){return r-n},arguments[0])},g.tan=Math.tan,g.total=function(r){if(arguments.length>1?r=arguments:1!==arguments.length||Array.isArray(r)?0===arguments.length&&(r=[]):r=[r],0===r.length)return 0;var n,t=0;for(n=0;n1?r=arguments:1!==arguments.length||Array.isArray(r)||(r=[r]),!r||0===r.length)return[0];var n,t=[],e=0;for(n=0;n1?r=arguments:1!==arguments.length||Array.isArray(r)||(r=[r]),!r||0===r.length)return 0;var n,t=0;for(n=0;n"===t)return r>n;if("<="===t)return r<=n;if(">="===t)return r>=n;if("=="===t)return r===n;if("!="===t)return r!==n;throw new Error("Unknown comparison operation "+t)},g.cos=Math.cos,g.degrees=function(r){return 180*r/Math.PI},g.divide=function(r,n){function t(r){if(0===r)throw new Error("Divide by zero")}var e=arguments.length;if(2===e)return t(n),r/n;if(1===e)return t(r),1/r;if(0===e)throw new Error("Wrong number of arguments");return _.reduce([].slice.call(arguments,1),function(r,n){return t(n),r/n},arguments[0])},g.e=function(){return Math.E},g.even=function(r){return r%2===0},g.floor=Math.floor,g.integer=function(r){return 0|r},g.log=function(r){return r>0?Math.log(r):-Math.log(-r)},g.makeNumbers=function(r,n){if(!r)return[];n||(n="");var t,e,u=[],o=r.split(n);for(t=0;t0&&r>n)return[];if(t<0&&r=n;u+=t)o.push(u);else for(u=r;u>n;u+=t)o.push(u);return o},g.round=function(r,n){return n|=0,n?Math.round(r/n)*n:Math.round(r)},g.sample=function(r,n,t,e){var u,o,i=[];for(i.length=r,u=e?(t-n)/r:(t-n)/(r-1),o=0;o0?1:0===r?0:-1},g.sin=Math.sin,g.sqrt=Math.sqrt,g.subtract=function(r,n){var t=arguments.length;if(2===t)return r-n;if(1===t)return-r;if(0===t)throw new Error("Wrong number of arguments");return _.reduce([].slice.call(arguments,1),function(r,n){return r-n},arguments[0])},g.tan=Math.tan,g.total=function(r){if(arguments.length>1?r=arguments:1!==arguments.length||Array.isArray(r)?0===arguments.length&&(r=[]):r=[r],0===r.length)return 0;var n,t=0;for(n=0;nr){for(var n=randomGenerator(Math.abs(r)),e=0;23>e;e+=1)n();return randomGenerator(n(0,1e4))}return function(n,e){n=n||0,e=e||1,r=(9301*r+49297)%233280;var a=r/233280;return n+a*(e-n)}};exports.randomGenerator=randomGenerator; +"use strict";var randomGenerator=function(r){if(r<0){for(var n=randomGenerator(Math.abs(r)),e=0;e<23;e+=1)n();return randomGenerator(n(0,1e4))}return function(n,e){n=n||0,e=e||1,r=(9301*r+49297)%233280;var a=r/233280;return n+a*(e-n)}};exports.randomGenerator=randomGenerator; },{}],25:[function(require,module,exports){ -"use strict";var Color=require("../objects/color"),vg={};vg.isDrawable=function(o){return Array.isArray(o)&&(o=o[0]),o?"function"==typeof o.draw?!0:void 0!==o.x&&void 0!==o.y?!0:void 0!==o.r&&void 0!==o.g&&void 0!==o.b?!0:!1:!1},vg.drawPoints=function(o,r){var t,i;for(o.fillStyle="blue",o.beginPath(),i=0;it;t+=1){var e=r[t];o.fillStyle=Color.toCSS(e),o.fillRect(e.x-2,e.y-2,4,4)}},vg.drawRectangles=function(o,r){var t,i;for(o.save(),t=0;te;e+=1)vg.draw(o,r[e]);else r.draw(o);else void 0!==t.x&&void 0!==t.y?void 0!==t.r&&void 0!==t.g&&void 0!==t.b?vg.drawColoredPoints(o,i?r:[r]):void 0!==t.width&&void 0!==t.height?vg.drawRectangles(o,i?r:[r]):vg.drawPoints(o,i?r:[r]):void 0!==t.r&&void 0!==t.g&&void 0!==t.b&&vg.drawColors(o,i?r:[r])},vg.toSVG=function(o,r){r=r||{};var t=r.header===!0,i=void 0!==r.x?r.x:0,e=void 0!==r.y?r.y:0,v=void 0!==r.width?r.width:500,n=void 0!==r.height?r.height:500,l="";if(o)if("function"==typeof o.toSVG)l=o.toSVG();else if(Array.isArray(o)){l="\n";for(var d=0,a=o.length;a>d;d+=1)l+=vg.toSVG(o[d])+"\n";l+="\n"}return t&&(l='\n'+l+"\n"),l},module.exports=vg; +"use strict";var Color=require("../objects/color"),vg={};vg.isDrawable=function(o){return Array.isArray(o)&&(o=o[0]),!!o&&("function"==typeof o.draw||(void 0!==o.x&&void 0!==o.y||void 0!==o.r&&void 0!==o.g&&void 0!==o.b))},vg.drawPoints=function(o,r){var t,i;for(o.fillStyle="blue",o.beginPath(),i=0;i\n"}return t&&(l='\n'+l+"\n"),l},module.exports=vg; },{"../objects/color":28}],26:[function(require,module,exports){ -"use strict";function _cloneCommand(e){var n={type:e.type};return n.type!==bezier.CLOSE&&(n.x=e.x,n.y=e.y),n.type===bezier.QUADTO?(n.x1=e.x1,n.y1=e.y1):n.type===bezier.CURVETO&&(n.x1=e.x1,n.y1=e.y1,n.x2=e.x2,n.y2=e.y2),n}var _=require("lodash"),ClipperLib=require("js-clipper"),bezier=require("../util/bezier"),geo=require("../util/geo"),math=require("../util/math"),random=require("../util/random"),Color=require("../objects/color"),Group=require("../objects/group"),Path=require("../objects/path"),Point=require("../objects/point"),Rect=require("../objects/rect"),Transform=require("../objects/transform"),Transformable=require("../objects/transformable"),vg={};vg.HORIZONTAL="horizontal",vg.VERTICAL="vertical",vg.EAST="e",vg.WEST="w",vg.NORTH="n",vg.SOUTH="s",vg.bounds=function(e){var n,r,t;if(e){if("function"==typeof e.bounds)return e.bounds();if(void 0!==e.x&&void 0!==e.y)return void 0!==e.width&&void 0!==e.height?new Rect(e.x,e.y,e.width,e.height):new Rect(e.x,e.y,0,0);if(void 0!==e.r&&void 0!==e.g&&void 0!==e.b)return new vg.Rect(0,0,30,30);if(Array.isArray(e)){if(n=null,t=e.length,t>0&&void 0!==e[0].r&&void 0!==e[0].g&&void 0!==e[0].b)return new Rect(0,0,30*e.length,30);for(r=0;t>r;r+=1)n=n?n.unite(vg.bounds(e[r])):vg.bounds(e[r]);return n||new Rect}return new Rect}return new Rect},vg.makeCenteredRect=function(e,n,r,t){var o=e-r/2,i=n-t/2;return new Rect(o,i,r,t)},vg.makePoint=function(e,n){return new Point(e,n)},vg.makeRect=function(e,n,r,t){return new Rect(e,n,r,t)},vg.merge=function(){return new Group(_.reject(_.flatten(arguments,!0),_.isEmpty))},vg.combinePaths=function(e){return Path.combine(e)},vg.shapePoints=vg.toPoints=function(e){if(!e)return[];if(e.commands)return _.map(_.filter(e.commands,function(e){return void 0!==e.x?!0:!1}),function(e){return new Point(e.x,e.y)});var n,r=[];for(n=0;na;a+=1){for(s=new Transform,u=0;u0&&void 0!==e[0].x&&void 0!==e[0].y?c=c.concat(s.transformShape(e)):c.push(s.transformShape(e)),p+=t.x,f+=t.y,l+=o,v+=i.x,y+=i.y}return c},vg.fit=function(e,n,r,t,o){if(e){o=void 0!==o?o:!1;var i,a,s,u=vg.bounds(e),h=u.x,c=u.y,p=u.width,f=u.height;return p=p>1e-12?p:0,f=f>1e-12?f:0,i=new Transform,i=i.translate(n.x,n.y),o?(a=p>0?r/p:1,s=f>0?t/f:1):(a=p>0?r/p:Number.MAX_VALUE,s=f>0?t/f:Number.MAX_VALUE,a=s=Math.min(a,s)),i=i.scale(a,s),i=i.translate(-p/2-h,-f/2-c),i.transformShape(e)}},vg.fitTo=function(e,n,r){if(e&&n){var t=vg.bounds(n),o=t.x,i=t.y,a=t.width,s=t.height;return vg.fit(e,{x:o+a/2,y:i+s/2},a,s,r)}},vg.mirror=function(e,n,r,t){if(e){r=r||new Point,0!==n&&(n=n||90);var o=function(e,t){var o=geo.distance(e,t,r.x,r.y),i=geo.angle(e,t,r.x,r.y),a=geo.coordinates(r.x,r.y,180+n,o*Math.cos(math.radians(i-n)));return o=geo.distance(e,t,a.x,a.y),i=geo.angle(e,t,a.x,a.y),a=geo.coordinates(e,t,i,2*o),new Point(a.x,a.y)},i=function(e){for(var n,r,t,i=new Path([],e.fill,e.stroke,e.strokeWidth),a=0;a0&&void 0!==e[0].x&&void 0!==e[0].y)return a(e);var n=e.shapes?s:i;return n(e)},h=u(e);return t?Array.isArray(e)&&e.length>0&&void 0!==e[0].x&&void 0!==e[0].y?e.concat(h):new Group([e,h]):h}},vg.pathLength=function(e,n){var r=20;return n&&n.precision&&(r=n.precision),e.length(r)},vg.resampleByLength=function(e,n){return e?e.resampleByLength(n):void 0},vg.resampleByAmount=function(e,n,r){return e?e.resampleByAmount(n,r):void 0},vg.wigglePoints=function(e,n,r){r=void 0!==r?r:Math.random();var t=random.generator(r);void 0===n?n={x:10,y:10}:"number"==typeof n&&(n={x:n,y:n});var o=function(e){var r,i,a;if(e.commands){var s=new Path([],e.fill,e.stroke,e.strokeWidth);for(r=0;r0&&void 0!==e[0].x&&void 0!==e[0].y){var h=[];for(r=0;rt;t+=1)for(i=100;i>0;){var b=0;for(a=c+u(0,1)*f,s=p+u(0,1)*l,o=0;o0&&void 0!==e[0].x&&void 0!==e[0].y?_.map(e,function(e){var o=math.snap(e.x+t.x,n,r)-t.x,i=math.snap(e.y+t.y,n,r)-t.y;return new Point(o,i)}):_.map(e,o)};return o(e)}},vg.deletePoints=function(e,n,r){var t=function(e){var o,i,a,s=[],u=[];if(e.commands){var h=!0;for(o=0;o0&&void 0!==e[0].x&&void 0!==e[0].y){for(o=0;on&&(n=1+n);var r=e.point(n);return new Point(r.x,r.y)}},vg._x=function(e){return void 0!==e.x?e.x:e.bounds().x},vg._y=function(e){return void 0!==e.y?e.y:e.bounds().y},vg._angleToPoint=function(e){return function(n){if(void 0!==n.x&&void 0!==n.y)return geo.angle(n.x,n.y,e.x,e.y);var r=n.bounds().centerPoint();return geo.angle(r.x,r.y,e.x,e.y)}},vg._distanceToPoint=function(e){return function(n){if(void 0!==n.x&&void 0!==n.y)return geo.distance(n.x,n.y,e.x,e.y);var r=n.bounds().centerPoint();return geo.distance(r.x,r.y,e.x,e.y)}},vg.shapeSort=function(e,n,r){if(e){r=r||Point.ZERO;var t={x:vg._x,y:vg._y,angle:vg._angleToPoint(r),distance:vg._distanceToPoint(r)};if(n=t[n],void 0===n)return e;var o=e.slice(0);return o.sort(function(e,r){var t=n(e),o=n(r);return o>t?-1:t>o?1:0}),o}},vg.group=function(){return new Group(_.flatten(arguments))},vg.ungroup=function(e){if(e){if(e.shapes){var n,r,t=[];for(n=0;n0&&void 0!==e[0].r&&void 0!==e[0].g&&void 0!==e[0].b)return new Rect(0,0,30*e.length,30);for(n=0;n0&&void 0!==e[0].x&&void 0!==e[0].y?p=p.concat(s.transformShape(e)):p.push(s.transformShape(e)),h+=t.x,l+=t.y,y+=o,v+=i.x,f+=i.y}return p},vg.fit=function(e,r,n,t,o){if(e){o=void 0!==o&&o;var i,a,s,u=vg.bounds(e),c=u.x,p=u.y,h=u.width,l=u.height;return h=h>1e-12?h:0,l=l>1e-12?l:0,i=new Transform,i=i.translate(r.x,r.y),o?(a=h>0?n/h:1,s=l>0?t/l:1):(a=h>0?n/h:Number.MAX_VALUE,s=l>0?t/l:Number.MAX_VALUE,a=s=Math.min(a,s)),i=i.scale(a,s),i=i.translate(-h/2-c,-l/2-p),i.transformShape(e)}},vg.fitTo=function(e,r,n){if(e&&r){var t=vg.bounds(r),o=t.x,i=t.y,a=t.width,s=t.height;return vg.fit(e,{x:o+a/2,y:i+s/2},a,s,n)}},vg.mirror=function(e,r,n,t){if(e){n=n||new Point,0!==r&&(r=r||90);var o,i,a,s,u=function(e,t){var o=geo.distance(e,t,n.x,n.y),i=geo.angle(e,t,n.x,n.y),a=geo.coordinates(n.x,n.y,180+r,o*Math.cos(math.radians(i-r)));return o=geo.distance(e,t,a.x,a.y),i=geo.angle(e,t,a.x,a.y),a=geo.coordinates(e,t,i,2*o),new Point(a.x,a.y)};o=function(e){for(var r,n,t,o=new Path([],e.fill,e.stroke,e.strokeWidth),i=0;i0&&void 0!==e[0].x&&void 0!==e[0].y)return i(e);var r=e.shapes?a:o;return r(e)};var c=s(e);return t?Array.isArray(e)&&e.length>0&&void 0!==e[0].x&&void 0!==e[0].y?e.concat(c):new Group([e,c]):c}},vg.pathLength=function(e,r){var n=20;return r&&r.precision&&(n=r.precision),e.length(n)},vg.resampleByLength=function(e,r){if(e)return e.resampleByLength(r)},vg.resampleByAmount=function(e,r,n){if(e)return e.resampleByAmount(r,n)},vg.wigglePoints=function(e,r,n){n=void 0!==n?n:Math.random();var t=random.generator(n);void 0===r?r={x:10,y:10}:"number"==typeof r&&(r={x:r,y:r});var o=function(e){var n,i,a;if(e.commands){var s=new Path([],e.fill,e.stroke,e.strokeWidth);for(n=0;n0&&void 0!==e[0].x&&void 0!==e[0].y){var c=[];for(n=0;n0;){var b=0;for(a=p+u(0,1)*l,s=h+u(0,1)*y,o=0;o0&&void 0!==e[0].x&&void 0!==e[0].y?_.map(e,function(e){var o=math.snap(e.x+t.x,r,n)-t.x,i=math.snap(e.y+t.y,r,n)-t.y;return new Point(o,i)}):_.map(e,o)};return o(e)}},vg.deletePoints=function(e,r,n){var t=function(e){var o,i,a,s=[],u=[];if(e.commands){var c=!0;for(o=0;o0&&void 0!==e[0].x&&void 0!==e[0].y){for(o=0;oo?1:0}),o}},vg.group=function(){return new Group(_.flatten(arguments))},vg.ungroup=function(e){if(e){if(e.shapes){var r,n,t=[];for(r=0;ru;u+=1)l=geo.coordinates(g,d,y*u+c,v),0===u?x.moveTo(l.x,l.y):x.lineTo(l.x,l.y);return x.close(),x},vg.star=function(e,t,n,r){var o=arguments;5===o.length||4===o.length&&"number"==typeof o[0]&&"number"==typeof o[1]?(e=Point.read(o[0],o[1]),t=o[2],n=o[3],r=o[4]):e=Point.read(e),r||(r=n);var a,i,u,l,g,d=new Path;for(d.moveTo(e.x,e.y+n/2),a=1;2*t>a;a+=1)i=a*Math.PI/t,u=a%2===1?r/2:n/2,l=e.x+u*Math.sin(i),g=e.y+u*Math.cos(i),d.lineTo(l,g);return d.close(),d},vg.freehand=function(e){var t,n,r,o=function(e){return""!==e},a=_.filter(e.split("M"),o);a=_.map(a,function(e){return e.replace(/,/g," ")});var i=new Path;for(n=0;n1?(a=n*(e-1),i=o.x-a/2):i=o.x,t>1?(u=r*(t-1),l=o.y-u/2):l=o.y,c=0,g=0;t>g;g+=1)for(d=0;e>d;d+=1)v=i+d*n,y=l+g*r,x[c]=new Point(v,y),c+=1;return x},vg.text=function(){var e=Object.create(gText.prototype);return e.constructor=gText.prototype,gText.apply(e,arguments),e},vg.demoRect=function(){return new vg.rect({x:0,y:0},100,100,{x:0,y:0})},vg.demoEllipse=function(){return new vg.ellipse({x:0,y:0},100,100)},module.exports=vg; +},{"../objects/color":28,"../objects/group":29,"../objects/path":31,"../objects/point":32,"../objects/rect":33,"../objects/transform":35,"../objects/transformable":36,"../util/bezier":38,"../util/geo":40,"../util/math":42,"../util/random":43,"js-clipper":2,"lodash":3}],27:[function(require,module,exports){ +"use strict";var _=require("lodash"),geo=require("../util/geo"),Color=require("../objects/color"),Path=require("../objects/path"),Point=require("../objects/point"),gText=require("../objects/text"),vg={};vg.roundedRect=function(e,t,n,r,o,a){var i=new Path;return i.addRoundedRect(e,t,n,r,o,a),i},vg.quad=function(e,t,n,r){var o=arguments,a=new Path;return 8===o.length?Path.prototype.addQuad.apply(a,o):(e=Point.read(e),t=Point.read(t),n=Point.read(n),r=Point.read(r),a.addQuad(e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y)),a},vg.rect=function(e,t,n,r){var o=arguments;if(3===o.length?e=Point.read(e):4===o.length?"number"==typeof o[0]&&"number"==typeof o[1]?(e=Point.read(o[0],o[1]),t=o[2],n=o[3],r=null):(e=Point.read(e),r=Point.read(r)):5!==o.length&&6!==o.length||(e=Point.read(o[0],o[1]),t=o[2],n=o[3],r=5===o.length&&"number"==typeof o[4]?Point.read(o[4],o[4]):Point.read(o[4],o[5])),!r||0===r.x&&0===r.y){var a=new Path;return a.addRect(e.x-t/2,e.y-n/2,t,n),a}return vg.roundedRect(e.x-t/2,e.y-n/2,t,n,r.x,r.y)},vg.ellipse=function(e,t,n){var r=arguments;4===r.length?(e=Point.read(r[0],r[1]),t=r[2],n=r[3]):e=Point.read(e);var o=new Path;return o.addEllipse(e.x-t/2,e.y-n/2,t,n),o},vg.line=function(e,t){var n=arguments;4===n.length?(e=Point.read(n[0],n[1]),t=Point.read(n[2],n[3])):(e=Point.read(e),t=Point.read(t));var r=new Path;return r.addLine(e.x,e.y,t.x,t.y),r.fill=null,r.stroke="black",r},vg.lineAngle=function(e,t,n){var r=arguments;4===r.length?(e=Point.read(r[0],r[1]),n=r[2],t=r[3]):e=Point.read(e);var o=geo.coordinates(e.x,e.y,t,n);return vg.line(e,o)},vg.arc=function(e,t,n,r,o,a){var i=arguments;7===i.length?(e=Point.read(i[0],i[1]),t=i[2],n=i[3],r=i[4],o=i[5],a=i[6]):e=Point.read(e);var l=new Path;return l.addArc(e.x,e.y,t,n,r,o,a),l},vg.curve=function(e,t,n,r){var o=arguments;6===o.length?(e=Point.read(o[0],o[1]),t=Point.read(o[2],o[3]),n=o[4],r=o[5]):(e=Point.read(e),t=Point.read(t));var a=e.x+n*(t.x-e.x),i=e.y+n*(t.y-e.y),l=geo.angle(e.x,e.y,t.x,t.y)+90,d=geo.coordinates(a,i,l,r),u=d.x,g=d.y,v=e.x+2/3*(u-e.x),y=e.y+2/3*(g-e.y),c=t.x+2/3*(u-t.x),x=t.y+2/3*(g-t.y),P=new Path;return P.moveTo(e.x,e.y),P.curveTo(v,y,c,x,t.x,t.y),P.fill=null,P.stroke=Color.BLACK,P},vg.polygon=function(e,t,n,r){var o=arguments;5===o.length||4===o.length&&"number"==typeof o[0]&&"number"==typeof o[1]?(e=Point.read(o[0],o[1]),t=o[2],n=o[3],r=5!==o.length||o[4]):(e=Point.read(e),3===o.length&&(r=!0)),n=Math.max(n,3);var a,i,l,d,u=e.x,g=e.y,v=t,y=360/n,c=0;r===!0&&(a=geo.coordinates(u,g,0,v),i=geo.coordinates(u,g,y,v),c=-geo.angle(i.x,i.y,a.x,a.y));var x=new Path;for(l=0;l1?(a=n*(e-1),i=o.x-a/2):i=o.x,t>1?(l=r*(t-1),d=o.y-l/2):d=o.y,c=0,u=0;u=1?color.rgb2hex(this.r,this.g,this.b):color.rgba2hex(this.r,this.g,this.b,this.a)},Color.prototype.desaturate=function(r){if(this.r===this.g&&this.g===this.b)return this;var o,t,e;void 0!==r&&r.method&&"ITU-R BT.601"!==r.method?"ITU-R BT.709"===r.method&&(o=.2125,t=.7154,e=.0721):(o=.3,t=.59,e=.11);var s=this.r*o+this.g*t+this.b*e;return new Color(s,s,s,this.a)},Color.prototype.invert=function(){return new Color(1-this.r,1-this.g,1-this.b,this.a)},Color.clone=function(r){return null===r||void 0===r?null:"string"==typeof r?r:new Color(r.r,r.g,r.b,r.a)},Color.toCSS=function(r){if(null===r)return"none";if(void 0===r)return"black";if("string"==typeof r)return r;if(r instanceof Color){var o=Math.round(255*r.r),t=Math.round(255*r.g),e=Math.round(255*r.b);return"rgba("+o+", "+t+", "+e+", "+r.a+")"}if(void 0!==r.r&&void 0!==r.g&&void 0!==r.b)return void 0===r.a?"rgb("+r.r+", "+r.g+", "+r.b+")":"rgba("+r.r+", "+r.g+", "+r.b+", "+r.a+")";throw new Error("Don't know how to convert "+r+" to CSS.")},Color.toHex=function(r){return Color.parse(r).toHex()},Color.make=function(){var r=Object.create(Color.prototype);return r.constructor=Color.prototype,Color.apply(r,arguments),r},Color.parse=function(r){function o(r,o){return r&&o?(r=String(r),0===r.indexOf(o)):!1}var t;if(void 0===r||null===r)return new Color(0,0,0,0);if(r instanceof Color)return r;if(color.namedColors[r])return Color.make.apply(null,color.namedColors[r]);if("#"===r[0])return new Color(r,0,0,0,{mode:HEX});if(o(r,"rgba"))return t=r.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+|\d+.\d+)\s*\)$/i),t?new Color(parseInt(t[1])/255,parseInt(t[2])/255,parseInt(t[3])/255,parseFloat(t[4])):(t=r.match(/^rgba\s*\(\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)\s*\)$/i))?new Color(parseFloat(t[1])/100,parseFloat(t[2])/100,parseFloat(t[3])/100,parseFloat(t[4])):new Color(0,0,0,0);if(o(r,"rgb"))return t=r.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i),t?new Color(parseInt(t[1])/255,parseInt(t[2])/255,parseInt(t[3])/255):(t=r.match(/^rgb\s*\(\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*\)$/i))?new Color(parseFloat(t[1])/100,parseFloat(t[2])/100,parseFloat(t[3])/100):new Color(0,0,0,0);if(o(r,"hsla"))return t=r.match(/^hsla\s*\(\s*(\d+|\d+.\d+)\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)\s*\)$/i),t?new Color(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100,parseFloat(t[4])):new Color(0,0,0,0);if(o(r,"hsl"))return t=r.match(/^hsl\s*\(\s*(\d+|\d+.\d+)\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*\)$/i),t?new Color(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100):new Color(0,0,0,0);if("none"===r||"null"===r||o(r,"url("))return new Color(0,0,0,0);throw new Error("Color "+r+"can not be parsed")},Color.gray=function(r,o,t){return t=Math.max(t,1),new Color(r/t,r/t,r/t,o/t)},Color.rgb=function(r,o,t,e,s){return s=Math.max(s,1),new Color(r/s,o/s,t/s,e/s)},Color.hsb=function(r,o,t,e,s){return s=Math.max(s,1),new Color(r/s,o/s,t/s,e/s,{mode:HSB})},Color.hsl=function(r,o,t,e,s){return s=Math.max(s,1),new Color(r/s,o/s,t/s,e/s,{mode:HSL})},module.exports=Color; +},{"../objects/color":28,"../objects/path":31,"../objects/point":32,"../objects/text":34,"../util/geo":40,"lodash":3}],28:[function(require,module,exports){ +"use strict";var math=require("../util/math"),color=require("../util/color"),js=require("../util/js"),HSB="HSB",HSL="HSL",HEX="HEX",Color=function(r,o,t,e,s){var n,i,l,a,h,d;void 0===r?(n=i=l=0,a=1):Array.isArray(r)?(d=o||{},n=void 0!==r[0]?r[0]:0,i=void 0!==r[1]?r[1]:0,l=void 0!==r[2]?r[2]:0,a=void 0!==r[3]?r[3]:d.range||1):void 0!==r.r?(d=o||{},n=r.r,i=r.g,l=r.b,a=void 0!==r.a?r.a:d.range||1):"string"==typeof r?(h=color.hex2rgb(r),n=h[0],i=h[1],l=h[2],a=1):"number"==typeof r&&(1===arguments.length?(n=i=l=r,a=1):2===arguments.length?(n=i=l=r,"number"==typeof o?a=o:(d=o,a=d.range||1)):3===arguments.length?"number"==typeof t?(n=r,i=o,l=t,a=1):(n=i=l=r,a=o,d=t):4===arguments.length?(n=r,i=o,l=t,"number"==typeof e?a=e:(d=e,a=d.range||1)):(n=r,i=o,l=t,a=e,d=s)),d=d||{},void 0!==d.range&&(n/=d.range,i/=d.range,l/=d.range,a/=d.range,d.mode===HSB&&(r/=d.range,o/=d.range,t/=d.range)),d.mode===HSB?(r=math.clamp(r,0,1),o=math.clamp(o,0,1),t=math.clamp(t,0,1),h=color.hsb2rgb(r,o,t),n=h[0],i=h[1],l=h[2]):d.mode===HSL?(r=math.clamp(r,0,1),o=math.clamp(o,0,1),t=math.clamp(t,0,1),h=color.hsl2rgb(r,o,t),n=h[0],i=h[1],l=h[2]):d.mode===HEX&&(h=color.hex2rgb(r),n=h[0],i=h[1],l=h[2],a=1),this.r=math.clamp(n,0,1),this.g=math.clamp(i,0,1),this.b=math.clamp(l,0,1),this.a=math.clamp(a,0,1)};Color.BLACK=new Color(0),Color.WHITE=new Color(1),js.defineAlias(Color,"r","red"),js.defineAlias(Color,"g","green"),js.defineAlias(Color,"b","blue"),js.defineAlias(Color,"a","alpha"),js.defineGetter(Color,"h",function(){return color.rgb2hsl(this.r,this.g,this.b)[0]}),js.defineGetter(Color,"s",function(){return color.rgb2hsl(this.r,this.g,this.b)[1]}),js.defineGetter(Color,"l",function(){return color.rgb2hsl(this.r,this.g,this.b)[2]}),js.defineAlias(Color,"h","hue"),js.defineAlias(Color,"s","saturation"),js.defineAlias(Color,"l","lightness"),js.defineGetter(Color,"rgb",function(){return[this.r,this.g,this.b]}),js.defineGetter(Color,"rgba",function(){return[this.r,this.g,this.b,this.a]}),js.defineGetter(Color,"hsb",function(){return color.rgb2hsb(this.r,this.g,this.b)}),js.defineGetter(Color,"hsba",function(){return color.rgb2hsb(this.r,this.g,this.b).concat([this.a])}),js.defineGetter(Color,"hsl",function(){return color.rgb2hsl(this.r,this.g,this.b)}),js.defineGetter(Color,"hsla",function(){return color.rgb2hsl(this.r,this.g,this.b).concat([this.a])}),Color.prototype.toCSS=function(){return Color.toCSS(this)},Color.prototype.toHex=function(){return this.a>=1?color.rgb2hex(this.r,this.g,this.b):color.rgba2hex(this.r,this.g,this.b,this.a)},Color.prototype.desaturate=function(r){if(this.r===this.g&&this.g===this.b)return this;var o,t,e;void 0!==r&&r.method&&"ITU-R BT.601"!==r.method?"ITU-R BT.709"===r.method&&(o=.2125,t=.7154,e=.0721):(o=.3,t=.59,e=.11);var s=this.r*o+this.g*t+this.b*e;return new Color(s,s,s,this.a)},Color.prototype.invert=function(){return new Color(1-this.r,1-this.g,1-this.b,this.a)},Color.clone=function(r){return null===r||void 0===r?null:"string"==typeof r?r:new Color(r.r,r.g,r.b,r.a)},Color.toCSS=function(r){if(null===r)return"none";if(void 0===r)return"black";if("string"==typeof r)return r;if(r instanceof Color){var o=Math.round(255*r.r),t=Math.round(255*r.g),e=Math.round(255*r.b);return"rgba("+o+", "+t+", "+e+", "+r.a+")"}if(void 0!==r.r&&void 0!==r.g&&void 0!==r.b)return void 0===r.a?"rgb("+r.r+", "+r.g+", "+r.b+")":"rgba("+r.r+", "+r.g+", "+r.b+", "+r.a+")";throw new Error("Don't know how to convert "+r+" to CSS.")},Color.toHex=function(r){return Color.parse(r).toHex()},Color.make=function(){var r=Object.create(Color.prototype);return r.constructor=Color.prototype,Color.apply(r,arguments),r},Color.parse=function(r){function o(r,o){return!(!r||!o)&&(r=String(r),0===r.indexOf(o))}var t;if(void 0===r||null===r)return new Color(0,0,0,0);if(r instanceof Color)return r;if(color.namedColors[r])return Color.make.apply(null,color.namedColors[r]);if("#"===r[0])return new Color(r,0,0,0,{mode:HEX});if(o(r,"rgba"))return t=r.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+|\d+.\d+)\s*\)$/i),t?new Color(parseInt(t[1])/255,parseInt(t[2])/255,parseInt(t[3])/255,parseFloat(t[4])):(t=r.match(/^rgba\s*\(\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)\s*\)$/i))?new Color(parseFloat(t[1])/100,parseFloat(t[2])/100,parseFloat(t[3])/100,parseFloat(t[4])):new Color(0,0,0,0);if(o(r,"rgb"))return t=r.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i),t?new Color(parseInt(t[1])/255,parseInt(t[2])/255,parseInt(t[3])/255):(t=r.match(/^rgb\s*\(\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*\)$/i))?new Color(parseFloat(t[1])/100,parseFloat(t[2])/100,parseFloat(t[3])/100):new Color(0,0,0,0);if(o(r,"hsla"))return t=r.match(/^hsla\s*\(\s*(\d+|\d+.\d+)\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)\s*\)$/i),t?new Color(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100,parseFloat(t[4])):new Color(0,0,0,0);if(o(r,"hsl"))return t=r.match(/^hsl\s*\(\s*(\d+|\d+.\d+)\s*,\s*(\d+|\d+.\d+)%\s*,\s*(\d+|\d+.\d+)%\s*\)$/i),t?new Color(parseFloat(t[1])/360,parseFloat(t[2])/100,parseFloat(t[3])/100):new Color(0,0,0,0);if("none"===r||"null"===r||o(r,"url("))return new Color(0,0,0,0);throw new Error("Color "+r+"can not be parsed")},Color.gray=function(r,o,t){return t=Math.max(t,1),new Color(r/t,r/t,r/t,o/t)},Color.rgb=function(r,o,t,e,s){return s=Math.max(s,1),new Color(r/s,o/s,t/s,e/s)},Color.hsb=function(r,o,t,e,s){return s=Math.max(s,1),new Color(r/s,o/s,t/s,e/s,{mode:HSB})},Color.hsl=function(r,o,t,e,s){return s=Math.max(s,1),new Color(r/s,o/s,t/s,e/s,{mode:HSL})},module.exports=Color; },{"../util/color":39,"../util/js":41,"../util/math":42}],29:[function(require,module,exports){ -"use strict";var _=require("lodash"),Path=require("../objects/path"),Rect=require("../objects/rect"),Color=require("../objects/color"),Group=function(t){t?t.shapes||t.commands?this.shapes=[t]:t&&(this.shapes=t):this.shapes=[]};Group.prototype.add=function(t){this.shapes.push(t)},Group.prototype.clone=function(){var t,e=[],r=this.shapes.length;for(e.length=r,t=0;r>t;t+=1)e[t]=this.shapes[t].clone();return new Group(e)},Group.prototype.colorize=function(t){var e=arguments;("object"!=typeof t||t instanceof Color)&&(t={},void 0!==e[0]&&(t.fill=e[0]),void 0!==e[1]&&(t.stroke=e[1]),void 0!==e[2]&&(t.strokeWidth=e[2]));var r=_.map(this.shapes,function(e){return e.colorize(t)});return new Group(r)},Group.prototype.desaturate=function(t){var e=_.map(this.shapes,function(e){return e.desaturate(t)});return new Group(e)},Group.prototype.invert=function(){var t=_.map(this.shapes,function(t){return t.invert()});return new Group(t)},Group.prototype.bounds=function(){if(0===this.shapes.length)return new Rect(0,0,0,0);var t,e,r,o=this.shapes;for(t=0;t"+t.join("")+""},Group.prototype.draw=function(t){var e,r=this.shapes,o=r.length;for(e=0;o>e;e+=1)r[e].draw(t)},module.exports=Group; +"use strict";var _=require("lodash"),Path=require("../objects/path"),Rect=require("../objects/rect"),Color=require("../objects/color"),Group=function(t){t?t.shapes||t.commands?this.shapes=[t]:t&&(this.shapes=t):this.shapes=[]};Group.prototype.add=function(t){this.shapes.push(t)},Group.prototype.clone=function(){var t,e=[],r=this.shapes.length;for(e.length=r,t=0;t"+t.join("")+""},Group.prototype.draw=function(t){var e,r=this.shapes,o=r.length;for(e=0;et;t+=1)o.commands[t]=_cloneCommand(this.commands[t]);return o.fill=Color.clone(this.fill),o.stroke=Color.clone(this.stroke),o.strokeWidth=this.strokeWidth,o},Path.prototype.extend=function(t){var o=t.commands||t;Array.prototype.push.apply(this.commands,o)},Path.prototype.moveTo=function(t,o){this.commands.push({type:MOVETO,x:t,y:o})},Path.prototype.lineTo=function(t,o){this.commands.push({type:LINETO,x:t,y:o})},Path.prototype.curveTo=function(t,o,e,i,s,r){this.commands.push({type:CURVETO,x1:t,y1:o,x2:e,y2:i,x:s,y:r})},Path.prototype.quadTo=function(t,o,e,i){var s=this.commands[this.commands.length-1].x,r=this.commands[this.commands.length-1].y,n=s+2/3*(t-s),h=r+2/3*(o-r),a=n+1/3*(e-s),l=h+1/3*(i-r);this.curveTo(n,h,a,l,e,i)},Path.prototype.closePath=Path.prototype.close=function(){this.commands.push(CLOSE_COMMAND)},Path.prototype.isClosed=function(){return 0===this.commands.length?!1:this.commands[this.commands.length-1].type===CLOSE},Path.prototype.addRect=function(t,o,e,i){this.moveTo(t,o),this.lineTo(t+e,o),this.lineTo(t+e,o+i),this.lineTo(t,o+i),this.close()},Path.prototype.addRoundedRect=function(t,o,e,i,s,r){var n=1-.552,h=s,a=r,l=t,c=t+e,p=o,u=o+i;h=Math.min(h,.5*e),a=Math.min(a,.5*i),this.moveTo(l+h,p),.5*e>h&&this.lineTo(c-s,p),this.curveTo(c-h*n,p,c,p+a*n,c,p+a),.5*i>a&&this.lineTo(c,u-a),this.curveTo(c,u-a*n,c-h*n,u,c-h,u),.5*e>h&&this.lineTo(l+h,u),this.curveTo(l+h*n,u,l,u-a*n,l,u-a),.5*i>a&&this.lineTo(l,p+a),this.curveTo(l,p+a*n,l+h*n,p,l+h,p),this.close()},Path.prototype.addEllipse=function(t,o,e,i){var s=.5*KAPPA*e,r=.5*KAPPA*i,n=t+.5*e,h=o+.5*i,a=t+e,l=o+i;this.moveTo(t,h),this.curveTo(t,h-r,n-s,o,n,o),this.curveTo(n+s,o,a,h-r,a,h),this.curveTo(a,h+r,n+s,l,n,l),this.curveTo(n-s,l,t,h+r,t,h),this.close()},Path.prototype.addLine=function(t,o,e,i){this.moveTo(t,o),this.lineTo(e,i)},Path.prototype.addQuad=function(t,o,e,i,s,r,n,h){this.moveTo(t,o),this.lineTo(e,i),this.lineTo(s,r),this.lineTo(n,h),this.close()},Path.prototype.addArc=function(t,o,e,i,s,r,n){n=n||"pie";var h,a,l,c,p,u,m,d,y,f,v,T,P;for(h=e/2,a=i/2,l=math.radians(s),c=r,c>=360||-360>=c?(p=4,u=Math.PI/2,m=.5522847498307933,0>c&&(u=-u,m=-m)):(p=Math.ceil(Math.abs(c)/90),u=math.radians(c/p),m=4/3*Math.sin(u/2)/(1+Math.cos(u/2)),0===m&&(p=0)),"open"===n?d=0:"chord"===n?d=1:"pie"===n&&(d=2),(0>h||0>a)&&(p=d=-1),y=0;p+d>=y;)f=l,0===y?this.moveTo(t+Math.cos(f)*h,o+Math.sin(f)*a):y>p?y===p+d?this.close():this.lineTo(t,o):(f+=u*(y-1),v=Math.cos(f),T=Math.sin(f),P=[],P.push(t+(v-m*T)*h),P.push(o+(T+m*v)*a),f+=u,v=Math.cos(f),T=Math.sin(f),P.push(t+(v+m*T)*h),P.push(o+(T-m*v)*a),P.push(t+v*h),P.push(o+T*a),Path.prototype.curveTo.apply(this,P)),y+=1},Path.prototype.colorize=function(t){var o=arguments;("object"!=typeof t||t instanceof Color)&&(t={},void 0!==o[0]&&(t.fill=o[0]),void 0!==o[1]&&(t.stroke=o[1]),void 0!==o[2]&&(t.strokeWidth=o[2]));var e=this.clone();return t.fill&&(e.fill=Color.clone(t.fill)),t.stroke&&(e.stroke=Color.clone(t.stroke)),(t.strokeWidth||0===t.strokeWidth)&&(e.strokeWidth=t.strokeWidth),e},Path.prototype.desaturate=function(t){var o=this.clone(),e=o.fill,i=o.stroke;return e instanceof Color||(e=Color.parse(e)),i instanceof Color||(i=Color.parse(i)),o.fill=e.desaturate(t),o.stroke=i.desaturate(t),o},Path.prototype.invert=function(){var t=this.clone(),o=t.fill,e=t.stroke;return o instanceof Color||(o=Color.parse(o)),e instanceof Color||(e=Color.parse(e)),t.fill=o.invert(),t.stroke=e.invert(),t},Path.prototype.contours=function(){var t=[],o=[];return _.each(this.commands,function(e){e.type===MOVETO?(0!==o.length&&t.push(o),o=[e]):o.push(e)}),0!==o.length&&t.push(o),t},Path.prototype.bounds=function(){if(this._bounds)return this._bounds;if(0===this.commands.length)return new Rect(0,0,0,0);var t,o,e,i,s,r=Number.MAX_VALUE,n=Number.MAX_VALUE,h=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return _.each(this.commands,function(l){if(l.type===MOVETO||l.type===LINETO)t=l.x,o=l.y,r>t&&(r=t),n>o&&(n=o),t>h&&(h=t),o>a&&(a=o),e=l;else if(l.type===CURVETO){var c=bezier.extrema(e.x,e.y,l.x1,l.y1,l.x2,l.y2,l.x,l.y);i=c.x+c.width,s=c.y+c.height,c.xh&&(h=i),c.ya&&(a=s),e=l}}),new Rect(r,n,h-r,a-n)},Path.prototype.point=function(t,o){return void 0===o&&(o=bezier.segmentLengths(this.commands,!0,10)),bezier.point(this,t,o)},Path.prototype.points=function(t,o){var e=o&&void 0!==o.start?o.start:0,i=o&&void 0!==o.end?o.end:1;if(0===this.commands.length)return[];t=Math.round(t);var s;s=o&&o.closed?t>1?(i-e)/t:i-e:t>1?(i-e)/(t-1):i-e;for(var r=[],n=bezier.segmentLengths(this.commands,!0,10),h=0;t>h;h+=1)r.push(this.point(e+s*h,n));return r},Path.prototype.length=function(t){return void 0===t&&(t=20),bezier.length(this,t)},Path.prototype.contains=function(t,o,e){var i=this.points(void 0!==e?e:100);return geo.pointInPolygon(i,t,o)},Path.prototype.resampleByAmount=function(t,o){for(var e=o?this.contours():[this.commands],i=new Path([],this.fill,this.stroke,this.strokeWidth),s=0;se;e+=1)i=this.commands[e],i.type===MOVETO?t.moveTo(i.x,i.y):i.type===LINETO?t.lineTo(i.x,i.y):i.type===QUADTO?t.quadraticCurveTo(i.x1,i.y1,i.x,i.y):i.type===CURVETO?t.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type===CLOSE&&t.closePath();null!==this.fill&&void 0!==this.fill&&(t.fillStyle=Color.toCSS(this.fill),t.fill()),null!==this.stroke&&void 0!==this.stroke&&null!==this.strokeWidth&&this.strokeWidth>0&&(t.strokeStyle=Color.toCSS(this.stroke),t.lineWidth=this.strokeWidth,t.stroke())},Path.combine=function(){for(var t=_.flatten(arguments),o=[],e=0;e=360||c<=-360?(p=4,u=Math.PI/2,m=.5522847498307933,c<0&&(u=-u,m=-m)):(p=Math.ceil(Math.abs(c)/90),u=math.radians(c/p),m=4/3*Math.sin(u/2)/(1+Math.cos(u/2)),0===m&&(p=0)),"open"===n?d=0:"chord"===n?d=1:"pie"===n&&(d=2),(h<0||a<0)&&(p=d=-1),y=0;y<=p+d;)f=l,0===y?this.moveTo(t+Math.cos(f)*h,o+Math.sin(f)*a):y>p?y===p+d?this.close():this.lineTo(t,o):(f+=u*(y-1),v=Math.cos(f),T=Math.sin(f),P=[],P.push(t+(v-m*T)*h),P.push(o+(T+m*v)*a),f+=u,v=Math.cos(f),T=Math.sin(f),P.push(t+(v+m*T)*h),P.push(o+(T-m*v)*a),P.push(t+v*h),P.push(o+T*a),Path.prototype.curveTo.apply(this,P)),y+=1},Path.prototype.colorize=function(t){var o=arguments;("object"!=typeof t||t instanceof Color)&&(t={},void 0!==o[0]&&(t.fill=o[0]),void 0!==o[1]&&(t.stroke=o[1]),void 0!==o[2]&&(t.strokeWidth=o[2]));var e=this.clone();return t.fill&&(e.fill=Color.clone(t.fill)),t.stroke&&(e.stroke=Color.clone(t.stroke)),(t.strokeWidth||0===t.strokeWidth)&&(e.strokeWidth=t.strokeWidth),e},Path.prototype.desaturate=function(t){var o=this.clone(),e=o.fill,i=o.stroke;return e instanceof Color||(e=Color.parse(e)),i instanceof Color||(i=Color.parse(i)),o.fill=e.desaturate(t),o.stroke=i.desaturate(t),o},Path.prototype.invert=function(){var t=this.clone(),o=t.fill,e=t.stroke;return o instanceof Color||(o=Color.parse(o)),e instanceof Color||(e=Color.parse(e)),t.fill=o.invert(),t.stroke=e.invert(),t},Path.prototype.contours=function(){var t=[],o=[];return _.each(this.commands,function(e){e.type===MOVETO?(0!==o.length&&t.push(o),o=[e]):o.push(e)}),0!==o.length&&t.push(o),t},Path.prototype.bounds=function(){if(this._bounds)return this._bounds;if(0===this.commands.length)return new Rect(0,0,0,0);var t,o,e,i,s,r=Number.MAX_VALUE,n=Number.MAX_VALUE,h=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return _.each(this.commands,function(l){if(l.type===MOVETO||l.type===LINETO)t=l.x,o=l.y,th&&(h=t),o>a&&(a=o),e=l;else if(l.type===CURVETO){var c=bezier.extrema(e.x,e.y,l.x1,l.y1,l.x2,l.y2,l.x,l.y);i=c.x+c.width,s=c.y+c.height,c.xh&&(h=i),c.ya&&(a=s),e=l}}),new Rect(r,n,h-r,a-n)},Path.prototype.point=function(t,o){return void 0===o&&(o=bezier.segmentLengths(this.commands,!0,10)),bezier.point(this,t,o)},Path.prototype.points=function(t,o){var e=o&&void 0!==o.start?o.start:0,i=o&&void 0!==o.end?o.end:1;if(0===this.commands.length)return[];t=Math.round(t);var s;s=o&&o.closed?t>1?(i-e)/t:i-e:t>1?(i-e)/(t-1):i-e;for(var r=[],n=bezier.segmentLengths(this.commands,!0,10),h=0;h0&&(t.strokeStyle=Color.toCSS(this.stroke),t.lineWidth=this.strokeWidth,t.stroke())},Path.combine=function(){for(var t=_.flatten(arguments),o=[],e=0;e1?i[1]:t,new Point(t,n)):void 0!==i.x&&void 0!==i.y?new Point(i.x,i.y):Point.ZERO},Point.prototype.clone=function(){return new Point(this.x,this.y)},Point.prototype.add=function(t){return new Point(this.x+t.x,this.y+t.y)},Point.prototype.subtract=Point.prototype.sub=function(t){return new Point(this.x-t.x,this.y-t.y)},Point.prototype.divide=function(t){return new Point(this.x/t,this.y/t)},Point.prototype.multiply=function(t){return new Point(this.x*t,this.y*t)},Point.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},Point.prototype.magnitudeSquared=function(){return this.x*this.x+this.y*this.y},Point.prototype.heading=function(){return Math.atan2(this.y,this.x)},Point.prototype.distanceTo=function(t){var n=this.x-t.x,i=this.y-t.y;return Math.sqrt(n*n+i*i)},Point.prototype.normalize=function(){var t=this.magnitude();return 0!==t?this.divide(t):Point.ZERO},Point.prototype.limit=function(t){return this.magnitudeSquared()>t*t?this.normalize().multiply(t):this},Point.prototype.translate=function(t,n){return new Point(this.x+t,this.y+n)},Point.prototype.scale=function(t,n){return n=void 0!==n?n:t,new Point(this.x*t,this.y*n)},Point.prototype.toString=function(){return"["+this.x+", "+this.y+"]"},module.exports=Point; },{}],33:[function(require,module,exports){ -"use strict";var Point=require("../objects/point"),Rect=function(t,i,h,e){this.x=void 0!==t?t:0,this.y=void 0!==i?i:0,this.width=void 0!==h?h:0,this.height=void 0!==e?e:0};Object.defineProperty(Rect.prototype,"xywh",{get:function(){return[this.x,this.y,this.width,this.height]}}),Rect.prototype.normalize=function(){var t=this.x,i=this.y,h=this.width,e=this.height;return 0>h&&(t+=h,h=-h),0>e&&(i+=e,e=-e),new Rect(t,i,h,e)},Rect.prototype.containsPoint=function(t,i){return 1===arguments.length&&(i=t.y,t=t.x),t>=this.x&&t<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},Rect.prototype.containsRect=function(t){return t.x>=this.x&&t.x+t.width<=this.x+this.width&&t.y>=this.y&&t.y+t.height<=this.y+this.height},Rect.prototype.grow=function(t,i){var h=this.x-t,e=this.y-i,s=this.width+2*t,n=this.height+2*i;return new Rect(h,e,s,n)},Rect.prototype.unite=function(t){var i=Math.min(this.x,t.x),h=Math.min(this.y,t.y),e=Math.max(this.x+this.width,t.x+t.width)-i,s=Math.max(this.y+this.height,t.y+t.height)-h;return new Rect(i,h,e,s)},Rect.prototype.addPoint=function(t,i){var h,e,s=this.x,n=this.y,o=this.width,r=this.height;return tthis.x+this.width&&(h=t-(this.x+this.width),o+=h),ithis.y+this.height&&(e=i-(this.y+this.height),r+=e),new Rect(s,n,o,r)},Rect.prototype.centerPoint=function(){return new Point(this.x+this.width/2,this.y+this.height/2)},module.exports=Rect; +"use strict";var Point=require("../objects/point"),Rect=function(t,i,h,e){this.x=void 0!==t?t:0,this.y=void 0!==i?i:0,this.width=void 0!==h?h:0,this.height=void 0!==e?e:0};Object.defineProperty(Rect.prototype,"xywh",{get:function(){return[this.x,this.y,this.width,this.height]}}),Rect.prototype.normalize=function(){var t=this.x,i=this.y,h=this.width,e=this.height;return h<0&&(t+=h,h=-h),e<0&&(i+=e,e=-e),new Rect(t,i,h,e)},Rect.prototype.containsPoint=function(t,i){return 1===arguments.length&&(i=t.y,t=t.x),t>=this.x&&t<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},Rect.prototype.containsRect=function(t){return t.x>=this.x&&t.x+t.width<=this.x+this.width&&t.y>=this.y&&t.y+t.height<=this.y+this.height},Rect.prototype.grow=function(t,i){var h=this.x-t,e=this.y-i,s=this.width+2*t,n=this.height+2*i;return new Rect(h,e,s,n)},Rect.prototype.unite=function(t){var i=Math.min(this.x,t.x),h=Math.min(this.y,t.y),e=Math.max(this.x+this.width,t.x+t.width)-i,s=Math.max(this.y+this.height,t.y+t.height)-h;return new Rect(i,h,e,s)},Rect.prototype.addPoint=function(t,i){var h,e,s=this.x,n=this.y,o=this.width,r=this.height;return tthis.x+this.width&&(h=t-(this.x+this.width),o+=h),ithis.y+this.height&&(e=i-(this.y+this.height),r+=e),new Rect(s,n,o,r)},Rect.prototype.centerPoint=function(){return new Point(this.x+this.width/2,this.y+this.height/2)},module.exports=Rect; },{"../objects/point":32}],34:[function(require,module,exports){ -"use strict";var Color=require("../objects/color"),Rect=require("../objects/rect"),Transform=require("../objects/transform"),_dummyContext=null,gText=function(t){var e,i=Array.prototype.slice.call(arguments,1),n=arguments[1],o=arguments[2],s=arguments[arguments.length-1];this.text=String(t),"number"==typeof n?(this.x=n,this.y=o,i=i.slice(2)):Array.isArray(n)?(this.x=n[0],this.y=n[1],i=i.slice(1)):"object"==typeof n?(this.x=void 0!==n.x?n.x:0,this.y=void 0!==n.y?n.y:0,i=i.slice(1)):(this.x=0,this.y=0),"object"==typeof s?(e=s,n!==s&&(i=i.slice(0,i.length-1))):e={},i.length?this.fontFamily=i.shift():this.fontFamily=e.fontFamily||e.fontName||e.font||"sans-serif",i.length?this.fontSize=i.shift():this.fontSize=e.fontSize||24,i.length?this.textAlign=i.shift():this.textAlign=e.align||e.textAlign||"left",i.length?this.fill=i.shift():this.fill=e.fill||"black",this.transform=new Transform};gText.prototype.clone=function(){var t=new gText;return t.text=this.text,t.x=this.x,t.y=this.y,t.fontFamily=this.fontFamily,t.fontSize=this.fontSize,t.textAlign=this.textAlign,t.fill=Color.clone(this.fill),t.transform=this.transform,t},gText._getDummyContext=function(){return _dummyContext||(_dummyContext="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):{font:"10px sans-serif",measureText:function(t){var e=parseFloat(this.font);return{width:t.length*e*.6}}}),_dummyContext},gText.prototype._getFont=function(){return this.fontSize+"px "+this.fontFamily},gText.prototype.colorize=function(t){var e=this.clone();return e.fill=Color.clone(t),e},gText.prototype.draw=function(t){t.save(),t.font=this._getFont(),t.textAlign=this.textAlign;var e=this.transform.m;t.transform(e[0],e[1],e[3],e[4],e[6],e[7]),t.fillStyle=Color.toCSS(this.fill),t.fillText(this.text,this.x,this.y),t.restore()},gText.prototype.bounds=function(){var t,e=gText._getDummyContext(),i=this.x;return e.font=this._getFont(),t=e.measureText(this.text),"center"===this.textAlign?i=this.x-t.width/2:"right"===this.textAlign&&(i=this.x-t.width),new Rect(i,this.y-this.fontSize,t.width,1.2*this.fontSize)},gText.prototype.toSVG=function(){var t=""},module.exports=gText; +"use strict";var Color=require("../objects/color"),Rect=require("../objects/rect"),Transform=require("../objects/transform"),_dummyContext=null,GText=function(t){var e,i=Array.prototype.slice.call(arguments,1),n=arguments[1],o=arguments[2],s=arguments[arguments.length-1];this.text=String(t),"number"==typeof n?(this.x=n,this.y=o,i=i.slice(2)):Array.isArray(n)?(this.x=n[0],this.y=n[1],i=i.slice(1)):"object"==typeof n?(this.x=void 0!==n.x?n.x:0,this.y=void 0!==n.y?n.y:0,i=i.slice(1)):(this.x=0,this.y=0),"object"==typeof s?(e=s,n!==s&&(i=i.slice(0,i.length-1))):e={},i.length?this.fontFamily=i.shift():this.fontFamily=e.fontFamily||e.fontName||e.font||"sans-serif",i.length?this.fontSize=i.shift():this.fontSize=e.fontSize||24,i.length?this.textAlign=i.shift():this.textAlign=e.align||e.textAlign||"left",i.length?this.fill=i.shift():this.fill=e.fill||"black",this.transform=new Transform};GText.prototype.clone=function(){var t=new GText;return t.text=this.text,t.x=this.x,t.y=this.y,t.fontFamily=this.fontFamily,t.fontSize=this.fontSize,t.textAlign=this.textAlign,t.fill=Color.clone(this.fill),t.transform=this.transform,t},GText._getDummyContext=function(){return _dummyContext||(_dummyContext="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):{font:"10px sans-serif",measureText:function(t){var e=parseFloat(this.font);return{width:t.length*e*.6}}}),_dummyContext},GText.prototype._getFont=function(){return this.fontSize+"px "+this.fontFamily},GText.prototype.colorize=function(t){var e=this.clone();return e.fill=Color.clone(t),e},GText.prototype.draw=function(t){t.save(),t.font=this._getFont(),t.textAlign=this.textAlign;var e=this.transform.m;t.transform(e[0],e[1],e[3],e[4],e[6],e[7]),t.fillStyle=Color.toCSS(this.fill),t.fillText(this.text,this.x,this.y),t.restore()},GText.prototype.bounds=function(){var t,e=GText._getDummyContext(),i=this.x;return e.font=this._getFont(),t=e.measureText(this.text),"center"===this.textAlign?i=this.x-t.width/2:"right"===this.textAlign&&(i=this.x-t.width),new Rect(i,this.y-this.fontSize,t.width,1.2*this.fontSize)},GText.prototype.toSVG=function(){var t=""},module.exports=GText; },{"../objects/color":28,"../objects/rect":33,"../objects/transform":35}],35:[function(require,module,exports){ -"use strict";var _=require("lodash"),bezier=require("../util/bezier"),math=require("../util/math"),Group=require("../objects/group"),Path=require("../objects/path"),Point=require("../objects/point"),MOVETO=bezier.MOVETO,LINETO=bezier.LINETO,QUADTO=bezier.QUADTO,CURVETO=bezier.CURVETO,CLOSE=bezier.CLOSE,Transform=function(r){void 0!==r?this.m=r:this.m=[1,0,0,0,1,0,0,0,1]};Transform.IDENTITY=new Transform,Transform.identity=function(){return new Transform},Transform._mmult=function(r,t){return void 0!==r.m&&(r=r.m),void 0!==t.m&&(t=t.m),new Transform([r[0]*t[0]+r[1]*t[3],r[0]*t[1]+r[1]*t[4],0,r[3]*t[0]+r[4]*t[3],r[3]*t[1]+r[4]*t[4],0,r[6]*t[0]+r[7]*t[3]+t[6],r[6]*t[1]+r[7]*t[4]+t[7],1])},Transform.prototype.isIdentity=function(){var r=this.m;return 1===r[0]&&0===r[1]&&0===r[2]&&0===r[3]&&1===r[4]&&0===r[5]&&0===r[6]&&0===r[7]&&1===r[8]},Transform.prototype.prepend=function(r){return Transform._mmult(this.m,r.m)},Transform.prototype.append=function(r){return Transform._mmult(r.m,this.m)},Transform.prototype.inverse=function(){var r=this.m,t=r[0]*r[4]-r[1]*r[3];return new Transform([r[4]/t,-r[1]/t,0,-r[3]/t,r[0]/t,0,(r[3]*r[7]-r[4]*r[6])/t,-(r[0]*r[7]-r[1]*r[6])/t,1])},Transform.prototype.scale=function(r,t){return void 0===t&&(t=r),Transform._mmult([r,0,0,0,t,0,0,0,1],this.m)},Transform.prototype.translate=function(r,t){return Transform._mmult([1,0,0,0,1,0,r,t,1],this.m)},Transform.prototype.rotate=function(r){var t=Math.cos(math.radians(r)),n=Math.sin(math.radians(r));return Transform._mmult([t,n,0,-n,t,0,0,0,1],this.m)},Transform.prototype.skew=function(r,t){var n=Math.PI*r/180,o=Math.PI*t/180;return Transform._mmult([1,Math.tan(o),0,-Math.tan(n),1,0,0,0,1],this.m)},Transform.prototype.transformPoint=function(r){var t=r.x,n=r.y,o=this.m;return new Point(t*o[0]+n*o[3]+o[6],t*o[1]+n*o[4]+o[7])},Transform.prototype.transformPoints=function(r){var t=this;return _.map(r,function(r){return t.transformPoint(r)})},Transform.prototype.transformPath=function(r){var t,n,o,e=this,s=_.map(r.commands,function(r){if(r.type===MOVETO)return t=e.transformPoint({x:r.x,y:r.y}),{type:MOVETO,x:t.x,y:t.y};if(r.type===LINETO)return t=e.transformPoint({x:r.x,y:r.y}),{type:LINETO,x:t.x,y:t.y};if(r.type===QUADTO)return t=e.transformPoint({x:r.x,y:r.y}),n=e.transformPoint({x:r.x1,y:r.y1}),{type:QUADTO,x1:n.x,y1:n.y,x:t.x,y:t.y};if(r.type===CURVETO)return t=e.transformPoint({x:r.x,y:r.y}),n=e.transformPoint({x:r.x1,y:r.y1}),o=e.transformPoint({x:r.x2,y:r.y2}),{type:CURVETO,x1:n.x,y1:n.y,x2:o.x,y2:o.y,x:t.x,y:t.y};if(r.type===CLOSE)return r;throw new Error("Unknown command type "+r)});return new Path(s,r.fill,r.stroke,r.strokeWidth)},Transform.prototype.transformText=function(r){var t=r.clone();return t.transform=this.append(t.transform),t},Transform.prototype.transformGroup=function(r){var t=this,n=_.map(r.shapes,function(r){return t.transformShape(r)});return new Group(n)},Transform.prototype.transformShape=function(r){var t;if(r.shapes)t=this.transformGroup;else if(r.commands)t=this.transformPath;else if(r.text)t=this.transformText;else if(void 0!==r.x&&void 0!==r.y)t=this.transformPoint;else{if(void 0!==r._transform)return r._transform(this.m);if(!(Array.isArray(r)&&r.length>0))throw new Error("Don't know how to transform "+r);if(void 0===r[0].x||void 0===r[0].y){for(var n=[],o=0;o0))throw new Error("Don't know how to transform "+r);if(void 0===r[0].x||void 0===r[0].y){for(var n=[],o=0;o65535){e-=655 },{}],38:[function(require,module,exports){ -"use strict";var _=require("lodash"),math=require("../util/math"),Point=require("../objects/point"),Rect=require("../objects/rect"),bezier={},MOVETO=bezier.MOVETO="M",LINETO=bezier.LINETO="L";bezier.QUADTO="Q";var CURVETO=bezier.CURVETO="C",CLOSE=bezier.CLOSE="Z";bezier.linePoint=function(e,t,r,n,i){var a=t+e*(n-t),o=r+e*(i-r);return{type:LINETO,x:a,y:o}},bezier.lineLength=function(e,t,r,n){var i=Math.pow(Math.abs(e-r),2),a=Math.pow(Math.abs(t-n),2);return Math.sqrt(i+a)},bezier.curvePoint=function(e,t,r,n,i,a,o,u,h){var s=1-e,b=t*s+n*e,c=r*s+i*e,y=n*s+a*e,m=i*s+o*e,x=a*s+u*e,z=o*s+h*e,O=b*s+y*e,v=c*s+m*e,p=y*s+x*e,M=m*s+z*e,E=O*s+p*e,L=v*s+M*e;return{type:CURVETO,x1:O,y1:v,x2:p,y2:M,x:E,y:L}},bezier.curveLength=function(e,t,r,n,i,a,o,u,h){void 0===h&&(h=20);var s,b,c,y=0,m=e,x=t;for(s=0;h>s;s+=1)b=(s+1)/h,c=bezier.curvePoint(b,e,t,r,n,i,a,o,u),y+=Math.sqrt(Math.pow(Math.abs(m-c.x),2)+Math.pow(Math.abs(x-c.y),2)),m=c.x,x=c.y;return y},bezier.segmentLengths=function(e,t,r){t=void 0!==t?t:!1,void 0===r&&(r=20);var n,i,a,o,u,h,s,b,c;for(c=[],n=0;n0?_.map(c,function(e){return e/b}):_.map(c,function(){return 0})):c},bezier.length=function(e,t){return t=t||20,math.sum(bezier.segmentLengths(e.commands,!1,t))},bezier._locate=function(e,t,r){var n,i,a;for(void 0===r&&(r=bezier.segmentLengths(e.commands,!0)),n=0;n=0&&1>=e){var t=b(e);t.xm&&(m=t.x),t.yz&&(z=t.y)}}var y,m,x,z,O,v,p,M,E,L,f,g,l,T;return o>e?(y=e,m=o):(y=o,m=e),u>t?(x=t,z=u):(x=u,z=t),O=3*(-e+3*r-3*i+o),v=6*(e-2*r+i),p=3*(-e+r),h(O+1,1)?h(v+1,1)||c(-p/v):(l=v*v-4*O*p,l>=0&&(f=Math.sqrt(l),g=1/(2*O),c((-v+f)*g),c((-v-f)*g))),M=3*(-t+3*n-3*a+u),E=6*(t-2*n+a),L=3*(-t+n),h(M+1,1)?h(E+1,1)||c(-L/E):(T=E*E-4*M*L,T>0&&(f=Math.sqrt(T),g=1/(2*M),c((-E+f)*g),c((-E-f)*g))),new Rect(y,x,m-y,z-x)},module.exports=bezier; +"use strict";var _=require("lodash"),math=require("../util/math"),Point=require("../objects/point"),Rect=require("../objects/rect"),bezier={},MOVETO=bezier.MOVETO="M",LINETO=bezier.LINETO="L";bezier.QUADTO="Q";var CURVETO=bezier.CURVETO="C",CLOSE=bezier.CLOSE="Z";bezier.linePoint=function(e,t,r,n,i){var a=t+e*(n-t),o=r+e*(i-r);return{type:LINETO,x:a,y:o}},bezier.lineLength=function(e,t,r,n){var i=Math.pow(Math.abs(e-r),2),a=Math.pow(Math.abs(t-n),2);return Math.sqrt(i+a)},bezier.curvePoint=function(e,t,r,n,i,a,o,u,h){var s=1-e,b=t*s+n*e,c=r*s+i*e,y=n*s+a*e,m=i*s+o*e,x=a*s+u*e,z=o*s+h*e,O=b*s+y*e,v=c*s+m*e,p=y*s+x*e,M=m*s+z*e,E=O*s+p*e,L=v*s+M*e;return{type:CURVETO,x1:O,y1:v,x2:p,y2:M,x:E,y:L}},bezier.curveLength=function(e,t,r,n,i,a,o,u,h){void 0===h&&(h=20);var s,b,c,y=0,m=e,x=t;for(s=0;s0?_.map(c,function(e){return e/b}):_.map(c,function(){return 0})):c},bezier.length=function(e,t){return t=t||20,math.sum(bezier.segmentLengths(e.commands,!1,t))},bezier._locate=function(e,t,r){var n,i,a;for(void 0===r&&(r=bezier.segmentLengths(e.commands,!0)),n=0;n=0&&e<=1){var t=b(e);t.xm&&(m=t.x),t.yz&&(z=t.y)}}var y,m,x,z,O,v,p,M,E,L,f,g,l,T;return e=0&&(f=Math.sqrt(l),g=1/(2*O),c((-v+f)*g),c((-v-f)*g))),M=3*(-t+3*n-3*a+u),E=6*(t-2*n+a),L=3*(-t+n),h(M+1,1)?h(E+1,1)||c(-L/E):(T=E*E-4*M*L,T>0&&(f=Math.sqrt(T),g=1/(2*M),c((-E+f)*g),c((-E-f)*g))),new Rect(y,x,m-y,z-x)},module.exports=bezier; -},{"../objects/point":32,"../objects/rect":33,"../util/math":42,"lodash":4}],39:[function(require,module,exports){ -"use strict";function toHex(e){var r;return 0===e?"00":(r=e.toString(16).toUpperCase(),r.length<2&&(r="0"+r),r)}var color={};color.namedColors={lightpink:[1,.71,.76],pink:[1,.75,.8],crimson:[.86,.08,.24],lavenderblush:[1,.94,.96],palevioletred:[.86,.44,.58],hotpink:[1,.41,.71],deeppink:[1,.08,.58],mediumvioletred:[.78,.08,.52],orchid:[.85,.44,.84],thistle:[.85,.75,.85],plum:[.87,.63,.87],violet:[.93,.51,.93],fuchsia:[1,0,1],darkmagenta:[.55,0,.55],purple:[.5,0,.5],mediumorchid:[.73,.33,.83],darkviolet:[.58,0,.83],darkorchid:[.6,.2,.8],indigo:[.29,0,.51],blueviolet:[.54,.17,.89],mediumpurple:[.58,.44,.86],mediumslateblue:[.48,.41,.93],slateblue:[.42,.35,.8],darkslateblue:[.28,.24,.55],ghostwhite:[.97,.97,1],lavender:[.9,.9,.98],blue:[0,0,1],mediumblue:[0,0,.8],darkblue:[0,0,.55],navy:[0,0,.5],midnightblue:[.1,.1,.44],royalblue:[.25,.41,.88],cornflowerblue:[.39,.58,.93],lightsteelblue:[.69,.77,.87],lightslategray:[.47,.53,.6],slategray:[.44,.5,.56],dodgerblue:[.12,.56,1],aliceblue:[.94,.97,1],steelblue:[.27,.51,.71],lightskyblue:[.53,.81,.98],skyblue:[.53,.81,.92],deepskyblue:[0,.75,1],lightblue:[.68,.85,.9],powderblue:[.69,.88,.9],cadetblue:[.37,.62,.63],darkturquoise:[0,.81,.82],azure:[.94,1,1],lightcyan:[.88,1,1],paleturquoise:[.69,.93,.93],aqua:[0,1,1],darkcyan:[0,.55,.55],teal:[0,.5,.5],darkslategray:[.18,.31,.31],mediumturquoise:[.28,.82,.8],lightseagreen:[.13,.7,.67],turquoise:[.25,.88,.82],aquamarine:[.5,1,.83],mediumaquamarine:[.4,.8,.67],mediumspringgreen:[0,.98,.6],mintcream:[.96,1,.98],springgreen:[0,1,.5],mediumseagreen:[.24,.7,.44],seagreen:[.18,.55,.34],honeydew:[.94,1,.94],darkseagreen:[.56,.74,.56],palegreen:[.6,.98,.6],lightgreen:[.56,.93,.56],limegreen:[.2,.8,.2],lime:[0,1,0],forestgreen:[.13,.55,.13],green:[0,.5,0],darkgreen:[0,.39,0],lawngreen:[.49,.99,0],chartreuse:[.5,1,0],greenyellow:[.68,1,.18],darkolivegreen:[.33,.42,.18],yellowgreen:[.6,.8,.2],olivedrab:[.42,.56,.14],ivory:[1,1,.94],beige:[.96,.96,.86],lightyellow:[1,1,.88],lightgoldenrodyellow:[.98,.98,.82],yellow:[1,1,0],olive:[.5,.5,0],darkkhaki:[.74,.72,.42],palegoldenrod:[.93,.91,.67],lemonchiffon:[1,.98,.8],khaki:[.94,.9,.55],gold:[1,.84,0],cornsilk:[1,.97,.86],goldenrod:[.85,.65,.13],darkgoldenrod:[.72,.53,.04],floralwhite:[1,.98,.94],oldlace:[.99,.96,.9],wheat:[.96,.87,.07],orange:[1,.65,0],moccasin:[1,.89,.71],papayawhip:[1,.94,.84],blanchedalmond:[1,.92,.8],navajowhite:[1,.87,.68],antiquewhite:[.98,.92,.84],tan:[.82,.71,.55],burlywood:[.87,.72,.53],darkorange:[1,.55,0],bisque:[1,.89,.77],linen:[.98,.94,.9],peru:[.8,.52,.25],peachpuff:[1,.85,.73],sandybrown:[.96,.64,.38],chocolate:[.82,.41,.12],saddlebrown:[.55,.27,.07],seashell:[1,.96,.93],sienna:[.63,.32,.18],lightsalmon:[1,.63,.48],coral:[1,.5,.31],orangered:[1,.27,0],darksalmon:[.91,.59,.48],tomato:[1,.39,.28],salmon:[.98,.5,.45],mistyrose:[1,.89,.88],lightcoral:[.94,.5,.5],snow:[1,.98,.98],rosybrown:[.74,.56,.56],indianred:[.8,.36,.36],red:[1,0,0],brown:[.65,.16,.16],firebrick:[.7,.13,.13],darkred:[.55,0,0],maroon:[.5,0,0],white:[1,1,1],whitesmoke:[.96,.96,.96],gainsboro:[.86,.86,.86],lightgrey:[.83,.83,.83],silver:[.75,.75,.75],darkgray:[.66,.66,.66],gray:[.5,.5,.5],grey:[.5,.5,.5],dimgray:[.41,.41,.41],dimgrey:[.41,.41,.41],black:[0,0,0],cyan:[0,.68,.94],transparent:[0,0,0,0],bark:[.25,.19,.13]},color.rgb2hex=function(e,r,a){return"#"+toHex(Math.round(255*e))+toHex(Math.round(255*r))+toHex(Math.round(255*a))},color.rgba2hex=function(e,r,a,o){return"#"+toHex(Math.round(255*e))+toHex(Math.round(255*r))+toHex(Math.round(255*a))+toHex(Math.round(255*o))},color.hex2rgb=function(e){var r,a,o,l;return e=e.replace(/^#/,""),e.length<6&&(r=[],r.length=6-e.length,e+=r.join(e.substr(e.length-1))),a=parseInt(e.substr(0,2),16)/255,o=parseInt(e.substr(2,2),16)/255,l=parseInt(e.substr(4,2),16)/255,[a,o,l]},color.rgb2hsb=function(e,r,a){var o=0,l=0,n=Math.max(e,r,a),t=n-Math.min(e,r,a);return 0!==n&&(l=t/n),0!==l&&(o=e===n?0+(r-a)/t:r===n?2+(a-e)/t:4+(e-r)/t),o*=60/360,0>o&&(o+=1),[o,l,n]},color.hsb2rgb=function(e,r,a){if(0===r)return[a,a,a];e=e%1*6;var o=Math.floor(e),l=e-o,n=a*(1-r),t=a*(1-r*l),i=a*(1-r*(1-l));return o>4?[a,n,t]:[[a,i,n],[t,a,n],[n,a,i],[n,t,a],[i,n,a]][parseInt(o,10)]},color.rgb2hsl=function(e,r,a){var o,l,n,t=Math.min(e,r,a),i=Math.max(e,r,a),u=i-t;return i===t?o=0:e===i?o=(r-a)/u:r===i?o=2+(a-e)/u:a===i&&(o=4+(e-r)/u),o=Math.min(60*o,360),0>o&&(o+=360),n=(t+i)/2,l=i===t?0:.5>=n?u/(i+t):u/(2-i-t),[o/360,l,n]},color.hsl2rgb=function(e,r,a){var o,l,n,t,i;if(0===r)return i=a,[i,i,i];l=.5>a?a*(1+r):a+r-a*r,o=2*a-l,t=[0,0,0];for(var u=0;3>u;u++)n=e+1/3*-(u-1),0>n&&(n+=1),n>1&&(n-=1),i=1>6*n?o+6*(l-o)*n:1>2*n?l:2>3*n?o+(l-o)*(2/3-n)*6:o,t[u]=i;return t},module.exports=color; +},{"../objects/point":32,"../objects/rect":33,"../util/math":42,"lodash":3}],39:[function(require,module,exports){ +"use strict";function toHex(e){var r;return 0===e?"00":(r=e.toString(16).toUpperCase(),r.length<2&&(r="0"+r),r)}var color={};color.namedColors={lightpink:[1,.71,.76],pink:[1,.75,.8],crimson:[.86,.08,.24],lavenderblush:[1,.94,.96],palevioletred:[.86,.44,.58],hotpink:[1,.41,.71],deeppink:[1,.08,.58],mediumvioletred:[.78,.08,.52],orchid:[.85,.44,.84],thistle:[.85,.75,.85],plum:[.87,.63,.87],violet:[.93,.51,.93],fuchsia:[1,0,1],darkmagenta:[.55,0,.55],purple:[.5,0,.5],mediumorchid:[.73,.33,.83],darkviolet:[.58,0,.83],darkorchid:[.6,.2,.8],indigo:[.29,0,.51],blueviolet:[.54,.17,.89],mediumpurple:[.58,.44,.86],mediumslateblue:[.48,.41,.93],slateblue:[.42,.35,.8],darkslateblue:[.28,.24,.55],ghostwhite:[.97,.97,1],lavender:[.9,.9,.98],blue:[0,0,1],mediumblue:[0,0,.8],darkblue:[0,0,.55],navy:[0,0,.5],midnightblue:[.1,.1,.44],royalblue:[.25,.41,.88],cornflowerblue:[.39,.58,.93],lightsteelblue:[.69,.77,.87],lightslategray:[.47,.53,.6],slategray:[.44,.5,.56],dodgerblue:[.12,.56,1],aliceblue:[.94,.97,1],steelblue:[.27,.51,.71],lightskyblue:[.53,.81,.98],skyblue:[.53,.81,.92],deepskyblue:[0,.75,1],lightblue:[.68,.85,.9],powderblue:[.69,.88,.9],cadetblue:[.37,.62,.63],darkturquoise:[0,.81,.82],azure:[.94,1,1],lightcyan:[.88,1,1],paleturquoise:[.69,.93,.93],aqua:[0,1,1],darkcyan:[0,.55,.55],teal:[0,.5,.5],darkslategray:[.18,.31,.31],mediumturquoise:[.28,.82,.8],lightseagreen:[.13,.7,.67],turquoise:[.25,.88,.82],aquamarine:[.5,1,.83],mediumaquamarine:[.4,.8,.67],mediumspringgreen:[0,.98,.6],mintcream:[.96,1,.98],springgreen:[0,1,.5],mediumseagreen:[.24,.7,.44],seagreen:[.18,.55,.34],honeydew:[.94,1,.94],darkseagreen:[.56,.74,.56],palegreen:[.6,.98,.6],lightgreen:[.56,.93,.56],limegreen:[.2,.8,.2],lime:[0,1,0],forestgreen:[.13,.55,.13],green:[0,.5,0],darkgreen:[0,.39,0],lawngreen:[.49,.99,0],chartreuse:[.5,1,0],greenyellow:[.68,1,.18],darkolivegreen:[.33,.42,.18],yellowgreen:[.6,.8,.2],olivedrab:[.42,.56,.14],ivory:[1,1,.94],beige:[.96,.96,.86],lightyellow:[1,1,.88],lightgoldenrodyellow:[.98,.98,.82],yellow:[1,1,0],olive:[.5,.5,0],darkkhaki:[.74,.72,.42],palegoldenrod:[.93,.91,.67],lemonchiffon:[1,.98,.8],khaki:[.94,.9,.55],gold:[1,.84,0],cornsilk:[1,.97,.86],goldenrod:[.85,.65,.13],darkgoldenrod:[.72,.53,.04],floralwhite:[1,.98,.94],oldlace:[.99,.96,.9],wheat:[.96,.87,.07],orange:[1,.65,0],moccasin:[1,.89,.71],papayawhip:[1,.94,.84],blanchedalmond:[1,.92,.8],navajowhite:[1,.87,.68],antiquewhite:[.98,.92,.84],tan:[.82,.71,.55],burlywood:[.87,.72,.53],darkorange:[1,.55,0],bisque:[1,.89,.77],linen:[.98,.94,.9],peru:[.8,.52,.25],peachpuff:[1,.85,.73],sandybrown:[.96,.64,.38],chocolate:[.82,.41,.12],saddlebrown:[.55,.27,.07],seashell:[1,.96,.93],sienna:[.63,.32,.18],lightsalmon:[1,.63,.48],coral:[1,.5,.31],orangered:[1,.27,0],darksalmon:[.91,.59,.48],tomato:[1,.39,.28],salmon:[.98,.5,.45],mistyrose:[1,.89,.88],lightcoral:[.94,.5,.5],snow:[1,.98,.98],rosybrown:[.74,.56,.56],indianred:[.8,.36,.36],red:[1,0,0],brown:[.65,.16,.16],firebrick:[.7,.13,.13],darkred:[.55,0,0],maroon:[.5,0,0],white:[1,1,1],whitesmoke:[.96,.96,.96],gainsboro:[.86,.86,.86],lightgrey:[.83,.83,.83],silver:[.75,.75,.75],darkgray:[.66,.66,.66],gray:[.5,.5,.5],grey:[.5,.5,.5],dimgray:[.41,.41,.41],dimgrey:[.41,.41,.41],black:[0,0,0],cyan:[0,.68,.94],transparent:[0,0,0,0],bark:[.25,.19,.13]},color.rgb2hex=function(e,r,a){return"#"+toHex(Math.round(255*e))+toHex(Math.round(255*r))+toHex(Math.round(255*a))},color.rgba2hex=function(e,r,a,o){return"#"+toHex(Math.round(255*e))+toHex(Math.round(255*r))+toHex(Math.round(255*a))+toHex(Math.round(255*o))},color.hex2rgb=function(e){var r,a,o;if(e=e.replace(/^#/,""),3!==e.length&&6!==e.length||!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex value: #"+e);return 3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),r=parseInt(e.substr(0,2),16)/255,a=parseInt(e.substr(2,2),16)/255,o=parseInt(e.substr(4,2),16)/255,[r,a,o]},color.rgb2hsb=function(e,r,a){var o=0,l=0,n=Math.max(e,r,a),t=n-Math.min(e,r,a);return 0!==n&&(l=t/n),0!==l&&(o=e===n?0+(r-a)/t:r===n?2+(a-e)/t:4+(e-r)/t),o*=60/360,o<0&&(o+=1),[o,l,n]},color.hsb2rgb=function(e,r,a){if(0===r)return[a,a,a];e=e%1*6;var o=Math.floor(e),l=e-o,n=a*(1-r),t=a*(1-r*l),i=a*(1-r*(1-l));return o>4?[a,n,t]:[[a,i,n],[t,a,n],[n,a,i],[n,t,a],[i,n,a]][parseInt(o,10)]},color.rgb2hsl=function(e,r,a){var o,l,n,t=Math.min(e,r,a),i=Math.max(e,r,a),u=i-t;return i===t?o=0:e===i?o=(r-a)/u:r===i?o=2+(a-e)/u:a===i&&(o=4+(e-r)/u),o=Math.min(60*o,360),o<0&&(o+=360),n=(t+i)/2,l=i===t?0:n<=.5?u/(i+t):u/(2-i-t),[o/360,l,n]},color.hsl2rgb=function(e,r,a){var o,l,n,t,i;if(0===r)return i=a,[i,i,i];l=a<.5?a*(1+r):a+r-a*r,o=2*a-l,t=[0,0,0];for(var u=0;u<3;u++)n=e+1/3*-(u-1),n<0&&(n+=1),n>1&&(n-=1),i=6*n<1?o+6*(l-o)*n:2*n<1?l:3*n<2?o+(l-o)*(2/3-n)*6:o,t[u]=i;return t},module.exports=color; },{}],40:[function(require,module,exports){ -"use strict";var math=require("../util/math"),Point=require("../objects/point"),geo={};geo.angle=function(t,n,e,o){return math.degrees(Math.atan2(o-n,e-t))},geo.distance=function(t,n,e,o){return Math.sqrt(Math.pow(e-t,2)+Math.pow(o-n,2))},geo.coordinates=function(t,n,e,o){var a=t+Math.cos(math.radians(e))*o,r=n+Math.sin(math.radians(e))*o;return new Point(a,r)},geo.pointInPolygon=function(t,n,e){var o,a,r,i,u,h,s=!1,g=t.length;for(o=0;g>o;o+=1)a=g-1>o?o+1:0,r=t[o].x,i=t[o].y,u=t[a].x,h=t[a].y,(e>i&&h>=e||e>h&&i>=e)&&n>r+(e-i)/(h-i)*(u-r)&&(s=!s);return s},module.exports=geo; +"use strict";var math=require("../util/math"),Point=require("../objects/point"),geo={};geo.angle=function(t,n,e,o){return math.degrees(Math.atan2(o-n,e-t))},geo.distance=function(t,n,e,o){return Math.sqrt(Math.pow(e-t,2)+Math.pow(o-n,2))},geo.coordinates=function(t,n,e,o){var a=t+Math.cos(math.radians(e))*o,r=n+Math.sin(math.radians(e))*o;return new Point(a,r)},geo.pointInPolygon=function(t,n,e){var o,a,r,i,u,h,s=!1,g=t.length;for(o=0;o=e||h=e)&&r+(e-i)/(h-i)*(u-r)65535){e-=655 },{}],42:[function(require,module,exports){ -"use strict";function _fade(r){return r*r*r*(r*(6*r-15)+10)}function _grad(r,t,n,a){var e,o,u;return e=15&r,o=8>e?t:n,u=4>e?n:12===e||14===e?t:a,(0===(1&e)?o:-o)+(0===(2&e)?u:-u)}function _scale(r){return(1+r)/2}var math={};math.sum=function(r){var t,n=r.length,a=0;for(t=0;n>t;t+=1)a+=r[t];return a},math.round=function(r,t){return t?Math.round(r*Math.pow(10,t))/Math.pow(10,t):Math.round(r)},math.sign=function(r){return 0>r?-1:r>0?1:0},math.degrees=function(r){return 180*r/Math.PI},math.radians=function(r){return r/180*Math.PI},math.clamp=function(r,t,n){return n>t?t>r?t:r>n?n:r:n>r?n:r>t?t:r},math.snap=function(r,t,n){return n=void 0!==n?n:1,r*(1-n)+n*Math.round(r/t)*t},math.dot=function(r,t){var n,a=Math.min(r.length,t.length),e=0;for(n=0;a>n;n+=1)e+=r[n]*t[n];return e};var _lerp=math.mix=math.lerp=function(r,t,n,a){if(a){if(0>n)return r;if(n>1)return t}return r+(t-r)*n},_permutation=function(){var r,t,n;for(r=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],t=new Uint8Array(512),n=0;256>n;n+=1)t[256+n]=t[n]=r[n];return t}();math.noise=function(r,t,n){var a=_permutation,e=255&Math.floor(r),o=255&Math.floor(t),u=255&Math.floor(n);r-=Math.floor(r),t-=Math.floor(t),n-=Math.floor(n);var f=_fade(r),h=_fade(t),i=_fade(n),_=a[e]+o,d=a[_]+u,l=a[_+1]+u,m=a[e+1]+o,c=a[m]+u,p=a[m+1]+u;return _scale(_lerp(_lerp(_lerp(_grad(a[d],r,t,n),_grad(a[c],r-1,t,n),f),_lerp(_grad(a[l],r,t-1,n),_grad(a[p],r-1,t-1,n),f),h),_lerp(_lerp(_grad(a[d+1],r,t,n-1),_grad(a[c+1],r-1,t,n-1),f),_lerp(_grad(a[l+1],r,t-1,n-1),_grad(a[p+1],r-1,t-1,n-1),f),h),i))},module.exports=math; +"use strict";function _fade(r){return r*r*r*(r*(6*r-15)+10)}function _grad(r,t,n,a){var e,o,u;return e=15&r,o=e<8?t:n,u=e<4?n:12===e||14===e?t:a,(0===(1&e)?o:-o)+(0===(2&e)?u:-u)}function _scale(r){return(1+r)/2}var math={};math.sum=function(r){var t,n=r.length,a=0;for(t=0;t0?1:0},math.degrees=function(r){return 180*r/Math.PI},math.radians=function(r){return r/180*Math.PI},math.clamp=function(r,t,n){return tn?n:r:rt?t:r},math.snap=function(r,t,n){return n=void 0!==n?n:1,r*(1-n)+n*Math.round(r/t)*t},math.dot=function(r,t){var n,a=Math.min(r.length,t.length),e=0;for(n=0;n1)return t}return r+(t-r)*n},_permutation=function(){var r,t,n;for(r=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],t=new Uint8Array(512),n=0;n<256;n+=1)t[256+n]=t[n]=r[n];return t}();math.noise=function(r,t,n){var a=_permutation,e=255&Math.floor(r),o=255&Math.floor(t),u=255&Math.floor(n);r-=Math.floor(r),t-=Math.floor(t),n-=Math.floor(n);var f=_fade(r),h=_fade(t),i=_fade(n),_=a[e]+o,d=a[_]+u,l=a[_+1]+u,m=a[e+1]+o,c=a[m]+u,p=a[m+1]+u;return _scale(_lerp(_lerp(_lerp(_grad(a[d],r,t,n),_grad(a[c],r-1,t,n),f),_lerp(_grad(a[l],r,t-1,n),_grad(a[p],r-1,t-1,n),f),h),_lerp(_lerp(_grad(a[d+1],r,t,n-1),_grad(a[c+1],r-1,t,n-1),f),_lerp(_grad(a[l+1],r,t-1,n-1),_grad(a[p+1],r-1,t-1,n-1),f),h),i))},module.exports=math; },{}],43:[function(require,module,exports){ -"use strict";function generator(r){if(0>r){for(var e=generator(Math.abs(r)),t=0;23>t;t+=1)e();return generator(e(0,1e4))}return function(e,t){e=e||0,t=t||1,r=(9301*r+49297)%233280;var n=r/233280;return e+n*(t-e)}}exports.generator=generator; +"use strict";function generator(r){if(r<0){for(var e=generator(Math.abs(r)),t=0;t<23;t+=1)e();return generator(e(0,1e4))}return function(e,t){e=e||0,t=t||1,r=(9301*r+49297)%233280;var n=r/233280;return e+n*(t-e)}}exports.generator=generator; },{}],44:[function(require,module,exports){ -"use strict";var _=require("lodash"),xmldom=require("xmldom"),Color=require("../objects/color"),Group=require("../objects/group"),Path=require("../objects/path"),Point=require("../objects/point"),Transform=require("../objects/transform"),trim=function(t){return t.replace(/^\s+|\s+$/g,"")},compressSpaces=function(t){return t.replace(/[\s\r\t\n]+/gm," ")},toNumberArray=function(t){var e,r=trim(compressSpaces((t||"").replace(/,/g," "))).split(" ");for(e=0;e0){for(d=new Transform,m=0;m0&&void 0===r&&(r="black");var a=e.fillOpacity,o=e.stroke,n=e.strokeOpacity,i=e.opacity,s=e.strokeWidth,c=e.transform,l=e.color;"currentColor"===r&&(r=void 0===l?"black":l),void 0!==r&&(r=Color.parse(r),void 0!==a&&(r.a*=a),void 0!==i&&(r.a*=i)),"currentColor"===o&&(o=void 0===l?"black":l),void 0!==o&&(o=Color.parse(o),void 0!==n&&(o.a*=n),void 0!==i&&(o.a*=i));var u;u=c?c.transformShape(t).commands:t.commands;var d=void 0===r?t.fill:r,m=void 0===o?t.stroke:o,p=void 0===s?t.strokeWidth:s;return void 0!==p&&void 0!==c&&(p*=c.m[0]),new Path(u,d,m,p)},arcToSegments=function(t,e,r,a,o,n,i,s,c){var l,u,d,m,p,v,h,g,f,b,y,A,C,k,x,S,P,w,M,T,F,E,q,$,O,V,L;for(l=i*(Math.PI/180),u=Math.sin(l),d=Math.cos(l),r=Math.abs(r),a=Math.abs(a),m=d*(s-t)*.5+u*(c-e)*.5,p=d*(c-e)*.5-u*(s-t)*.5,v=m*m/(r*r)+p*p/(a*a),v>1&&(v=Math.sqrt(v),r*=v,a*=v),h=d/r,g=u/r,f=-u/a,b=d/a,y=h*s+g*c,A=f*s+b*c,C=h*t+g*e,k=f*t+b*e,x=(C-y)*(C-y)+(k-A)*(k-A),S=1/x-.25,0>S&&(S=0),P=Math.sqrt(S),n===o&&(P=-P),w=.5*(y+C)-P*(k-A),M=.5*(A+k)+P*(C-y),T=Math.atan2(A-M,y-w),F=Math.atan2(k-M,C-w),E=F-T,0>E&&1===n?E+=2*Math.PI:E>0&&0===n&&(E-=2*Math.PI),q=Math.ceil(Math.abs(E/(.5*Math.PI+.001))),$=[],L=0;q>L;L+=1)O=T+L*E/q,V=T+(L+1)*E/q,$[L]=[w,M,O,V,r,a,u,d];return $},segmentToBezier=function(t,e,r,a,o,n,i,s){var c=s*o,l=-i*n,u=i*o,d=s*n,m=.5*(a-r),p=8/3*Math.sin(.5*m)*Math.sin(.5*m)/Math.sin(m),v=t+Math.cos(r)-p*Math.sin(r),h=e+Math.sin(r)+p*Math.cos(r),g=t+Math.cos(a),f=e+Math.sin(a),b=g+p*Math.sin(a),y=f-p*Math.cos(a);return[c*v+l*h,u*v+d*h,c*b+l*y,u*b+d*y,c*g+l*f,u*g+d*f]},read={svg:function(){return read.g.apply(this,arguments)},g:function(t,e){var r=[],a=readSvgAttributes(t,e);return _.each(t.childNodes,function(t){var e,o,n;e=t.nodeName,e&&(o=e.replace(/svg\:/gi,"").toLowerCase(),void 0!==read[o]&&(n=read[o].call(this,t,a),r.push(n)))}),new Group(r)},_polyline:function(t){var e=t.getAttribute("points"),r=new Path;return e.replace(/([\d\.?]+),([\d\.?]+)/g,function(t,e,a){var o=parseFloat(e),n=parseFloat(a);0===r.commands.length?r.moveTo(o,n):r.lineTo(o,n)}),r},polygon:function(t,e){var r=readSvgAttributes(t,e),a=read._polyline(t);return a.close(),applySvgAttributes(a,r)},polyline:function(t,e){var r=readSvgAttributes(t,e),a=read._polyline(t);return applySvgAttributes(a,r)},rect:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("x")),o=parseFloat(t.getAttribute("y"));a||(a=0),o||(o=0);var n=parseFloat(t.getAttribute("width")),i=parseFloat(t.getAttribute("height"));n||(n=0),i||(i=0),0>n&&(console.error('Error: invalid negative value for attribute width="'+n+'"'),n=0),0>i&&(console.error('Error: invalid negative value for attribute height="'+i+'"'),i=0);var s=parseFloat(t.getAttribute("rx")),c=parseFloat(t.getAttribute("ry"));s||(s=0),c||(c=0),0>s&&(console.error('Error: invalid negative value for attribute rx="'+s+'"'),s=0),0>c&&(console.error('Error: invalid negative value for attribute ry="'+c+'"'),c=0),s&&c||(s=c=Math.max(s,c)),s>n/2&&(s=n/2),c>i/2&&(c=i/2);var l=new Path;return s&&c?l.addRoundedRect(a,o,n,i,s,c):l.addRect(a,o,n,i),applySvgAttributes(l,r)},ellipse:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("cx")),o=parseFloat(t.getAttribute("cy"));a||(a=0),o||(o=0);var n=parseFloat(t.getAttribute("rx")),i=parseFloat(t.getAttribute("ry"));n||(n=0),i||(i=0),0>n&&(console.error('Error: invalid negative value for attribute rx="'+n+'"'),n=0),0>i&&(console.error('Error: invalid negative value for attribute ry="'+i+'"'),i=0);var s=new Path;return s.addEllipse(a-n,o-i,2*n,2*i),applySvgAttributes(s,r)},circle:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("cx")),o=parseFloat(t.getAttribute("cy"));a||(a=0),o||(o=0);var n=parseFloat(t.getAttribute("r"));n||(n=0),0>n&&(console.error('Error: invalid negative value for attribute r="'+n+'"'),n=0);var i=new Path;return i.addEllipse(a-n,o-n,2*n,2*n),applySvgAttributes(i,r)},line:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("x1")),o=parseFloat(t.getAttribute("y1")),n=parseFloat(t.getAttribute("x2")),i=parseFloat(t.getAttribute("y2"));a||(a=0),o||(o=0),n||(n=0),i||(i=0);var s=new Path;return s.addLine(a,o,n,i),applySvgAttributes(s,r)},path:function(t,e){var r,a,o,n,i,s,c,l,u,d,m,p,v,h,g,f,b,y,A,C,k,x,S,P=readSvgAttributes(t,e);r=t.getAttribute("d"),r=r.replace(/,/gm," "),r=r.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),r=r.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),r=r.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2"),r=r.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),r=r.replace(/([0-9])([+\-])/gm,"$1 $2"),r=r.replace(/(\.[0-9]*)(\.)/gm,"$1 $2"),r=r.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 "),r=compressSpaces(r),r=trim(r),a=function(t){this.tokens=t.split(" "),this.reset=function(){this.i=-1,this.command="",this.previousCommand="",this.start=new Point(0,0),this.control=new Point(0,0),this.current=new Point(0,0),this.points=[],this.angles=[]},this.isEnd=function(){return this.i>=this.tokens.length-1},this.isCommandOrEnd=function(){return this.isEnd()?!0: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+=1,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 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(){if("c"!==this.previousCommand.toLowerCase()&&"s"!==this.previousCommand.toLowerCase()&&"q"!==this.previousCommand.toLowerCase()&&"t"!==this.previousCommand.toLowerCase())return this.current;var t=new Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y);return t},this.makeAbsolute=function(t){return this.isRelativeCommand()?new Point(t.x+this.current.x,t.y+this.current.y):t}};var w=new Path;for(o=new a(r),o.reset();!o.isEnd();)switch(o.nextCommand(),o.command){case"M":case"m":for(n=o.getAsCurrentPoint(),w.moveTo(n.x,n.y),o.start=o.current;!o.isCommandOrEnd();)n=o.getAsCurrentPoint(),w.lineTo(n.x,n.y);break;case"L":case"l":for(;!o.isCommandOrEnd();)n=o.getAsCurrentPoint(),w.lineTo(n.x,n.y);break;case"H":case"h":for(;!o.isCommandOrEnd();)i=new Point((o.isRelativeCommand()?o.current.x:0)+o.getScalar(),o.current.y),o.current=i,w.lineTo(o.current.x,o.current.y);break;case"V":case"v":for(;!o.isCommandOrEnd();)i=new Point(o.current.x,(o.isRelativeCommand()?o.current.y:0)+o.getScalar()),o.current=i,w.lineTo(o.current.x,o.current.y);break;case"C":case"c":for(;!o.isCommandOrEnd();)s=o.current,c=o.getPoint(),l=o.getAsControlPoint(),u=o.getAsCurrentPoint(),w.curveTo(c.x,c.y,l.x,l.y,u.x,u.y);break;case"S":case"s":for(;!o.isCommandOrEnd();)s=o.current,c=o.getReflectedControlPoint(),l=o.getAsControlPoint(),u=o.getAsCurrentPoint(),w.curveTo(c.x,c.y,l.x,l.y,u.x,u.y);break;case"Q":case"q":for(;!o.isCommandOrEnd();)s=o.current,l=o.getAsControlPoint(),u=o.getAsCurrentPoint(),d=s.x+2/3*(l.x-s.x),m=s.y+2/3*(l.y-s.y),p=d+1/3*(u.x-s.x),v=m+1/3*(u.y-s.y),w.curveTo(d,m,p,v,u.x,u.y);break;case"T":case"t":for(;!o.isCommandOrEnd();)s=o.current,l=o.getReflectedControlPoint(),o.control=l,u=o.getAsCurrentPoint(),d=s.x+2/3*(l.x-s.x),m=s.y+2/3*(l.y-s.y),p=d+1/3*(u.x-s.x),v=m+1/3*(u.y-s.y),w.curveTo(d,m,p,v,u.x,u.y);break;case"A":case"a":for(;!o.isCommandOrEnd();)for(s=o.current,h=o.getScalar(),g=o.getScalar(),f=o.getScalar(),b=o.getScalar(),y=o.getScalar(),u=o.getAsCurrentPoint(),A=u.x,C=u.y,k=arcToSegments(A,C,h,g,b,y,f,s.x,s.y),x=0;x0){for(d=new Transform,p=0;p0&&void 0===r&&(r="black");var a=e.fillOpacity,o=e.stroke,n=e.strokeOpacity,i=e.opacity,s=e.strokeWidth,c=e.transform,l=e.color;"currentColor"===r&&(r=void 0===l?"black":l),void 0!==r&&(r=Color.parse(r),void 0!==a&&(r.a*=a),void 0!==i&&(r.a*=i)),"currentColor"===o&&(o=void 0===l?"black":l),void 0!==o&&(o=Color.parse(o),void 0!==n&&(o.a*=n),void 0!==i&&(o.a*=i));var u;u=c?c.transformShape(t).commands:t.commands;var d=void 0===r?t.fill:r,p=void 0===o?t.stroke:o,m=void 0===s?t.strokeWidth:s;return void 0!==m&&void 0!==c&&(m*=c.m[0]),new Path(u,d,p,m)},arcToSegments=function(t,e,r,a,o,n,i,s,c){var l,u,d,p,m,h,v,g,f,b,y,A,C,k,x,S,P,w,M,T,F,E,q,$,O,V,L;for(l=i*(Math.PI/180),u=Math.sin(l),d=Math.cos(l),r=Math.abs(r),a=Math.abs(a),p=d*(s-t)*.5+u*(c-e)*.5,m=d*(c-e)*.5-u*(s-t)*.5,h=p*p/(r*r)+m*m/(a*a),h>1&&(h=Math.sqrt(h),r*=h,a*=h),v=d/r,g=u/r,f=-u/a,b=d/a,y=v*s+g*c,A=f*s+b*c,C=v*t+g*e,k=f*t+b*e,x=(C-y)*(C-y)+(k-A)*(k-A),S=1/x-.25,S<0&&(S=0),P=Math.sqrt(S),n===o&&(P=-P),w=.5*(y+C)-P*(k-A),M=.5*(A+k)+P*(C-y),T=Math.atan2(A-M,y-w),F=Math.atan2(k-M,C-w),E=F-T,E<0&&1===n?E+=2*Math.PI:E>0&&0===n&&(E-=2*Math.PI),q=Math.ceil(Math.abs(E/(.5*Math.PI+.001))),$=[],L=0;L attribute width="'+n+'"'),n=0),i<0&&(console.error('Error: invalid negative value for attribute height="'+i+'"'),i=0);var s=parseFloat(t.getAttribute("rx")),c=parseFloat(t.getAttribute("ry"));s||(s=0),c||(c=0),s<0&&(console.error('Error: invalid negative value for attribute rx="'+s+'"'),s=0),c<0&&(console.error('Error: invalid negative value for attribute ry="'+c+'"'),c=0),s&&c||(s=c=Math.max(s,c)),s>n/2&&(s=n/2),c>i/2&&(c=i/2);var l=new Path;return s&&c?l.addRoundedRect(a,o,n,i,s,c):l.addRect(a,o,n,i),applySvgAttributes(l,r)},ellipse:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("cx")),o=parseFloat(t.getAttribute("cy"));a||(a=0),o||(o=0);var n=parseFloat(t.getAttribute("rx")),i=parseFloat(t.getAttribute("ry"));n||(n=0),i||(i=0),n<0&&(console.error('Error: invalid negative value for attribute rx="'+n+'"'),n=0),i<0&&(console.error('Error: invalid negative value for attribute ry="'+i+'"'),i=0);var s=new Path;return s.addEllipse(a-n,o-i,2*n,2*i),applySvgAttributes(s,r)},circle:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("cx")),o=parseFloat(t.getAttribute("cy"));a||(a=0),o||(o=0);var n=parseFloat(t.getAttribute("r"));n||(n=0),n<0&&(console.error('Error: invalid negative value for attribute r="'+n+'"'),n=0);var i=new Path;return i.addEllipse(a-n,o-n,2*n,2*n),applySvgAttributes(i,r)},line:function(t,e){var r=readSvgAttributes(t,e),a=parseFloat(t.getAttribute("x1")),o=parseFloat(t.getAttribute("y1")),n=parseFloat(t.getAttribute("x2")),i=parseFloat(t.getAttribute("y2"));a||(a=0),o||(o=0),n||(n=0),i||(i=0);var s=new Path;return s.addLine(a,o,n,i),applySvgAttributes(s,r)},path:function(t,e){var r,a,o,n,i,s,c,l,u,d,p,m,h,v,g,f,b,y,A,C,k,x,S,P=readSvgAttributes(t,e);r=t.getAttribute("d"),r=r.replace(/,/gm," "),r=r.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),r=r.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),r=r.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2"),r=r.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),r=r.replace(/([0-9])([+\-])/gm,"$1 $2"),r=r.replace(/(\.[0-9]*)(\.)/gm,"$1 $2"),r=r.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 "),r=compressSpaces(r),r=trim(r),a=function(t){this.tokens=t.split(" "),this.reset=function(){this.i=-1,this.command="",this.previousCommand="",this.start=new Point(0,0),this.control=new Point(0,0),this.current=new 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+=1,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 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(){if("c"!==this.previousCommand.toLowerCase()&&"s"!==this.previousCommand.toLowerCase()&&"q"!==this.previousCommand.toLowerCase()&&"t"!==this.previousCommand.toLowerCase())return this.current;var t=new Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y);return t},this.makeAbsolute=function(t){return this.isRelativeCommand()?new Point(t.x+this.current.x,t.y+this.current.y):t}};var w=new Path;for(o=new a(r),o.reset();!o.isEnd();)switch(o.nextCommand(),o.command){case"M":case"m":for(n=o.getAsCurrentPoint(),w.moveTo(n.x,n.y),o.start=o.current;!o.isCommandOrEnd();)n=o.getAsCurrentPoint(),w.lineTo(n.x,n.y);break;case"L":case"l":for(;!o.isCommandOrEnd();)n=o.getAsCurrentPoint(),w.lineTo(n.x,n.y);break;case"H":case"h":for(;!o.isCommandOrEnd();)i=new Point((o.isRelativeCommand()?o.current.x:0)+o.getScalar(),o.current.y),o.current=i,w.lineTo(o.current.x,o.current.y);break;case"V":case"v":for(;!o.isCommandOrEnd();)i=new Point(o.current.x,(o.isRelativeCommand()?o.current.y:0)+o.getScalar()),o.current=i,w.lineTo(o.current.x,o.current.y);break;case"C":case"c":for(;!o.isCommandOrEnd();)s=o.current,c=o.getPoint(),l=o.getAsControlPoint(),u=o.getAsCurrentPoint(),w.curveTo(c.x,c.y,l.x,l.y,u.x,u.y);break;case"S":case"s":for(;!o.isCommandOrEnd();)s=o.current,c=o.getReflectedControlPoint(),l=o.getAsControlPoint(),u=o.getAsCurrentPoint(),w.curveTo(c.x,c.y,l.x,l.y,u.x,u.y);break;case"Q":case"q":for(;!o.isCommandOrEnd();)s=o.current,l=o.getAsControlPoint(),u=o.getAsCurrentPoint(),d=s.x+2/3*(l.x-s.x),p=s.y+2/3*(l.y-s.y),m=d+1/3*(u.x-s.x),h=p+1/3*(u.y-s.y),w.curveTo(d,p,m,h,u.x,u.y);break;case"T":case"t":for(;!o.isCommandOrEnd();)s=o.current,l=o.getReflectedControlPoint(),o.control=l,u=o.getAsCurrentPoint(),d=s.x+2/3*(l.x-s.x),p=s.y+2/3*(l.y-s.y),m=d+1/3*(u.x-s.x),h=p+1/3*(u.y-s.y),w.curveTo(d,p,m,h,u.x,u.y);break;case"A":case"a":for(;!o.isCommandOrEnd();)for(s=o.current,v=o.getScalar(),g=o.getScalar(),f=o.getScalar(),b=o.getScalar(),y=o.getScalar(),u=o.getAsCurrentPoint(),A=u.x,C=u.y,k=arcToSegments(A,C,v,g,b,y,f,s.x,s.y),x=0;x